lcd.c 19 KB

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