lcd.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. /*
  2. * (C) Copyright 2001-2002
  3. * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /************************************************************************/
  24. /* ** HEADER FILES */
  25. /************************************************************************/
  26. #include <config.h>
  27. #include <common.h>
  28. #include <version.h>
  29. #include <stdarg.h>
  30. #include <lcdvideo.h>
  31. #include <linux/types.h>
  32. #include <devices.h>
  33. #if defined(CONFIG_POST)
  34. #include <post.h>
  35. #endif
  36. #ifdef CONFIG_LCD
  37. /************************************************************************/
  38. /* ** CONFIG STUFF -- should be moved to board config file */
  39. /************************************************************************/
  40. #define CONFIG_LCD_LOGO
  41. #define LCD_INFO /* Display Logo, (C) and system info */
  42. #if defined(CONFIG_V37) || defined(CONFIG_EDT32F10)
  43. #undef CONFIG_LCD_LOGO
  44. #undef LCD_INFO
  45. #endif
  46. /* #define LCD_TEST_PATTERN */ /* color backgnd for frame/color adjust */
  47. /* #define CFG_INVERT_COLORS */ /* Not needed - adjust vl_dp instead */
  48. /************************************************************************/
  49. /************************************************************************/
  50. /* ** BITMAP DISPLAY SUPPORT -- should probably be moved elsewhere */
  51. /************************************************************************/
  52. #if (CONFIG_COMMANDS & CFG_CMD_BMP)
  53. #include <bmp_layout.h>
  54. #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) */
  55. /************************************************************************/
  56. /* ** FONT AND LOGO DATA */
  57. /************************************************************************/
  58. #include <video_font.h> /* Get font data, width and height */
  59. #ifdef CONFIG_LCD_LOGO
  60. # include <bmp_logo.h> /* Get logo data, width and height */
  61. #endif
  62. /************************************************************************/
  63. /************************************************************************/
  64. /*
  65. * Information about displays we are using. This is for configuring
  66. * the LCD controller and memory allocation. Someone has to know what
  67. * is connected, as we can't autodetect anything.
  68. */
  69. #define CFG_HIGH 0 /* Pins are active high */
  70. #define CFG_LOW 1 /* Pins are active low */
  71. typedef struct vidinfo {
  72. ushort vl_col; /* Number of columns (i.e. 640) */
  73. ushort vl_row; /* Number of rows (i.e. 480) */
  74. ushort vl_width; /* Width of display area in millimeters */
  75. ushort vl_height; /* Height of display area in millimeters */
  76. /* LCD configuration register.
  77. */
  78. u_char vl_clkp; /* Clock polarity */
  79. u_char vl_oep; /* Output Enable polarity */
  80. u_char vl_hsp; /* Horizontal Sync polarity */
  81. u_char vl_vsp; /* Vertical Sync polarity */
  82. u_char vl_dp; /* Data polarity */
  83. u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
  84. u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */
  85. u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */
  86. u_char vl_clor; /* Color, 0 = mono, 1 = color */
  87. u_char vl_tft; /* 0 = passive, 1 = TFT */
  88. /* Horizontal control register. Timing from data sheet.
  89. */
  90. ushort vl_wbl; /* Wait between lines */
  91. /* Vertical control register.
  92. */
  93. u_char vl_vpw; /* Vertical sync pulse width */
  94. u_char vl_lcdac; /* LCD AC timing */
  95. u_char vl_wbf; /* Wait between frames */
  96. } vidinfo_t;
  97. #define LCD_MONOCHROME 0
  98. #define LCD_COLOR2 1
  99. #define LCD_COLOR4 2
  100. #define LCD_COLOR8 3
  101. /*----------------------------------------------------------------------*/
  102. #ifdef CONFIG_KYOCERA_KCS057QV1AJ
  103. /*
  104. * Kyocera KCS057QV1AJ-G23. Passive, color, single scan.
  105. */
  106. #define LCD_BPP LCD_COLOR4
  107. static vidinfo_t panel_info = {
  108. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
  109. LCD_BPP, 1, 0, 1, 0, 5, 0, 0, 0
  110. /* wbl, vpw, lcdac, wbf */
  111. };
  112. #endif /* CONFIG_KYOCERA_KCS057QV1AJ */
  113. /*----------------------------------------------------------------------*/
  114. /*----------------------------------------------------------------------*/
  115. #ifdef CONFIG_NEC_NL6648AC33
  116. /*
  117. * NEC NL6648AC33-18. Active, color, single scan.
  118. */
  119. static vidinfo_t panel_info = {
  120. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  121. 3, 0, 0, 1, 1, 144, 2, 0, 33
  122. /* wbl, vpw, lcdac, wbf */
  123. };
  124. #endif /* CONFIG_NEC_NL6648AC33 */
  125. /*----------------------------------------------------------------------*/
  126. #ifdef CONFIG_NEC_NL6648BC20
  127. /*
  128. * NEC NL6648BC20-08. 6.5", 640x480. Active, color, single scan.
  129. */
  130. static vidinfo_t panel_info = {
  131. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  132. 3, 0, 0, 1, 1, 144, 2, 0, 33
  133. /* wbl, vpw, lcdac, wbf */
  134. };
  135. #endif /* CONFIG_NEC_NL6648BC20 */
  136. /*----------------------------------------------------------------------*/
  137. #ifdef CONFIG_SHARP_LQ104V7DS01
  138. /*
  139. * SHARP LQ104V7DS01. 6.5", 640x480. Active, color, single scan.
  140. */
  141. static vidinfo_t panel_info = {
  142. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW,
  143. 3, 0, 0, 1, 1, 25, 1, 0, 33
  144. /* wbl, vpw, lcdac, wbf */
  145. };
  146. #endif /* CONFIG_SHARP_LQ104V7DS01 */
  147. /*----------------------------------------------------------------------*/
  148. #ifdef CONFIG_SHARP_16x9
  149. /*
  150. * Sharp 320x240. Active, color, single scan. It isn't 16x9, and I am
  151. * not sure what it is.......
  152. */
  153. static vidinfo_t panel_info = {
  154. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
  155. 3, 0, 0, 1, 1, 15, 4, 0, 3
  156. };
  157. #endif /* CONFIG_SHARP_16x9 */
  158. /*----------------------------------------------------------------------*/
  159. #ifdef CONFIG_SHARP_LQ057Q3DC02
  160. /*
  161. * Sharp LQ057Q3DC02 display. Active, color, single scan.
  162. */
  163. #define LCD_DF 12
  164. static vidinfo_t panel_info = {
  165. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  166. 3, 0, 0, 1, 1, 15, 4, 0, 3
  167. /* wbl, vpw, lcdac, wbf */
  168. };
  169. #define LCD_INFO_BELOW_LOGO
  170. #endif /* CONFIG_SHARP_LQ057Q3DC02 */
  171. /*----------------------------------------------------------------------*/
  172. #ifdef CONFIG_SHARP_LQ64D341
  173. /*
  174. * Sharp LQ64D341 display, 640x480. Active, color, single scan.
  175. */
  176. static vidinfo_t panel_info = {
  177. 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  178. 3, 0, 0, 1, 1, 128, 16, 0, 32
  179. /* wbl, vpw, lcdac, wbf */
  180. };
  181. #endif /* CONFIG_SHARP_LQ64D341 */
  182. #ifdef CONFIG_SHARP_LQ084V1DG21
  183. /*
  184. * Sharp LQ084V1DG21 display, 640x480. Active, color, single scan.
  185. */
  186. static vidinfo_t panel_info = {
  187. 640, 480, 171, 129, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW,
  188. 3, 0, 0, 1, 1, 160, 3, 0, 48
  189. /* wbl, vpw, lcdac, wbf */
  190. };
  191. #endif /* CONFIG_SHARP_LQ084V1DG21 */
  192. /*----------------------------------------------------------------------*/
  193. #ifdef CONFIG_HLD1045
  194. /*
  195. * HLD1045 display, 640x480. Active, color, single scan.
  196. */
  197. static vidinfo_t panel_info = {
  198. 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  199. 3, 0, 0, 1, 1, 160, 3, 0, 48
  200. /* wbl, vpw, lcdac, wbf */
  201. };
  202. #endif /* CONFIG_HLD1045 */
  203. /*----------------------------------------------------------------------*/
  204. #ifdef CONFIG_PRIMEVIEW_V16C6448AC
  205. /*
  206. * Prime View V16C6448AC
  207. */
  208. static vidinfo_t panel_info = {
  209. 640, 480, 130, 98, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  210. 3, 0, 0, 1, 1, 144, 2, 0, 35
  211. /* wbl, vpw, lcdac, wbf */
  212. };
  213. #endif /* CONFIG_PRIMEVIEW_V16C6448AC */
  214. /*----------------------------------------------------------------------*/
  215. #ifdef CONFIG_OPTREX_BW
  216. /*
  217. * Optrex CBL50840-2 NF-FW 99 22 M5
  218. * or
  219. * Hitachi LMG6912RPFC-00T
  220. * or
  221. * Hitachi SP14Q002
  222. *
  223. * 320x240. Black & white.
  224. */
  225. #define OPTREX_BPP 0 /* 0 - monochrome, 1 bpp */
  226. /* 1 - 4 grey levels, 2 bpp */
  227. /* 2 - 16 grey levels, 4 bpp */
  228. static vidinfo_t panel_info = {
  229. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW,
  230. OPTREX_BPP, 0, 0, 0, 0, 0, 0, 0, 0, 4
  231. };
  232. #endif /* CONFIG_OPTREX_BW */
  233. /*-----------------------------------------------------------------*/
  234. #ifdef CONFIG_EDT32F10
  235. /*
  236. * Emerging Display Technologies 320x240. Passive, monochrome, single scan.
  237. */
  238. #define LCD_BPP LCD_MONOCHROME
  239. #define LCD_DF 10
  240. static vidinfo_t panel_info = {
  241. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW,
  242. LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0
  243. };
  244. #endif
  245. /*----------------------------------------------------------------------*/
  246. #if defined(LCD_INFO_BELOW_LOGO)
  247. # define LCD_INFO_X 0
  248. # define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
  249. #elif defined(CONFIG_LCD_LOGO)
  250. # define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
  251. # define LCD_INFO_Y (VIDEO_FONT_HEIGHT)
  252. #else
  253. # define LCD_INFO_X (VIDEO_FONT_WIDTH)
  254. # define LCD_INFO_Y (VIDEO_FONT_HEIGHT)
  255. #endif
  256. #ifndef LCD_BPP
  257. #define LCD_BPP LCD_COLOR8
  258. #endif
  259. #ifndef LCD_DF
  260. #define LCD_DF 1
  261. #endif
  262. #define NBITS(bit_code) (1 << (bit_code))
  263. #define NCOLORS(bit_code) (1 << NBITS(bit_code))
  264. static int lcd_line_length;
  265. static int lcd_color_fg;
  266. static int lcd_color_bg;
  267. static char lcd_is_enabled = 0; /* Indicate that LCD is enabled */
  268. /*
  269. * Frame buffer memory information
  270. */
  271. static void *lcd_base; /* Start of framebuffer memory */
  272. static void *lcd_console_address; /* Start of console buffer */
  273. /************************************************************************/
  274. /* ** CONSOLE CONSTANTS */
  275. /************************************************************************/
  276. #if LCD_BPP == LCD_MONOCHROME
  277. /*
  278. * Simple color definitions
  279. */
  280. #define CONSOLE_COLOR_BLACK 0
  281. #define CONSOLE_COLOR_WHITE 1 /* Must remain last / highest */
  282. #else
  283. /*
  284. * Simple color definitions
  285. */
  286. #define CONSOLE_COLOR_BLACK 0
  287. #define CONSOLE_COLOR_RED 1
  288. #define CONSOLE_COLOR_GREEN 2
  289. #define CONSOLE_COLOR_YELLOW 3
  290. #define CONSOLE_COLOR_BLUE 4
  291. #define CONSOLE_COLOR_MAGENTA 5
  292. #define CONSOLE_COLOR_CYAN 6
  293. #define CONSOLE_COLOR_GREY 14
  294. #define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
  295. #endif
  296. #if defined(CONFIG_LCD_LOGO) && (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET)
  297. #error Default Color Map overlaps with Logo Color Map
  298. #endif
  299. /************************************************************************/
  300. #ifndef PAGE_SIZE
  301. #define PAGE_SIZE 4096
  302. #endif
  303. /************************************************************************/
  304. /* ** CONSOLE DEFINITIONS & FUNCTIONS */
  305. /************************************************************************/
  306. #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
  307. #define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \
  308. / VIDEO_FONT_HEIGHT)
  309. #else
  310. #define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT)
  311. #endif
  312. #define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH)
  313. #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length)
  314. #define CONSOLE_ROW_FIRST (lcd_console_address)
  315. #define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE)
  316. #define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \
  317. - CONSOLE_ROW_SIZE)
  318. #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
  319. #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
  320. #if LCD_BPP == LCD_MONOCHROME
  321. #define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \
  322. (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
  323. #elif LCD_BPP == LCD_COLOR8
  324. #define COLOR_MASK(c) (c)
  325. #else
  326. #error Unsupported LCD BPP.
  327. #endif
  328. static short console_col;
  329. static short console_row;
  330. /************************************************************************/
  331. ulong lcd_setmem (ulong addr);
  332. static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
  333. static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
  334. static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
  335. static int lcd_init (void *lcdbase);
  336. static void lcd_ctrl_init (void *lcdbase);
  337. static void lcd_enable (void);
  338. static void *lcd_logo (void);
  339. #if LCD_BPP == LCD_COLOR8
  340. static void lcd_setcolreg (ushort regno,
  341. ushort red, ushort green, ushort blue);
  342. #endif
  343. #if LCD_BPP == LCD_MONOCHROME
  344. static void lcd_initcolregs (void);
  345. #endif
  346. static int lcd_getbgcolor (void);
  347. static void lcd_setfgcolor (int color);
  348. static void lcd_setbgcolor (int color);
  349. #ifdef NOT_USED_SO_FAR
  350. static void lcd_disable (void);
  351. static void lcd_getcolreg (ushort regno,
  352. ushort *red, ushort *green, ushort *blue);
  353. static int lcd_getfgcolor (void);
  354. #endif /* NOT_USED_SO_FAR */
  355. /************************************************************************/
  356. /*----------------------------------------------------------------------*/
  357. static void console_scrollup (void)
  358. {
  359. #if 1
  360. /* Copy up rows ignoring the first one */
  361. memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
  362. /* Clear the last one */
  363. memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
  364. #else
  365. /*
  366. * Poor attempt to optimize speed by moving "long"s.
  367. * But the code is ugly, and not a bit faster :-(
  368. */
  369. ulong *t = (ulong *)CONSOLE_ROW_FIRST;
  370. ulong *s = (ulong *)CONSOLE_ROW_SECOND;
  371. ulong l = CONSOLE_SCROLL_SIZE / sizeof(ulong);
  372. uchar c = lcd_color_bg & 0xFF;
  373. ulong val= (c<<24) | (c<<16) | (c<<8) | c;
  374. while (l--)
  375. *t++ = *s++;
  376. t = (ulong *)CONSOLE_ROW_LAST;
  377. l = CONSOLE_ROW_SIZE / sizeof(ulong);
  378. while (l-- > 0)
  379. *t++ = val;
  380. #endif
  381. }
  382. /*----------------------------------------------------------------------*/
  383. static inline void console_back (void)
  384. {
  385. if (--console_col < 0) {
  386. console_col = CONSOLE_COLS-1 ;
  387. if (--console_row < 0) {
  388. console_row = 0;
  389. }
  390. }
  391. lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
  392. console_row * VIDEO_FONT_HEIGHT,
  393. ' ');
  394. }
  395. /*----------------------------------------------------------------------*/
  396. static inline void console_newline (void)
  397. {
  398. ++console_row;
  399. console_col = 0;
  400. /* Check if we need to scroll the terminal */
  401. if (console_row >= CONSOLE_ROWS) {
  402. /* Scroll everything up */
  403. console_scrollup () ;
  404. --console_row;
  405. }
  406. }
  407. /*----------------------------------------------------------------------*/
  408. void lcd_putc (const char c)
  409. {
  410. if (!lcd_is_enabled) {
  411. serial_putc(c);
  412. return;
  413. }
  414. switch (c) {
  415. case '\r': console_col = 0;
  416. return;
  417. case '\n': console_newline();
  418. return;
  419. case '\t': /* Tab (8 chars alignment) */
  420. console_col |= 8;
  421. console_col &= ~7;
  422. if (console_col >= CONSOLE_COLS) {
  423. console_newline();
  424. }
  425. return;
  426. case '\b': console_back();
  427. return;
  428. default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
  429. console_row * VIDEO_FONT_HEIGHT,
  430. c);
  431. if (++console_col >= CONSOLE_COLS) {
  432. console_newline();
  433. }
  434. return;
  435. }
  436. /* NOTREACHED */
  437. }
  438. /*----------------------------------------------------------------------*/
  439. void lcd_puts (const char *s)
  440. {
  441. if (!lcd_is_enabled) {
  442. serial_puts (s);
  443. return;
  444. }
  445. while (*s) {
  446. lcd_putc (*s++);
  447. }
  448. }
  449. /************************************************************************/
  450. /* ** Low-Level Graphics Routines */
  451. /************************************************************************/
  452. static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
  453. {
  454. uchar *dest;
  455. ushort off, row;
  456. dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
  457. off = x * (1 << LCD_BPP) % 8;
  458. for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
  459. uchar *s = str;
  460. uchar *d = dest;
  461. int i;
  462. #if LCD_BPP == LCD_MONOCHROME
  463. uchar rest = *d & -(1 << (8-off));
  464. uchar sym;
  465. #endif
  466. for (i=0; i<count; ++i) {
  467. uchar c, bits;
  468. c = *s++;
  469. bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
  470. #if LCD_BPP == LCD_MONOCHROME
  471. sym = (COLOR_MASK(lcd_color_fg) & bits) |
  472. (COLOR_MASK(lcd_color_bg) & ~bits);
  473. *d++ = rest | (sym >> off);
  474. rest = sym << (8-off);
  475. #elif LCD_BPP == LCD_COLOR8
  476. for (c=0; c<8; ++c) {
  477. *d++ = (bits & 0x80) ?
  478. lcd_color_fg : lcd_color_bg;
  479. bits <<= 1;
  480. }
  481. #endif
  482. }
  483. #if LCD_BPP == LCD_MONOCHROME
  484. *d = rest | (*d & ((1 << (8-off)) - 1));
  485. #endif
  486. }
  487. }
  488. /*----------------------------------------------------------------------*/
  489. static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
  490. {
  491. #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
  492. lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s));
  493. #else
  494. lcd_drawchars (x, y, s, strlen (s));
  495. #endif
  496. }
  497. /*----------------------------------------------------------------------*/
  498. static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
  499. {
  500. #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
  501. lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
  502. #else
  503. lcd_drawchars (x, y, &c, 1);
  504. #endif
  505. }
  506. /************************************************************************/
  507. /** Small utility to check that you got the colours right */
  508. /************************************************************************/
  509. #ifdef LCD_TEST_PATTERN
  510. #define N_BLK_VERT 2
  511. #define N_BLK_HOR 3
  512. static int test_colors[N_BLK_HOR*N_BLK_VERT] = {
  513. CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW,
  514. CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN,
  515. };
  516. static void test_pattern (void)
  517. {
  518. ushort v_max = panel_info.vl_row;
  519. ushort h_max = panel_info.vl_col;
  520. ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
  521. ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR;
  522. ushort v, h;
  523. uchar *pix = (uchar *)lcd_base;
  524. printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n",
  525. h_max, v_max, h_step, v_step);
  526. /* WARNING: Code silently assumes 8bit/pixel */
  527. for (v=0; v<v_max; ++v) {
  528. uchar iy = v / v_step;
  529. for (h=0; h<h_max; ++h) {
  530. uchar ix = N_BLK_HOR * iy + (h/h_step);
  531. *pix++ = test_colors[ix];
  532. }
  533. }
  534. }
  535. #endif /* LCD_TEST_PATTERN */
  536. /************************************************************************/
  537. /* ** GENERIC Initialization Routines */
  538. /************************************************************************/
  539. int drv_lcd_init (void)
  540. {
  541. DECLARE_GLOBAL_DATA_PTR;
  542. device_t lcddev;
  543. int rc;
  544. lcd_base = (void *)(gd->fb_base);
  545. lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
  546. lcd_init (lcd_base); /* LCD initialization */
  547. /* Device initialization */
  548. memset (&lcddev, 0, sizeof (lcddev));
  549. strcpy (lcddev.name, "lcd");
  550. lcddev.ext = 0; /* No extensions */
  551. lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
  552. lcddev.putc = lcd_putc; /* 'putc' function */
  553. lcddev.puts = lcd_puts; /* 'puts' function */
  554. rc = device_register (&lcddev);
  555. return (rc == 0) ? 1 : rc;
  556. }
  557. /*----------------------------------------------------------------------*/
  558. static int lcd_init (void *lcdbase)
  559. {
  560. /* Initialize the lcd controller */
  561. debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
  562. lcd_ctrl_init (lcdbase);
  563. #if LCD_BPP == LCD_MONOCHROME
  564. /* Setting the palette */
  565. lcd_initcolregs();
  566. #elif LCD_BPP == LCD_COLOR8
  567. /* Setting the palette */
  568. lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0);
  569. lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0);
  570. lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
  571. lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
  572. lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
  573. lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
  574. lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
  575. lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
  576. lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
  577. #endif
  578. #ifndef CFG_WHITE_ON_BLACK
  579. lcd_setfgcolor (CONSOLE_COLOR_BLACK);
  580. lcd_setbgcolor (CONSOLE_COLOR_WHITE);
  581. #else
  582. lcd_setfgcolor (CONSOLE_COLOR_WHITE);
  583. lcd_setbgcolor (CONSOLE_COLOR_BLACK);
  584. #endif /* CFG_WHITE_ON_BLACK */
  585. #ifdef LCD_TEST_PATTERN
  586. test_pattern();
  587. #else
  588. /* set framebuffer to background color */
  589. memset ((char *)lcd_base,
  590. COLOR_MASK(lcd_getbgcolor()),
  591. lcd_line_length*panel_info.vl_row);
  592. #endif
  593. lcd_enable ();
  594. /* Paint the logo and retrieve LCD base address */
  595. debug ("[LCD] Drawing the logo...\n");
  596. lcd_console_address = lcd_logo ();
  597. /* Initialize the console */
  598. console_col = 0;
  599. #ifdef LCD_INFO_BELOW_LOGO
  600. console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
  601. #else
  602. console_row = 1; /* leave 1 blank line below logo */
  603. #endif
  604. lcd_is_enabled = 1;
  605. return 0;
  606. }
  607. /************************************************************************/
  608. /* ** ROM capable initialization part - needed to reserve FB memory */
  609. /************************************************************************/
  610. /*
  611. * This is called early in the system initialization to grab memory
  612. * for the LCD controller.
  613. * Returns new address for monitor, after reserving LCD buffer memory
  614. *
  615. * Note that this is running from ROM, so no write access to global data.
  616. */
  617. ulong lcd_setmem (ulong addr)
  618. {
  619. ulong size;
  620. int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
  621. debug ("LCD panel info: %d x %d, %d bit/pix\n",
  622. panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
  623. size = line_length * panel_info.vl_row;
  624. /* Round up to nearest full page */
  625. size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
  626. /* Allocate pages for the frame buffer. */
  627. addr -= size;
  628. debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr);
  629. return (addr);
  630. }
  631. /************************************************************************/
  632. /* ----------------- chipset specific functions ----------------------- */
  633. /************************************************************************/
  634. static void lcd_ctrl_init (void *lcdbase)
  635. {
  636. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  637. volatile lcd823_t *lcdp = &immr->im_lcd;
  638. uint lccrtmp;
  639. /* Initialize the LCD control register according to the LCD
  640. * parameters defined. We do everything here but enable
  641. * the controller.
  642. */
  643. lccrtmp = LCDBIT (LCCR_BNUM_BIT,
  644. (((panel_info.vl_row * panel_info.vl_col) * (1 << LCD_BPP)) / 128));
  645. lccrtmp |= LCDBIT (LCCR_CLKP_BIT, panel_info.vl_clkp) |
  646. LCDBIT (LCCR_OEP_BIT, panel_info.vl_oep) |
  647. LCDBIT (LCCR_HSP_BIT, panel_info.vl_hsp) |
  648. LCDBIT (LCCR_VSP_BIT, panel_info.vl_vsp) |
  649. LCDBIT (LCCR_DP_BIT, panel_info.vl_dp) |
  650. LCDBIT (LCCR_BPIX_BIT, panel_info.vl_bpix) |
  651. LCDBIT (LCCR_LBW_BIT, panel_info.vl_lbw) |
  652. LCDBIT (LCCR_SPLT_BIT, panel_info.vl_splt) |
  653. LCDBIT (LCCR_CLOR_BIT, panel_info.vl_clor) |
  654. LCDBIT (LCCR_TFT_BIT, panel_info.vl_tft);
  655. #if 0
  656. lccrtmp |= ((SIU_LEVEL5 / 2) << 12);
  657. lccrtmp |= LCCR_EIEN;
  658. #endif
  659. lcdp->lcd_lccr = lccrtmp;
  660. lcdp->lcd_lcsr = 0xFF; /* Clear pending interrupts */
  661. /* Initialize LCD controller bus priorities.
  662. */
  663. immr->im_siu_conf.sc_sdcr &= ~0x0f; /* RAID = LAID = 0 */
  664. /* set SHFT/CLOCK division factor 4
  665. * This needs to be set based upon display type and processor
  666. * speed. The TFT displays run about 20 to 30 MHz.
  667. * I was running 64 MHz processor speed.
  668. * The value for this divider must be chosen so the result is
  669. * an integer of the processor speed (i.e., divide by 3 with
  670. * 64 MHz would be bad).
  671. */
  672. immr->im_clkrst.car_sccr &= ~0x1F;
  673. immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */
  674. #ifndef CONFIG_EDT32F10
  675. /* Enable LCD on port D.
  676. */
  677. immr->im_ioport.iop_pdpar |= 0x1FFF;
  678. immr->im_ioport.iop_pddir |= 0x1FFF;
  679. /* Enable LCD_A/B/C on port B.
  680. */
  681. immr->im_cpm.cp_pbpar |= 0x00005001;
  682. immr->im_cpm.cp_pbdir |= 0x00005001;
  683. #else
  684. /* Enable LCD on port D.
  685. */
  686. immr->im_ioport.iop_pdpar |= 0x1DFF;
  687. immr->im_ioport.iop_pdpar &= ~0x0200;
  688. immr->im_ioport.iop_pddir |= 0x1FFF;
  689. immr->im_ioport.iop_pddat |= 0x0200;
  690. #endif
  691. /* Load the physical address of the linear frame buffer
  692. * into the LCD controller.
  693. * BIG NOTE: This has to be modified to load A and B depending
  694. * upon the split mode of the LCD.
  695. */
  696. lcdp->lcd_lcfaa = (ulong)lcd_base;
  697. lcdp->lcd_lcfba = (ulong)lcd_base;
  698. /* MORE HACKS...This must be updated according to 823 manual
  699. * for different panels.
  700. */
  701. #ifndef CONFIG_EDT32F10
  702. lcdp->lcd_lchcr = LCHCR_BO |
  703. LCDBIT (LCHCR_AT_BIT, 4) |
  704. LCDBIT (LCHCR_HPC_BIT, panel_info.vl_col) |
  705. panel_info.vl_wbl;
  706. #else
  707. lcdp->lcd_lchcr = LCHCR_BO |
  708. LCDBIT (LCHCR_AT_BIT, 4) |
  709. LCDBIT (LCHCR_HPC_BIT, panel_info.vl_col/4) |
  710. panel_info.vl_wbl;
  711. #endif
  712. lcdp->lcd_lcvcr = LCDBIT (LCVCR_VPW_BIT, panel_info.vl_vpw) |
  713. LCDBIT (LCVCR_LCD_AC_BIT, panel_info.vl_lcdac) |
  714. LCDBIT (LCVCR_VPC_BIT, panel_info.vl_row) |
  715. panel_info.vl_wbf;
  716. }
  717. /*----------------------------------------------------------------------*/
  718. #ifdef NOT_USED_SO_FAR
  719. static void
  720. lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue)
  721. {
  722. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  723. volatile cpm8xx_t *cp = &(immr->im_cpm);
  724. unsigned short colreg, *cmap_ptr;
  725. cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2];
  726. colreg = *cmap_ptr;
  727. #ifdef CFG_INVERT_COLORS
  728. colreg ^= 0x0FFF;
  729. #endif
  730. *red = (colreg >> 8) & 0x0F;
  731. *green = (colreg >> 4) & 0x0F;
  732. *blue = colreg & 0x0F;
  733. }
  734. #endif /* NOT_USED_SO_FAR */
  735. /*----------------------------------------------------------------------*/
  736. #if LCD_BPP == LCD_COLOR8
  737. static void
  738. lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
  739. {
  740. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  741. volatile cpm8xx_t *cp = &(immr->im_cpm);
  742. unsigned short colreg, *cmap_ptr;
  743. cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2];
  744. colreg = ((red & 0x0F) << 8) |
  745. ((green & 0x0F) << 4) |
  746. (blue & 0x0F) ;
  747. #ifdef CFG_INVERT_COLORS
  748. colreg ^= 0x0FFF;
  749. #endif
  750. *cmap_ptr = colreg;
  751. debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n",
  752. regno, &(cp->lcd_cmap[regno * 2]),
  753. red, green, blue,
  754. cp->lcd_cmap[ regno * 2 ], cp->lcd_cmap[(regno * 2) + 1]);
  755. }
  756. #endif /* LCD_COLOR8 */
  757. /*----------------------------------------------------------------------*/
  758. #if LCD_BPP == LCD_MONOCHROME
  759. static
  760. void lcd_initcolregs (void)
  761. {
  762. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  763. volatile cpm8xx_t *cp = &(immr->im_cpm);
  764. ushort regno;
  765. for (regno = 0; regno < 16; regno++) {
  766. cp->lcd_cmap[regno * 2] = 0;
  767. cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f;
  768. }
  769. }
  770. #endif
  771. /*----------------------------------------------------------------------*/
  772. static void lcd_setfgcolor (int color)
  773. {
  774. lcd_color_fg = color & 0x0F;
  775. }
  776. /*----------------------------------------------------------------------*/
  777. static void lcd_setbgcolor (int color)
  778. {
  779. lcd_color_bg = color & 0x0F;
  780. }
  781. /*----------------------------------------------------------------------*/
  782. #ifdef NOT_USED_SO_FAR
  783. static int lcd_getfgcolor (void)
  784. {
  785. return lcd_color_fg;
  786. }
  787. #endif /* NOT_USED_SO_FAR */
  788. /*----------------------------------------------------------------------*/
  789. static int lcd_getbgcolor (void)
  790. {
  791. return lcd_color_bg;
  792. }
  793. /*----------------------------------------------------------------------*/
  794. static void lcd_enable (void)
  795. {
  796. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  797. volatile lcd823_t *lcdp = &immr->im_lcd;
  798. /* Enable the LCD panel */
  799. immr->im_siu_conf.sc_sdcr |= (1 << (31 - 25)); /* LAM = 1 */
  800. lcdp->lcd_lccr |= LCCR_PON;
  801. #ifdef CONFIG_V37
  802. /* Turn on display backlight */
  803. immr->im_cpm.cp_pbpar |= 0x00008000;
  804. immr->im_cpm.cp_pbdir |= 0x00008000;
  805. #endif
  806. #if defined(CONFIG_LWMON)
  807. { uchar c = pic_read (0x60);
  808. #if defined(CONFIG_LCD) && defined(CONFIG_LWMON) && (CONFIG_POST & CFG_POST_SYSMON)
  809. c |= 0x04; /* Chip Enable LCD */
  810. #else
  811. c |= 0x07; /* Power on CCFL, Enable CCFL, Chip Enable LCD */
  812. #endif
  813. pic_write (0x60, c);
  814. }
  815. #endif /* CONFIG_LWMON */
  816. #if defined(CONFIG_R360MPI)
  817. {
  818. extern void r360_i2c_lcd_write (uchar data0, uchar data1);
  819. r360_i2c_lcd_write(0x10, 0x01);
  820. r360_i2c_lcd_write(0x20, 0x01);
  821. r360_i2c_lcd_write(0x3F, 0xFF);
  822. r360_i2c_lcd_write(0x47, 0xFF);
  823. }
  824. #endif /* CONFIG_R360MPI */
  825. }
  826. /*----------------------------------------------------------------------*/
  827. #ifdef NOT_USED_SO_FAR
  828. static void lcd_disable (void)
  829. {
  830. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  831. volatile lcd823_t *lcdp = &immr->im_lcd;
  832. #if defined(CONFIG_LWMON)
  833. { uchar c = pic_read (0x60);
  834. c &= ~0x07; /* Power off CCFL, Disable CCFL, Chip Disable LCD */
  835. pic_write (0x60, c);
  836. }
  837. #elif defined(CONFIG_R360MPI)
  838. {
  839. extern void r360_i2c_lcd_write (uchar data0, uchar data1);
  840. r360_i2c_lcd_write(0x10, 0x00);
  841. r360_i2c_lcd_write(0x20, 0x00);
  842. r360_i2c_lcd_write(0x30, 0x00);
  843. r360_i2c_lcd_write(0x40, 0x00);
  844. }
  845. #endif /* CONFIG_LWMON */
  846. /* Disable the LCD panel */
  847. lcdp->lcd_lccr &= ~LCCR_PON;
  848. immr->im_siu_conf.sc_sdcr &= ~(1 << (31 - 25)); /* LAM = 0 */
  849. }
  850. #endif /* NOT_USED_SO_FAR */
  851. /************************************************************************/
  852. /* ** Chipset depending Bitmap / Logo stuff... */
  853. /************************************************************************/
  854. #ifdef CONFIG_LCD_LOGO
  855. static void bitmap_plot (int x, int y)
  856. {
  857. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  858. volatile cpm8xx_t *cp = &(immr->im_cpm);
  859. ushort *cmap;
  860. ushort i;
  861. uchar *bmap;
  862. uchar *fb;
  863. debug ("Logo: width %d height %d colors %d cmap %d\n",
  864. BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
  865. sizeof(bmp_logo_palette)/(sizeof(ushort))
  866. );
  867. /* Leave room for default color map */
  868. cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
  869. /* Set color map */
  870. for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) {
  871. ushort colreg = bmp_logo_palette[i];
  872. #ifdef CFG_INVERT_COLORS
  873. colreg ^= 0xFFF;
  874. #endif
  875. *cmap++ = colreg;
  876. }
  877. bmap = &bmp_logo_bitmap[0];
  878. fb = (char *)(lcd_base + y * lcd_line_length + x);
  879. for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
  880. memcpy (fb, bmap, BMP_LOGO_WIDTH);
  881. bmap += BMP_LOGO_WIDTH;
  882. fb += panel_info.vl_col;
  883. }
  884. }
  885. #endif /* CONFIG_LCD_LOGO */
  886. #if (CONFIG_COMMANDS & CFG_CMD_BMP)
  887. /*
  888. * Display the BMP file located at address bmp_image.
  889. * Only uncompressed
  890. */
  891. int lcd_display_bitmap(ulong bmp_image)
  892. {
  893. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  894. volatile cpm8xx_t *cp = &(immr->im_cpm);
  895. ushort *cmap;
  896. ushort i, j;
  897. uchar *fb;
  898. bmp_image_t *bmp=(bmp_image_t *)bmp_image;
  899. uchar *bmap;
  900. ushort padded_line;
  901. unsigned long width, height;
  902. unsigned colors,bpix;
  903. unsigned long compression;
  904. if (!((bmp->header.signature[0]=='B') &&
  905. (bmp->header.signature[1]=='M'))) {
  906. printf ("Error: no valid bmp image at %lx\n", bmp_image);
  907. return 1;
  908. }
  909. width = le32_to_cpu (bmp->header.width);
  910. height = le32_to_cpu (bmp->header.height);
  911. colors = 1<<le16_to_cpu (bmp->header.bit_count);
  912. compression = le32_to_cpu (bmp->header.compression);
  913. bpix = NBITS(panel_info.vl_bpix);
  914. if ((bpix != 1) && (bpix != 8)) {
  915. printf ("Error: %d bit/pixel mode not supported by U-Boot\n",
  916. bpix);
  917. return 1;
  918. }
  919. if (bpix != le16_to_cpu(bmp->header.bit_count)) {
  920. printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
  921. bpix,
  922. le16_to_cpu(bmp->header.bit_count));
  923. return 1;
  924. }
  925. if (compression!=BMP_BI_RGB) {
  926. printf ("Error: compression type %ld not supported\n",
  927. compression);
  928. return 1;
  929. }
  930. debug ("Display-bmp: %d x %d with %d colors\n",
  931. width, height, colors);
  932. if (bpix==8) {
  933. /* Fill the entire color map */
  934. cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
  935. /* Set color map */
  936. for (i = 0; i < colors; ++i) {
  937. bmp_color_table_entry_t cte = bmp->color_table[i];
  938. ushort colreg =
  939. ((cte.red>>4) << 8) |
  940. ((cte.green>>4) << 4) |
  941. (cte.blue>>4) ;
  942. #ifdef CFG_INVERT_COLORS
  943. colreg ^= 0xFFF;
  944. #endif
  945. *cmap-- = colreg;
  946. }
  947. }
  948. padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
  949. if (width>panel_info.vl_col)
  950. width = panel_info.vl_col;
  951. if (height>panel_info.vl_row)
  952. height = panel_info.vl_row;
  953. bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
  954. fb = (uchar *)
  955. (lcd_base +
  956. (((height>=panel_info.vl_row) ? panel_info.vl_row : height)-1)
  957. * lcd_line_length);
  958. for (i = 0; i < height; ++i) {
  959. for (j = 0; j < width ; j++)
  960. *(fb++)=255-*(bmap++);
  961. bmap += (width - padded_line);
  962. fb -= (width + lcd_line_length);
  963. }
  964. return (0);
  965. }
  966. #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) */
  967. /*----------------------------------------------------------------------*/
  968. static void *lcd_logo (void)
  969. {
  970. #ifdef LCD_INFO
  971. DECLARE_GLOBAL_DATA_PTR;
  972. char info[80];
  973. char temp[32];
  974. #endif /* LCD_INFO */
  975. #ifdef CONFIG_SPLASH_SCREEN
  976. char *s;
  977. ulong addr;
  978. if ((s = getenv("splashimage")) != NULL) {
  979. addr = simple_strtoul(s, NULL, 16);
  980. if (lcd_display_bitmap (addr) == 0) {
  981. return ((void *)lcd_base);
  982. }
  983. }
  984. #endif /* CONFIG_SPLASH_SCREEN */
  985. #ifdef CONFIG_LCD_LOGO
  986. bitmap_plot (0, 0);
  987. #endif /* CONFIG_LCD_LOGO */
  988. #ifdef LCD_INFO
  989. sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
  990. lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, info, strlen(info));
  991. sprintf (info, "(C) 2003 DENX Software Engineering");
  992. lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT,
  993. info, strlen(info));
  994. sprintf (info, " Wolfgang DENK, wd@denx.de");
  995. lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2,
  996. info, strlen(info));
  997. #ifdef LCD_INFO_BELOW_LOGO
  998. sprintf (info, "MPC823 CPU at %s MHz",
  999. strmhz(temp, gd->cpu_clk));
  1000. lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
  1001. info, strlen(info));
  1002. sprintf (info, " %ld MB RAM, %ld MB Flash",
  1003. gd->ram_size >> 20,
  1004. gd->bd->bi_flashsize >> 20 );
  1005. lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
  1006. info, strlen(info));
  1007. #else
  1008. /* leave one blank line */
  1009. sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",
  1010. strmhz(temp, gd->cpu_clk),
  1011. gd->ram_size >> 20,
  1012. gd->bd->bi_flashsize >> 20 );
  1013. lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
  1014. info, strlen(info));
  1015. #endif /* LCD_INFO_BELOW_LOGO */
  1016. #endif /* LCD_INFO */
  1017. #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
  1018. return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
  1019. #else
  1020. return ((void *)lcd_base);
  1021. #endif /* CONFIG_LCD_LOGO */
  1022. }
  1023. /************************************************************************/
  1024. /************************************************************************/
  1025. #endif /* CONFIG_LCD */