PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/source/u-boot/drivers/cfb_console.c

https://bitbucket.org/tfzxyinhao/kindle-fire
C | 1274 lines | 932 code | 159 blank | 183 comment | 105 complexity | d4e16ade19dabfde4126f2315e6b14be MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-3.0, 0BSD, MPL-2.0-no-copyleft-exception, GPL-2.0, LGPL-2.0, BSD-3-Clause, LGPL-2.1, Apache-2.0, AGPL-3.0, GPL-3.0
  1. /*
  2. * (C) Copyright 2002 ELTEC Elektronik AG
  3. * Frank Gottschling <fgottschling@eltec.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. * cfb_console.c
  25. *
  26. * Color Framebuffer Console driver for 8/15/16/24/32 bits per pixel.
  27. *
  28. * At the moment only the 8x16 font is tested and the font fore- and
  29. * background color is limited to black/white/gray colors. The Linux
  30. * logo can be placed in the upper left corner and additional board
  31. * information strings (that normaly goes to serial port) can be drawed.
  32. *
  33. * The console driver can use the standard PC keyboard interface (i8042)
  34. * for character input. Character output goes to a memory mapped video
  35. * framebuffer with little or big-endian organisation.
  36. * With environment setting 'console=serial' the console i/o can be
  37. * forced to serial port.
  38. The driver uses graphic specific defines/parameters/functions:
  39. (for SMI LynxE graphic chip)
  40. CONFIG_VIDEO_SMI_LYNXEM - use graphic driver for SMI 710,712,810
  41. VIDEO_FB_LITTLE_ENDIAN - framebuffer organisation default: big endian
  42. VIDEO_HW_RECTFILL - graphic driver supports hardware rectangle fill
  43. VIDEO_HW_BITBLT - graphic driver supports hardware bit blt
  44. Console Parameters are set by graphic drivers global struct:
  45. VIDEO_VISIBLE_COLS - x resolution
  46. VIDEO_VISIBLE_ROWS - y resolution
  47. VIDEO_PIXEL_SIZE - storage size in byte per pixel
  48. VIDEO_DATA_FORMAT - graphical data format GDF
  49. VIDEO_FB_ADRS - start of video memory
  50. CONFIG_I8042_KBD - AT Keyboard driver for i8042
  51. VIDEO_KBD_INIT_FCT - init function for keyboard
  52. VIDEO_TSTC_FCT - keyboard_tstc function
  53. VIDEO_GETC_FCT - keyboard_getc function
  54. CONFIG_CONSOLE_CURSOR - on/off drawing cursor is done with delay
  55. loop in VIDEO_TSTC_FCT (i8042)
  56. CFG_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
  57. CONFIG_CONSOLE_TIME - display time/date in upper right corner,
  58. needs CFG_CMD_DATE and CONFIG_CONSOLE_CURSOR
  59. CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner
  60. CONFIG_VIDEO_BMP_LOGO - use bmp_logo instead of linux_logo
  61. CONFIG_CONSOLE_EXTRA_INFO - display additional board information strings
  62. that normaly goes to serial port. This define
  63. requires a board specific function:
  64. video_drawstring (VIDEO_INFO_X,
  65. VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT,
  66. info);
  67. that fills a info buffer at i=row.
  68. s.a: board/eltec/bab7xx.
  69. CONFIG_VGA_AS_SINGLE_DEVICE - If set the framebuffer device will be initialised
  70. as an output only device. The Keyboard driver
  71. will not be set-up. This may be used, if you
  72. have none or more than one Keyboard devices
  73. (USB Keyboard, AT Keyboard).
  74. CONFIG_VIDEO_SW_CURSOR: - Draws a cursor after the last character. No
  75. blinking is provided. Uses the macros CURSOR_SET
  76. and CURSOR_OFF.
  77. CONFIG_VIDEO_HW_CURSOR: - Uses the hardware cursor capability of the
  78. graphic chip. Uses the macro CURSOR_SET.
  79. ATTENTION: If booting an OS, the display driver
  80. must disable the hardware register of the graphic
  81. chip. Otherwise a blinking field is displayed
  82. */
  83. #include <common.h>
  84. #ifdef CONFIG_CFB_CONSOLE
  85. #include <malloc.h>
  86. /*****************************************************************************/
  87. /* Console device defines with SMI graphic */
  88. /* Any other graphic must change this section */
  89. /*****************************************************************************/
  90. #ifdef CONFIG_VIDEO_SMI_LYNXEM
  91. #define VIDEO_FB_LITTLE_ENDIAN
  92. #define VIDEO_HW_RECTFILL
  93. #define VIDEO_HW_BITBLT
  94. #endif
  95. /*****************************************************************************/
  96. /* Defines for the CT69000 driver */
  97. /*****************************************************************************/
  98. #ifdef CONFIG_VIDEO_CT69000
  99. #define VIDEO_FB_LITTLE_ENDIAN
  100. #define VIDEO_HW_RECTFILL
  101. #define VIDEO_HW_BITBLT
  102. #endif
  103. /*****************************************************************************/
  104. /* Defines for the SED13806 driver */
  105. /*****************************************************************************/
  106. #ifdef CONFIG_VIDEO_SED13806
  107. #ifndef CONFIG_TOTAL5200
  108. #define VIDEO_FB_LITTLE_ENDIAN
  109. #endif
  110. #define VIDEO_HW_RECTFILL
  111. #define VIDEO_HW_BITBLT
  112. #endif
  113. /*****************************************************************************/
  114. /* Defines for the SED13806 driver */
  115. /*****************************************************************************/
  116. #ifdef CONFIG_VIDEO_SM501
  117. #ifdef CONFIG_HH405
  118. #define VIDEO_FB_LITTLE_ENDIAN
  119. #endif
  120. #endif
  121. /*****************************************************************************/
  122. /* Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc */
  123. /*****************************************************************************/
  124. #include <video_fb.h>
  125. /*****************************************************************************/
  126. /* some Macros */
  127. /*****************************************************************************/
  128. #define VIDEO_VISIBLE_COLS (pGD->winSizeX)
  129. #define VIDEO_VISIBLE_ROWS (pGD->winSizeY)
  130. #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP)
  131. #define VIDEO_DATA_FORMAT (pGD->gdfIndex)
  132. #define VIDEO_FB_ADRS (pGD->frameAdrs)
  133. /*****************************************************************************/
  134. /* Console device defines with i8042 keyboard controller */
  135. /* Any other keyboard controller must change this section */
  136. /*****************************************************************************/
  137. #ifdef CONFIG_I8042_KBD
  138. #include <i8042.h>
  139. #define VIDEO_KBD_INIT_FCT i8042_kbd_init()
  140. #define VIDEO_TSTC_FCT i8042_tstc
  141. #define VIDEO_GETC_FCT i8042_getc
  142. #endif
  143. /*****************************************************************************/
  144. /* Console device */
  145. /*****************************************************************************/
  146. #include <version.h>
  147. #include <linux/types.h>
  148. #include <devices.h>
  149. #include <video_font.h>
  150. #ifdef CFG_CMD_DATE
  151. #include <rtc.h>
  152. #endif
  153. #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
  154. #include <watchdog.h>
  155. #include <bmp_layout.h>
  156. #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
  157. /*****************************************************************************/
  158. /* Cursor definition: */
  159. /* CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/i8042.c) to */
  160. /* let the cursor blink. Uses the macros CURSOR_OFF */
  161. /* and CURSOR_ON. */
  162. /* CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No */
  163. /* blinking is provided. Uses the macros CURSOR_SET */
  164. /* and CURSOR_OFF. */
  165. /* CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the */
  166. /* graphic chip. Uses the macro CURSOR_SET. */
  167. /* ATTENTION: If booting an OS, the display driver */
  168. /* must disable the hardware register of the graphic */
  169. /* chip. Otherwise a blinking field is displayed */
  170. /*****************************************************************************/
  171. #if !defined(CONFIG_CONSOLE_CURSOR) && \
  172. !defined(CONFIG_VIDEO_SW_CURSOR) && \
  173. !defined(CONFIG_VIDEO_HW_CURSOR)
  174. /* no Cursor defined */
  175. #define CURSOR_ON
  176. #define CURSOR_OFF
  177. #define CURSOR_SET
  178. #endif
  179. #ifdef CONFIG_CONSOLE_CURSOR
  180. #ifdef CURSOR_ON
  181. #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
  182. #endif
  183. void console_cursor (int state);
  184. #define CURSOR_ON console_cursor(1);
  185. #define CURSOR_OFF console_cursor(0);
  186. #define CURSOR_SET
  187. #ifndef CONFIG_I8042_KBD
  188. #warning Cursor drawing on/off needs timer function s.a. drivers/i8042.c
  189. #endif
  190. #else
  191. #ifdef CONFIG_CONSOLE_TIME
  192. #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
  193. #endif
  194. #endif /* CONFIG_CONSOLE_CURSOR */
  195. #ifdef CONFIG_VIDEO_SW_CURSOR
  196. #ifdef CURSOR_ON
  197. #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
  198. #endif
  199. #define CURSOR_ON
  200. #define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
  201. console_row * VIDEO_FONT_HEIGHT, ' ');
  202. #define CURSOR_SET video_set_cursor();
  203. #endif /* CONFIG_VIDEO_SW_CURSOR */
  204. #ifdef CONFIG_VIDEO_HW_CURSOR
  205. #ifdef CURSOR_ON
  206. #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
  207. #endif
  208. #define CURSOR_ON
  209. #define CURSOR_OFF
  210. #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \
  211. (console_row * VIDEO_FONT_HEIGHT) + VIDEO_LOGO_HEIGHT);
  212. #endif /* CONFIG_VIDEO_HW_CURSOR */
  213. #ifdef CONFIG_VIDEO_LOGO
  214. #ifdef CONFIG_VIDEO_BMP_LOGO
  215. #include <bmp_logo.h>
  216. #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH
  217. #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT
  218. #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET
  219. #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS
  220. #else /* CONFIG_VIDEO_BMP_LOGO */
  221. #define LINUX_LOGO_WIDTH 80
  222. #define LINUX_LOGO_HEIGHT 80
  223. #define LINUX_LOGO_COLORS 214
  224. #define LINUX_LOGO_LUT_OFFSET 0x20
  225. #define __initdata
  226. #include <linux_logo.h>
  227. #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH
  228. #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT
  229. #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET
  230. #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS
  231. #endif /* CONFIG_VIDEO_BMP_LOGO */
  232. #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH)
  233. #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2)
  234. #else /* CONFIG_VIDEO_LOGO */
  235. #define VIDEO_LOGO_WIDTH 0
  236. #define VIDEO_LOGO_HEIGHT 0
  237. #endif /* CONFIG_VIDEO_LOGO */
  238. #define VIDEO_COLS VIDEO_VISIBLE_COLS
  239. #define VIDEO_ROWS VIDEO_VISIBLE_ROWS
  240. #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
  241. #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2)
  242. #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE)
  243. #define VIDEO_BURST_LEN (VIDEO_COLS/8)
  244. #ifdef CONFIG_VIDEO_LOGO
  245. #define CONSOLE_ROWS ((VIDEO_ROWS - VIDEO_LOGO_HEIGHT) / VIDEO_FONT_HEIGHT)
  246. #else
  247. #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT)
  248. #endif
  249. #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH)
  250. #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN)
  251. #define CONSOLE_ROW_FIRST (video_console_address)
  252. #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE)
  253. #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
  254. #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
  255. #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
  256. /* Macros */
  257. #ifdef VIDEO_FB_LITTLE_ENDIAN
  258. #define SWAP16(x) ((((x) & 0x00ff) << 8) | ( (x) >> 8))
  259. #define SWAP32(x) ((((x) & 0x000000ff) << 24) | (((x) & 0x0000ff00) << 8)|\
  260. (((x) & 0x00ff0000) >> 8) | (((x) & 0xff000000) >> 24) )
  261. #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | (((x) & 0x0000ff00) >> 8)|\
  262. (((x) & 0x00ff0000) << 8) | (((x) & 0xff000000) >> 8) )
  263. #else
  264. #define SWAP16(x) (x)
  265. #define SWAP32(x) (x)
  266. #define SHORTSWAP32(x) (x)
  267. #endif
  268. #if defined(DEBUG) || defined(DEBUG_CFB_CONSOLE)
  269. #define PRINTD(x) printf(x)
  270. #else
  271. #define PRINTD(x)
  272. #endif
  273. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  274. extern void video_get_info_str ( /* setup a board string: type, speed, etc. */
  275. int line_number, /* location to place info string beside logo */
  276. char *info /* buffer for info string */
  277. );
  278. #endif
  279. /* Locals */
  280. static GraphicDevice *pGD; /* Pointer to Graphic array */
  281. static void *video_fb_address; /* frame buffer address */
  282. static void *video_console_address; /* console buffer start address */
  283. static int console_col = 0; /* cursor col */
  284. static int console_row = 0; /* cursor row */
  285. static u32 eorx, fgx, bgx; /* color pats */
  286. static const int video_font_draw_table8[] = {
  287. 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
  288. 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
  289. 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
  290. 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff };
  291. static const int video_font_draw_table15[] = {
  292. 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff };
  293. static const int video_font_draw_table16[] = {
  294. 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff };
  295. static const int video_font_draw_table24[16][3] = {
  296. { 0x00000000, 0x00000000, 0x00000000 },
  297. { 0x00000000, 0x00000000, 0x00ffffff },
  298. { 0x00000000, 0x0000ffff, 0xff000000 },
  299. { 0x00000000, 0x0000ffff, 0xffffffff },
  300. { 0x000000ff, 0xffff0000, 0x00000000 },
  301. { 0x000000ff, 0xffff0000, 0x00ffffff },
  302. { 0x000000ff, 0xffffffff, 0xff000000 },
  303. { 0x000000ff, 0xffffffff, 0xffffffff },
  304. { 0xffffff00, 0x00000000, 0x00000000 },
  305. { 0xffffff00, 0x00000000, 0x00ffffff },
  306. { 0xffffff00, 0x0000ffff, 0xff000000 },
  307. { 0xffffff00, 0x0000ffff, 0xffffffff },
  308. { 0xffffffff, 0xffff0000, 0x00000000 },
  309. { 0xffffffff, 0xffff0000, 0x00ffffff },
  310. { 0xffffffff, 0xffffffff, 0xff000000 },
  311. { 0xffffffff, 0xffffffff, 0xffffffff } };
  312. static const int video_font_draw_table32[16][4] = {
  313. { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
  314. { 0x00000000, 0x00000000, 0x00000000, 0x00ffffff },
  315. { 0x00000000, 0x00000000, 0x00ffffff, 0x00000000 },
  316. { 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff },
  317. { 0x00000000, 0x00ffffff, 0x00000000, 0x00000000 },
  318. { 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff },
  319. { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000 },
  320. { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff },
  321. { 0x00ffffff, 0x00000000, 0x00000000, 0x00000000 },
  322. { 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff },
  323. { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000 },
  324. { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff },
  325. { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000 },
  326. { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff },
  327. { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000 },
  328. { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff } };
  329. int gunzip(void *, int, unsigned char *, unsigned long *);
  330. /******************************************************************************/
  331. static void video_drawchars (int xx, int yy, unsigned char *s, int count)
  332. {
  333. u8 *cdat, *dest, *dest0;
  334. int rows, offset, c;
  335. offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE;
  336. dest0 = video_fb_address + offset;
  337. switch (VIDEO_DATA_FORMAT) {
  338. case GDF__8BIT_INDEX:
  339. case GDF__8BIT_332RGB:
  340. while (count--) {
  341. c = *s;
  342. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  343. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  344. rows--;
  345. dest += VIDEO_LINE_LEN) {
  346. u8 bits = *cdat++;
  347. ((u32 *) dest)[0] = (video_font_draw_table8[bits >> 4] & eorx) ^ bgx;
  348. ((u32 *) dest)[1] = (video_font_draw_table8[bits & 15] & eorx) ^ bgx;
  349. }
  350. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  351. s++;
  352. }
  353. break;
  354. case GDF_15BIT_555RGB:
  355. while (count--) {
  356. c = *s;
  357. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  358. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  359. rows--;
  360. dest += VIDEO_LINE_LEN) {
  361. u8 bits = *cdat++;
  362. ((u32 *) dest)[0] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 6] & eorx) ^ bgx);
  363. ((u32 *) dest)[1] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 4 & 3] & eorx) ^ bgx);
  364. ((u32 *) dest)[2] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 2 & 3] & eorx) ^ bgx);
  365. ((u32 *) dest)[3] = SHORTSWAP32 ((video_font_draw_table15 [bits & 3] & eorx) ^ bgx);
  366. }
  367. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  368. s++;
  369. }
  370. break;
  371. case GDF_16BIT_565RGB:
  372. while (count--) {
  373. c = *s;
  374. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  375. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  376. rows--;
  377. dest += VIDEO_LINE_LEN) {
  378. u8 bits = *cdat++;
  379. ((u32 *) dest)[0] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 6] & eorx) ^ bgx);
  380. ((u32 *) dest)[1] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 4 & 3] & eorx) ^ bgx);
  381. ((u32 *) dest)[2] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 2 & 3] & eorx) ^ bgx);
  382. ((u32 *) dest)[3] = SHORTSWAP32 ((video_font_draw_table16 [bits & 3] & eorx) ^ bgx);
  383. }
  384. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  385. s++;
  386. }
  387. break;
  388. case GDF_32BIT_X888RGB:
  389. while (count--) {
  390. c = *s;
  391. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  392. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  393. rows--;
  394. dest += VIDEO_LINE_LEN) {
  395. u8 bits = *cdat++;
  396. ((u32 *) dest)[0] = SWAP32 ((video_font_draw_table32 [bits >> 4][0] & eorx) ^ bgx);
  397. ((u32 *) dest)[1] = SWAP32 ((video_font_draw_table32 [bits >> 4][1] & eorx) ^ bgx);
  398. ((u32 *) dest)[2] = SWAP32 ((video_font_draw_table32 [bits >> 4][2] & eorx) ^ bgx);
  399. ((u32 *) dest)[3] = SWAP32 ((video_font_draw_table32 [bits >> 4][3] & eorx) ^ bgx);
  400. ((u32 *) dest)[4] = SWAP32 ((video_font_draw_table32 [bits & 15][0] & eorx) ^ bgx);
  401. ((u32 *) dest)[5] = SWAP32 ((video_font_draw_table32 [bits & 15][1] & eorx) ^ bgx);
  402. ((u32 *) dest)[6] = SWAP32 ((video_font_draw_table32 [bits & 15][2] & eorx) ^ bgx);
  403. ((u32 *) dest)[7] = SWAP32 ((video_font_draw_table32 [bits & 15][3] & eorx) ^ bgx);
  404. }
  405. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  406. s++;
  407. }
  408. break;
  409. case GDF_24BIT_888RGB:
  410. while (count--) {
  411. c = *s;
  412. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  413. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  414. rows--;
  415. dest += VIDEO_LINE_LEN) {
  416. u8 bits = *cdat++;
  417. ((u32 *) dest)[0] = (video_font_draw_table24[bits >> 4][0] & eorx) ^ bgx;
  418. ((u32 *) dest)[1] = (video_font_draw_table24[bits >> 4][1] & eorx) ^ bgx;
  419. ((u32 *) dest)[2] = (video_font_draw_table24[bits >> 4][2] & eorx) ^ bgx;
  420. ((u32 *) dest)[3] = (video_font_draw_table24[bits & 15][0] & eorx) ^ bgx;
  421. ((u32 *) dest)[4] = (video_font_draw_table24[bits & 15][1] & eorx) ^ bgx;
  422. ((u32 *) dest)[5] = (video_font_draw_table24[bits & 15][2] & eorx) ^ bgx;
  423. }
  424. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  425. s++;
  426. }
  427. break;
  428. }
  429. }
  430. /*****************************************************************************/
  431. static inline void video_drawstring (int xx, int yy, unsigned char *s)
  432. {
  433. video_drawchars (xx, yy, s, strlen ((char *)s));
  434. }
  435. /*****************************************************************************/
  436. static void video_putchar (int xx, int yy, unsigned char c)
  437. {
  438. video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1);
  439. }
  440. /*****************************************************************************/
  441. #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
  442. static void video_set_cursor (void)
  443. {
  444. /* swap drawing colors */
  445. eorx = fgx;
  446. fgx = bgx;
  447. bgx = eorx;
  448. eorx = fgx ^ bgx;
  449. /* draw cursor */
  450. video_putchar (console_col * VIDEO_FONT_WIDTH,
  451. console_row * VIDEO_FONT_HEIGHT,
  452. ' ');
  453. /* restore drawing colors */
  454. eorx = fgx;
  455. fgx = bgx;
  456. bgx = eorx;
  457. eorx = fgx ^ bgx;
  458. }
  459. #endif
  460. /*****************************************************************************/
  461. #ifdef CONFIG_CONSOLE_CURSOR
  462. void console_cursor (int state)
  463. {
  464. static int last_state = 0;
  465. #ifdef CONFIG_CONSOLE_TIME
  466. struct rtc_time tm;
  467. char info[16];
  468. /* time update only if cursor is on (faster scroll) */
  469. if (state) {
  470. rtc_get (&tm);
  471. sprintf (info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,
  472. tm.tm_sec);
  473. video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
  474. VIDEO_INFO_Y, (uchar *)info);
  475. sprintf (info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,
  476. tm.tm_year);
  477. video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
  478. VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, (uchar *)info);
  479. }
  480. #endif
  481. if (state && (last_state != state)) {
  482. video_set_cursor ();
  483. }
  484. if (!state && (last_state != state)) {
  485. /* clear cursor */
  486. video_putchar (console_col * VIDEO_FONT_WIDTH,
  487. console_row * VIDEO_FONT_HEIGHT,
  488. ' ');
  489. }
  490. last_state = state;
  491. }
  492. #endif
  493. /*****************************************************************************/
  494. #ifndef VIDEO_HW_RECTFILL
  495. static void memsetl (int *p, int c, int v)
  496. {
  497. while (c--)
  498. *(p++) = v;
  499. }
  500. #endif
  501. /*****************************************************************************/
  502. #ifndef VIDEO_HW_BITBLT
  503. static void memcpyl (int *d, int *s, int c)
  504. {
  505. while (c--)
  506. *(d++) = *(s++);
  507. }
  508. #endif
  509. /*****************************************************************************/
  510. static void console_scrollup (void)
  511. {
  512. /* copy up rows ignoring the first one */
  513. #ifdef VIDEO_HW_BITBLT
  514. video_hw_bitblt (VIDEO_PIXEL_SIZE, /* bytes per pixel */
  515. 0, /* source pos x */
  516. VIDEO_LOGO_HEIGHT + VIDEO_FONT_HEIGHT, /* source pos y */
  517. 0, /* dest pos x */
  518. VIDEO_LOGO_HEIGHT, /* dest pos y */
  519. VIDEO_VISIBLE_COLS, /* frame width */
  520. VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT - VIDEO_FONT_HEIGHT /* frame height */
  521. );
  522. #else
  523. memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND,
  524. CONSOLE_SCROLL_SIZE >> 2);
  525. #endif
  526. /* clear the last one */
  527. #ifdef VIDEO_HW_RECTFILL
  528. video_hw_rectfill (VIDEO_PIXEL_SIZE, /* bytes per pixel */
  529. 0, /* dest pos x */
  530. VIDEO_VISIBLE_ROWS - VIDEO_FONT_HEIGHT, /* dest pos y */
  531. VIDEO_VISIBLE_COLS, /* frame width */
  532. VIDEO_FONT_HEIGHT, /* frame height */
  533. CONSOLE_BG_COL /* fill color */
  534. );
  535. #else
  536. memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
  537. #endif
  538. }
  539. /*****************************************************************************/
  540. static void console_back (void)
  541. {
  542. CURSOR_OFF console_col--;
  543. if (console_col < 0) {
  544. console_col = CONSOLE_COLS - 1;
  545. console_row--;
  546. if (console_row < 0)
  547. console_row = 0;
  548. }
  549. video_putchar (console_col * VIDEO_FONT_WIDTH,
  550. console_row * VIDEO_FONT_HEIGHT,
  551. ' ');
  552. }
  553. /*****************************************************************************/
  554. static void console_newline (void)
  555. {
  556. CURSOR_OFF console_row++;
  557. console_col = 0;
  558. /* Check if we need to scroll the terminal */
  559. if (console_row >= CONSOLE_ROWS) {
  560. /* Scroll everything up */
  561. console_scrollup ();
  562. /* Decrement row number */
  563. console_row--;
  564. }
  565. }
  566. /*****************************************************************************/
  567. void video_putc (const char c)
  568. {
  569. switch (c) {
  570. case 13: /* ignore */
  571. break;
  572. case '\n': /* next line */
  573. console_newline ();
  574. break;
  575. case 9: /* tab 8 */
  576. CURSOR_OFF console_col |= 0x0008;
  577. console_col &= ~0x0007;
  578. if (console_col >= CONSOLE_COLS)
  579. console_newline ();
  580. break;
  581. case 8: /* backspace */
  582. console_back ();
  583. break;
  584. default: /* draw the char */
  585. video_putchar (console_col * VIDEO_FONT_WIDTH,
  586. console_row * VIDEO_FONT_HEIGHT,
  587. c);
  588. console_col++;
  589. /* check for newline */
  590. if (console_col >= CONSOLE_COLS)
  591. console_newline ();
  592. }
  593. CURSOR_SET}
  594. /*****************************************************************************/
  595. void video_puts (const char *s)
  596. {
  597. int count = strlen (s);
  598. while (count--)
  599. video_putc (*s++);
  600. }
  601. /*****************************************************************************/
  602. #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
  603. #define FILL_8BIT_332RGB(r,g,b) { \
  604. *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6); \
  605. fb ++; \
  606. }
  607. #define FILL_15BIT_555RGB(r,g,b) { \
  608. *(unsigned short *)fb = SWAP16((unsigned short)(((r>>3)<<10) | ((g>>3)<<5) | (b>>3))); \
  609. fb += 2; \
  610. }
  611. #define FILL_16BIT_565RGB(r,g,b) { \
  612. *(unsigned short *)fb = SWAP16((unsigned short)((((r)>>3)<<11) | (((g)>>2)<<5) | ((b)>>3))); \
  613. fb += 2; \
  614. }
  615. #define FILL_32BIT_X888RGB(r,g,b) { \
  616. *(unsigned long *)fb = SWAP32((unsigned long)(((r<<16) | (g<<8) | b))); \
  617. fb += 4; \
  618. }
  619. #ifdef VIDEO_FB_LITTLE_ENDIAN
  620. #define FILL_24BIT_888RGB(r,g,b) { \
  621. fb[0] = b; \
  622. fb[1] = g; \
  623. fb[2] = r; \
  624. fb += 3; \
  625. }
  626. #else
  627. #define FILL_24BIT_888RGB(r,g,b) { \
  628. fb[0] = r; \
  629. fb[1] = g; \
  630. fb[2] = b; \
  631. fb += 3; \
  632. }
  633. #endif
  634. /*
  635. * Display the BMP file located at address bmp_image.
  636. * Only uncompressed
  637. */
  638. int video_display_bitmap (ulong bmp_image, int x, int y)
  639. {
  640. ushort xcount, ycount;
  641. uchar *fb;
  642. bmp_image_t *bmp = (bmp_image_t *) bmp_image;
  643. uchar *bmap;
  644. ushort padded_line;
  645. unsigned long width, height, bpp;
  646. unsigned colors;
  647. unsigned long compression;
  648. bmp_color_table_entry_t cte;
  649. #ifdef CONFIG_VIDEO_BMP_GZIP
  650. unsigned char *dst = NULL;
  651. ulong len;
  652. #endif
  653. WATCHDOG_RESET ();
  654. if (!((bmp->header.signature[0] == 'B') &&
  655. (bmp->header.signature[1] == 'M'))) {
  656. #ifdef CONFIG_VIDEO_BMP_GZIP
  657. /*
  658. * Could be a gzipped bmp image, try to decrompress...
  659. */
  660. len = CFG_VIDEO_LOGO_MAX_SIZE;
  661. dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);
  662. if (dst == NULL) {
  663. printf("Error: malloc in gunzip failed!\n");
  664. return(1);
  665. }
  666. if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)bmp_image, &len) != 0) {
  667. printf ("Error: no valid bmp or bmp.gz image at %lx\n", bmp_image);
  668. free(dst);
  669. return 1;
  670. }
  671. if (len == CFG_VIDEO_LOGO_MAX_SIZE) {
  672. printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n");
  673. }
  674. /*
  675. * Set addr to decompressed image
  676. */
  677. bmp = (bmp_image_t *)dst;
  678. if (!((bmp->header.signature[0] == 'B') &&
  679. (bmp->header.signature[1] == 'M'))) {
  680. printf ("Error: no valid bmp.gz image at %lx\n", bmp_image);
  681. return 1;
  682. }
  683. #else
  684. printf ("Error: no valid bmp image at %lx\n", bmp_image);
  685. return 1;
  686. #endif /* CONFIG_VIDEO_BMP_GZIP */
  687. }
  688. width = le32_to_cpu (bmp->header.width);
  689. height = le32_to_cpu (bmp->header.height);
  690. bpp = le16_to_cpu (bmp->header.bit_count);
  691. colors = le32_to_cpu (bmp->header.colors_used);
  692. compression = le32_to_cpu (bmp->header.compression);
  693. debug ("Display-bmp: %d x %d with %d colors\n",
  694. width, height, colors);
  695. if (compression != BMP_BI_RGB) {
  696. printf ("Error: compression type %ld not supported\n",
  697. compression);
  698. return 1;
  699. }
  700. padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3;
  701. if ((x + width) > VIDEO_VISIBLE_COLS)
  702. width = VIDEO_VISIBLE_COLS - x;
  703. if ((y + height) > VIDEO_VISIBLE_ROWS)
  704. height = VIDEO_VISIBLE_ROWS - y;
  705. bmap = (uchar *) bmp + le32_to_cpu (bmp->header.data_offset);
  706. fb = (uchar *) (video_fb_address +
  707. ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
  708. x * VIDEO_PIXEL_SIZE);
  709. /* We handle only 8bpp or 24 bpp bitmap */
  710. switch (le16_to_cpu (bmp->header.bit_count)) {
  711. case 8:
  712. padded_line -= width;
  713. if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
  714. /* Copy colormap */
  715. for (xcount = 0; xcount < colors; ++xcount) {
  716. cte = bmp->color_table[xcount];
  717. video_set_lut (xcount, cte.red, cte.green, cte.blue);
  718. }
  719. }
  720. ycount = height;
  721. switch (VIDEO_DATA_FORMAT) {
  722. case GDF__8BIT_INDEX:
  723. while (ycount--) {
  724. WATCHDOG_RESET ();
  725. xcount = width;
  726. while (xcount--) {
  727. *fb++ = *bmap++;
  728. }
  729. bmap += padded_line;
  730. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  731. }
  732. break;
  733. case GDF__8BIT_332RGB:
  734. while (ycount--) {
  735. WATCHDOG_RESET ();
  736. xcount = width;
  737. while (xcount--) {
  738. cte = bmp->color_table[*bmap++];
  739. FILL_8BIT_332RGB (cte.red, cte.green, cte.blue);
  740. }
  741. bmap += padded_line;
  742. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  743. }
  744. break;
  745. case GDF_15BIT_555RGB:
  746. while (ycount--) {
  747. WATCHDOG_RESET ();
  748. xcount = width;
  749. while (xcount--) {
  750. cte = bmp->color_table[*bmap++];
  751. FILL_15BIT_555RGB (cte.red, cte.green, cte.blue);
  752. }
  753. bmap += padded_line;
  754. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  755. }
  756. break;
  757. case GDF_16BIT_565RGB:
  758. while (ycount--) {
  759. WATCHDOG_RESET ();
  760. xcount = width;
  761. while (xcount--) {
  762. cte = bmp->color_table[*bmap++];
  763. FILL_16BIT_565RGB (cte.red, cte.green, cte.blue);
  764. }
  765. bmap += padded_line;
  766. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  767. }
  768. break;
  769. case GDF_32BIT_X888RGB:
  770. while (ycount--) {
  771. WATCHDOG_RESET ();
  772. xcount = width;
  773. while (xcount--) {
  774. cte = bmp->color_table[*bmap++];
  775. FILL_32BIT_X888RGB (cte.red, cte.green, cte.blue);
  776. }
  777. bmap += padded_line;
  778. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  779. }
  780. break;
  781. case GDF_24BIT_888RGB:
  782. while (ycount--) {
  783. WATCHDOG_RESET ();
  784. xcount = width;
  785. while (xcount--) {
  786. cte = bmp->color_table[*bmap++];
  787. FILL_24BIT_888RGB (cte.red, cte.green, cte.blue);
  788. }
  789. bmap += padded_line;
  790. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  791. }
  792. break;
  793. }
  794. break;
  795. case 24:
  796. padded_line -= 3 * width;
  797. ycount = height;
  798. switch (VIDEO_DATA_FORMAT) {
  799. case GDF__8BIT_332RGB:
  800. while (ycount--) {
  801. WATCHDOG_RESET ();
  802. xcount = width;
  803. while (xcount--) {
  804. FILL_8BIT_332RGB (bmap[2], bmap[1], bmap[0]);
  805. bmap += 3;
  806. }
  807. bmap += padded_line;
  808. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  809. }
  810. break;
  811. case GDF_15BIT_555RGB:
  812. while (ycount--) {
  813. WATCHDOG_RESET ();
  814. xcount = width;
  815. while (xcount--) {
  816. FILL_15BIT_555RGB (bmap[2], bmap[1], bmap[0]);
  817. bmap += 3;
  818. }
  819. bmap += padded_line;
  820. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  821. }
  822. break;
  823. case GDF_16BIT_565RGB:
  824. while (ycount--) {
  825. WATCHDOG_RESET ();
  826. xcount = width;
  827. while (xcount--) {
  828. FILL_16BIT_565RGB (bmap[2], bmap[1], bmap[0]);
  829. bmap += 3;
  830. }
  831. bmap += padded_line;
  832. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  833. }
  834. break;
  835. case GDF_32BIT_X888RGB:
  836. while (ycount--) {
  837. WATCHDOG_RESET ();
  838. xcount = width;
  839. while (xcount--) {
  840. FILL_32BIT_X888RGB (bmap[2], bmap[1], bmap[0]);
  841. bmap += 3;
  842. }
  843. bmap += padded_line;
  844. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  845. }
  846. break;
  847. case GDF_24BIT_888RGB:
  848. while (ycount--) {
  849. WATCHDOG_RESET ();
  850. xcount = width;
  851. while (xcount--) {
  852. FILL_24BIT_888RGB (bmap[2], bmap[1], bmap[0]);
  853. bmap += 3;
  854. }
  855. bmap += padded_line;
  856. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  857. }
  858. break;
  859. default:
  860. printf ("Error: 24 bits/pixel bitmap incompatible with current video mode\n");
  861. break;
  862. }
  863. break;
  864. default:
  865. printf ("Error: %d bit/pixel bitmaps not supported by U-Boot\n",
  866. le16_to_cpu (bmp->header.bit_count));
  867. break;
  868. }
  869. #ifdef CONFIG_VIDEO_BMP_GZIP
  870. if (dst) {
  871. free(dst);
  872. }
  873. #endif
  874. return (0);
  875. }
  876. #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
  877. /*****************************************************************************/
  878. #ifdef CONFIG_VIDEO_LOGO
  879. void logo_plot (void *screen, int width, int x, int y)
  880. {
  881. int xcount, i;
  882. int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
  883. int ycount = VIDEO_LOGO_HEIGHT;
  884. unsigned char r, g, b, *logo_red, *logo_blue, *logo_green;
  885. unsigned char *source;
  886. unsigned char *dest = (unsigned char *)screen + ((y * width * VIDEO_PIXEL_SIZE) + x);
  887. #ifdef CONFIG_VIDEO_BMP_LOGO
  888. source = bmp_logo_bitmap;
  889. /* Allocate temporary space for computing colormap */
  890. logo_red = malloc (BMP_LOGO_COLORS);
  891. logo_green = malloc (BMP_LOGO_COLORS);
  892. logo_blue = malloc (BMP_LOGO_COLORS);
  893. /* Compute color map */
  894. for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
  895. logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4;
  896. logo_green[i] = (bmp_logo_palette[i] & 0x00f0);
  897. logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4;
  898. }
  899. #else
  900. source = linux_logo;
  901. logo_red = linux_logo_red;
  902. logo_green = linux_logo_green;
  903. logo_blue = linux_logo_blue;
  904. #endif
  905. if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
  906. for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
  907. video_set_lut (i + VIDEO_LOGO_LUT_OFFSET,
  908. logo_red[i], logo_green[i], logo_blue[i]);
  909. }
  910. }
  911. while (ycount--) {
  912. xcount = VIDEO_LOGO_WIDTH;
  913. while (xcount--) {
  914. r = logo_red[*source - VIDEO_LOGO_LUT_OFFSET];
  915. g = logo_green[*source - VIDEO_LOGO_LUT_OFFSET];
  916. b = logo_blue[*source - VIDEO_LOGO_LUT_OFFSET];
  917. switch (VIDEO_DATA_FORMAT) {
  918. case GDF__8BIT_INDEX:
  919. *dest = *source;
  920. break;
  921. case GDF__8BIT_332RGB:
  922. *dest = ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
  923. break;
  924. case GDF_15BIT_555RGB:
  925. *(unsigned short *) dest =
  926. SWAP16 ((unsigned short) (((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3)));
  927. break;
  928. case GDF_16BIT_565RGB:
  929. *(unsigned short *) dest =
  930. SWAP16 ((unsigned short) (((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)));
  931. break;
  932. case GDF_32BIT_X888RGB:
  933. *(unsigned long *) dest =
  934. SWAP32 ((unsigned long) ((r << 16) | (g << 8) | b));
  935. break;
  936. case GDF_24BIT_888RGB:
  937. #ifdef VIDEO_FB_LITTLE_ENDIAN
  938. dest[0] = b;
  939. dest[1] = g;
  940. dest[2] = r;
  941. #else
  942. dest[0] = r;
  943. dest[1] = g;
  944. dest[2] = b;
  945. #endif
  946. break;
  947. }
  948. source++;
  949. dest += VIDEO_PIXEL_SIZE;
  950. }
  951. dest += skip;
  952. }
  953. #ifdef CONFIG_VIDEO_BMP_LOGO
  954. free (logo_red);
  955. free (logo_green);
  956. free (logo_blue);
  957. #endif
  958. }
  959. /*****************************************************************************/
  960. static void *video_logo (void)
  961. {
  962. char info[128];
  963. extern char version_string;
  964. #ifdef CONFIG_SPLASH_SCREEN
  965. char *s;
  966. ulong addr;
  967. if ((s = getenv ("splashimage")) != NULL) {
  968. addr = simple_strtoul (s, NULL, 16);
  969. if (video_display_bitmap (addr, 0, 0) == 0) {
  970. return ((void *) (video_fb_address));
  971. }
  972. }
  973. #endif /* CONFIG_SPLASH_SCREEN */
  974. logo_plot (video_fb_address, VIDEO_COLS, 0, 0);
  975. sprintf (info, " %s", &version_string);
  976. video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *)info);
  977. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  978. {
  979. int i, n = ((VIDEO_LOGO_HEIGHT - VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT);
  980. for (i = 1; i < n; i++) {
  981. video_get_info_str (i, info);
  982. if (*info)
  983. video_drawstring (VIDEO_INFO_X,
  984. VIDEO_INFO_Y + i * VIDEO_FONT_HEIGHT,
  985. (uchar *)info);
  986. }
  987. }
  988. #endif
  989. return (video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN);
  990. }
  991. #endif
  992. /*****************************************************************************/
  993. static int video_init (void)
  994. {
  995. unsigned char color8;
  996. if ((pGD = video_hw_init ()) == NULL)
  997. return -1;
  998. video_fb_address = (void *) VIDEO_FB_ADRS;
  999. #ifdef CONFIG_VIDEO_HW_CURSOR
  1000. video_init_hw_cursor (VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
  1001. #endif
  1002. /* Init drawing pats */
  1003. switch (VIDEO_DATA_FORMAT) {
  1004. case GDF__8BIT_INDEX:
  1005. video_set_lut (0x01, CONSOLE_FG_COL, CONSOLE_FG_COL, CONSOLE_FG_COL);
  1006. video_set_lut (0x00, CONSOLE_BG_COL, CONSOLE_BG_COL, CONSOLE_BG_COL);
  1007. fgx = 0x01010101;
  1008. bgx = 0x00000000;
  1009. break;
  1010. case GDF__8BIT_332RGB:
  1011. color8 = ((CONSOLE_FG_COL & 0xe0) |
  1012. ((CONSOLE_FG_COL >> 3) & 0x1c) | CONSOLE_FG_COL >> 6);
  1013. fgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | color8;
  1014. color8 = ((CONSOLE_BG_COL & 0xe0) |
  1015. ((CONSOLE_BG_COL >> 3) & 0x1c) | CONSOLE_BG_COL >> 6);
  1016. bgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | color8;
  1017. break;
  1018. case GDF_15BIT_555RGB:
  1019. fgx = (((CONSOLE_FG_COL >> 3) << 26) |
  1020. ((CONSOLE_FG_COL >> 3) << 21) | ((CONSOLE_FG_COL >> 3) << 16) |
  1021. ((CONSOLE_FG_COL >> 3) << 10) | ((CONSOLE_FG_COL >> 3) << 5) |
  1022. (CONSOLE_FG_COL >> 3));
  1023. bgx = (((CONSOLE_BG_COL >> 3) << 26) |
  1024. ((CONSOLE_BG_COL >> 3) << 21) | ((CONSOLE_BG_COL >> 3) << 16) |
  1025. ((CONSOLE_BG_COL >> 3) << 10) | ((CONSOLE_BG_COL >> 3) << 5) |
  1026. (CONSOLE_BG_COL >> 3));
  1027. break;
  1028. case GDF_16BIT_565RGB:
  1029. fgx = (((CONSOLE_FG_COL >> 3) << 27) |
  1030. ((CONSOLE_FG_COL >> 2) << 21) | ((CONSOLE_FG_COL >> 3) << 16) |
  1031. ((CONSOLE_FG_COL >> 3) << 11) | ((CONSOLE_FG_COL >> 2) << 5) |
  1032. (CONSOLE_FG_COL >> 3));
  1033. bgx = (((CONSOLE_BG_COL >> 3) << 27) |
  1034. ((CONSOLE_BG_COL >> 2) << 21) | ((CONSOLE_BG_COL >> 3) << 16) |
  1035. ((CONSOLE_BG_COL >> 3) << 11) | ((CONSOLE_BG_COL >> 2) << 5) |
  1036. (CONSOLE_BG_COL >> 3));
  1037. break;
  1038. case GDF_32BIT_X888RGB:
  1039. fgx = (CONSOLE_FG_COL << 16) | (CONSOLE_FG_COL << 8) | CONSOLE_FG_COL;
  1040. bgx = (CONSOLE_BG_COL << 16) | (CONSOLE_BG_COL << 8) | CONSOLE_BG_COL;
  1041. break;
  1042. case GDF_24BIT_888RGB:
  1043. fgx = (CONSOLE_FG_COL << 24) | (CONSOLE_FG_COL << 16) |
  1044. (CONSOLE_FG_COL << 8) | CONSOLE_FG_COL;
  1045. bgx = (CONSOLE_BG_COL << 24) | (CONSOLE_BG_COL << 16) |
  1046. (CONSOLE_BG_COL << 8) | CONSOLE_BG_COL;
  1047. break;
  1048. }
  1049. eorx = fgx ^ bgx;
  1050. #ifdef CONFIG_VIDEO_LOGO
  1051. /* Plot the logo and get start point of console */
  1052. PRINTD ("Video: Drawing the logo ...\n");
  1053. video_console_address = video_logo ();
  1054. #else
  1055. video_console_address = video_fb_address;
  1056. #endif
  1057. /* Initialize the console */
  1058. console_col = 0;
  1059. console_row = 0;
  1060. return 0;
  1061. }
  1062. /*****************************************************************************/
  1063. int drv_video_init (void)
  1064. {
  1065. int skip_dev_init;
  1066. device_t console_dev;
  1067. skip_dev_init = 0;
  1068. /* Init video chip - returns with framebuffer cleared */
  1069. if (video_init () == -1)
  1070. skip_dev_init = 1;
  1071. #ifdef CONFIG_VGA_AS_SINGLE_DEVICE
  1072. /* Devices VGA and Keyboard will be assigned seperately */
  1073. /* Init vga device */
  1074. if (!skip_dev_init) {
  1075. memset (&console_dev, 0, sizeof (console_dev));
  1076. strcpy (console_dev.name, "vga");
  1077. console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
  1078. console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
  1079. console_dev.putc = video_putc; /* 'putc' function */
  1080. console_dev.puts = video_puts; /* 'puts' function */
  1081. console_dev.tstc = NULL; /* 'tstc' function */
  1082. console_dev.getc = NULL; /* 'getc' function */
  1083. if (device_register (&console_dev) == 0)
  1084. return 1;
  1085. }
  1086. #else
  1087. PRINTD ("KBD: Keyboard init ...\n");
  1088. if (VIDEO_KBD_INIT_FCT == -1)
  1089. skip_dev_init = 1;
  1090. /* Init console device */
  1091. if (!skip_dev_init) {
  1092. memset (&console_dev, 0, sizeof (console_dev));
  1093. strcpy (console_dev.name, "vga");
  1094. console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
  1095. console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
  1096. console_dev.putc = video_putc; /* 'putc' function */
  1097. console_dev.puts = video_puts; /* 'puts' function */
  1098. console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
  1099. console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
  1100. if (device_register (&console_dev) == 0)
  1101. return 1;
  1102. }
  1103. #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
  1104. /* No console dev available */
  1105. return 0;
  1106. }
  1107. #endif /* CONFIG_CFB_CONSOLE */