lcd.c 34 KB

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