lcd.c 19 KB

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