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

📄 video.c.svn-base

📁 PowerPC850系列的產品開機程式uboot是linuxOS BASED的程式碼
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
			s++;			dest0 += VIDEO_FONT_WIDTH * 2;		}		break;	}}static inline void video_drawstring (int xx, int yy, char *s){	video_drawchars (xx, yy, (unsigned char *)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, (unsigned char *)s, strlen ((char *)s));}/************************************************************************//* ** VIDEO CONTROLLER LOW-LEVEL FUNCTIONS				*//************************************************************************/#if !defined(CONFIG_RRVISION)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 */}#endifstatic 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;	debug("X1=%d, X2=%d, Y1=%d, Y2=%d, DX=%d, DY=%d VIDEO_COLS=%d \n",	      X1, X2, Y1, Y2, DX, DY, VIDEO_COLS);#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#if defined(CONFIG_RRVISION)#define HPW   160  /* horizontal pulse width (was 139)	*/#define VPW	2  /* vertical pulse width		*/#define HBP   104  /* horizontal back porch (was 112)	*/#define VBP    19  /* vertical back porch (was 19)	*/#define VID_R 240  /* number of rows			*/	debug ("[VIDEO CTRL] Starting to add controller entries...");/* * Even field */	ADDENTRY (0, 3, 0, 3, 1, 0, 2, 0, 0);	ADDENTRY (0, 0, 0, 3, 1, 0, HPW, 0, 0);	ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 0, 0);	ADDENTRY (0, 0, 0, 3, 1, 0, VPW, 1, 0);	ADDENTRY (0, 0, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, VBP, 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);/* * Active area */	ADDENTRY (0, 3, 0, 3, 1, 0, VID_R , 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, HBP, 0, 0);	ADDENTRY (3, 3, 0, 3, 0, 0, VIDEO_COLS*2, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, 72, 1, 1);	ADDENTRY (0, 3, 0, 3, 1, 0, 51, 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, HBP +(VIDEO_COLS * 2) + 72 , 1, 0);/* * Odd field */	ADDENTRY (0, 3, 0, 3, 1, 0, 2, 0, 0);	ADDENTRY (0, 0, 0, 3, 1, 0, HPW, 0, 0);	ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 0, 0);	ADDENTRY (0, 0, 0, 3, 1, 0, VPW+1, 1, 0);	ADDENTRY (0, 0, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, VBP, 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);/* * Active area */	ADDENTRY (0, 3, 0, 3, 1, 0, VID_R , 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, HBP, 0, 0);	ADDENTRY (3, 3, 0, 3, 0, 0, VIDEO_COLS*2, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, 72, 1, 1);	ADDENTRY (0, 3, 0, 3, 1, 0, 51, 1, 0);	ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);	ADDENTRY (3, 3, 0, 3, 1, 0, HBP +(VIDEO_COLS * 2) + 72 , 1, 0);	debug ("done\n");#else  /* !CONFIG_RRVISION *//* *	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 /* CONFIG_RRVISION */#endif /* VIDEO_MODE_PAL */	/* 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	int rc;	/* Initialize the I2C */	debug ("[VIDEO ENCODER] Initializing I2C bus...\n");	i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);#ifdef CONFIG_FADS	/* Reset ADV7176 chip */	debug ("[VIDEO ENCODER] Resetting encoder...\n");	(*(int *) BCSR4) &= ~(1 << 21);	/* Wait for 5 ms inside the reset */	debug ("[VIDEO ENCODER] Waiting for encoder reset...\n");	udelay (5000);	/* Take ADV7176 out of reset */	(*(int *) BCSR4) |= 1 << 21;	/* Wait for 5 ms after the reset */	udelay (5000);#endif	/* CONFIG_FADS */	/* Send configuration */#ifdef DEBUG	{		int i;		puts ("[VIDEO ENCODER] Configuring the encoder...\n");		printf ("Sending %d bytes (@ %08lX) to I2C 0x%X:\n   ",			sizeof(video_encoder_data),			(ulong)video_encoder_data,			VIDEO_I2C_ADDR);		for (i=0; i<sizeof(video_encoder_data); ++i) {			printf(" %02X", video_encoder_data[i]);		}		putc ('\n');	}#endif	/* DEBUG */	if ((rc = i2c_write (VIDEO_I2C_ADDR, 0, 1,			 video_encoder_data,			 sizeof(video_encoder_data))) != 0) {		printf ("i2c_send error: rc=%d\n", rc);		return;	}#endif	/* VIDEO_I2C */	return;}static void video_ctrl_init (void *memptr){	immap_t *immap = (immap_t *) CFG_IMMR;	video_fb_address = memptr;	/* Set background */	debug ("[VIDEO CTRL] Setting background color...\n");	immap->im_vid.vid_vbcb = VIDEO_BG_COL;	/* Show the background */	debug ("[VIDEO CTRL] Forcing background...\n");	SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 1);	/* Turn off video controller */	debug ("[VIDEO CTRL] Turning off video controller...\n");	SETBIT (immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 0);#ifdef CONFIG_FADS	/* Turn on Video Port LED */	debug ("[VIDEO CTRL] Turning off video port led...\n");	SETBIT (*(int *) BCSR4, VIDEO_BCSR4_VIDLED_BIT, 1);	/* Disable internal clock */	debug ("[VIDEO CTRL] Disabling internal clock...\n");	SETBIT (*(int *) BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 0);#endif	/* Generate and make active a new video mode */	debug ("[VIDEO CTRL] Generating video mode...\n");	video_mode_generate ();

⌨️ 快捷键说明

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