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

📄 video.c.svn-base

📁 PowerPC850系列的產品開機程式uboot是linuxOS BASED的程式碼
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
	/* Start of frame buffer (even and odd frame, to make it working with */	/* any selected active set) */	debug ("[VIDEO CTRL] Setting frame buffer address...\n");	immap->im_vid.vid_vfaa1 =		immap->im_vid.vid_vfaa0 = (u32) video_fb_address;	immap->im_vid.vid_vfba1 =	immap->im_vid.vid_vfba0 =		(u32) video_fb_address + VIDEO_LINE_LEN;	/* YUV, Big endian, SHIFT/CLK/CLK input (BEFORE ENABLING 27MHZ EXT CLOCK) */	debug ("[VIDEO CTRL] Setting pixel mode and clocks...\n");	immap->im_vid.vid_vccr = 0x2042;	/* Configure port pins */	debug ("[VIDEO CTRL] Configuring input/output pins...\n");	immap->im_ioport.iop_pdpar = 0x1fff;	immap->im_ioport.iop_pddir = 0x0000;#ifdef CONFIG_FADS	/* Turn on Video Port Clock - ONLY AFTER SET VCCR TO ENABLE EXTERNAL CLOCK */	debug ("[VIDEO CTRL] Turning on video clock...\n");	SETBIT (*(int *) BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 1);	/* Turn on Video Port LED */	debug ("[VIDEO CTRL] Turning on video port led...\n");	SETBIT (*(int *) BCSR4, VIDEO_BCSR4_VIDLED_BIT, 0);#endif#ifdef CONFIG_RRVISION	debug ("PC5->Output(1): enable PAL clock");	immap->im_ioport.iop_pcpar &= ~(0x0400);	immap->im_ioport.iop_pcdir |=   0x0400 ;	immap->im_ioport.iop_pcdat |=   0x0400 ;	debug ("PDPAR=0x%04X PDDIR=0x%04X PDDAT=0x%04X\n",	       immap->im_ioport.iop_pdpar,	       immap->im_ioport.iop_pddir,	       immap->im_ioport.iop_pddat);	debug ("PCPAR=0x%04X PCDIR=0x%04X PCDAT=0x%04X\n",	       immap->im_ioport.iop_pcpar,	       immap->im_ioport.iop_pcdir,	       immap->im_ioport.iop_pcdat);#endif	/* CONFIG_RRVISION */	/* Blanking the screen. */	debug ("[VIDEO CTRL] Blanking the screen...\n");	video_fill (VIDEO_BG_COL);	/*	 * Turns on Aggressive Mode. Normally, turning on the caches	 * will cause the screen to flicker when the caches try to	 * fill. This gives the FIFO's for the Video Controller	 * higher priority and prevents flickering because of	 * underrun. This may still be an issue when using FLASH,	 * since accessing data from Flash is so slow.	 */	debug ("[VIDEO CTRL] Turning on aggressive mode...\n");	immap->im_siu_conf.sc_sdcr = 0x40;	/* Turn on video controller */	debug ("[VIDEO CTRL] Turning on video controller...\n");	SETBIT (immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 1);	/* Show the display */	debug ("[VIDEO CTRL] Enabling the video...\n");	SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 0);}/************************************************************************//* ** CONSOLE FUNCTIONS							*//************************************************************************/static void console_scrollup (void){	/* Copy up rows ignoring the first one */	memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE >> 2);	/* Clear the last one */	memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, VIDEO_BG_COL);}static inline void console_back (void){	console_col--;	if (console_col < 0) {		console_col = CONSOLE_COLS - 1;		console_row--;		if (console_row < 0)			console_row = 0;	}	video_putchar ( console_col * VIDEO_FONT_WIDTH,			console_row * VIDEO_FONT_HEIGHT, ' ');}static inline void console_newline (void){	console_row++;	console_col = 0;	/* Check if we need to scroll the terminal */	if (console_row >= CONSOLE_ROWS) {		/* Scroll everything up */		console_scrollup ();		/* Decrement row number */		console_row--;	}}void video_putc (const char c){	if (!video_enable) {		serial_putc (c);		return;	}	switch (c) {	case 13:			/* Simply ignore this */		break;	case '\n':			/* Next line, please */		console_newline ();		break;	case 9:				/* Tab (8 chars alignment) */		console_col |= 0x0008;	/* Next 8 chars boundary */		console_col &= ~0x0007;	/* Set this bit to zero */		if (console_col >= CONSOLE_COLS)			console_newline ();		break;	case 8:				/* Eat last character */		console_back ();		break;	default:			/* Add to the console */		video_putchar ( console_col * VIDEO_FONT_WIDTH,				console_row * VIDEO_FONT_HEIGHT, c);		console_col++;		/* Check if we need to go to next row */		if (console_col >= CONSOLE_COLS)			console_newline ();	}}void video_puts (const char *s){	int count = strlen (s);	if (!video_enable)		while (count--)			serial_putc (*s++);	else		while (count--)			video_putc (*s++);}/************************************************************************//* ** CURSOR BLINKING FUNCTIONS						*//************************************************************************/#ifdef VIDEO_BLINK#define BLINK_TIMER_ID		0#define BLINK_TIMER_HZ		2static unsigned char blink_enabled = 0;static timer_t blink_timer;static void blink_update (void){	static int blink_row = -1, blink_col = -1, blink_old = 0;	/* Check if we have a new position to invert */	if ((console_row != blink_row) || (console_col != blink_col)) {		/* Check if we need to reverse last character */		if (blink_old)			video_revchar ( blink_col * VIDEO_FONT_WIDTH,					(blink_row#ifdef CONFIG_VIDEO_LOGO					 + VIDEO_LOGO_HEIGHT#endif					) * VIDEO_FONT_HEIGHT);		/* Update values */		blink_row = console_row;		blink_col = console_col;		blink_old = 0;	}/* Reverse this character */	blink_old = !blink_old;	video_revchar ( console_col * VIDEO_FONT_WIDTH,			(console_row#ifdef CONFIG_VIDEO_LOGO			+ VIDEO_LOGO_HEIGHT#endif			) * VIDEO_FONT_HEIGHT);}/* * Handler for blinking cursor */static void blink_handler (void *arg){/* Blink */	blink_update ();/* Ack the timer */	timer_ack (&blink_timer);}int blink_set (int blink){	int ret = blink_enabled;	if (blink)		timer_enable (&blink_timer);	else		timer_disable (&blink_timer);	blink_enabled = blink;	return ret;}static inline void blink_close (void){	timer_close (&blink_timer);}static inline void blink_init (void){	timer_init (&blink_timer,			BLINK_TIMER_ID, BLINK_TIMER_HZ,			blink_handler);}#endif/************************************************************************//* ** LOGO PLOTTING FUNCTIONS						*//************************************************************************/#ifdef CONFIG_VIDEO_LOGOvoid easylogo_plot (fastimage_t * image, void *screen, int width, int x,					int y){	int skip = width - image->width, xcount, ycount = image->height;#ifdef VIDEO_MODE_YUYV	ushort *source = (ushort *) image->data;	ushort *dest   = (ushort *) screen + y * width + x;	while (ycount--) {		xcount = image->width;		while (xcount--)			*dest++ = *source++;		dest += skip;	}#endif#ifdef VIDEO_MODE_RGB	unsigned char	*source = (unsigned short *) image->data,			*dest = (unsigned short *) screen + ((y * width) + x) * 3;	while (ycount--) {		xcount = image->width * 3;		memcpy (dest, source, xcount);		source += xcount;		dest += ycount;	}#endif}static void *video_logo (void){	u16 *screen = video_fb_address, width = VIDEO_COLS;#ifdef VIDEO_INFO# ifndef CONFIG_FADS	char temp[32];# endif	char info[80];#endif /* VIDEO_INFO */	easylogo_plot (VIDEO_LOGO_ADDR, screen, width, 0, 0);#ifdef VIDEO_INFO	sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);	video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info);	sprintf (info, "(C) 2002 DENX Software Engineering");	video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,					info);	sprintf (info, "    Wolfgang DENK, wd@denx.de");	video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 2,					info);#ifndef CONFIG_FADS		/* all normal boards */	/* leave one blank line */	sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",		strmhz(temp, gd->cpu_clk),		gd->ram_size >> 20,		gd->bd->bi_flashsize >> 20 );	video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 4,					info);#else				/* FADS :-( */	sprintf (info, "MPC823 CPU at 50 MHz on FADS823 board");	video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,					  info);	sprintf (info, "2MB FLASH - 8MB DRAM - 4MB SRAM");	video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 2,					  info);#endif#endif	return video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN;}#endif/************************************************************************//* ** VIDEO HIGH-LEVEL FUNCTIONS					*//************************************************************************/static int video_init (void *videobase){	/* Initialize the encoder */	debug ("[VIDEO] Initializing video encoder...\n");	video_encoder_init ();	/* Initialize the video controller */	debug ("[VIDEO] Initializing video controller at %08x...\n",		   (int) videobase);	video_ctrl_init (videobase);	/* Setting the palette */	video_setpalette  (CONSOLE_COLOR_BLACK,	     0,	   0,	 0);	video_setpalette  (CONSOLE_COLOR_RED,	  0xFF,	   0,	 0);	video_setpalette  (CONSOLE_COLOR_GREEN,	     0, 0xFF,	 0);	video_setpalette  (CONSOLE_COLOR_YELLOW,  0xFF, 0xFF,	 0);	video_setpalette  (CONSOLE_COLOR_BLUE,	     0,	   0, 0xFF);	video_setpalette  (CONSOLE_COLOR_MAGENTA, 0xFF,	   0, 0xFF);	video_setpalette  (CONSOLE_COLOR_CYAN,	     0, 0xFF, 0xFF);	video_setpalette  (CONSOLE_COLOR_GREY,	  0xAA, 0xAA, 0xAA);	video_setpalette  (CONSOLE_COLOR_GREY2,	  0xF8, 0xF8, 0xF8);	video_setpalette  (CONSOLE_COLOR_WHITE,	  0xFF, 0xFF, 0xFF);#ifndef CFG_WHITE_ON_BLACK	video_setfgcolor (CONSOLE_COLOR_BLACK);	video_setbgcolor (CONSOLE_COLOR_GREY2);#else	video_setfgcolor (CONSOLE_COLOR_GREY2);	video_setbgcolor (CONSOLE_COLOR_BLACK);#endif	/* CFG_WHITE_ON_BLACK */#ifdef CONFIG_VIDEO_LOGO	/* Paint the logo and retrieve tv base address */	debug ("[VIDEO] Drawing the logo...\n");	video_console_address = video_logo ();#else	video_console_address = video_fb_address;#endif#ifdef VIDEO_BLINK	/* Enable the blinking (under construction) */	blink_init ();	blink_set (0);				/* To Fix! */#endif	/* Initialize the console */	console_col = 0;	console_row = 0;	video_enable = 1;#ifdef VIDEO_MODE_PAL# define VIDEO_MODE_TMP1	"PAL"#endif#ifdef VIDEO_MODE_NTSC# define VIDEO_MODE_TMP1	"NTSC"#endif#ifdef VIDEO_MODE_YUYV# define VIDEO_MODE_TMP2	"YCbYCr"#endif#ifdef VIDEO_MODE_RGB# define VIDEO_MODE_TMP2	"RGB"#endif	debug ( VIDEO_MODE_TMP1		" %dx%dx%d (" VIDEO_MODE_TMP2 ") on %s - console %dx%d\n",			VIDEO_COLS, VIDEO_ROWS, VIDEO_MODE_BPP,			VIDEO_ENCODER_NAME, CONSOLE_COLS, CONSOLE_ROWS);	return 0;}int drv_video_init (void){	int error, devices = 1;	device_t videodev;	video_init ((void *)(gd->fb_base));	/* Video initialization *//* Device initialization */	memset (&videodev, 0, sizeof (videodev));	strcpy (videodev.name, "video");	videodev.ext = DEV_EXT_VIDEO;	/* Video extensions */	videodev.flags = DEV_FLAGS_OUTPUT;	/* Output only */	videodev.putc = video_putc;	/* 'putc' function */	videodev.puts = video_puts;	/* 'puts' function */	error = device_register (&videodev);	return (error == 0) ? devices : error;}/************************************************************************//* ** ROM capable initialization part - needed to reserve FB memory	*//************************************************************************//* * This is called early in the system initialization to grab memory * for the video controller. * Returns new address for monitor, after reserving video buffer memory * * Note that this is running from ROM, so no write access to global data. */ulong video_setmem (ulong addr){	/* Allocate pages for the frame buffer. */	addr -= VIDEO_SIZE;	debug ("Reserving %dk for Video Framebuffer at: %08lx\n",		VIDEO_SIZE>>10, addr);	return (addr);}#endif

⌨️ 快捷键说明

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