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
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,
26 /************************************************************************/
28 /************************************************************************/
36 #include <linux/types.h>
37 #include <stdio_dev.h>
38 #include <asm/system.h>
39 #if defined(CONFIG_POST)
45 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
46 #include <asm/byteorder.h>
49 #if defined(CONFIG_MPC823)
53 #if defined(CONFIG_ATMEL_LCD)
54 #include <atmel_lcdc.h>
57 /************************************************************************/
59 /************************************************************************/
60 #include <video_font.h> /* Get font data, width and height */
62 /************************************************************************/
64 /************************************************************************/
65 #ifdef CONFIG_LCD_LOGO
66 # include <bmp_logo.h> /* Get logo data, width and height */
67 # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
68 # error Default Color Map overlaps with Logo Color Map
72 DECLARE_GLOBAL_DATA_PTR;
74 ulong lcd_setmem (ulong addr);
76 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
77 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
78 static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
80 static int lcd_init (void *lcdbase);
81 static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc,
83 static void *lcd_logo(void);
84 int lcd_display_bitmap_24(ulong bmp_image, int x, int y);
86 static int lcd_getbgcolor(void);
87 static void lcd_setfgcolor(int color);
88 static void lcd_setbgcolor(int color);
90 #ifdef CONFIG_QSD8X50_LCDC
91 extern void lcdc_drawchar(ushort x, ushort y, uchar c);
92 extern void lcd_disable(void);
93 extern void lcd_enable(void);
96 static int lcd_getbgcolor (void);
97 static void lcd_setfgcolor (int color);
98 static void lcd_setbgcolor (int color);
100 char lcd_is_enabled = 0;
102 static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */
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 /* Flush LCD activity to the caches */
118 if (lcd_flush_dcache)
119 flush_dcache_range((ulong)lcd_base,
120 (ulong)(lcd_base + lcd_get_size(&line_length)));
123 void lcd_set_flush_dcache(int flush)
125 lcd_flush_dcache = flush != 0;
128 /*----------------------------------------------------------------------*/
130 static void console_scrollup (void)
132 /* Copy up rows ignoring the first one */
133 memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
135 /* Clear the last one */
136 memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
140 /*----------------------------------------------------------------------*/
142 static inline void console_back (void)
144 if (--console_col < 0) {
145 console_col = CONSOLE_COLS-1 ;
146 if (--console_row < 0) {
151 lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
152 console_row * VIDEO_FONT_HEIGHT,
156 /*----------------------------------------------------------------------*/
158 static inline void console_newline (void)
163 /* Check if we need to scroll the terminal */
164 if (console_row >= CONSOLE_ROWS) {
165 /* Scroll everything up */
166 console_scrollup () ;
171 /*----------------------------------------------------------------------*/
173 void lcd_putc (const char c)
175 if (!lcd_is_enabled) {
181 case '\r': console_col = 0;
184 case '\n': console_newline();
187 case '\t': /* Tab (8 chars alignment) */
191 if (console_col >= CONSOLE_COLS) {
196 case '\b': console_back();
199 default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
200 console_row * VIDEO_FONT_HEIGHT,
202 if (++console_col >= CONSOLE_COLS) {
210 /*----------------------------------------------------------------------*/
212 void lcd_puts (const char *s)
214 if (!lcd_is_enabled) {
225 /*----------------------------------------------------------------------*/
227 void lcd_printf(const char *fmt, ...)
230 char buf[CONFIG_SYS_PBSIZE];
233 vsprintf(buf, fmt, args);
239 /************************************************************************/
240 /* ** Low-Level Graphics Routines */
241 /************************************************************************/
243 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
248 #if LCD_BPP == LCD_MONOCHROME
250 off = x * (1 << LCD_BPP) % 8;
252 dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
254 for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
257 #if LCD_BPP == LCD_COLOR16
258 ushort *d = (ushort *)dest;
263 #if LCD_BPP == LCD_MONOCHROME
264 uchar rest = *d & -(1 << (8-off));
267 for (i=0; i<count; ++i) {
271 bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
273 #if LCD_BPP == LCD_MONOCHROME
274 sym = (COLOR_MASK(lcd_color_fg) & bits) |
275 (COLOR_MASK(lcd_color_bg) & ~bits);
277 *d++ = rest | (sym >> off);
278 rest = sym << (8-off);
279 #elif LCD_BPP == LCD_COLOR8
280 for (c=0; c<8; ++c) {
281 *d++ = (bits & 0x80) ?
282 lcd_color_fg : lcd_color_bg;
285 #elif LCD_BPP == LCD_COLOR16
286 for (c=0; c<8; ++c) {
287 *d++ = (bits & 0x80) ?
288 lcd_color_fg : lcd_color_bg;
293 #if LCD_BPP == LCD_MONOCHROME
294 *d = rest | (*d & ((1 << (8-off)) - 1));
299 /*----------------------------------------------------------------------*/
301 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
303 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
304 lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen ((char *)s));
306 lcd_drawchars (x, y, s, strlen ((char *)s));
310 /*----------------------------------------------------------------------*/
312 static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
314 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
315 lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
317 lcd_drawchars (x, y, &c, 1);
321 /************************************************************************/
322 /** Small utility to check that you got the colours right */
323 /************************************************************************/
324 #ifdef LCD_TEST_PATTERN
329 static int test_colors[N_BLK_HOR*N_BLK_VERT] = {
330 CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW,
331 CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN,
334 static void test_pattern (void)
336 ushort v_max = panel_info.vl_row;
337 ushort h_max = panel_info.vl_col;
338 ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
339 ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR;
341 uchar *pix = (uchar *)lcd_base;
343 printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n",
344 h_max, v_max, h_step, v_step);
346 /* WARNING: Code silently assumes 8bit/pixel */
347 for (v=0; v<v_max; ++v) {
348 uchar iy = v / v_step;
349 for (h=0; h<h_max; ++h) {
350 uchar ix = N_BLK_HOR * iy + (h/h_step);
351 *pix++ = test_colors[ix];
355 #endif /* LCD_TEST_PATTERN */
358 /************************************************************************/
359 /* ** GENERIC Initialization Routines */
360 /************************************************************************/
362 int lcd_get_size(int *line_length)
364 *line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
365 return *line_length * panel_info.vl_row;
368 int drv_lcd_init (void)
370 struct stdio_dev lcddev;
373 lcd_base = (void *)(gd->fb_base);
375 lcd_get_size(&lcd_line_length);
377 lcd_init (lcd_base); /* LCD initialization */
379 /* Device initialization */
380 memset (&lcddev, 0, sizeof (lcddev));
382 strcpy (lcddev.name, "lcd");
383 lcddev.ext = 0; /* No extensions */
384 lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
385 lcddev.putc = lcd_putc; /* 'putc' function */
386 lcddev.puts = lcd_puts; /* 'puts' function */
388 rc = stdio_register (&lcddev);
390 return (rc == 0) ? 1 : rc;
393 /*----------------------------------------------------------------------*/
396 #if LCD_BPP == LCD_MONOCHROME
397 /* Setting the palette */
400 #elif LCD_BPP == LCD_COLOR8
401 /* Setting the palette */
402 lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0);
403 lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0);
404 lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
405 lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
406 lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
407 lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
408 lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
409 lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
410 lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
413 #ifndef CONFIG_SYS_WHITE_ON_BLACK
414 lcd_setfgcolor (CONSOLE_COLOR_BLACK);
415 lcd_setbgcolor (CONSOLE_COLOR_WHITE);
417 lcd_setfgcolor (CONSOLE_COLOR_WHITE);
418 lcd_setbgcolor (CONSOLE_COLOR_BLACK);
419 #endif /* CONFIG_SYS_WHITE_ON_BLACK */
421 #ifdef LCD_TEST_PATTERN
424 /* set framebuffer to background color */
425 memset ((char *)lcd_base,
426 COLOR_MASK(lcd_getbgcolor()),
427 lcd_line_length*panel_info.vl_row);
429 /* Paint the logo and retrieve LCD base address */
430 debug ("[LCD] Drawing the logo...\n");
431 lcd_console_address = lcd_logo ();
440 static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc,
447 cls, 1, 1, do_lcd_clear,
452 /*----------------------------------------------------------------------*/
454 static int lcd_init (void *lcdbase)
456 /* Initialize the lcd controller */
457 debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
459 lcd_ctrl_init (lcdbase);
461 do_lcd_clear (NULL, 1, 1, NULL); /* dummy args */
464 /* Initialize the console */
466 #ifdef CONFIG_LCD_INFO_BELOW_LOGO
467 console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
469 console_row = 1; /* leave 1 blank line below logo */
476 /************************************************************************/
477 /* ** ROM capable initialization part - needed to reserve FB memory */
478 /************************************************************************/
480 * This is called early in the system initialization to grab memory
481 * for the LCD controller.
482 * Returns new address for monitor, after reserving LCD buffer memory
484 * Note that this is running from ROM, so no write access to global data.
486 ulong lcd_setmem (ulong addr)
491 debug ("LCD panel info: %d x %d, %d bit/pix\n",
492 panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
494 size = lcd_get_size(&line_length);
496 /* Round up to nearest full page, or MMU section if defined */
497 #ifdef CONFIG_ALIGN_LCD_TO_SECTION
498 size = ALIGN(size, MMU_SECTION_SIZE);
499 addr = ALIGN(addr- MMU_SECTION_SIZE + 1, MMU_SECTION_SIZE);
501 size = ALIGN(size, PAGE_SIZE);
502 addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE);
505 /* Allocate pages for the frame buffer. */
508 debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr);
513 /*----------------------------------------------------------------------*/
515 static void lcd_setfgcolor (int color)
517 lcd_color_fg = color;
520 /*----------------------------------------------------------------------*/
522 static void lcd_setbgcolor (int color)
524 lcd_color_bg = color;
527 /*----------------------------------------------------------------------*/
529 #ifdef NOT_USED_SO_FAR
530 static int lcd_getfgcolor (void)
534 #endif /* NOT_USED_SO_FAR */
536 /*----------------------------------------------------------------------*/
538 static int lcd_getbgcolor (void)
543 /*----------------------------------------------------------------------*/
545 /************************************************************************/
546 /* ** Chipset depending Bitmap / Logo stuff... */
547 /************************************************************************/
548 #ifdef CONFIG_LCD_LOGO
549 void bitmap_plot (int x, int y)
551 #ifdef CONFIG_ATMEL_LCD
560 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
561 struct pxafb_info *fbi = &panel_info.pxa;
562 #elif defined(CONFIG_MPC823)
563 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
564 volatile cpm8xx_t *cp = &(immr->im_cpm);
567 debug ("Logo: width %d height %d colors %d cmap %d\n",
568 BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
569 (int)(sizeof(bmp_logo_palette)/(sizeof(ushort))));
571 bmap = &bmp_logo_bitmap[0];
572 fb = (uchar *)(lcd_base + y * lcd_line_length + x);
574 if (NBITS(panel_info.vl_bpix) < 12) {
575 /* Leave room for default color map */
576 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
577 cmap = (ushort *)fbi->palette;
578 #elif defined(CONFIG_MPC823)
579 cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
580 #elif defined(CONFIG_ATMEL_LCD)
581 cmap = (uint *) (panel_info.mmio + ATMEL_LCDC_LUT(0));
584 * default case: generic system with no cmap (most likely 16bpp)
585 * We set cmap to the source palette, so no change is done.
586 * This avoids even more ifdef in the next stanza
588 cmap = bmp_logo_palette;
594 for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) {
595 ushort colreg = bmp_logo_palette[i];
596 #ifdef CONFIG_ATMEL_LCD
598 #ifdef CONFIG_ATMEL_LCD_BGR555
599 lut_entry = ((colreg & 0x000F) << 11) |
600 ((colreg & 0x00F0) << 2) |
601 ((colreg & 0x0F00) >> 7);
602 #else /* CONFIG_ATMEL_LCD_RGB565 */
603 lut_entry = ((colreg & 0x000F) << 1) |
604 ((colreg & 0x00F0) << 3) |
605 ((colreg & 0x0F00) << 4);
607 *(cmap + BMP_LOGO_OFFSET) = lut_entry;
609 #else /* !CONFIG_ATMEL_LCD */
610 #ifdef CONFIG_SYS_INVERT_COLORS
611 *cmap++ = 0xffff - colreg;
615 #endif /* CONFIG_ATMEL_LCD */
620 for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
621 memcpy (fb, bmap, BMP_LOGO_WIDTH);
622 bmap += BMP_LOGO_WIDTH;
623 fb += panel_info.vl_col;
626 else { /* true color mode */
628 fb16 = (ushort *)(lcd_base + y * lcd_line_length + x);
629 for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
630 for (j=0; j<BMP_LOGO_WIDTH; j++) {
631 col16 = bmp_logo_palette[(bmap[j]-16)];
633 ((col16 & 0x000F) << 1) |
634 ((col16 & 0x00F0) << 3) |
635 ((col16 & 0x0F00) << 4);
637 bmap += BMP_LOGO_WIDTH;
638 fb16 += panel_info.vl_col;
645 #endif /* CONFIG_LCD_LOGO */
647 /*----------------------------------------------------------------------*/
648 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
650 * Display the BMP file located at address bmp_image.
654 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
655 #define BMP_ALIGN_CENTER 0x7FFF
658 #ifdef CONFIG_LCD_BMP_RLE8
660 #define BMP_RLE8_ESCAPE 0
661 #define BMP_RLE8_EOL 0
662 #define BMP_RLE8_EOBMP 1
663 #define BMP_RLE8_DELTA 2
665 static uchar *draw_unencoded_bitmap(uchar *fb, uchar *bmap, ushort *cmap,
668 ushort *fb_short = (ushort *)fb;
670 *fb_short++ = cmap[*bmap++];
673 return (uchar *)fb_short;
676 static uchar *draw_encoded_bitmap(uchar *fb, ushort c, int cnt)
678 ushort *fb_short = (ushort *)fb;
679 int cnt_8copy = cnt >> 3;
680 cnt -= cnt_8copy << 3;
681 while (cnt_8copy > 0) {
696 return (uchar *)fb_short;
699 /* Do not call this function directly, must be called from
700 * lcd_display_bitmap.
702 static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb,
703 int x_off, int y_off)
711 width = le32_to_cpu(bmp->header.width);
712 height = le32_to_cpu(bmp->header.height);
713 bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset);
719 if (bmap[0] == BMP_RLE8_ESCAPE) {
726 /* 16bpix, 2-byte per pixel, width should *2 */
727 fb -= (width * 2 + lcd_line_length);
737 /* 16bpix, 2-byte per pixel, x should *2 */
738 fb = (uchar *) (lcd_base + (y + y_off - 1)
739 * lcd_line_length + (x + x_off) * 2);
748 if (x + runlen > width)
752 fb = draw_unencoded_bitmap(fb,
766 /* aggregate the same code */
767 while (bmap[0] == 0xff &&
768 bmap[2] != BMP_RLE8_ESCAPE &&
769 bmap[1] == bmap[3]) {
773 if (x + runlen > width)
777 fb = draw_encoded_bitmap(fb,
786 #endif /* CONFIG_LCD_BMP_RLE8 */
788 int lcd_display_bitmap(ulong bmp_image, int x, int y)
790 #if !defined(CONFIG_MCC200)
793 ushort *cmap_base = NULL;
796 bmp_image_t *bmp=(bmp_image_t *)bmp_image;
799 unsigned long width, height, byte_width;
800 unsigned long pwidth = panel_info.vl_col;
801 unsigned colors, bpix, bmp_bpix;
802 unsigned long compression;
803 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
804 struct pxafb_info *fbi = &panel_info.pxa;
805 #elif defined(CONFIG_MPC823)
806 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
807 volatile cpm8xx_t *cp = &(immr->im_cpm);
810 if (!((bmp->header.signature[0]=='B') &&
811 (bmp->header.signature[1]=='M'))) {
812 printf ("Error: no valid bmp image at %lx\n", bmp_image);
816 width = le32_to_cpu (bmp->header.width);
817 height = le32_to_cpu (bmp->header.height);
818 bmp_bpix = le16_to_cpu(bmp->header.bit_count);
819 colors = 1 << bmp_bpix;
820 compression = le32_to_cpu (bmp->header.compression);
822 bpix = NBITS(panel_info.vl_bpix);
824 if ((bpix != 1) && (bpix != 8) && (bpix != 16)) {
825 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
830 /* We support displaying 8bpp BMPs on 16bpp LCDs */
831 if (bpix != bmp_bpix && (bmp_bpix != 8 || bpix != 16)) {
832 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
834 le16_to_cpu(bmp->header.bit_count));
838 debug ("Display-bmp: %d x %d with %d colors\n",
839 (int)width, (int)height, (int)colors);
841 #if !defined(CONFIG_MCC200)
842 /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
844 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
845 cmap = (ushort *)fbi->palette;
846 #elif defined(CONFIG_MPC823)
847 cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
848 #elif !defined(CONFIG_ATMEL_LCD)
849 cmap = panel_info.cmap;
855 for (i=0; i<colors; ++i) {
856 bmp_color_table_entry_t cte = bmp->color_table[i];
857 #if !defined(CONFIG_ATMEL_LCD)
859 ( ((cte.red) << 8) & 0xf800) |
860 ( ((cte.green) << 3) & 0x07e0) |
861 ( ((cte.blue) >> 3) & 0x001f) ;
862 #ifdef CONFIG_SYS_INVERT_COLORS
863 *cmap = 0xffff - colreg;
867 #if defined(CONFIG_MPC823)
872 #else /* CONFIG_ATMEL_LCD */
873 lcd_setcolreg(i, cte.red, cte.green, cte.blue);
880 * BMP format for Monochrome assumes that the state of a
881 * pixel is described on a per Bit basis, not per Byte.
882 * So, in case of Monochrome BMP we should align widths
883 * on a byte boundary and convert them from Bit to Byte
885 * Probably, PXA250 and MPC823 process 1bpp BMP images in
886 * their own ways, so make the converting to be MCC200
889 #if defined(CONFIG_MCC200)
892 width = ((width + 7) & ~7) >> 3;
893 x = ((x + 7) & ~7) >> 3;
894 pwidth= ((pwidth + 7) & ~7) >> 3;
898 padded_width = (width&0x3) ? ((width&~0x3)+4) : (width);
900 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
901 if (x == BMP_ALIGN_CENTER)
902 x = max(0, (pwidth - width) / 2);
904 x = max(0, pwidth - width + x + 1);
906 if (y == BMP_ALIGN_CENTER)
907 y = max(0, (panel_info.vl_row - height) / 2);
909 y = max(0, panel_info.vl_row - height + y + 1);
910 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
912 if ((x + width)>pwidth)
914 if ((y + height)>panel_info.vl_row)
915 height = panel_info.vl_row - y;
917 bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset);
918 fb = (uchar *) (lcd_base + (y + height - 1) * lcd_line_length + x);
919 /* additional fb shift for bpix == 16 since each pixel is 2-byte */
924 case 1: /* pass through */
926 #ifdef CONFIG_LCD_BMP_RLE8
927 if (compression == BMP_BI_RLE8) {
929 /* TODO implement render code for bpix != 16 */
930 printf("Error: only support 16 bpix");
933 lcd_display_rle8_bitmap(bmp, cmap_base, fb, x, y);
941 byte_width = width * 2;
943 for (i = 0; i < height; ++i) {
945 for (j = 0; j < width; j++) {
947 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS || defined(CONFIG_ATMEL_LCD)
949 #elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
950 *(fb++) = 255 - *(bmap++);
953 *(uint16_t *)fb = cmap_base[*(bmap++)];
954 fb += sizeof(uint16_t) / sizeof(*fb);
957 bmap += (padded_width - width);
958 fb -= (byte_width + lcd_line_length);
962 #if defined(CONFIG_BMP_16BPP)
964 for (i = 0; i < height; ++i) {
966 for (j = 0; j < width; j++) {
967 #if defined(CONFIG_ATMEL_LCD_BGR555)
968 *(fb++) = ((bmap[0] & 0x1f) << 2) |
970 *(fb++) = (bmap[0] & 0xe0) |
971 ((bmap[1] & 0x7c) >> 2);
978 bmap += (padded_width - width) * 2;
979 fb -= (width * 2 + lcd_line_length);
982 #endif /* CONFIG_BMP_16BPP */
994 static void *lcd_logo (void)
996 #ifdef CONFIG_SPLASH_SCREEN
999 static int do_splash = 1;
1001 if (do_splash && (s = getenv("splashimage")) != NULL) {
1005 addr = simple_strtoul (s, NULL, 16);
1006 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
1007 if ((s = getenv ("splashpos")) != NULL) {
1009 x = BMP_ALIGN_CENTER;
1011 x = simple_strtol (s, NULL, 0);
1013 if ((s = strchr (s + 1, ',')) != NULL) {
1015 y = BMP_ALIGN_CENTER;
1017 y = simple_strtol (s + 1, NULL, 0);
1020 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
1022 #ifdef CONFIG_VIDEO_BMP_GZIP
1023 bmp_image_t *bmp = (bmp_image_t *)addr;
1026 if (!((bmp->header.signature[0]=='B') &&
1027 (bmp->header.signature[1]=='M'))) {
1028 addr = (ulong)gunzip_bmp(addr, &len);
1032 if (lcd_display_bitmap (addr, x, y) == 0) {
1033 return ((void *)lcd_base);
1036 #endif /* CONFIG_SPLASH_SCREEN */
1038 #ifdef CONFIG_LCD_LOGO
1040 #endif /* CONFIG_LCD_LOGO */
1042 #ifdef CONFIG_LCD_INFO
1043 console_col = LCD_INFO_X / VIDEO_FONT_WIDTH;
1044 console_row = LCD_INFO_Y / VIDEO_FONT_HEIGHT;
1045 lcd_show_board_info();
1046 #endif /* CONFIG_LCD_INFO */
1048 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
1049 return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
1051 return ((void *)lcd_base);
1052 #endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */
1055 /*---------------- functions required by vboot wrapper -----------------*/
1056 void lcd_position_cursor (unsigned col, unsigned row)
1058 console_col = min(col, CONSOLE_COLS - 1);
1059 console_row = min(row, CONSOLE_ROWS - 1);
1062 int lcd_get_pixel_width (void)
1064 return panel_info.vl_col;
1067 int lcd_get_pixel_height (void)
1069 return panel_info.vl_row;
1072 int lcd_get_screen_rows (void)
1074 return CONSOLE_ROWS;
1077 int lcd_get_screen_columns (void)
1079 return CONSOLE_COLS;
1082 /************************************************************************/
1083 /************************************************************************/