cfb_console.c 36 KB

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