lcd.c 34 KB

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