⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 saa7114.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
📖 第 1 页 / 共 2 页
字号:
/*-----------------------------------------------------------------------------
 * SAA7114.C
 *
 * Version 2.0 - February 21, 2000
 *
 * This file contains routines to control the Philips SAA7114 video decoder.
 *  
 * History:
 *    Initial version ported from sample code provided by Philips.
 *    Versions 0.1 through 2.0 by Brian Falardeau.
 *
 * Copyright (c) 1999-2000 National Semiconductor.
 *-----------------------------------------------------------------------------
 */

/*---------------------------*/
/*  TABLE OF DEFAULT VALUES  */
/*---------------------------*/

typedef struct tagGFX_SAA7114_INIT
{
    unsigned char index;
    unsigned char value;

} GFX_SAA7114_INIT;

GFX_SAA7114_INIT gfx_saa7114_init_values[] = {
    { 0x01, 0x08 }, { 0x02, 0xC0 }, { 0x03, 0x10 }, { 0x04, 0x90 }, 
    { 0x05, 0x90 }, { 0x06, 0xEB }, { 0x07, 0xE0 }, { 0x08, 0x98 }, 
    { 0x09, 0x40 }, { 0x0A, 0x80 }, { 0x0B, 0x44 }, { 0x0C, 0x40 }, 
    { 0x0D, 0x00 }, { 0x0E, 0x89 }, { 0x0F, 0x2E }, { 0x10, 0x0E }, 
    { 0x11, 0x00 }, { 0x12, 0x00 }, { 0x13, 0x00 }, { 0x14, 0x00 }, 
    { 0x15, 0x11 }, { 0x16, 0xFE }, { 0x17, 0xC0 }, { 0x18, 0x40 }, 
    { 0x19, 0x80 }, { 0x30, 0xBC }, { 0x31, 0xDF }, { 0x32, 0x02 }, 
    { 0x34, 0xCD }, { 0x35, 0xCC }, { 0x36, 0x3A }, { 0x38, 0x03 },
    { 0x39, 0x10 }, { 0x3A, 0x00 }, { 0x40, 0x00 }, { 0x41, 0xFF }, 
    { 0x42, 0xFF }, { 0x43, 0xFF }, { 0x44, 0xFF }, { 0x45, 0xFF }, 
    { 0x46, 0xFF }, { 0x47, 0xFF }, { 0x48, 0xFF }, { 0x49, 0xFF },
    { 0x4A, 0xFF }, { 0x4B, 0xFF }, { 0x4C, 0xFF }, { 0x4D, 0xFF },
    { 0x4E, 0xFF }, { 0x4F, 0xFF }, { 0x50, 0xFF }, { 0x51, 0xFF },
    { 0x52, 0xFF }, { 0x53, 0xFF }, { 0x54, 0xFF }, { 0x55, 0xFF },
    { 0x56, 0xFF }, { 0x57, 0xFF }, { 0x58, 0x00 }, { 0x59, 0x47 },
    { 0x5A, 0x06 }, { 0x5B, 0x83 }, { 0x5D, 0x3E }, { 0x5E, 0x00 },
    { 0x80, 0x10 }, { 0x83, 0x00 }, { 0x84, 0x60 }, { 0x85, 0x00 }, 
    { 0x86, 0xE5 }, { 0x87, 0x01 }, { 0x88, 0xF8 }, { 0x90, 0x00 }, 
    { 0x91, 0x08 }, { 0x92, 0x10 }, { 0x93, 0x80 }, { 0x94, 0x00 }, 
    { 0x95, 0x00 }, { 0x96, 0xD0 }, { 0x97, 0x02 }, { 0x98, 0x00 }, 
    { 0x99, 0x00 }, { 0x9A, 0xF2 }, { 0x9B, 0x00 }, { 0x9C, 0xD0 }, 
    { 0x9D, 0x02 }, { 0x9E, 0xF0 }, { 0x9F, 0x00 }, { 0xA0, 0x01 }, 
    { 0xA1, 0x00 }, { 0xA2, 0x00 }, { 0xA4, 0x80 }, { 0xA5, 0x40 },
    { 0xA6, 0x40 }, { 0xA8, 0x00 }, { 0xA9, 0x04 }, { 0xAA, 0x00 },
    { 0xAC, 0x00 }, { 0xAD, 0x02 }, { 0xAE, 0x00 }, { 0xB0, 0x00 },
    { 0xB1, 0x04 }, { 0xB2, 0x00 }, { 0xB3, 0x04 }, { 0xB4, 0x00 },
    { 0xB8, 0x00 }, { 0xB9, 0x00 }, { 0xBA, 0x00 }, { 0xBB, 0x00 },
    { 0xBC, 0x00 }, { 0xBD, 0x00 }, { 0xBE, 0x00 }, { 0xBF, 0x00 },
    { 0xC0, 0x00 }, { 0xC1, 0x08 }, { 0xC2, 0x00 }, { 0xC3, 0x80 },
    { 0xC4, 0x00 }, { 0xC5, 0x00 }, { 0xC6, 0xD0 }, { 0xC7, 0x02 },
    { 0xC8, 0x00 }, { 0xC9, 0x00 }, { 0xCA, 0x06 }, { 0xCB, 0x01 }, 
    { 0xCC, 0xD0 }, { 0xCD, 0x02 }, { 0xCE, 0x06 }, { 0xCF, 0x01 },
    { 0xD0, 0x01 }, { 0xD1, 0x00 }, { 0xD2, 0x00 }, { 0xD4, 0x80 },
    { 0xD5, 0x3F }, { 0xD6, 0x3F }, { 0xD8, 0x00 }, { 0xD9, 0x04 },
    { 0xDA, 0x00 }, { 0xDC, 0x00 }, { 0xDD, 0x02 }, { 0xDE, 0x00 },
    { 0xE0, 0x00 }, { 0xE1, 0x04 }, { 0xE2, 0x00 }, { 0xE3, 0x04 },
    { 0xE4, 0x01 }, { 0xE8, 0x00 }, { 0xE9, 0x00 }, { 0xEA, 0x00 },
    { 0xEB, 0x00 }, { 0xEC, 0x00 }, { 0xED, 0x00 }, { 0xEE, 0x00 }, 
    { 0xEF, 0x00 },
};

#define GFX_NUM_SAA7114_INIT_VALUES sizeof(gfx_saa7114_init_values)/sizeof(GFX_SAA7114_INIT)

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_defaults
 *
 * This routine is called to set the initial register values of the 
 * video decoder.
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_defaults(void)
#else
int gfx_set_decoder_defaults(void)
#endif
{
    int i;

    /* LOOP THROUGH INDEX/DATA PAIRS IN THE TABLE */

    for (i = 0; i < GFX_NUM_SAA7114_INIT_VALUES; i++)
    {
        gfx_i2c_write(SAA7114_CHIPADDR, 
            gfx_saa7114_init_values[i].index, 
            gfx_saa7114_init_values[i].value);
    }

    /* SUGGESTED SOFTWARE RESET */ 
    
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xC0);
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xF0);
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_brightness
 *
 * This routine sets the brightness of the video decoder. 
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_brightness(unsigned char brightness)
#else
int gfx_set_decoder_brightness(unsigned char brightness)
#endif
{
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_BRIGHTNESS, brightness); 
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_contrast
 *
 * This routine sets the contrast of the video decoder. 
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_contrast(unsigned char contrast)
#else
int gfx_set_decoder_contrast(unsigned char contrast)
#endif
{
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_CONTRAST, (unsigned char) (contrast >> 1)); 
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_hue
 *
 * This routine sets the hue control of the video decoder. 
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_hue(char hue)
#else
int gfx_set_decoder_hue(char hue)
#endif
{
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_HUE, (unsigned char) hue); 
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_saturation
 *
 * This routine sets the saturation adjustment of the video decoder. 
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_saturation(unsigned char saturation)
#else
int gfx_set_decoder_saturation(unsigned char saturation)
#endif
{
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_SATURATION, (unsigned char) (saturation >> 1)); 
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_input_offset
 *
 * This routine sets the size of the decoder input window.
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_input_offset(unsigned short x, unsigned short y)
#else
int gfx_set_decoder_input_offset(unsigned short x, unsigned short y)
#endif
{
    /* SET THE INPUT WINDOW OFFSET */

    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_HORZ_OFFSET_LO, 
        (unsigned char) (x & 0x00FF));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_HORZ_OFFSET_HI, 
        (unsigned char) (x >> 8));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_VERT_OFFSET_LO, 
        (unsigned char) (y & 0x00FF));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_VERT_OFFSET_HI, 
        (unsigned char) (y >> 8));

    /* SUGGESTED SOFTWARE RESET */ 
    
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xC0);
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xF0);
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_input_size
 *
 * This routine sets the size of the decoder input window.
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_input_size(unsigned short width, unsigned short height)
#else
int gfx_set_decoder_input_size(unsigned short width, unsigned short height)
#endif
{
    /* DIVIDE HEIGHT BY TWO FOR INTERLACING */

    height = (height + 1) >> 1;

    /* SET THE INPUT WINDOW SIZE */

    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_HORZ_INPUT_LO, 
        (unsigned char) (width & 0x00FF));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_HORZ_INPUT_HI, 
        (unsigned char) (width >> 8));
    height += 2; /* Philips sample code adds 2 extra lines for overrun */
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_VERT_INPUT_LO, 
        (unsigned char) (height & 0x00FF));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_VERT_INPUT_HI, 
        (unsigned char) (height >> 8));

    /* SUGGESTED SOFTWARE RESET */ 
    
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xC0);
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xF0);
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_output_size
 *
 * This routine sets the size of the decoder output window.
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_output_size(unsigned short width, unsigned short height)
#else
int gfx_set_decoder_output_size(unsigned short width, unsigned short height)
#endif
{
    /* DIVIDE HEIGHT BY TWO FOR INTERLACING */

    height = (height + 1) >> 1;

    /* SET THE OUTPUT WINDOW SIZE */

    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_HORZ_OUTPUT_LO, 
        (unsigned char) (width & 0x00FF));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_HORZ_OUTPUT_HI, 
        (unsigned char) (width >> 8));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_VERT_OUTPUT_LO, 
        (unsigned char) (height & 0x00FF));
    gfx_i2c_write(SAA7114_CHIPADDR, SAA7114_VERT_OUTPUT_HI, 
        (unsigned char) (height >> 8));

    /* SUGGESTED SOFTWARE RESET */ 
    
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xC0);
    gfx_i2c_write(SAA7114_CHIPADDR, 0x88, 0xF0);
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_set_decoder_scale
 *
 * This routine sets the scaling of the video decoder.
 *-----------------------------------------------------------------------------
 */
#if GFX_DECODER_DYNAMIC
int saa7114_set_decoder_scale(unsigned short srcw, unsigned short srch, 
    unsigned short dstw, unsigned short dsth)
#else
int gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -