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

📄 vid_1400.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
📖 第 1 页 / 共 2 页
字号:
 * comapare graphics data.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_set_video_color_key(unsigned long key, unsigned long mask, 
    int graphics)
#else
int gfx_set_video_color_key(unsigned long key, unsigned long mask, 
    int graphics)
#endif
{
    unsigned long dcfg = 0;

    /* SET SC1400 COLOR KEY VALUE */

    WRITE_VID32(SC1400_VIDEO_COLOR_KEY, key);
    WRITE_VID32(SC1400_VIDEO_COLOR_MASK, mask);

    /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */

    dcfg = READ_VID32(SC1400_DISPLAY_CONFIG);
    if (graphics & 0x01) dcfg &= ~SC1400_DCFG_VG_CK;
    else dcfg |= SC1400_DCFG_VG_CK;
    WRITE_VID32(SC1400_DISPLAY_CONFIG, dcfg);
    return(0);
}

/*---------------------------------------------------------------------------
 * gfx_set_video_filter
 * 
 * This routine enables or disables the video overlay filters.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_set_video_filter(int xfilter, int yfilter)
#else
int gfx_set_video_filter(int xfilter, int yfilter)
#endif
{
    unsigned long vcfg = 0;

    /* ENABLE OR DISABLE SC1400 VIDEO OVERLAY FILTERS */

    vcfg = READ_VID32(SC1400_VIDEO_CONFIG);
    vcfg &= ~(SC1400_VCFG_X_FILTER_EN | SC1400_VCFG_Y_FILTER_EN);
    if (xfilter) vcfg |= SC1400_VCFG_X_FILTER_EN;
    if (yfilter) vcfg |= SC1400_VCFG_Y_FILTER_EN;
    WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg);
    return(0);
}

/*---------------------------------------------------------------------------
 * gfx_set_video_palette
 * 
 * This routine loads the video hardware palette.  If a NULL pointer is 
 * specified, the palette is bypassed (for SC1400, this means loading the 
 * palette with identity values). 
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_set_video_palette(unsigned long *palette)
#else
int gfx_set_video_palette(unsigned long *palette)
#endif
{
    unsigned long i, entry;

    /* LOAD SC1400 VIDEO PALETTE */

    WRITE_VID32(SC1400_PALETTE_ADDRESS, 0);
    for (i = 0; i < 256; i++)
    {
        if (palette) entry = palette[i];
        else entry = i | (i << 8) | (i << 16);
        WRITE_VID32(SC1400_PALETTE_DATA, entry);
    }
    return(0);
}

/*************************************************************/
/*  READ ROUTINES  |  INCLUDED FOR DIAGNOSTIC PURPOSES ONLY  */
/*************************************************************/

#if GFX_READ_ROUTINES

/*---------------------------------------------------------------------------
 * gfx_get_sync_polarities
 *
 * This routine returns the polarities of the sync pulses:
 *     Bit 0: Set if negative horizontal polarity.
 *     Bit 1: Set if negative vertical polarity.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_get_sync_polarities(void)
#else
int gfx_get_sync_polarities(void)
#endif
{
    int polarities = 0;
    if (READ_VID32(SC1400_DISPLAY_CONFIG) & 0x00000100) polarities |= 1;
    if (READ_VID32(SC1400_DISPLAY_CONFIG) & 0x00000200) polarities |= 2;
    return(polarities);
}

/*-----------------------------------------------------------------------------
 * gfx_get_video_enable
 *
 * This routine returns the value "one" if video overlay is currently enabled,
 * otherwise it returns the value "zero".
 *-----------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_get_video_enable(void)
#else
int gfx_get_video_enable(void)
#endif
{
    if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_VID_EN) return(1);
    return(0);
}

/*-----------------------------------------------------------------------------
 * gfx_get_video_format
 *
 * This routine returns the current video overlay format.
 *-----------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_get_video_format(void)
#else
int gfx_get_video_format(void)
#endif
{
    unsigned long vcfg;
    vcfg = READ_VID32(SC1400_VIDEO_CONFIG);
    if (vcfg & SC1400_VCFG_CSC_BYPASS) return(4);
    else return((vcfg >> 2) & 3);
}

/*-----------------------------------------------------------------------------
 * gfx_get_video_src_size
 *
 * This routine returns the size of the source video overlay buffer.  The 
 * return value is (height << 16) | width.
 *-----------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_src_size(void)
#else
unsigned long gfx_get_video_src_size(void)
#endif
{
    unsigned long width = 0, height = 0;

    /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */

    width = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE;
    if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER)
        width += 512;

    if (width)
    {
        /* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */
        /* Get total size from display controller - abtracted. */

        height = gfx_get_display_video_size() / (width << 1);
    }
    return((height << 16) | width);
}

/*-----------------------------------------------------------------------------
 * gfx_get_video_line_size
 *
 * This routine returns the line size of the source video overlay buffer, in 
 * pixels.
 *-----------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_line_size(void)
#else
unsigned long gfx_get_video_line_size(void)
#endif
{
    unsigned long width = 0;

    /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */

    width = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE;
    if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER)
        width += 512;
    return(width);
}

/*-----------------------------------------------------------------------------
 * gfx_get_video_xclip
 *
 * This routine returns the number of bytes clipped on the left side of a 
 * video overlay line (skipped at beginning).
 *-----------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_xclip(void)
#else
unsigned long gfx_get_video_xclip(void)
#endif
{
    unsigned long clip = 0;

    /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */

    clip = (READ_VID32(SC1400_VIDEO_CONFIG) >> 14) & 0x000007FC;
    return(clip);
}

/*-----------------------------------------------------------------------------
 * gfx_get_video_offset
 *
 * This routine returns the current offset for the video overlay buffer.
 *-----------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_offset(void)
#else
unsigned long gfx_get_video_offset(void)
#endif
{
    return(gfx_get_display_video_offset());
}

/*---------------------------------------------------------------------------
 * gfx_get_video_scale
 * 
 * This routine returns the scale factor for the video overlay window.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_scale(void)
#else
unsigned long gfx_get_video_scale(void)
#endif
{
    return(READ_VID32(SC1400_VIDEO_SCALE));
}

/*---------------------------------------------------------------------------
 * gfx_get_video_dst_size
 * 
 * This routine returns the size of the displayed video overlay window.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_dst_size(void)
#else
unsigned long gfx_get_video_dst_size(void)
#endif
{
    unsigned long xsize, ysize;

    xsize = READ_VID32(SC1400_VIDEO_X_POS);
    xsize = ((xsize >> 16) & 0x3FF) - (xsize & 0x03FF);
    ysize = READ_VID32(SC1400_VIDEO_Y_POS);
    ysize = ((ysize >> 16) & 0x3FF) - (ysize & 0x03FF);
    return((ysize << 16) | xsize);
}

/*---------------------------------------------------------------------------
 * gfx_get_video_position
 * 
 * This routine returns the position of the video overlay window.  The
 * return value is (ypos << 16) | xpos.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_position(void)
#else
unsigned long gfx_get_video_position(void)
#endif
{
    unsigned long hadjust, vadjust;
    unsigned long xpos, ypos;

    /* READ HARDWARE POSITION */

    xpos = READ_VID32(SC1400_VIDEO_X_POS) & 0x000003FF;
    ypos = READ_VID32(SC1400_VIDEO_Y_POS) & 0x000003FF;
    
    /* GET ADJUSTMENT VALUES */
    /* Use routines to abstract version of display controller. */

    hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13;
    vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1;
    xpos -= hadjust;
    ypos -= vadjust;
    return((ypos << 16) | (xpos & 0x0000FFFF));
}

/*---------------------------------------------------------------------------
 * gfx_get_video_color_key
 * 
 * This routine returns the current video color key value.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_color_key(void)
#else
unsigned long gfx_get_video_color_key(void)
#endif
{
    return(READ_VID32(SC1400_VIDEO_COLOR_KEY));
}

/*---------------------------------------------------------------------------
 * gfx_get_video_color_key_mask
 * 
 * This routine returns the current video color mask value.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_video_color_key_mask(void)
#else
unsigned long gfx_get_video_color_key_mask(void)
#endif
{
    return(READ_VID32(SC1400_VIDEO_COLOR_MASK));
}

/*---------------------------------------------------------------------------
 * gfx_get_video_color_key_src
 * 
 * This routine returns 0 for video data compare, 1 for graphics data.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_get_video_color_key_src(void)
#else
int gfx_get_video_color_key_src(void)
#endif
{
    if (READ_VID32(SC1400_DISPLAY_CONFIG) & SC1400_DCFG_VG_CK) return(0);
    return(1);
}

/*---------------------------------------------------------------------------
 * gfx_get_video_filter
 * 
 * This routine returns if the filters are currently enabled.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
int sc1400_get_video_filter(void)
#else
int gfx_get_video_filter(void)
#endif
{
    int retval = 0;
    if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_X_FILTER_EN) 
        retval |= 1;
    if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_Y_FILTER_EN) 
        retval |= 2;
    return(retval);
}

/*---------------------------------------------------------------------------
 * gfx_get_clock_frequency
 *
 * This routine returns the current clock frequency in 16.16 format.
 * It reads the current register value and finds the match in the table.
 * If no match is found, this routine returns 0.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_get_clock_frequency(void)
#else
unsigned long gfx_get_clock_frequency(void)
#endif
{
    int index;
    unsigned long value, mask;
    mask = 0x007FFF0F;
    value = READ_VID32(SC1400_VID_CLOCK_SELECT) & mask;
    for (index = 0; index < NUM_SC1400_FREQUENCIES; index++)
    {
        if ((gfx_sc1400_clock_table[index].clock_select & mask) == value)
            return(gfx_sc1400_clock_table[index].frequency);
    }
    return(0);
}

/*---------------------------------------------------------------------------
 * gfx_read_crc
 *
 * This routine returns the hardware CRC value, which is used for automated 
 * testing.  The value is like a checksum, but will change if pixels move
 * locations.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1400_read_crc(void)
#else
unsigned long gfx_read_crc(void)
#endif
{
    unsigned long crc = 0xFFFFFFFF;
    if (gfx_test_timing_active())
    {
        // WAIT UNTIL ACTIVE DISPLAY

        while(!gfx_test_vertical_active());

        // RESET CRC DURING ACTIVE DISPLAY

        WRITE_VID32(SC1400_VID_CRC, 0);
        WRITE_VID32(SC1400_VID_CRC, 1);

        // WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE
        
        while(gfx_test_vertical_active());
        while(!gfx_test_vertical_active());
        while(gfx_test_vertical_active());
        while(!gfx_test_vertical_active());
        crc = READ_VID32(SC1400_VID_CRC) >> 8;
    }
    return(crc);
}   

#endif /* GFX_READ_ROUTINES */

/* END OF FILE */

⌨️ 快捷键说明

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