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

📄 vid_1200.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
📖 第 1 页 / 共 3 页
字号:
 * 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 sc1200_get_video_line_size(void)
#else
unsigned long gfx_get_video_line_size(void)
#endif
{
    unsigned long width = 0;

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

    width = (READ_VID32(SC1200_VIDEO_CONFIG) >> 7) & 0x000001FE;
    if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_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 sc1200_get_video_xclip(void)
#else
unsigned long gfx_get_video_xclip(void)
#endif
{
    unsigned long clip = 0;

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

    clip = (READ_VID32(SC1200_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 sc1200_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 sc1200_get_video_scale(void)
#else
unsigned long gfx_get_video_scale(void)
#endif
{
    return(READ_VID32(SC1200_VIDEO_SCALE));
}

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

    xsize = READ_VID32(SC1200_VIDEO_X_POS);
    xsize = ((xsize >> 16) & 0x3FF) - (xsize & 0x03FF);
    ysize = READ_VID32(SC1200_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 sc1200_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(SC1200_VIDEO_X_POS) & 0x000003FF;
    ypos = READ_VID32(SC1200_VIDEO_Y_POS) & 0x000003FF;
    
    /* GET ADJUSTMENT VALUES */
    /* Use routines to abstract version of display controller. */

    hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 14;
    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 sc1200_get_video_color_key(void)
#else
unsigned long gfx_get_video_color_key(void)
#endif
{
    return(READ_VID32(SC1200_VIDEO_COLOR_KEY));
}

/*---------------------------------------------------------------------------
 * gfx_get_video_color_key_mask
 * 
 * This routine returns the current video color mask value.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
unsigned long sc1200_get_video_color_key_mask(void)
#else
unsigned long gfx_get_video_color_key_mask(void)
#endif
{
    return(READ_VID32(SC1200_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 sc1200_get_video_color_key_src(void)
#else
int gfx_get_video_color_key_src(void)
#endif
{
    if (READ_VID32(SC1200_DISPLAY_CONFIG) & SC1200_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 sc1200_get_video_filter(void)
#else
int gfx_get_video_filter(void)
#endif
{
    int retval = 0;
    if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_X_FILTER_EN) 
        retval |= 1;
    if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_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 sc1200_get_clock_frequency(void)
#else
unsigned long gfx_get_clock_frequency(void)
#endif
{
    int index;
    unsigned long value, mask;
    mask = 0x007FFF0F;
    value = READ_VID32(SC1200_VID_CLOCK_SELECT) & mask;
    for (index = 0; index < NUM_SC1200_FREQUENCIES; index++)
    {
        if ((gfx_sc1200_clock_table[index].clock_select & mask) == value)
            return(gfx_sc1200_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 sc1200_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(SC1200_VID_CRC, 0);
        WRITE_VID32(SC1200_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(SC1200_VID_CRC) >> 8;
    }
    return(crc);
}   

/*---------------------------------------------------------------------------
 * gfx_get_alpha_enable
 * 
 * This routine returns 1 if the selected alpha window is currently 
 * enabled, or 0 if it is currently disabled.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
void sc1200_get_alpha_enable(int *enable)
#else
void gfx_get_alpha_enable(int *enable)
#endif
{
    unsigned long value = 0;
    *enable = 0;
    if (gfx_alpha_select <= 2)
    {
        value = READ_VID32(SC1200_ALPHA_CONTROL_1 + (gfx_alpha_select << 4));
        if (value & SC1200_ACTRL_WIN_ENABLE) *enable = 1;
    }
    return;
}

/*---------------------------------------------------------------------------
 * gfx_get_alpha_size
 * 
 * This routine returns the size of the currently selected alpha region.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
void sc1200_get_alpha_size(unsigned short *x, unsigned short *y, 
    unsigned short *width, unsigned short *height)
#else
void gfx_get_alpha_size(unsigned short *x, unsigned short *y, 
    unsigned short *width, unsigned short *height)
#endif
{
    unsigned long value = 0;
    *x = 0;
    *y = 0;
    *width = 0;
    *height = 0;
    if (gfx_alpha_select <= 2)
    {
        value = READ_VID32(SC1200_ALPHA_XPOS_1 + (gfx_alpha_select << 4));
        *x = (unsigned short) (value & 0x000007FF);
        *width = (unsigned short) ((value >> 16) & 0x000007FF) - *x;
        value = READ_VID32(SC1200_ALPHA_YPOS_1 + (gfx_alpha_select << 4));
        *y = (unsigned short) (value & 0x000007FF);
        *height = (unsigned short) ((value >> 16) & 0x000007FF) - *y;
    }
    *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2;
    *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1;
    return;
}

/*---------------------------------------------------------------------------
 * gfx_get_alpha_value
 * 
 * This routine returns the alpha value and increment/decrement value of 
 * the currently selected alpha region.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
void sc1200_get_alpha_value(unsigned char *alpha, char *delta)
#else
void gfx_get_alpha_value(unsigned char *alpha, char *delta)
#endif
{
    unsigned long value = 0;
    *alpha = 0;
    *delta = 0;
    if (gfx_alpha_select <= 2)
    {
        value = READ_VID32(SC1200_ALPHA_CONTROL_1 + (gfx_alpha_select << 4));
        *alpha = (unsigned char) (value & 0x00FF);
        *delta = (char) ((value >> 8) & 0x00FF);
    }
    return;
}

/*---------------------------------------------------------------------------
 * gfx_get_alpha_priority
 * 
 * This routine returns the priority of the currently selected alpha region.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
void sc1200_get_alpha_priority(int *priority)
#else
void gfx_get_alpha_priority(int *priority)
#endif
{
    unsigned long pos = 0, value = 0;
    *priority = 0;
    if (gfx_alpha_select <= 2)
    {
        value = READ_VID32(SC1200_VID_ALPHA_CONTROL);
        pos = 16 + (gfx_alpha_select << 1);
        *priority = (int) ((value >> pos) & 3);
    }
    return;
}

/*---------------------------------------------------------------------------
 * gfx_get_alpha_color
 * 
 * This routine returns the color register value for the currently selected 
 * alpha region.  Bit 24 is set if the color register is enabled.
 *---------------------------------------------------------------------------
 */
#if GFX_VIDEO_DYNAMIC
void sc1200_get_alpha_color(unsigned long *color)
#else
void gfx_get_alpha_color(unsigned long *color)
#endif
{
    *color = 0;
    if (gfx_alpha_select <= 2)
    {
        *color = READ_VID32(SC1200_ALPHA_COLOR_1 + (gfx_alpha_select << 4));
    }
    return;
}

#endif /* GFX_READ_ROUTINES */

/* END OF FILE */

⌨️ 快捷键说明

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