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 /************************************************************************/
35 #include <linux/types.h>
36 #include <stdio_dev.h>
37 #if defined(CONFIG_POST)
43 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
44 #include <asm/byteorder.h>
47 #if defined(CONFIG_MPC823)
51 #if defined(CONFIG_ATMEL_LCD)
52 #include <atmel_lcdc.h>
55 /************************************************************************/
57 /************************************************************************/
58 #include <video_font.h> /* Get font data, width and height */
60 /************************************************************************/
62 /************************************************************************/
63 #ifdef CONFIG_LCD_LOGO
65 #include <sp_bmp_logo.h>
66 #include <thor_bmp_logo.h>
67 #include <charge_bmp_logo.h>
68 #include <prog_start_logo.h>
69 #include <prog_mid_logo.h>
70 #include <prog_end_logo.h>
71 # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
72 # error Default Color Map overlaps with Logo Color Map
77 #include "../property/tizen_misc.h"
80 DECLARE_GLOBAL_DATA_PTR;
82 ulong lcd_setmem (ulong addr);
84 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
85 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
86 static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
88 static int lcd_init (void *lcdbase);
90 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]);
91 static void *lcd_logo (void);
93 static int lcd_getbgcolor (void);
94 void lcd_setfgcolor (int color);
95 static void lcd_setbgcolor (int color);
98 char lcd_is_enabled = 0;
100 #ifdef NOT_USED_SO_FAR
101 static void lcd_getcolreg (ushort regno,
102 ushort *red, ushort *green, ushort *blue);
103 static int lcd_getfgcolor (void);
104 #endif /* NOT_USED_SO_FAR */
106 /************************************************************************/
108 /*----------------------------------------------------------------------*/
110 static void console_scrollup (void)
112 /* Copy up rows ignoring the first one */
113 memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
115 /* Clear the last one */
116 memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
119 /*----------------------------------------------------------------------*/
121 static inline void console_back (void)
123 if (--console_col < 0) {
124 console_col = CONSOLE_COLS-1 ;
125 if (--console_row < 0) {
130 lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
131 console_row * VIDEO_FONT_HEIGHT,
135 /*----------------------------------------------------------------------*/
137 static inline void console_newline (void)
142 /* Check if we need to scroll the terminal */
143 if (console_row >= CONSOLE_ROWS) {
144 /* Scroll everything up */
145 console_scrollup () ;
150 /*----------------------------------------------------------------------*/
152 void lcd_putc (const char c)
154 if (!lcd_is_enabled) {
160 case '\r': console_col = 0;
163 case '\n': console_newline();
166 case '\t': /* Tab (8 chars alignment) */
170 if (console_col >= CONSOLE_COLS) {
175 case '\b': console_back();
178 default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
179 console_row * VIDEO_FONT_HEIGHT,
181 if (++console_col >= CONSOLE_COLS) {
189 /*----------------------------------------------------------------------*/
191 void lcd_puts (const char *s)
193 if (!lcd_is_enabled) {
203 /*----------------------------------------------------------------------*/
205 void lcd_printf(const char *fmt, ...)
208 char buf[CONFIG_SYS_PBSIZE];
211 vsprintf(buf, fmt, args);
217 /************************************************************************/
218 /* ** Low-Level Graphics Routines */
219 /************************************************************************/
221 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
226 #if LCD_BPP == LCD_MONOCHROME
227 ushort off = x * (1 << LCD_BPP) % 8;
230 dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
232 for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
235 #if LCD_BPP == LCD_COLOR16
236 ushort *d = (ushort *)dest;
241 #if LCD_BPP == LCD_MONOCHROME
242 uchar rest = *d & -(1 << (8-off));
245 for (i=0; i<count; ++i) {
249 bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
251 #if LCD_BPP == LCD_MONOCHROME
252 sym = (COLOR_MASK(lcd_color_fg) & bits) |
253 (COLOR_MASK(lcd_color_bg) & ~bits);
255 *d++ = rest | (sym >> off);
256 rest = sym << (8-off);
257 #elif LCD_BPP == LCD_COLOR8
258 for (c=0; c<8; ++c) {
259 *d++ = (bits & 0x80) ?
260 lcd_color_fg : lcd_color_bg;
263 #elif LCD_BPP == LCD_COLOR16
264 for (c=0; c<8; ++c) {
265 *d++ = (bits & 0x80) ?
266 lcd_color_fg : lcd_color_bg;
271 #if LCD_BPP == LCD_MONOCHROME
272 *d = rest | (*d & ((1 << (8-off)) - 1));
277 /*----------------------------------------------------------------------*/
279 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
281 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) && !defined(CONFIG_TIZEN)
282 lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen ((char *)s));
284 lcd_drawchars (x, y, s, strlen ((char *)s));
288 /*----------------------------------------------------------------------*/
290 static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
292 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) && !defined(CONFIG_TIZEN)
293 lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
295 lcd_drawchars (x, y, &c, 1);
299 /************************************************************************/
300 /** Small utility to check that you got the colours right */
301 /************************************************************************/
302 #ifdef LCD_TEST_PATTERN
307 static int test_colors[N_BLK_HOR*N_BLK_VERT] = {
308 CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW,
309 CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN,
312 static void test_pattern (void)
314 ushort v_max = panel_info.vl_row;
315 ushort h_max = panel_info.vl_col;
316 ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
317 ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR;
319 uchar *pix = (uchar *)lcd_base;
321 printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n",
322 h_max, v_max, h_step, v_step);
324 /* WARNING: Code silently assumes 8bit/pixel */
325 for (v=0; v<v_max; ++v) {
326 uchar iy = v / v_step;
327 for (h=0; h<h_max; ++h) {
328 uchar ix = N_BLK_HOR * iy + (h/h_step);
329 *pix++ = test_colors[ix];
333 #endif /* LCD_TEST_PATTERN */
336 /************************************************************************/
337 /* ** GENERIC Initialization Routines */
338 /************************************************************************/
340 int drv_lcd_init (void)
342 struct stdio_dev lcddev;
345 lcd_base = (void *)(gd->fb_base);
347 lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
349 lcd_init (lcd_base); /* LCD initialization */
351 /* Device initialization */
352 memset (&lcddev, 0, sizeof (lcddev));
354 strcpy (lcddev.name, "lcd");
355 lcddev.ext = 0; /* No extensions */
356 lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
357 lcddev.putc = lcd_putc; /* 'putc' function */
358 lcddev.puts = lcd_puts; /* 'puts' function */
360 rc = stdio_register (&lcddev);
362 return (rc == 0) ? 1 : rc;
365 /*----------------------------------------------------------------------*/
366 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
368 #if LCD_BPP == LCD_MONOCHROME
369 /* Setting the palette */
372 #elif LCD_BPP == LCD_COLOR8
373 /* Setting the palette */
374 lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0);
375 lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0);
376 lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
377 lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
378 lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
379 lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
380 lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
381 lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
382 lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
385 #ifndef CONFIG_SYS_WHITE_ON_BLACK
386 lcd_setfgcolor (CONSOLE_COLOR_BLACK);
387 lcd_setbgcolor (CONSOLE_COLOR_WHITE);
389 //lcd_setfgcolor (CONSOLE_COLOR_WHITE);
390 #define CONSOLE_COLOR_RED (0x1f<<11)
391 lcd_setfgcolor (CONSOLE_COLOR_RED);
392 lcd_setbgcolor (CONSOLE_COLOR_BLACK);
393 #endif /* CONFIG_SYS_WHITE_ON_BLACK */
395 #ifdef LCD_TEST_PATTERN
398 /* set framebuffer to background color */
399 memset ((char *)lcd_base,
400 COLOR_MASK(lcd_getbgcolor()),
401 lcd_line_length*panel_info.vl_row);
403 /* Paint the logo and retrieve LCD base address */
404 debug ("[LCD] Drawing the logo...\n");
405 lcd_console_address = lcd_logo ();
414 cls, 1, 1, lcd_clear,
419 /*----------------------------------------------------------------------*/
421 static int lcd_init (void *lcdbase)
423 /* Initialize the lcd controller */
424 debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
426 lcd_ctrl_init (lcdbase);
428 lcd_clear (NULL, 1, 1, NULL); /* dummy args */
431 /* Initialize the console */
433 #ifdef CONFIG_LCD_INFO_BELOW_LOGO
434 console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
436 console_row = 1; /* leave 1 blank line below logo */
443 /************************************************************************/
444 /* ** ROM capable initialization part - needed to reserve FB memory */
445 /************************************************************************/
447 * This is called early in the system initialization to grab memory
448 * for the LCD controller.
449 * Returns new address for monitor, after reserving LCD buffer memory
451 * Note that this is running from ROM, so no write access to global data.
453 ulong lcd_setmem (ulong addr)
456 int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
458 debug ("LCD panel info: %d x %d, %d bit/pix\n",
459 panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
461 size = line_length * panel_info.vl_row;
463 /* Round up to nearest full page */
464 size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
466 /* Allocate pages for the frame buffer. */
469 debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr);
474 /*----------------------------------------------------------------------*/
476 void lcd_setfgcolor (int color)
478 lcd_color_fg = color;
481 /*----------------------------------------------------------------------*/
483 static void lcd_setbgcolor (int color)
485 lcd_color_bg = color;
488 /*----------------------------------------------------------------------*/
490 #ifdef NOT_USED_SO_FAR
491 static int lcd_getfgcolor (void)
495 #endif /* NOT_USED_SO_FAR */
497 /*----------------------------------------------------------------------*/
499 static int lcd_getbgcolor (void)
504 /*----------------------------------------------------------------------*/
506 /************************************************************************/
507 /* ** Chipset depending Bitmap / Logo stuff... */
508 /************************************************************************/
509 #ifdef CONFIG_LCD_LOGO
510 void _draw_image(int x, int y, int width, int height, unsigned short *palette, unsigned short *bitmap,
511 unsigned int *num_bitmap, unsigned int num_elem, int clear) {
512 unsigned long i, j, k, num_pre_pixels, num_post_pixels;
517 fb16 = (ushort *)(lcd_base);
519 num_pre_pixels = x + y * panel_info.vl_col;
520 num_post_pixels = (panel_info.vl_row * panel_info.vl_col) - (width * height);
524 memset(fb16, 0x0, num_pre_pixels * 2);
525 fb16 += num_pre_pixels;
529 for (i = 0; i < num_elem; i++) {
530 col16 = palette[bitmap[i]];
531 for (j = 0; j < num_bitmap[i]; j++) {
532 if (((k % width) == 0) && (k != 0)) {
533 fb16 += panel_info.vl_col;
535 memset(fb16, 0x0, panel_info.vl_col * 2);
538 (u16)(((col16 & 0xF) << 1) |
539 ((col16 & 0x0F0) << 3) |
540 ((col16 & 0xF00) << 4));
546 memset(fb16, 0x0, num_post_pixels * 2);
549 void draw_image(int mode) {
552 _draw_image(103, 530, sp_width, sp_height, sp_palette, sp_bitmap, sp_num_bitmap, sp_num_elem, 1);
555 _draw_image(171, 360, thor_width, thor_height, thor_palette, thor_bitmap, thor_num_bitmap, thor_num_elem, 1);
558 _draw_image(270, 440, charge_width, charge_height, charge_palette, charge_bitmap, charge_num_bitmap, charge_num_elem, 1);
563 #define DRAW_HEIGHT 925
565 static int last_non_drawn = -1;
567 void draw_progress(int per) {
568 int idx = (per * DRAW_STEP) / 100;
572 _draw_image(180, DRAW_HEIGHT, prog_start_width, prog_start_height, prog_start_palette, prog_start_bitmap, prog_start_num_bitmap, prog_start_num_elem, 0);
573 } else if(idx < DRAW_STEP) {
574 if (last_non_drawn == -1) {
575 _draw_image(180, DRAW_HEIGHT, prog_start_width, prog_start_height, prog_start_palette, prog_start_bitmap, prog_start_num_bitmap, prog_start_num_elem, 0);
578 tmp = last_non_drawn;
580 _draw_image(180 + 17 + (tmp - 1) * 6, DRAW_HEIGHT, prog_mid_width, prog_mid_height, prog_mid_palette, prog_mid_bitmap, prog_mid_num_bitmap, prog_mid_num_elem, 0);
583 if (last_non_drawn < idx)
584 last_non_drawn = idx;
586 if (idx == DRAW_STEP)
587 _draw_image(180, DRAW_HEIGHT, prog_start_width, prog_start_height, prog_start_palette, prog_start_bitmap, prog_start_num_bitmap, prog_start_num_elem, 0);
588 tmp = last_non_drawn;
590 _draw_image(180 + 17 + (tmp - 1) * 6, DRAW_HEIGHT, prog_mid_width, prog_mid_height, prog_mid_palette, prog_mid_bitmap, prog_mid_num_bitmap, prog_mid_num_elem, 0);
594 _draw_image(180 + 17 + (DRAW_STEP - 2) * 6, DRAW_HEIGHT, prog_end_width, prog_end_height, prog_end_palette, prog_end_bitmap, prog_end_num_bitmap, prog_end_num_elem, 0);
596 if (last_non_drawn < idx)
597 last_non_drawn = idx;
601 void bitmap_plot (int x, int y, int mode)
603 #ifdef CONFIG_ATMEL_LCD
612 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
613 struct pxafb_info *fbi = &panel_info.pxa;
614 #elif defined(CONFIG_MPC823)
615 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
616 volatile cpm8xx_t *cp = &(immr->im_cpm);
619 debug ("Logo: width %d height %d colors %d cmap %d\n",
620 BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
621 (int)(sizeof(bmp_logo_palette)/(sizeof(ushort))));
623 bmap = &bmp_logo_bitmap[0];
624 fb = (uchar *)(lcd_base + y * lcd_line_length + x);
626 if (NBITS(panel_info.vl_bpix) < 12) {
627 /* Leave room for default color map */
628 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
629 cmap = (ushort *)fbi->palette;
630 #elif defined(CONFIG_MPC823)
631 cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
632 #elif defined(CONFIG_ATMEL_LCD)
633 cmap = (uint *) (panel_info.mmio + ATMEL_LCDC_LUT(0));
636 * default case: generic system with no cmap (most likely 16bpp)
637 * We set cmap to the source palette, so no change is done.
638 * This avoids even more ifdef in the next stanza
640 cmap = bmp_logo_palette;
646 for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) {
647 ushort colreg = bmp_logo_palette[i];
648 #ifdef CONFIG_ATMEL_LCD
650 #ifdef CONFIG_ATMEL_LCD_BGR555
651 lut_entry = ((colreg & 0x000F) << 11) |
652 ((colreg & 0x00F0) << 2) |
653 ((colreg & 0x0F00) >> 7);
654 #else /* CONFIG_ATMEL_LCD_RGB565 */
655 lut_entry = ((colreg & 0x000F) << 1) |
656 ((colreg & 0x00F0) << 3) |
657 ((colreg & 0x0F00) << 4);
659 *(cmap + BMP_LOGO_OFFSET) = lut_entry;
661 #else /* !CONFIG_ATMEL_LCD */
662 #ifdef CONFIG_SYS_INVERT_COLORS
663 *cmap++ = 0xffff - colreg;
667 #endif /* CONFIG_ATMEL_LCD */
672 for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
673 memcpy (fb, bmap, BMP_LOGO_WIDTH);
674 bmap += BMP_LOGO_WIDTH;
675 fb += panel_info.vl_col;
678 else { /* true color mode */
685 #endif /* CONFIG_LCD_LOGO */
687 /*----------------------------------------------------------------------*/
688 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
690 * Display the BMP file located at address bmp_image.
694 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
695 #define BMP_ALIGN_CENTER 0x7FFF
698 int lcd_display_bitmap(ulong bmp_image, int x, int y)
700 #if !defined(CONFIG_MCC200)
703 ushort *cmap_base = NULL;
706 bmp_image_t *bmp=(bmp_image_t *)bmp_image;
709 unsigned long width, height, byte_width;
710 unsigned long pwidth = panel_info.vl_col;
711 unsigned colors, bpix, bmp_bpix;
712 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
713 struct pxafb_info *fbi = &panel_info.pxa;
714 #elif defined(CONFIG_MPC823)
715 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
716 volatile cpm8xx_t *cp = &(immr->im_cpm);
719 if (!((bmp->header.signature[0]=='B') &&
720 (bmp->header.signature[1]=='M'))) {
721 printf ("Error: no valid bmp image at %lx\n", bmp_image);
725 width = le32_to_cpu (bmp->header.width);
726 height = le32_to_cpu (bmp->header.height);
727 bmp_bpix = le16_to_cpu(bmp->header.bit_count);
728 colors = 1 << bmp_bpix;
730 bpix = NBITS(panel_info.vl_bpix);
732 if ((bpix != 1) && (bpix != 8) && (bpix != 16)) {
733 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
738 /* We support displaying 8bpp BMPs on 16bpp LCDs */
739 if (bpix != bmp_bpix && (bmp_bpix != 8 || bpix != 16)) {
740 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
742 le16_to_cpu(bmp->header.bit_count));
746 debug ("Display-bmp: %d x %d with %d colors\n",
747 (int)width, (int)height, (int)colors);
749 #if !defined(CONFIG_MCC200)
750 /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
752 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS
753 cmap = (ushort *)fbi->palette;
754 #elif defined(CONFIG_MPC823)
755 cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
756 #elif !defined(CONFIG_ATMEL_LCD)
757 cmap = panel_info.cmap;
763 for (i=0; i<colors; ++i) {
764 bmp_color_table_entry_t cte = bmp->color_table[i];
765 #if !defined(CONFIG_ATMEL_LCD)
767 ( ((cte.red) << 8) & 0xf800) |
768 ( ((cte.green) << 3) & 0x07e0) |
769 ( ((cte.blue) >> 3) & 0x001f) ;
770 #ifdef CONFIG_SYS_INVERT_COLORS
771 *cmap = 0xffff - colreg;
775 #if defined(CONFIG_MPC823)
780 #else /* CONFIG_ATMEL_LCD */
781 lcd_setcolreg(i, cte.red, cte.green, cte.blue);
788 * BMP format for Monochrome assumes that the state of a
789 * pixel is described on a per Bit basis, not per Byte.
790 * So, in case of Monochrome BMP we should align widths
791 * on a byte boundary and convert them from Bit to Byte
793 * Probably, PXA250 and MPC823 process 1bpp BMP images in
794 * their own ways, so make the converting to be MCC200
797 #if defined(CONFIG_MCC200)
800 width = ((width + 7) & ~7) >> 3;
801 x = ((x + 7) & ~7) >> 3;
802 pwidth= ((pwidth + 7) & ~7) >> 3;
806 padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
808 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
809 if (x == BMP_ALIGN_CENTER)
810 x = max(0, (pwidth - width) / 2);
812 x = max(0, pwidth - width + x + 1);
814 if (y == BMP_ALIGN_CENTER)
815 y = max(0, (panel_info.vl_row - height) / 2);
817 y = max(0, panel_info.vl_row - height + y + 1);
818 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
820 if ((x + width)>pwidth)
822 if ((y + height)>panel_info.vl_row)
823 height = panel_info.vl_row - y;
825 bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
826 fb = (uchar *) (lcd_base +
827 (y + height - 1) * lcd_line_length + x);
830 case 1: /* pass through */
835 byte_width = width * 2;
837 for (i = 0; i < height; ++i) {
839 for (j = 0; j < width; j++) {
841 #if defined CONFIG_PXA250 || defined CONFIG_PXA27X || defined CONFIG_CPU_MONAHANS || defined(CONFIG_ATMEL_LCD)
843 #elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
844 *(fb++) = 255 - *(bmap++);
847 *(uint16_t *)fb = cmap_base[*(bmap++)];
848 fb += sizeof(uint16_t) / sizeof(*fb);
851 bmap += (width - padded_line);
852 fb -= (byte_width + lcd_line_length);
856 #if defined(CONFIG_BMP_16BPP)
858 for (i = 0; i < height; ++i) {
860 for (j = 0; j < width; j++) {
861 #if defined(CONFIG_ATMEL_LCD_BGR555)
862 *(fb++) = ((bmap[0] & 0x1f) << 2) |
864 *(fb++) = (bmap[0] & 0xe0) |
865 ((bmap[1] & 0x7c) >> 2);
872 bmap += (padded_line - width) * 2;
873 fb -= (width * 2 + lcd_line_length);
876 #endif /* CONFIG_BMP_16BPP */
886 static void *lcd_logo (void)
888 #ifdef CONFIG_SPLASH_SCREEN
891 static int do_splash = 1;
893 if (do_splash && (s = getenv("splashimage")) != NULL) {
897 addr = simple_strtoul (s, NULL, 16);
898 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
899 if ((s = getenv ("splashpos")) != NULL) {
901 x = BMP_ALIGN_CENTER;
903 x = simple_strtol (s, NULL, 0);
905 if ((s = strchr (s + 1, ',')) != NULL) {
907 y = BMP_ALIGN_CENTER;
909 y = simple_strtol (s + 1, NULL, 0);
912 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
914 #ifdef CONFIG_VIDEO_BMP_GZIP
915 bmp_image_t *bmp = (bmp_image_t *)addr;
918 if (!((bmp->header.signature[0]=='B') &&
919 (bmp->header.signature[1]=='M'))) {
920 addr = (ulong)gunzip_bmp(addr, &len);
924 if (lcd_display_bitmap (addr, x, y) == 0) {
925 return ((void *)lcd_base);
928 #endif /* CONFIG_SPLASH_SCREEN */
930 #ifdef CONFIG_LCD_INFO
931 console_col = LCD_INFO_X / VIDEO_FONT_WIDTH;
932 console_row = LCD_INFO_Y / VIDEO_FONT_HEIGHT;
933 lcd_show_board_info();
934 #endif /* CONFIG_LCD_INFO */
936 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) && !defined(CONFIG_TIZEN)
937 return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
939 return ((void *)lcd_base);
940 #endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */
943 void lcd_set_cur_pos(short row, short col)
948 /************************************************************************/
949 /************************************************************************/