blob: eaed2abd80563d6fa6958d25b61dfeccd39dc551 [file] [log] [blame]
wdenk8655b6f2004-10-09 23:25:58 +00001/*
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>
wdenk8b0bfc62005-04-03 23:11:38 +000043#include <watchdog.h>
wdenk8655b6f2004-10-09 23:25:58 +000044
45#if defined(CONFIG_PXA250)
46#include <asm/byteorder.h>
47#endif
48
49#if defined(CONFIG_MPC823)
wdenk8655b6f2004-10-09 23:25:58 +000050#include <lcdvideo.h>
51#endif
52
wdenk8655b6f2004-10-09 23:25:58 +000053#ifdef CONFIG_LCD
54
55/************************************************************************/
56/* ** FONT DATA */
57/************************************************************************/
58#include <video_font.h> /* Get font data, width and height */
59
wdenk88804d12005-07-04 00:03:16 +000060/************************************************************************/
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
wdenk8655b6f2004-10-09 23:25:58 +000069
Wolfgang Denkd87080b2006-03-31 18:32:53 +020070DECLARE_GLOBAL_DATA_PTR;
71
wdenk8655b6f2004-10-09 23:25:58 +000072ulong lcd_setmem (ulong addr);
73
74static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
75static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
76static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
77
78static int lcd_init (void *lcdbase);
79
80static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
81extern void lcd_ctrl_init (void *lcdbase);
82extern void lcd_enable (void);
83static void *lcd_logo (void);
84
85
86#if LCD_BPP == LCD_COLOR8
87extern void lcd_setcolreg (ushort regno,
88 ushort red, ushort green, ushort blue);
89#endif
90#if LCD_BPP == LCD_MONOCHROME
91extern void lcd_initcolregs (void);
92#endif
93
94static int lcd_getbgcolor (void);
95static void lcd_setfgcolor (int color);
96static void lcd_setbgcolor (int color);
97
98char lcd_is_enabled = 0;
99extern vidinfo_t panel_info;
100
101#ifdef NOT_USED_SO_FAR
102static void lcd_getcolreg (ushort regno,
103 ushort *red, ushort *green, ushort *blue);
104static int lcd_getfgcolor (void);
105#endif /* NOT_USED_SO_FAR */
106
107/************************************************************************/
108
109/*----------------------------------------------------------------------*/
110
111static 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
143static 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
159static 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
174void 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
213void 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
229static 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
280static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
281{
wdenk88804d12005-07-04 00:03:16 +0000282#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200283 lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen ((char *)s));
wdenk8655b6f2004-10-09 23:25:58 +0000284#else
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200285 lcd_drawchars (x, y, s, strlen ((char *)s));
wdenk8655b6f2004-10-09 23:25:58 +0000286#endif
287}
288
289/*----------------------------------------------------------------------*/
290
291static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
292{
wdenk88804d12005-07-04 00:03:16 +0000293#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
wdenk8655b6f2004-10-09 23:25:58 +0000294 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
308static 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
313static 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
341int drv_lcd_init (void)
342{
wdenk8655b6f2004-10-09 23:25:58 +0000343 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/*----------------------------------------------------------------------*/
367static 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
412U_BOOT_CMD(
413 cls, 1, 1, lcd_clear,
414 "cls - clear screen\n",
415 NULL
416);
417
418/*----------------------------------------------------------------------*/
419
420static 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;
wdenk88804d12005-07-04 00:03:16 +0000431#ifdef CONFIG_LCD_INFO_BELOW_LOGO
wdenk8655b6f2004-10-09 23:25:58 +0000432 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 */
452ulong 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
475static void lcd_setfgcolor (int color)
476{
477 lcd_color_fg = color & 0x0F;
478}
479
480/*----------------------------------------------------------------------*/
481
482static void lcd_setbgcolor (int color)
483{
484 lcd_color_bg = color & 0x0F;
485}
486
487/*----------------------------------------------------------------------*/
488
489#ifdef NOT_USED_SO_FAR
490static int lcd_getfgcolor (void)
491{
492 return lcd_color_fg;
493}
494#endif /* NOT_USED_SO_FAR */
495
496/*----------------------------------------------------------------------*/
497
498static 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
509void 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];
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200528 fb = (uchar *)(lcd_base + y * lcd_line_length + x);
wdenk8655b6f2004-10-09 23:25:58 +0000529
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 */
579int lcd_display_bitmap(ulong bmp_image, int x, int y)
580{
Wolfgang Denkf6414712006-10-20 15:51:21 +0200581#if !defined(CONFIG_MCC200)
wdenk8655b6f2004-10-09 23:25:58 +0000582 ushort *cmap;
Wolfgang Denkf6414712006-10-20 15:51:21 +0200583#endif
wdenk8655b6f2004-10-09 23:25:58 +0000584 ushort i, j;
585 uchar *fb;
586 bmp_image_t *bmp=(bmp_image_t *)bmp_image;
587 uchar *bmap;
588 ushort padded_line;
589 unsigned long width, height;
Wolfgang Denke8143e72006-08-30 23:09:00 +0200590 unsigned long pwidth = panel_info.vl_col;
wdenk8655b6f2004-10-09 23:25:58 +0000591 unsigned colors,bpix;
592 unsigned long compression;
593#if defined(CONFIG_PXA250)
594 struct pxafb_info *fbi = &panel_info.pxa;
595#elif defined(CONFIG_MPC823)
596 volatile immap_t *immr = (immap_t *) CFG_IMMR;
597 volatile cpm8xx_t *cp = &(immr->im_cpm);
598#endif
599
600 if (!((bmp->header.signature[0]=='B') &&
601 (bmp->header.signature[1]=='M'))) {
602 printf ("Error: no valid bmp image at %lx\n", bmp_image);
603 return 1;
604}
605
606 width = le32_to_cpu (bmp->header.width);
607 height = le32_to_cpu (bmp->header.height);
608 colors = 1<<le16_to_cpu (bmp->header.bit_count);
609 compression = le32_to_cpu (bmp->header.compression);
610
611 bpix = NBITS(panel_info.vl_bpix);
612
613 if ((bpix != 1) && (bpix != 8)) {
614 printf ("Error: %d bit/pixel mode not supported by U-Boot\n",
615 bpix);
616 return 1;
617 }
618
619 if (bpix != le16_to_cpu(bmp->header.bit_count)) {
620 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
621 bpix,
622 le16_to_cpu(bmp->header.bit_count));
623 return 1;
624 }
625
626 debug ("Display-bmp: %d x %d with %d colors\n",
627 (int)width, (int)height, (int)colors);
628
Wolfgang Denkf6414712006-10-20 15:51:21 +0200629#if !defined(CONFIG_MCC200)
630 /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
wdenk8655b6f2004-10-09 23:25:58 +0000631 if (bpix==8) {
632#if defined(CONFIG_PXA250)
633 cmap = (ushort *)fbi->palette;
634#elif defined(CONFIG_MPC823)
635 cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
wdenk25d67122004-12-10 11:40:40 +0000636#else
637# error "Don't know location of color map"
wdenk8655b6f2004-10-09 23:25:58 +0000638#endif
639
640 /* Set color map */
641 for (i=0; i<colors; ++i) {
642 bmp_color_table_entry_t cte = bmp->color_table[i];
643 ushort colreg =
644 ( ((cte.red) << 8) & 0xf800) |
Wolfgang Denk59d80bf2005-09-21 15:24:52 +0200645 ( ((cte.green) << 3) & 0x07e0) |
646 ( ((cte.blue) >> 3) & 0x001f) ;
wdenk8655b6f2004-10-09 23:25:58 +0000647#ifdef CFG_INVERT_COLORS
wdenk25d67122004-12-10 11:40:40 +0000648 *cmap = 0xffff - colreg;
wdenk8655b6f2004-10-09 23:25:58 +0000649#else
wdenk25d67122004-12-10 11:40:40 +0000650 *cmap = colreg;
651#endif
652#if defined(CONFIG_PXA250)
653 cmap++;
654#elif defined(CONFIG_MPC823)
655 cmap--;
wdenk8655b6f2004-10-09 23:25:58 +0000656#endif
657 }
658 }
Wolfgang Denkf6414712006-10-20 15:51:21 +0200659#endif
wdenk8655b6f2004-10-09 23:25:58 +0000660
Wolfgang Denke8143e72006-08-30 23:09:00 +0200661 /*
662 * BMP format for Monochrome assumes that the state of a
663 * pixel is described on a per Bit basis, not per Byte.
664 * So, in case of Monochrome BMP we should align widths
665 * on a byte boundary and convert them from Bit to Byte
666 * units.
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200667 * Probably, PXA250 and MPC823 process 1bpp BMP images in
668 * their own ways, so make the converting to be MCC200
Wolfgang Denke8143e72006-08-30 23:09:00 +0200669 * specific.
670 */
671#if defined(CONFIG_MCC200)
672 if (bpix==1)
673 {
674 width = ((width + 7) & ~7) >> 3;
675 x = ((x + 7) & ~7) >> 3;
676 pwidth= ((pwidth + 7) & ~7) >> 3;
677 }
678#endif
679
wdenk8655b6f2004-10-09 23:25:58 +0000680 padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
Wolfgang Denke8143e72006-08-30 23:09:00 +0200681 if ((x + width)>pwidth)
682 width = pwidth - x;
wdenk8655b6f2004-10-09 23:25:58 +0000683 if ((y + height)>panel_info.vl_row)
684 height = panel_info.vl_row - y;
685
686 bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
687 fb = (uchar *) (lcd_base +
688 (y + height - 1) * lcd_line_length + x);
689 for (i = 0; i < height; ++i) {
wdenk51152c12005-06-05 20:30:43 +0000690 WATCHDOG_RESET();
wdenk8655b6f2004-10-09 23:25:58 +0000691 for (j = 0; j < width ; j++)
692#if defined(CONFIG_PXA250)
693 *(fb++)=*(bmap++);
Wolfgang Denke8143e72006-08-30 23:09:00 +0200694#elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
wdenk8655b6f2004-10-09 23:25:58 +0000695 *(fb++)=255-*(bmap++);
696#endif
697 bmap += (width - padded_line);
698 fb -= (width + lcd_line_length);
699 }
700
701 return (0);
702}
703#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
704
705
706static void *lcd_logo (void)
707{
wdenk88804d12005-07-04 00:03:16 +0000708#ifdef CONFIG_LCD_INFO
wdenk8655b6f2004-10-09 23:25:58 +0000709 char info[80];
710 char temp[32];
wdenk88804d12005-07-04 00:03:16 +0000711#endif /* CONFIG_LCD_INFO */
wdenk8655b6f2004-10-09 23:25:58 +0000712
713#ifdef CONFIG_SPLASH_SCREEN
714 char *s;
715 ulong addr;
716 static int do_splash = 1;
717
718 if (do_splash && (s = getenv("splashimage")) != NULL) {
719 addr = simple_strtoul(s, NULL, 16);
720 do_splash = 0;
721
722 if (lcd_display_bitmap (addr, 0, 0) == 0) {
723 return ((void *)lcd_base);
724 }
725 }
726#endif /* CONFIG_SPLASH_SCREEN */
727
728#ifdef CONFIG_LCD_LOGO
729 bitmap_plot (0, 0);
730#endif /* CONFIG_LCD_LOGO */
731
732#ifdef CONFIG_MPC823
wdenk88804d12005-07-04 00:03:16 +0000733# ifdef CONFIG_LCD_INFO
wdenk8655b6f2004-10-09 23:25:58 +0000734 sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200735 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, (uchar *)info, strlen(info));
wdenk8655b6f2004-10-09 23:25:58 +0000736
737 sprintf (info, "(C) 2004 DENX Software Engineering");
738 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT,
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200739 (uchar *)info, strlen(info));
wdenk8655b6f2004-10-09 23:25:58 +0000740
741 sprintf (info, " Wolfgang DENK, wd@denx.de");
742 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2,
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200743 (uchar *)info, strlen(info));
wdenk88804d12005-07-04 00:03:16 +0000744# ifdef CONFIG_LCD_INFO_BELOW_LOGO
wdenk8655b6f2004-10-09 23:25:58 +0000745 sprintf (info, "MPC823 CPU at %s MHz",
746 strmhz(temp, gd->cpu_clk));
747 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
748 info, strlen(info));
749 sprintf (info, " %ld MB RAM, %ld MB Flash",
750 gd->ram_size >> 20,
751 gd->bd->bi_flashsize >> 20 );
752 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
753 info, strlen(info));
wdenk88804d12005-07-04 00:03:16 +0000754# else
wdenk8655b6f2004-10-09 23:25:58 +0000755 /* leave one blank line */
756
757 sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",
758 strmhz(temp, gd->cpu_clk),
759 gd->ram_size >> 20,
760 gd->bd->bi_flashsize >> 20 );
761 lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200762 (uchar *)info, strlen(info));
wdenk8655b6f2004-10-09 23:25:58 +0000763
wdenk88804d12005-07-04 00:03:16 +0000764# endif /* CONFIG_LCD_INFO_BELOW_LOGO */
765# endif /* CONFIG_LCD_INFO */
wdenk8655b6f2004-10-09 23:25:58 +0000766#endif /* CONFIG_MPC823 */
wdenk8655b6f2004-10-09 23:25:58 +0000767
wdenk88804d12005-07-04 00:03:16 +0000768#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
wdenk8655b6f2004-10-09 23:25:58 +0000769 return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
770#else
771 return ((void *)lcd_base);
wdenk88804d12005-07-04 00:03:16 +0000772#endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */
wdenk8655b6f2004-10-09 23:25:58 +0000773}
774
775/************************************************************************/
776/************************************************************************/
777
778#endif /* CONFIG_LCD */