xref: /openbmc/u-boot/common/lcd.c (revision 2b208f53)
1 /*
2  * Common LCD routines for supported CPUs
3  *
4  * (C) Copyright 2001-2002
5  * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
6  *
7  * See file CREDITS for list of people who contributed to this
8  * project.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License as
12  * published by the Free Software Foundation; either version 2 of
13  * the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23  * MA 02111-1307 USA
24  */
25 
26 /************************************************************************/
27 /* ** HEADER FILES							*/
28 /************************************************************************/
29 
30 /* #define DEBUG */
31 
32 #include <config.h>
33 #include <common.h>
34 #include <command.h>
35 #include <version.h>
36 #include <stdarg.h>
37 #include <linux/types.h>
38 #include <devices.h>
39 #if defined(CONFIG_POST)
40 #include <post.h>
41 #endif
42 #include <lcd.h>
43 #include <watchdog.h>
44 
45 #if defined(CONFIG_PXA250)
46 #include <asm/byteorder.h>
47 #endif
48 
49 #if defined(CONFIG_MPC823)
50 #include <lcdvideo.h>
51 #endif
52 
53 #ifdef CONFIG_LCD
54 
55 /************************************************************************/
56 /* ** FONT DATA								*/
57 /************************************************************************/
58 #include <video_font.h>		/* Get font data, width and height	*/
59 
60 /************************************************************************/
61 /* ** LOGO DATA								*/
62 /************************************************************************/
63 #ifdef CONFIG_LCD_LOGO
64 # include <bmp_logo.h>		/* Get logo data, width and height	*/
65 # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET)
66 #  error Default Color Map overlaps with Logo Color Map
67 # endif
68 #endif
69 
70 DECLARE_GLOBAL_DATA_PTR;
71 
72 ulong lcd_setmem (ulong addr);
73 
74 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
75 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
76 static inline void lcd_putc_xy (ushort x, ushort y, uchar  c);
77 
78 static int lcd_init (void *lcdbase);
79 
80 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
81 extern void lcd_ctrl_init (void *lcdbase);
82 extern void lcd_enable (void);
83 static void *lcd_logo (void);
84 
85 
86 #if LCD_BPP == LCD_COLOR8
87 extern void lcd_setcolreg (ushort regno,
88 				ushort red, ushort green, ushort blue);
89 #endif
90 #if LCD_BPP == LCD_MONOCHROME
91 extern void lcd_initcolregs (void);
92 #endif
93 
94 static int lcd_getbgcolor (void);
95 static void lcd_setfgcolor (int color);
96 static void lcd_setbgcolor (int color);
97 
98 char lcd_is_enabled = 0;
99 extern vidinfo_t panel_info;
100 
101 #ifdef	NOT_USED_SO_FAR
102 static void lcd_getcolreg (ushort regno,
103 				ushort *red, ushort *green, ushort *blue);
104 static int lcd_getfgcolor (void);
105 #endif	/* NOT_USED_SO_FAR */
106 
107 /************************************************************************/
108 
109 /*----------------------------------------------------------------------*/
110 
111 static void console_scrollup (void)
112 {
113 #if 1
114 	/* Copy up rows ignoring the first one */
115 	memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
116 
117 	/* Clear the last one */
118 	memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
119 #else
120 	/*
121 	 * Poor attempt to optimize speed by moving "long"s.
122 	 * But the code is ugly, and not a bit faster :-(
123 	 */
124 	ulong *t = (ulong *)CONSOLE_ROW_FIRST;
125 	ulong *s = (ulong *)CONSOLE_ROW_SECOND;
126 	ulong    l = CONSOLE_SCROLL_SIZE / sizeof(ulong);
127 	uchar  c = lcd_color_bg & 0xFF;
128 	ulong val= (c<<24) | (c<<16) | (c<<8) | c;
129 
130 	while (l--)
131 		*t++ = *s++;
132 
133 	t = (ulong *)CONSOLE_ROW_LAST;
134 	l = CONSOLE_ROW_SIZE / sizeof(ulong);
135 
136 	while (l-- > 0)
137 		*t++ = val;
138 #endif
139 }
140 
141 /*----------------------------------------------------------------------*/
142 
143 static inline void console_back (void)
144 {
145 	if (--console_col < 0) {
146 		console_col = CONSOLE_COLS-1 ;
147 		if (--console_row < 0) {
148 			console_row = 0;
149 		}
150 	}
151 
152 	lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
153 		     console_row * VIDEO_FONT_HEIGHT,
154 		     ' ');
155 }
156 
157 /*----------------------------------------------------------------------*/
158 
159 static inline void console_newline (void)
160 {
161 	++console_row;
162 	console_col = 0;
163 
164 	/* Check if we need to scroll the terminal */
165 	if (console_row >= CONSOLE_ROWS) {
166 		/* Scroll everything up */
167 		console_scrollup () ;
168 		--console_row;
169 	}
170 }
171 
172 /*----------------------------------------------------------------------*/
173 
174 void lcd_putc (const char c)
175 {
176 	if (!lcd_is_enabled) {
177 		serial_putc(c);
178 		return;
179 	}
180 
181 	switch (c) {
182 	case '\r':	console_col = 0;
183 			return;
184 
185 	case '\n':	console_newline();
186 			return;
187 
188 	case '\t':	/* Tab (8 chars alignment) */
189 			console_col |=  8;
190 			console_col &= ~7;
191 
192 			if (console_col >= CONSOLE_COLS) {
193 				console_newline();
194 			}
195 			return;
196 
197 	case '\b':	console_back();
198 			return;
199 
200 	default:	lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
201 				     console_row * VIDEO_FONT_HEIGHT,
202 				     c);
203 			if (++console_col >= CONSOLE_COLS) {
204 				console_newline();
205 			}
206 			return;
207 	}
208 	/* NOTREACHED */
209 }
210 
211 /*----------------------------------------------------------------------*/
212 
213 void lcd_puts (const char *s)
214 {
215 	if (!lcd_is_enabled) {
216 		serial_puts (s);
217 		return;
218 	}
219 
220 	while (*s) {
221 		lcd_putc (*s++);
222 	}
223 }
224 
225 /************************************************************************/
226 /* ** Low-Level Graphics Routines					*/
227 /************************************************************************/
228 
229 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
230 {
231 	uchar *dest;
232 	ushort off, row;
233 
234 	dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
235 	off  = x * (1 << LCD_BPP) % 8;
236 
237 	for (row=0;  row < VIDEO_FONT_HEIGHT;  ++row, dest += lcd_line_length)  {
238 		uchar *s = str;
239 		uchar *d = dest;
240 		int i;
241 
242 #if LCD_BPP == LCD_MONOCHROME
243 		uchar rest = *d & -(1 << (8-off));
244 		uchar sym;
245 #endif
246 		for (i=0; i<count; ++i) {
247 			uchar c, bits;
248 
249 			c = *s++;
250 			bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
251 
252 #if LCD_BPP == LCD_MONOCHROME
253 			sym  = (COLOR_MASK(lcd_color_fg) & bits) |
254 			       (COLOR_MASK(lcd_color_bg) & ~bits);
255 
256 			*d++ = rest | (sym >> off);
257 			rest = sym << (8-off);
258 #elif LCD_BPP == LCD_COLOR8
259 			for (c=0; c<8; ++c) {
260 				*d++ = (bits & 0x80) ?
261 						lcd_color_fg : lcd_color_bg;
262 				bits <<= 1;
263 			}
264 #elif LCD_BPP == LCD_COLOR16
265 			for (c=0; c<16; ++c) {
266 				*d++ = (bits & 0x80) ?
267 						lcd_color_fg : lcd_color_bg;
268 				bits <<= 1;
269 			}
270 #endif
271 		}
272 #if LCD_BPP == LCD_MONOCHROME
273 		*d  = rest | (*d & ((1 << (8-off)) - 1));
274 #endif
275 	}
276 }
277 
278 /*----------------------------------------------------------------------*/
279 
280 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
281 {
282 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
283 	lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen ((char *)s));
284 #else
285 	lcd_drawchars (x, y, s, strlen ((char *)s));
286 #endif
287 }
288 
289 /*----------------------------------------------------------------------*/
290 
291 static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
292 {
293 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
294 	lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
295 #else
296 	lcd_drawchars (x, y, &c, 1);
297 #endif
298 }
299 
300 /************************************************************************/
301 /**  Small utility to check that you got the colours right		*/
302 /************************************************************************/
303 #ifdef LCD_TEST_PATTERN
304 
305 #define	N_BLK_VERT	2
306 #define	N_BLK_HOR	3
307 
308 static int test_colors[N_BLK_HOR*N_BLK_VERT] = {
309 	CONSOLE_COLOR_RED,	CONSOLE_COLOR_GREEN,	CONSOLE_COLOR_YELLOW,
310 	CONSOLE_COLOR_BLUE,	CONSOLE_COLOR_MAGENTA,	CONSOLE_COLOR_CYAN,
311 };
312 
313 static void test_pattern (void)
314 {
315 	ushort v_max  = panel_info.vl_row;
316 	ushort h_max  = panel_info.vl_col;
317 	ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
318 	ushort h_step = (h_max + N_BLK_HOR  - 1) / N_BLK_HOR;
319 	ushort v, h;
320 	uchar *pix = (uchar *)lcd_base;
321 
322 	printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n",
323 		h_max, v_max, h_step, v_step);
324 
325 	/* WARNING: Code silently assumes 8bit/pixel */
326 	for (v=0; v<v_max; ++v) {
327 		uchar iy = v / v_step;
328 		for (h=0; h<h_max; ++h) {
329 			uchar ix = N_BLK_HOR * iy + (h/h_step);
330 			*pix++ = test_colors[ix];
331 		}
332 	}
333 }
334 #endif /* LCD_TEST_PATTERN */
335 
336 
337 /************************************************************************/
338 /* ** GENERIC Initialization Routines					*/
339 /************************************************************************/
340 
341 int drv_lcd_init (void)
342 {
343 	device_t lcddev;
344 	int rc;
345 
346 	lcd_base = (void *)(gd->fb_base);
347 
348 	lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
349 
350 	lcd_init (lcd_base);		/* LCD initialization */
351 
352 	/* Device initialization */
353 	memset (&lcddev, 0, sizeof (lcddev));
354 
355 	strcpy (lcddev.name, "lcd");
356 	lcddev.ext   = 0;			/* No extensions */
357 	lcddev.flags = DEV_FLAGS_OUTPUT;	/* Output only */
358 	lcddev.putc  = lcd_putc;		/* 'putc' function */
359 	lcddev.puts  = lcd_puts;		/* 'puts' function */
360 
361 	rc = device_register (&lcddev);
362 
363 	return (rc == 0) ? 1 : rc;
364 }
365 
366 /*----------------------------------------------------------------------*/
367 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
368 {
369 #if LCD_BPP == LCD_MONOCHROME
370 	/* Setting the palette */
371 	lcd_initcolregs();
372 
373 #elif LCD_BPP == LCD_COLOR8
374 	/* Setting the palette */
375 	lcd_setcolreg  (CONSOLE_COLOR_BLACK,       0,    0,    0);
376 	lcd_setcolreg  (CONSOLE_COLOR_RED,	0xFF,    0,    0);
377 	lcd_setcolreg  (CONSOLE_COLOR_GREEN,       0, 0xFF,    0);
378 	lcd_setcolreg  (CONSOLE_COLOR_YELLOW,	0xFF, 0xFF,    0);
379 	lcd_setcolreg  (CONSOLE_COLOR_BLUE,        0,    0, 0xFF);
380 	lcd_setcolreg  (CONSOLE_COLOR_MAGENTA,	0xFF,    0, 0xFF);
381 	lcd_setcolreg  (CONSOLE_COLOR_CYAN,	   0, 0xFF, 0xFF);
382 	lcd_setcolreg  (CONSOLE_COLOR_GREY,	0xAA, 0xAA, 0xAA);
383 	lcd_setcolreg  (CONSOLE_COLOR_WHITE,	0xFF, 0xFF, 0xFF);
384 #endif
385 
386 #ifndef CFG_WHITE_ON_BLACK
387 	lcd_setfgcolor (CONSOLE_COLOR_BLACK);
388 	lcd_setbgcolor (CONSOLE_COLOR_WHITE);
389 #else
390 	lcd_setfgcolor (CONSOLE_COLOR_WHITE);
391 	lcd_setbgcolor (CONSOLE_COLOR_BLACK);
392 #endif	/* CFG_WHITE_ON_BLACK */
393 
394 #ifdef	LCD_TEST_PATTERN
395 	test_pattern();
396 #else
397 	/* set framebuffer to background color */
398 	memset ((char *)lcd_base,
399 		COLOR_MASK(lcd_getbgcolor()),
400 		lcd_line_length*panel_info.vl_row);
401 #endif
402 	/* Paint the logo and retrieve LCD base address */
403 	debug ("[LCD] Drawing the logo...\n");
404 	lcd_console_address = lcd_logo ();
405 
406 	console_col = 0;
407 	console_row = 0;
408 
409 	return (0);
410 }
411 
412 U_BOOT_CMD(
413 	cls,	1,	1,	lcd_clear,
414 	"cls     - clear screen\n",
415 	NULL
416 );
417 
418 /*----------------------------------------------------------------------*/
419 
420 static int lcd_init (void *lcdbase)
421 {
422 	/* Initialize the lcd controller */
423 	debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
424 
425 	lcd_ctrl_init (lcdbase);
426 	lcd_clear (NULL, 1, 1, NULL);	/* dummy args */
427 	lcd_enable ();
428 
429 	/* Initialize the console */
430 	console_col = 0;
431 #ifdef CONFIG_LCD_INFO_BELOW_LOGO
432 	console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
433 #else
434 	console_row = 1;	/* leave 1 blank line below logo */
435 #endif
436 	lcd_is_enabled = 1;
437 
438 	return 0;
439 }
440 
441 
442 /************************************************************************/
443 /* ** ROM capable initialization part - needed to reserve FB memory	*/
444 /************************************************************************/
445 /*
446  * This is called early in the system initialization to grab memory
447  * for the LCD controller.
448  * Returns new address for monitor, after reserving LCD buffer memory
449  *
450  * Note that this is running from ROM, so no write access to global data.
451  */
452 ulong lcd_setmem (ulong addr)
453 {
454 	ulong size;
455 	int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
456 
457 	debug ("LCD panel info: %d x %d, %d bit/pix\n",
458 		panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
459 
460 	size = line_length * panel_info.vl_row;
461 
462 	/* Round up to nearest full page */
463 	size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
464 
465 	/* Allocate pages for the frame buffer. */
466 	addr -= size;
467 
468 	debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr);
469 
470 	return (addr);
471 }
472 
473 /*----------------------------------------------------------------------*/
474 
475 static void lcd_setfgcolor (int color)
476 {
477 	lcd_color_fg = color & 0x0F;
478 }
479 
480 /*----------------------------------------------------------------------*/
481 
482 static void lcd_setbgcolor (int color)
483 {
484 	lcd_color_bg = color & 0x0F;
485 }
486 
487 /*----------------------------------------------------------------------*/
488 
489 #ifdef	NOT_USED_SO_FAR
490 static int lcd_getfgcolor (void)
491 {
492 	return lcd_color_fg;
493 }
494 #endif	/* NOT_USED_SO_FAR */
495 
496 /*----------------------------------------------------------------------*/
497 
498 static int lcd_getbgcolor (void)
499 {
500 	return lcd_color_bg;
501 }
502 
503 /*----------------------------------------------------------------------*/
504 
505 /************************************************************************/
506 /* ** Chipset depending Bitmap / Logo stuff...                          */
507 /************************************************************************/
508 #ifdef CONFIG_LCD_LOGO
509 void bitmap_plot (int x, int y)
510 {
511 	ushort *cmap;
512 	ushort i, j;
513 	uchar *bmap;
514 	uchar *fb;
515 	ushort *fb16;
516 #if defined(CONFIG_PXA250)
517 	struct pxafb_info *fbi = &panel_info.pxa;
518 #elif defined(CONFIG_MPC823)
519 	volatile immap_t *immr = (immap_t *) CFG_IMMR;
520 	volatile cpm8xx_t *cp = &(immr->im_cpm);
521 #endif
522 
523 	debug ("Logo: width %d  height %d  colors %d  cmap %d\n",
524 		BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
525 		sizeof(bmp_logo_palette)/(sizeof(ushort)));
526 
527 	bmap = &bmp_logo_bitmap[0];
528 	fb   = (uchar *)(lcd_base + y * lcd_line_length + x);
529 
530 	if (NBITS(panel_info.vl_bpix) < 12) {
531 		/* Leave room for default color map */
532 #if defined(CONFIG_PXA250)
533 		cmap = (ushort *)fbi->palette;
534 #elif defined(CONFIG_MPC823)
535 		cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
536 #endif
537 
538 		WATCHDOG_RESET();
539 
540 		/* Set color map */
541 		for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) {
542 			ushort colreg = bmp_logo_palette[i];
543 #ifdef  CFG_INVERT_COLORS
544 			*cmap++ = 0xffff - colreg;
545 #else
546 			*cmap++ = colreg;
547 #endif
548 		}
549 
550 		WATCHDOG_RESET();
551 
552 		for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
553 			memcpy (fb, bmap, BMP_LOGO_WIDTH);
554 			bmap += BMP_LOGO_WIDTH;
555 			fb   += panel_info.vl_col;
556 		}
557 	}
558 	else { /* true color mode */
559 		fb16 = (ushort *)(lcd_base + y * lcd_line_length + x);
560 		for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
561 			for (j=0; j<BMP_LOGO_WIDTH; j++) {
562 				fb16[j] = bmp_logo_palette[(bmap[j])];
563 				}
564 			bmap += BMP_LOGO_WIDTH;
565 			fb16 += panel_info.vl_col;
566 		}
567 	}
568 
569 	WATCHDOG_RESET();
570 }
571 #endif /* CONFIG_LCD_LOGO */
572 
573 /*----------------------------------------------------------------------*/
574 #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
575 /*
576  * Display the BMP file located at address bmp_image.
577  * Only uncompressed.
578  */
579 int lcd_display_bitmap(ulong bmp_image, int x, int y)
580 {
581 	ushort *cmap;
582 	ushort i, j;
583 	uchar *fb;
584 	bmp_image_t *bmp=(bmp_image_t *)bmp_image;
585 	uchar *bmap;
586 	ushort padded_line;
587 	unsigned long width, height;
588 	unsigned long pwidth = panel_info.vl_col;
589 	unsigned colors,bpix;
590 	unsigned long compression;
591 #if defined(CONFIG_PXA250)
592 	struct pxafb_info *fbi = &panel_info.pxa;
593 #elif defined(CONFIG_MPC823)
594 	volatile immap_t *immr = (immap_t *) CFG_IMMR;
595 	volatile cpm8xx_t *cp = &(immr->im_cpm);
596 #endif
597 
598 	if (!((bmp->header.signature[0]=='B') &&
599 		(bmp->header.signature[1]=='M'))) {
600 		printf ("Error: no valid bmp image at %lx\n", bmp_image);
601 		return 1;
602 }
603 
604 	width = le32_to_cpu (bmp->header.width);
605 	height = le32_to_cpu (bmp->header.height);
606 	colors = 1<<le16_to_cpu (bmp->header.bit_count);
607 	compression = le32_to_cpu (bmp->header.compression);
608 
609 	bpix = NBITS(panel_info.vl_bpix);
610 
611 	if ((bpix != 1) && (bpix != 8)) {
612 		printf ("Error: %d bit/pixel mode not supported by U-Boot\n",
613 			bpix);
614 		return 1;
615 	}
616 
617 	if (bpix != le16_to_cpu(bmp->header.bit_count)) {
618 		printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
619 			bpix,
620 			le16_to_cpu(bmp->header.bit_count));
621 		return 1;
622 	}
623 
624 	debug ("Display-bmp: %d x %d  with %d colors\n",
625 		(int)width, (int)height, (int)colors);
626 
627 	if (bpix==8) {
628 #if defined(CONFIG_PXA250)
629 		cmap = (ushort *)fbi->palette;
630 #elif defined(CONFIG_MPC823)
631 		cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
632 #elif defined(CONFIG_MCC200)
633 		/* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
634 #else
635 # error "Don't know location of color map"
636 #endif
637 
638 		/* Set color map */
639 		for (i=0; i<colors; ++i) {
640 			bmp_color_table_entry_t cte = bmp->color_table[i];
641 			ushort colreg =
642 				( ((cte.red)   << 8) & 0xf800) |
643 				( ((cte.green) << 3) & 0x07e0) |
644 				( ((cte.blue)  >> 3) & 0x001f) ;
645 #ifdef CFG_INVERT_COLORS
646 			*cmap = 0xffff - colreg;
647 #else
648 			*cmap = colreg;
649 #endif
650 #if defined(CONFIG_PXA250)
651 			cmap++;
652 #elif defined(CONFIG_MPC823)
653 			cmap--;
654 #endif
655 		}
656 	}
657 
658 	/*
659 	 *  BMP format for Monochrome assumes that the state of a
660 	 * pixel is described on a per Bit basis, not per Byte.
661 	 *  So, in case of Monochrome BMP we should align widths
662 	 * on a byte boundary and convert them from Bit to Byte
663 	 * units.
664 	 *  Probably, PXA250 and MPC823 process 1bpp BMP images in
665 	 * their own ways, so make the converting to be MCC200
666 	 * specific.
667 	 */
668 #if defined(CONFIG_MCC200)
669 	if (bpix==1)
670 	{
671 		width = ((width + 7) & ~7) >> 3;
672 		x     = ((x + 7) & ~7) >> 3;
673 		pwidth= ((pwidth + 7) & ~7) >> 3;
674 	}
675 #endif
676 
677 	padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
678 	if ((x + width)>pwidth)
679 		width = pwidth - x;
680 	if ((y + height)>panel_info.vl_row)
681 		height = panel_info.vl_row - y;
682 
683 	bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
684 	fb   = (uchar *) (lcd_base +
685 		(y + height - 1) * lcd_line_length + x);
686 	for (i = 0; i < height; ++i) {
687 		WATCHDOG_RESET();
688 		for (j = 0; j < width ; j++)
689 #if defined(CONFIG_PXA250)
690 			*(fb++)=*(bmap++);
691 #elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
692 			*(fb++)=255-*(bmap++);
693 #endif
694 		bmap += (width - padded_line);
695 		fb   -= (width + lcd_line_length);
696 	}
697 
698 	return (0);
699 }
700 #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
701 
702 
703 static void *lcd_logo (void)
704 {
705 #ifdef CONFIG_LCD_INFO
706 	char info[80];
707 	char temp[32];
708 #endif /* CONFIG_LCD_INFO */
709 
710 #ifdef CONFIG_SPLASH_SCREEN
711 	char *s;
712 	ulong addr;
713 	static int do_splash = 1;
714 
715 	if (do_splash && (s = getenv("splashimage")) != NULL) {
716 		addr = simple_strtoul(s, NULL, 16);
717 		do_splash = 0;
718 
719 		if (lcd_display_bitmap (addr, 0, 0) == 0) {
720 			return ((void *)lcd_base);
721 		}
722 	}
723 #endif /* CONFIG_SPLASH_SCREEN */
724 
725 #ifdef CONFIG_LCD_LOGO
726 	bitmap_plot (0, 0);
727 #endif /* CONFIG_LCD_LOGO */
728 
729 #ifdef CONFIG_MPC823
730 # ifdef CONFIG_LCD_INFO
731 	sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
732 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, (uchar *)info, strlen(info));
733 
734 	sprintf (info, "(C) 2004 DENX Software Engineering");
735 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT,
736 					(uchar *)info, strlen(info));
737 
738 	sprintf (info, "    Wolfgang DENK, wd@denx.de");
739 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2,
740 					(uchar *)info, strlen(info));
741 #  ifdef CONFIG_LCD_INFO_BELOW_LOGO
742 	sprintf (info, "MPC823 CPU at %s MHz",
743 		strmhz(temp, gd->cpu_clk));
744 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
745 					info, strlen(info));
746 	sprintf (info, "  %ld MB RAM, %ld MB Flash",
747 		gd->ram_size >> 20,
748 		gd->bd->bi_flashsize >> 20 );
749 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
750 					info, strlen(info));
751 #  else
752 	/* leave one blank line */
753 
754 	sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",
755 		strmhz(temp, gd->cpu_clk),
756 		gd->ram_size >> 20,
757 		gd->bd->bi_flashsize >> 20 );
758 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
759 					(uchar *)info, strlen(info));
760 
761 #  endif /* CONFIG_LCD_INFO_BELOW_LOGO */
762 # endif /* CONFIG_LCD_INFO */
763 #endif /* CONFIG_MPC823 */
764 
765 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
766 	return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
767 #else
768 	return ((void *)lcd_base);
769 #endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */
770 }
771 
772 /************************************************************************/
773 /************************************************************************/
774 
775 #endif /* CONFIG_LCD */
776