to make u-boot work for fat32 filesystem
[jz_uboot.git] / common / lcd.c
blob6bd340c1d971fa1e9fbbae392e82d236f5540852
1 /*
2 * Common LCD routines for supported CPUs
4 * (C) Copyright 2001-2002
5 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
7 * See file CREDITS for list of people who contributed to this
8 * project.
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.
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.
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
26 /************************************************************************/
27 /* ** HEADER FILES */
28 /************************************************************************/
29 /*#define DEBUG */
31 #include <config.h>
32 #include <common.h>
33 #include <command.h>
34 #include <version.h>
35 #include <stdarg.h>
36 #include <linux/types.h>
37 #include <devices.h>
38 #if defined(CONFIG_POST)
39 #include <post.h>
40 #endif
41 #include <lcd.h>
42 #include <watchdog.h>
44 #if defined(CONFIG_PXA250)
45 #include <asm/byteorder.h>
46 #endif
48 #if defined(CONFIG_MPC823)
49 #include <lcdvideo.h>
50 #endif
52 #ifdef CONFIG_LCD
54 /************************************************************************/
55 /* ** FONT DATA */
56 /************************************************************************/
57 #include <video_font.h> /* Get font data, width and height */
59 /************************************************************************/
60 /* ** LOGO DATA */
61 /************************************************************************/
62 #ifdef CONFIG_LCD_LOGO
63 # include <bmp_logo.h> /* Get logo data, width and height */
64 # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET)
65 //# error Default Color Map overlaps with Logo Color Map
66 # endif
67 #endif
69 DECLARE_GLOBAL_DATA_PTR;
71 ulong lcd_setmem (ulong addr);
73 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
74 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
75 static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
77 static int lcd_init (void *lcdbase);
79 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
80 extern void lcd_ctrl_init (void *lcdbase);
81 extern void lcd_enable (void);
82 static void *lcd_logo (void);
84 #ifdef CONFIG_JzRISC /* JzRISC core */
85 extern int flush_cache_all(void);
86 extern void jz_slcd_update(void);
87 extern void write_frame();
88 #endif
90 #if LCD_BPP == LCD_COLOR8
91 extern void lcd_setcolreg (ushort regno,
92 ushort red, ushort green, ushort blue);
93 #endif
94 #if LCD_BPP == LCD_MONOCHROME
95 extern void lcd_initcolregs (void);
96 #endif
98 static int lcd_getbgcolor (void);
99 static void lcd_setfgcolor (int color);
100 static void lcd_setbgcolor (int color);
102 char lcd_is_enabled = 0;
103 extern vidinfo_t panel_info;
105 #ifdef NOT_USED_SO_FAR
106 static void lcd_getcolreg (ushort regno,
107 ushort *red, ushort *green, ushort *blue);
108 static int lcd_getfgcolor (void);
109 #endif /* NOT_USED_SO_FAR */
111 /************************************************************************/
113 /*----------------------------------------------------------------------*/
115 static void console_scrollup (void)
117 #if 1
118 /* Copy up rows ignoring the first one */
119 memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
121 /* Clear the last one */
122 memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
123 #else
125 * Poor attempt to optimize speed by moving "long"s.
126 * But the code is ugly, and not a bit faster :-(
128 ulong *t = (ulong *)CONSOLE_ROW_FIRST;
129 ulong *s = (ulong *)CONSOLE_ROW_SECOND;
130 ulong l = CONSOLE_SCROLL_SIZE / sizeof(ulong);
131 uchar c = lcd_color_bg & 0xFF;
132 ulong val= (c<<24) | (c<<16) | (c<<8) | c;
134 while (l--)
135 *t++ = *s++;
137 t = (ulong *)CONSOLE_ROW_LAST;
138 l = CONSOLE_ROW_SIZE / sizeof(ulong);
140 while (l-- > 0)
141 *t++ = val;
142 #endif
145 /*----------------------------------------------------------------------*/
147 static inline void console_back (void)
149 if (--console_col < 0) {
150 console_col = CONSOLE_COLS-1 ;
151 if (--console_row < 0) {
152 console_row = 0;
156 lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
157 console_row * VIDEO_FONT_HEIGHT,
158 ' ');
161 /*----------------------------------------------------------------------*/
163 static inline void console_newline (void)
165 ++console_row;
166 console_col = 0;
168 /* Check if we need to scroll the terminal */
169 if (console_row >= CONSOLE_ROWS) {
170 /* Scroll everything up */
171 console_scrollup () ;
172 --console_row;
176 /*----------------------------------------------------------------------*/
177 #ifndef CFG_LCD_LOGOONLY_NOINFO
178 void lcd_putc (const char c)
180 serial_putc(c);
182 if (!lcd_is_enabled) {
183 return;
186 if ( BMP_LOGO_HEIGHT > (panel_info.vl_row - 2*VIDEO_FONT_HEIGHT))
187 return ;
189 switch (c) {
190 case '\r': console_col = 0;
191 return;
193 case '\n': console_newline();
194 return;
196 case '\t': /* Tab (8 chars alignment) */
197 console_col |= 8;
198 console_col &= ~7;
200 if (console_col >= CONSOLE_COLS) {
201 console_newline();
203 return;
205 case '\b': console_back();
206 return;
208 default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
209 console_row * VIDEO_FONT_HEIGHT,
211 if (++console_col >= CONSOLE_COLS) {
212 console_newline();
214 return;
216 /* NOTREACHED */
218 #else /* CFG_LCD_LOGOONLY_NOINFO, no info printed */
219 void lcd_putc (const char c)
221 serial_putc(c);
223 #endif /* CFG_LCD_LOGOONLY_NOINFO */
224 /*----------------------------------------------------------------------*/
226 void lcd_puts (const char *s)
228 if (!lcd_is_enabled) {
229 serial_puts (s);
230 return;
233 while (*s) {
234 lcd_putc (*s++);
238 /************************************************************************/
239 /* ** Low-Level Graphics Routines */
240 /************************************************************************/
242 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
245 uchar *dest;
246 ushort off, row;
248 dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
249 off = x * (1 << LCD_BPP) % 8;
251 for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
252 uchar *s = str;
253 uchar *d = dest;
254 int i;
256 #if LCD_BPP == LCD_MONOCHROME
257 uchar rest = *d & -(1 << (8-off));
258 uchar sym;
259 #endif
260 for (i=0; i<count; ++i) {
261 uchar c, bits;
263 c = *s++;
264 bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
266 #if LCD_BPP == LCD_MONOCHROME
267 sym = (COLOR_MASK(lcd_color_fg) & bits) |
268 (COLOR_MASK(lcd_color_bg) & ~bits);
270 *d++ = rest | (sym >> off);
271 rest = sym << (8-off);
272 #elif LCD_BPP == LCD_COLOR8
273 for (c=0; c<8; ++c) {
274 *d++ = (bits & 0x80) ?
275 lcd_color_fg : lcd_color_bg;
276 bits <<= 1;
278 #elif LCD_BPP == LCD_COLOR16
279 ushort *m = (ushort *)d;
280 for (c=0; c< 8; ++c) {
281 *m++ = (bits & 0x80) ?
282 lcd_color_fg : lcd_color_bg;
283 d+=2;
284 bits <<= 1;
286 #elif LCD_BPP == LCD_COLOR18
287 uint *m = (uint *)d;
288 for (c=0; c< 8 ; ++c) {
289 *m++ = (bits & 0x80) ?
290 lcd_color_fg : lcd_color_bg;
291 d+=4;
292 bits <<= 1;
294 #endif
296 #if LCD_BPP == LCD_MONOCHROME
297 *d = rest | (*d & ((1 << (8-off)) - 1));
298 #endif
301 #ifdef CONFIG_JZSLCD
302 //lcd_set_target(100,100,panel_info.vl_col,panel_info.vl_row);
303 write_frame();
304 jz_slcd_update();
306 #endif
307 #ifdef CONFIG_JzRISC /* JzRISC core */
308 flush_cache_all();
309 #endif
312 /*----------------------------------------------------------------------*/
314 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
316 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
317 lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen ((char *)s));
318 #else
319 lcd_drawchars (x, y, s, strlen ((char *)s));
320 #endif
323 /*----------------------------------------------------------------------*/
325 static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
327 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
328 lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
329 #else
330 lcd_drawchars (x, y, &c, 1);
331 #endif
334 /************************************************************************/
335 /** Small utility to check that you got the colours right */
336 /************************************************************************/
337 #ifdef LCD_TEST_PATTERN
339 #define N_BLK_VERT 2
340 #define N_BLK_HOR 3
342 static int test_colors[N_BLK_HOR*N_BLK_VERT] = {
343 CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW,
344 CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN,
347 static void test_pattern (void)
349 ushort v_max = panel_info.vl_row;
350 ushort h_max = panel_info.vl_col;
351 ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
352 ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR;
353 ushort v, h;
354 uchar *pix = (uchar *)lcd_base;
356 printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n",
357 h_max, v_max, h_step, v_step);
359 /* WARNING: Code silently assumes 8bit/pixel */
360 for (v=0; v<v_max; ++v) {
361 uchar iy = v / v_step;
362 for (h=0; h<h_max; ++h) {
363 uchar ix = N_BLK_HOR * iy + (h/h_step);
364 *pix++ = test_colors[ix];
368 #endif /* LCD_TEST_PATTERN */
371 /************************************************************************/
372 /* ** GENERIC Initialization Routines */
373 /************************************************************************/
375 int drv_lcd_init (void)
377 device_t lcddev;
378 int rc;
380 lcd_base = (void *)(gd->fb_base);
382 lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
384 lcd_init (lcd_base); /* LCD initialization */
386 /* Device initialization */
387 memset (&lcddev, 0, sizeof (lcddev));
389 strcpy (lcddev.name, "lcd");
390 lcddev.ext = 0; /* No extensions */
391 lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
392 lcddev.putc = lcd_putc; /* 'putc' function */
393 lcddev.puts = lcd_puts; /* 'puts' function */
395 rc = device_register (&lcddev);
397 return (rc == 0) ? 1 : rc;
400 /*----------------------------------------------------------------------*/
401 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
403 #if LCD_BPP == LCD_MONOCHROME
404 /* Setting the palette */
405 lcd_initcolregs();
407 #elif LCD_BPP == LCD_COLOR8
408 /* Setting the palette */
409 lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0);
410 lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0);
411 lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
412 lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
413 lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
414 lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
415 lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
416 lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
417 lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
418 #endif
420 #ifndef CFG_WHITE_ON_BLACK
421 lcd_setfgcolor (CONSOLE_COLOR_BLACK);
422 lcd_setbgcolor (CONSOLE_COLOR_WHITE);
423 #else
424 lcd_setfgcolor (CONSOLE_COLOR_WHITE);
425 lcd_setbgcolor (CONSOLE_COLOR_BLACK);
426 #endif /* CFG_WHITE_ON_BLACK */
428 #ifdef LCD_TEST_PATTERN
429 test_pattern();
430 #else
431 /* set framebuffer to background color */
432 #if LCD_BPP == LCD_COLOR16
433 long long i;
434 short *lcdbase_p = (short *)lcd_base;
435 for(i=0;i<lcd_line_length*panel_info.vl_row/2;i++)
436 *lcdbase_p++ = COLOR_MASK(lcd_getbgcolor());
438 #elif LCD_BPP == LCD_COLOR18
439 long long i;
440 int *lcdbase_p = (int *)lcd_base;
441 for(i=0;i<lcd_line_length*panel_info.vl_row/4;i++)
442 *lcdbase_p++ = COLOR_MASK(lcd_getbgcolor());
443 #else
444 memset ((char *)lcd_base,
445 COLOR_MASK(lcd_getbgcolor()),
446 lcd_line_length*panel_info.vl_row);
447 #endif
448 #endif
450 /* Paint the logo and retrieve LCD base address */
451 debug ("[LCD] Drawing the logo...\n");
452 lcd_console_address = lcd_logo ();
454 console_col = 0;
455 console_row = 0;
457 return (0);
460 U_BOOT_CMD(
461 cls, 1, 1, lcd_clear,
462 "cls - clear screen\n",
463 NULL
466 /*----------------------------------------------------------------------*/
468 static int lcd_init (void *lcdbase)
470 /* Initialize the lcd controller */
471 debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
473 lcd_ctrl_init (lcdbase);
474 lcd_clear (NULL, 1, 1, NULL); /* dummy args */
475 lcd_enable ();
477 /* Initialize the console */
478 console_col = 0;
479 #ifdef CONFIG_LCD_INFO_BELOW_LOGO
480 console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
481 #else
482 console_row = 1; /* leave 1 blank line below logo */
483 #endif
484 lcd_is_enabled = 1;
486 return 0;
490 /************************************************************************/
491 /* ** ROM capable initialization part - needed to reserve FB memory */
492 /************************************************************************/
494 * This is called early in the system initialization to grab memory
495 * for the LCD controller.
496 * Returns new address for monitor, after reserving LCD buffer memory
498 * Note that this is running from ROM, so no write access to global data.
500 ulong lcd_setmem (ulong addr)
502 ulong size;
503 int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
505 debug ("LCD panel info: %d x %d, %d bit/pix\n",
506 panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
508 size = line_length * panel_info.vl_row;
510 /* Round up to nearest full page */
511 size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
513 /* Allocate pages for the frame buffer. */
514 addr -= size;
516 debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr);
518 return (addr);
521 /*----------------------------------------------------------------------*/
523 static void lcd_setfgcolor (int color)
525 #if LCD_BPP == LCD_COLOR16
526 lcd_color_fg = color & 0xFFFF;
528 #elif LCD_BPP == LCD_COLOR18
529 lcd_color_fg = color & 0xFFFFFFFF;
530 #else
531 lcd_color_fg = color & 0xF;
532 #endif
535 /*----------------------------------------------------------------------*/
537 static void lcd_setbgcolor (int color)
539 #if LCD_BPP == LCD_COLOR16
540 lcd_color_bg = color & 0xFFFF;
542 #elif LCD_BPP == LCD_COLOR18
543 lcd_color_bg = color & 0xFFFFFFFF;
544 #else
545 lcd_color_bg = color & 0xF;
546 #endif
549 /*----------------------------------------------------------------------*/
551 #ifdef NOT_USED_SO_FAR
552 static int lcd_getfgcolor (void)
554 return lcd_color_fg;
557 #endif /* NOT_USED_SO_FAR */
559 /*----------------------------------------------------------------------*/
561 static int lcd_getbgcolor (void)
563 return lcd_color_bg;
566 /*----------------------------------------------------------------------*/
568 /************************************************************************/
569 /* ** Chipset depending Bitmap / Logo stuff... */
570 /************************************************************************/
571 #ifdef CONFIG_LCD_LOGO
572 void bitmap_plot (int x, int y)
574 ushort *cmap;
575 ushort i, j;
576 uchar *bmap;
577 uchar *fb;
578 ushort *fb16;
579 uint *fb32;
580 #if defined(CONFIG_PXA250)
581 struct pxafb_info *fbi = &panel_info.pxa;
582 #elif defined(CONFIG_MPC823)
583 volatile immap_t *immr = (immap_t *) CFG_IMMR;
584 volatile cpm8xx_t *cp = &(immr->im_cpm);
585 #endif
586 debug ("Logo: width %d height %d colors %d cmap %d\n",
587 BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
588 sizeof(bmp_logo_palette)/(sizeof(ushort)));
590 bmap = &bmp_logo_bitmap[0];
591 fb = (uchar *)(lcd_base + y * lcd_line_length + x);
593 if (NBITS(panel_info.vl_bpix) < 12) {
594 /* Leave room for default color map */
595 #if defined(CONFIG_PXA250)
596 cmap = (ushort *)fbi->palette;
597 #elif defined(CONFIG_MPC823)
598 cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
599 #endif
601 WATCHDOG_RESET();
603 /* Set color map */
605 for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) {
606 ushort colreg = bmp_logo_palette[i];
607 #ifdef CFG_INVERT_COLORS
608 *cmap++ = 0xffff - colreg;
609 #else
610 *cmap++ = colreg;
611 #endif
614 WATCHDOG_RESET();
616 for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
617 memcpy (fb, bmap, BMP_LOGO_WIDTH);
618 bmap += BMP_LOGO_WIDTH;
619 fb += panel_info.vl_col;
622 else{ /* true color mode */
623 if(NBITS(panel_info.vl_bpix) == 16){
624 fb16 = (ushort *)(lcd_base + y * lcd_line_length + x);
625 for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
626 for (j=0; j<BMP_LOGO_WIDTH; j++) {
627 fb16[j] = bmp_logo_palette[(bmap[j])];
629 bmap += BMP_LOGO_WIDTH;
630 fb16 += panel_info.vl_col;
633 else{
634 fb32 = (uint *)(lcd_base + y * lcd_line_length + x);
635 for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
636 for (j=0; j<BMP_LOGO_WIDTH; j++) {
637 fb32[j] = bmp_logo_palette[(bmap[j])];
639 bmap += BMP_LOGO_WIDTH;
640 fb32 += panel_info.vl_col;
646 WATCHDOG_RESET();
648 #endif /* CONFIG_LCD_LOGO */
650 /*----------------------------------------------------------------------*/
651 #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
653 * Display the BMP file located at address bmp_image.
654 * Only uncompressed.
656 int lcd_display_bitmap(ulong bmp_image, int x, int y)
658 #if !defined(CONFIG_MCC200)
659 ushort *cmap;
660 #endif
661 ushort i, j;
662 uchar *fb;
663 bmp_image_t *bmp=(bmp_image_t *)bmp_image;
664 uchar *bmap;
665 ushort padded_line;
666 unsigned long width, height;
667 unsigned long pwidth = panel_info.vl_col;
668 unsigned colors,bpix;
669 unsigned long compression;
670 #if defined(CONFIG_PXA250)
671 struct pxafb_info *fbi = &panel_info.pxa;
672 #elif defined(CONFIG_MPC823)
673 volatile immap_t *immr = (immap_t *) CFG_IMMR;
674 volatile cpm8xx_t *cp = &(immr->im_cpm);
675 #endif
677 if (!((bmp->header.signature[0]=='B') &&
678 (bmp->header.signature[1]=='M'))) {
679 printf ("Error: no valid bmp image at %lx\n", bmp_image);
680 return 1;
683 width = le32_to_cpu (bmp->header.width);
684 height = le32_to_cpu (bmp->header.height);
685 colors = 1<<le16_to_cpu (bmp->header.bit_count);
686 compression = le32_to_cpu (bmp->header.compression);
688 bpix = NBITS(panel_info.vl_bpix);
690 if ((bpix != 1) && (bpix != 8)) {
691 printf ("Error: %d bit/pixel mode not supported by U-Boot\n",
692 bpix);
693 return 1;
696 if (bpix != le16_to_cpu(bmp->header.bit_count)) {
697 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
698 bpix,
699 le16_to_cpu(bmp->header.bit_count));
700 return 1;
703 debug ("Display-bmp: %d x %d with %d colors\n",
704 (int)width, (int)height, (int)colors);
706 #if !defined(CONFIG_MCC200)
707 /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
708 if (bpix==8) {
709 #if defined(CONFIG_PXA250)
710 cmap = (ushort *)fbi->palette;
711 #elif defined(CONFIG_MPC823)
712 cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
713 #else
714 # error "Don't know location of color map"
715 #endif
717 /* Set color map */
718 for (i=0; i<colors; ++i) {
719 bmp_color_table_entry_t cte = bmp->color_table[i];
720 ushort colreg =
721 ( ((cte.red) << 8) & 0xf800) |
722 ( ((cte.green) << 3) & 0x07e0) |
723 ( ((cte.blue) >> 3) & 0x001f) ;
724 #ifdef CFG_INVERT_COLORS
725 *cmap = 0xffff - colreg;
726 #else
727 *cmap = colreg;
728 #endif
729 #if defined(CONFIG_PXA250)
730 cmap++;
731 #elif defined(CONFIG_MPC823)
732 cmap--;
733 #endif
736 #endif
739 * BMP format for Monochrome assumes that the state of a
740 * pixel is described on a per Bit basis, not per Byte.
741 * So, in case of Monochrome BMP we should align widths
742 * on a byte boundary and convert them from Bit to Byte
743 * units.
744 * Probably, PXA250 and MPC823 process 1bpp BMP images in
745 * their own ways, so make the converting to be MCC200
746 * specific.
748 #if defined(CONFIG_MCC200)
749 if (bpix==1)
751 width = ((width + 7) & ~7) >> 3;
752 x = ((x + 7) & ~7) >> 3;
753 pwidth= ((pwidth + 7) & ~7) >> 3;
755 #endif
757 padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
758 if ((x + width)>pwidth)
759 width = pwidth - x;
760 if ((y + height)>panel_info.vl_row)
761 height = panel_info.vl_row - y;
763 bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
764 fb = (uchar *) (lcd_base +
765 (y + height - 1) * lcd_line_length + x);
766 for (i = 0; i < height; ++i) {
767 WATCHDOG_RESET();
768 for (j = 0; j < width ; j++)
769 #if defined(CONFIG_PXA250)
770 *(fb++)=*(bmap++);
771 #elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
772 *(fb++)=255-*(bmap++);
773 #endif
774 bmap += (width - padded_line);
775 fb -= (width + lcd_line_length);
778 return (0);
780 #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
783 static void *lcd_logo (void)
785 #ifdef CONFIG_LCD_INFO
786 char info[80];
787 char temp[32];
788 #endif /* CONFIG_LCD_INFO */
790 #ifdef CONFIG_SPLASH_SCREEN
791 char *s;
792 ulong addr;
793 static int do_splash = 1;
795 if (do_splash && (s = getenv("splashimage")) != NULL) {
796 addr = simple_strtoul(s, NULL, 16);
797 do_splash = 0;
799 if (lcd_display_bitmap (addr, 0, 0) == 0) {
800 return ((void *)lcd_base);
803 #endif /* CONFIG_SPLASH_SCREEN */
805 #ifdef CONFIG_LCD_LOGO
806 bitmap_plot (0, 0);
807 flush_cache_all();
808 #endif /* CONFIG_LCD_LOGO */
810 #ifdef CONFIG_MPC823
811 # ifdef CONFIG_LCD_INFO
812 sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
813 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, (uchar *)info, strlen(info));
815 sprintf (info, "(C) 2004 DENX Software Engineering");
816 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT,
817 (uchar *)info, strlen(info));
819 sprintf (info, " Wolfgang DENK, wd@denx.de");
820 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2,
821 (uchar *)info, strlen(info));
822 # ifdef CONFIG_LCD_INFO_BELOW_LOGO
823 sprintf (info, "MPC823 CPU at %s MHz",
824 strmhz(temp, gd->cpu_clk));
825 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
826 info, strlen(info));
827 sprintf (info, " %ld MB RAM, %ld MB Flash",
828 gd->ram_size >> 20,
829 gd->bd->bi_flashsize >> 20 );
830 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
831 info, strlen(info));
832 # else
833 /* leave one blank line */
835 sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",
836 strmhz(temp, gd->cpu_clk),
837 gd->ram_size >> 20,
838 gd->bd->bi_flashsize >> 20 );
839 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
840 (uchar *)info, strlen(info));
842 # endif /* CONFIG_LCD_INFO_BELOW_LOGO */
843 # endif /* CONFIG_LCD_INFO */
844 #endif /* CONFIG_MPC823 */
846 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
847 return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
848 #else
849 return ((void *)lcd_base);
850 #endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */
853 /************************************************************************/
854 /************************************************************************/
856 #endif /* CONFIG_LCD */