?? video.c
字號:
if (VIDEO_FONT_WIDTH == 8) {
((u32 *)dest)[2] = (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx;
((u32 *)dest)[3] = (video_font_draw_table[bits & 3] & eorx) ^ bgx;
}
}
dest0 += VIDEO_FONT_WIDTH*2;
s++ ;
}
break;
case 12:
case 16:
while (count--) {
cdat = video_fontdata + (*s) * (VIDEO_FONT_HEIGHT << 1);
for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN) {
u8 bits = *cdat++;
((u32 *)dest)[0] = (video_font_draw_table[bits >> 6] & eorx) ^ bgx;
((u32 *)dest)[1] = (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx;
((u32 *)dest)[2] = (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx;
((u32 *)dest)[3] = (video_font_draw_table[bits & 3] & eorx) ^ bgx;
bits = *cdat++;
((u32 *)dest)[4] = (video_font_draw_table[bits >> 6] & eorx) ^ bgx;
((u32 *)dest)[5] = (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx;
if (VIDEO_FONT_WIDTH == 16) {
((u32 *)dest)[6] = (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx;
((u32 *)dest)[7] = (video_font_draw_table[bits & 3] & eorx) ^ bgx;
}
}
s++ ;
dest0 += VIDEO_FONT_WIDTH*2;
}
break;
}
}
static inline void video_drawstring(int xx, int yy, unsigned char *s)
{
video_drawchars (xx, yy, s, strlen(s)) ;
}
// Relative to console plotting functions
static void video_putchars(int xx, int yy, unsigned char *s, int count)
{
#ifdef CONFIG_VIDEO_LOGO
video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, s, count) ;
#else
video_drawchars (xx, yy, s, count) ;
#endif
}
static void video_putchar(int xx, int yy, unsigned char c)
{
#ifdef CONFIG_VIDEO_LOGO
video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1) ;
#else
video_drawchars (xx, yy, &c, 1) ;
#endif
}
static inline void video_putstring(int xx, int yy, unsigned char *s)
{
video_putchars (xx, yy, s, strlen(s)) ;
}
// ***********************************************************************
// ** VIDEO CONTROLLER LOW-LEVEL FUNCTIONS
// ***********************************************************************
static void video_mode_dupefield(VRAM *source, VRAM *dest, int entries)
{
int i ;
for(i=0; i<entries; i++)
{
dest[i] = source[i] ; // Copy the entire record
dest[i].fx = (!dest[i].fx)*3 ; // Negate field bit
}
dest[0].lcyc++ ; // Add a cycle to the first entry
dest[entries-1].lst = 1 ; // Set end of ram entries
}
static void inline video_mode_addentry(VRAM *vr,
int Hx,
int Vx,
int Fx,
int Bx,
int VDS,
int INT,
int LCYC,
int LP,
int LST)
{
vr->hx = Hx ;
vr->vx = Vx ;
vr->fx = Fx ;
vr->bx = Bx ;
vr->vds = VDS ;
vr->inter = INT ;
vr->lcyc = LCYC ;
vr->lp = LP ;
vr->lst = LST ;
}
#define ADDENTRY(a,b,c,d,e,f,g,h,i) video_mode_addentry(&vr[entry++],a,b,c,d,e,f,g,h,i)
static int video_mode_generate (void)
{
immap_t *immap = (immap_t *)CFG_IMMR;
VRAM *vr = (VRAM *)(((void *)immap) + 0xb00); // Pointer to the VRAM table
int DX, X1, X2, DY, Y1, Y2, entry=0, fifo ;
// CHECKING PARAMETERS
if (video_panning_factor_y < -128)
video_panning_factor_y = -128;
if (video_panning_factor_y > 128)
video_panning_factor_y = 128;
if (video_panning_factor_x < -128)
video_panning_factor_x = -128;
if (video_panning_factor_x > 128)
video_panning_factor_x = 128;
// Setting panning
DX = video_panning_range_x = (VIDEO_ACTIVE_COLS - VIDEO_COLS) * 2 ;
DY = video_panning_range_y = (VIDEO_ACTIVE_ROWS - VIDEO_ROWS) / 2 ;
video_panning_value_x = (video_panning_factor_x + 128) * DX / 256;
video_panning_value_y = (video_panning_factor_y + 128) * DY / 256;
// We assume these are burst units (multiplied by 2, we need it pari)
X1 = video_panning_value_x & 0xfffe;
X2 = DX - X1;
// We assume these are field line units (divided by 2, we need it pari)
Y1 = video_panning_value_y & 0xfffe;
Y2 = DY - Y1;
#ifdef VIDEO_MODE_NTSC
// Hx Vx Fx Bx VDS INT LCYC LP LST
//
// Retrace blanking
//
ADDENTRY( 0, 0, 3, 0, 1, 0, 3, 1, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 243, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
//
// Vertical blanking
//
ADDENTRY( 0, 0, 0, 0, 1, 0, 18, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 243, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
//
// Odd field active area (TOP)
//
if (Y1 > 0)
{
ADDENTRY( 0, 0, 0, 0, 1, 0, Y1, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 235, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 1, 0,1448, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
}
//
// Odd field active area
//
ADDENTRY( 0, 0, 0, 0, 1, 0, 240 - DY, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 235, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 1, 0, 8+X1, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 0, 0,VIDEO_COLS * 2, 0, 0 );
if (X2 > 0)
ADDENTRY( 3, 0, 0, 3, 1, 0, X2, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
//
// Odd field active area (BOTTOM)
//
if (Y1 > 0)
{
ADDENTRY( 0, 0, 0, 0, 1, 0, Y2, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 235, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 1, 0,1448, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
}
//
// Vertical blanking
//
ADDENTRY( 0, 0, 0, 0, 1, 0, 4, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 243, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
//
// Vertical blanking
//
ADDENTRY( 0, 0, 3, 0, 1, 0, 19, 1, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 243, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
//
// Even field active area (TOP)
//
if (Y1 > 0)
{
ADDENTRY( 0, 0, 3, 0, 1, 0, Y1, 1, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 235, 0, 0 );
ADDENTRY( 3, 0, 3, 3, 1, 0,1448, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
}
//
// Even field active area (CENTER)
//
ADDENTRY( 0, 0, 3, 0, 1, 0, 240 - DY, 1, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 235, 0, 0 );
ADDENTRY( 3, 0, 3, 3, 1, 0, 8+X1, 0, 0 );
ADDENTRY( 3, 0, 3, 3, 0, 0,VIDEO_COLS * 2, 0, 0 );
if (X2 > 0)
ADDENTRY( 3, 0, 3, 3, 1, 0, X2, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
//
// Even field active area (BOTTOM)
//
if (Y1 > 0)
{
ADDENTRY( 0, 0, 3, 0, 1, 0, Y2, 1, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 235, 0, 0 );
ADDENTRY( 3, 0, 3, 3, 1, 0,1448, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
}
//
// Vertical blanking
//
ADDENTRY( 0, 0, 3, 0, 1, 0, 1, 1, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0, 243, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 3, 0, 1, 1, 32, 1, 1 );
#endif
#ifdef VIDEO_MODE_PAL
// Hx Vx Fx Bx VDS INT LCYC LP LST
//
// vertical; blanking
//
ADDENTRY( 0, 0, 0, 0, 1, 0, 22, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 263, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 24, 1, 0 );
//
// active area (TOP)
//
if (Y1 > 0)
{
ADDENTRY( 0, 0, 0, 0, 1, 0, Y1, 1, 0 ); // 11?
ADDENTRY( 3, 0, 0, 0, 1, 0, 255, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 1, 0,1448, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 24, 1, 0 );
}
//
// field active area (CENTER)
//
ADDENTRY( 0, 0, 0, 0, 1, 0, 288-DY, 1, 0 ); // 265?
ADDENTRY( 3, 0, 0, 0, 1, 0, 255, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 1, 0, 8 + X1, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 0, 0, VIDEO_COLS * 2, 0, 0 );
if (X2 > 0)
ADDENTRY( 3, 0, 0, 1, 1, 0, X2, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 24, 1, 0 );
//
// field active area (BOTTOM)
//
if (Y2 > 0)
{
ADDENTRY( 0, 0, 0, 0, 1, 0, Y2, 1, 0 ); // 12?
ADDENTRY( 3, 0, 0, 0, 1, 0, 255, 0, 0 );
ADDENTRY( 3, 0, 0, 3, 1, 0,1448, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 24, 1, 0 );
}
//
// field vertical; blanking
//
ADDENTRY( 0, 0, 0, 0, 1, 0, 2, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 263, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 24, 1, 0 );
//
// Create the other field (like this, but whit other field selected,
// one more cycle loop and a last identifier)
//
video_mode_dupefield (vr, &vr[entry], entry);
#endif
// See what FIFO are we using
fifo = GETBIT(immap->im_vid.vid_vsr, VIDEO_VSR_CAS);
// Set number of lines and burst (only one frame for now)
if (fifo)
immap->im_vid.vid_vfcr0 = VIDEO_BURST_LEN |
(VIDEO_BURST_LEN << 8) |
((VIDEO_ROWS / 2) << 19) ;
else
immap->im_vid.vid_vfcr1 = VIDEO_BURST_LEN |
(VIDEO_BURST_LEN << 8) |
((VIDEO_ROWS / 2) << 19) ;
SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_ASEL, !fifo);
// Wait until changes are applied (not done)
// while (GETBIT(immap->im_vid.vid_vsr, VIDEO_VSR_CAS) == fifo) ;
// Return number of VRAM entries
return entry * 2 ;
}
static void video_encoder_init (void)
{
#ifdef VIDEO_I2C
// Initialize the I2C
PRINTD("\n[VIDEO ENCODER] Initializing I2C bus...");
i2c_init (VIDEO_I2C_RATE);
#ifdef CONFIG_FADS
// Reset ADV7176 chip
PRINTD("\n[VIDEO ENCODER] Resetting encoder...");
(*(int *)BCSR4) &= ~(1 << 21);
// Wait for 5 ms inside the reset
PRINTD("\n[VIDEO ENCODER] Waiting for encoder reset...");
udelay(5000);
// Take ADV7176 out of reset
(*(int *)BCSR4) |= 1 << 21;
// Wait for 5 ms after the reset
udelay(5000);
#endif
// Send configuration
PRINTD("\n[VIDEO ENCODER] Configuring the encoder...");
#if (VIDEO_DEBUG_STEP == 1)
printf("Sending %d bytes (%08x) to I2C 0x%x\n",
VIDEO_I2C_DATA_SIZE, VIDEO_I2C_DATA_ADDR, VIDEO_I2C_ADDR);
#endif
i2c_send(VIDEO_I2C_ADDR, 0, 1, VIDEO_I2C_DATA_SIZE, VIDEO_I2C_DATA_ADDR);
#endif
return ;
}
static void video_ctrl_init (void *memptr)
{
immap_t *immap = (immap_t *)CFG_IMMR;
video_fb_address = memptr;
// Set black background
PRINTD("\n[VIDEO CTRL] Setting background color...");
immap->im_vid.vid_vbcb = VIDEO_BG_COL;
// Show the background
PRINTD("\n[VIDEO CTRL] Forcing background...");
SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 1);
// Turn off video controller
PRINTD("\n[VIDEO CTRL] Turning off video controller...");
SETBIT(immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 0) ;
#ifdef CONFIG_FADS
// Turn on Video Port LED
PRINTD("\n[VIDEO CTRL] Turning off video port led...");
SETBIT(*(int *)BCSR4, VIDEO_BCSR4_VIDLED_BIT, 1);
// Disable internal clock
PRINTD("\n[VIDEO CTRL] Disabling internal clock...");
SETBIT(*(int *)BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 0);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -