cfb_console.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671
  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. CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
  57. CONFIG_CONSOLE_TIME - display time/date in upper right corner,
  58. needs CONFIG_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. #include <malloc.h>
  85. /*****************************************************************************/
  86. /* Console device defines with SMI graphic */
  87. /* Any other graphic must change this section */
  88. /*****************************************************************************/
  89. #ifdef CONFIG_VIDEO_SMI_LYNXEM
  90. #define VIDEO_FB_LITTLE_ENDIAN
  91. #define VIDEO_HW_RECTFILL
  92. #define VIDEO_HW_BITBLT
  93. #endif
  94. /*****************************************************************************/
  95. /* Defines for the CT69000 driver */
  96. /*****************************************************************************/
  97. #ifdef CONFIG_VIDEO_CT69000
  98. #define VIDEO_FB_LITTLE_ENDIAN
  99. #define VIDEO_HW_RECTFILL
  100. #define VIDEO_HW_BITBLT
  101. #endif
  102. /*****************************************************************************/
  103. /* Defines for the SED13806 driver */
  104. /*****************************************************************************/
  105. #ifdef CONFIG_VIDEO_SED13806
  106. #ifndef CONFIG_TOTAL5200
  107. #define VIDEO_FB_LITTLE_ENDIAN
  108. #endif
  109. #define VIDEO_HW_RECTFILL
  110. #define VIDEO_HW_BITBLT
  111. #endif
  112. /*****************************************************************************/
  113. /* Defines for the SED13806 driver */
  114. /*****************************************************************************/
  115. #ifdef CONFIG_VIDEO_SM501
  116. #ifdef CONFIG_HH405
  117. #define VIDEO_FB_LITTLE_ENDIAN
  118. #endif
  119. #endif
  120. /*****************************************************************************/
  121. /* Defines for the MB862xx driver */
  122. /*****************************************************************************/
  123. #ifdef CONFIG_VIDEO_MB862xx
  124. #ifdef CONFIG_VIDEO_CORALP
  125. #define VIDEO_FB_LITTLE_ENDIAN
  126. #endif
  127. #ifdef CONFIG_VIDEO_MB862xx_ACCEL
  128. #define VIDEO_HW_RECTFILL
  129. #define VIDEO_HW_BITBLT
  130. #endif
  131. #endif
  132. /*****************************************************************************/
  133. /* Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc */
  134. /*****************************************************************************/
  135. #include <video_fb.h>
  136. /*****************************************************************************/
  137. /* some Macros */
  138. /*****************************************************************************/
  139. #define VIDEO_VISIBLE_COLS (pGD->winSizeX)
  140. #define VIDEO_VISIBLE_ROWS (pGD->winSizeY)
  141. #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP)
  142. #define VIDEO_DATA_FORMAT (pGD->gdfIndex)
  143. #define VIDEO_FB_ADRS (pGD->frameAdrs)
  144. /*****************************************************************************/
  145. /* Console device defines with i8042 keyboard controller */
  146. /* Any other keyboard controller must change this section */
  147. /*****************************************************************************/
  148. #ifdef CONFIG_I8042_KBD
  149. #include <i8042.h>
  150. #define VIDEO_KBD_INIT_FCT i8042_kbd_init()
  151. #define VIDEO_TSTC_FCT i8042_tstc
  152. #define VIDEO_GETC_FCT i8042_getc
  153. #endif
  154. /*****************************************************************************/
  155. /* Console device */
  156. /*****************************************************************************/
  157. #include <version.h>
  158. #include <linux/types.h>
  159. #include <stdio_dev.h>
  160. #include <video_font.h>
  161. #if defined(CONFIG_CMD_DATE)
  162. #include <rtc.h>
  163. #endif
  164. #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
  165. #include <watchdog.h>
  166. #include <bmp_layout.h>
  167. #ifdef CONFIG_SPLASH_SCREEN_ALIGN
  168. #define BMP_ALIGN_CENTER 0x7FFF
  169. #endif
  170. #endif
  171. /*****************************************************************************/
  172. /* Cursor definition: */
  173. /* CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c) */
  174. /* to let the cursor blink. Uses the macros */
  175. /* CURSOR_OFF and CURSOR_ON. */
  176. /* CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No */
  177. /* blinking is provided. Uses the macros CURSOR_SET */
  178. /* and CURSOR_OFF. */
  179. /* CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the */
  180. /* graphic chip. Uses the macro CURSOR_SET. */
  181. /* ATTENTION: If booting an OS, the display driver */
  182. /* must disable the hardware register of the graphic */
  183. /* chip. Otherwise a blinking field is displayed */
  184. /*****************************************************************************/
  185. #if !defined(CONFIG_CONSOLE_CURSOR) && \
  186. !defined(CONFIG_VIDEO_SW_CURSOR) && \
  187. !defined(CONFIG_VIDEO_HW_CURSOR)
  188. /* no Cursor defined */
  189. #define CURSOR_ON
  190. #define CURSOR_OFF
  191. #define CURSOR_SET
  192. #endif
  193. #ifdef CONFIG_CONSOLE_CURSOR
  194. #ifdef CURSOR_ON
  195. #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
  196. #endif
  197. void console_cursor (int state);
  198. #define CURSOR_ON console_cursor(1)
  199. #define CURSOR_OFF console_cursor(0)
  200. #define CURSOR_SET
  201. #ifndef CONFIG_I8042_KBD
  202. #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
  203. #endif
  204. #else
  205. #ifdef CONFIG_CONSOLE_TIME
  206. #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
  207. #endif
  208. #endif /* CONFIG_CONSOLE_CURSOR */
  209. #ifdef CONFIG_VIDEO_SW_CURSOR
  210. #ifdef CURSOR_ON
  211. #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
  212. #endif
  213. #define CURSOR_ON
  214. #define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
  215. console_row * VIDEO_FONT_HEIGHT, ' ')
  216. #define CURSOR_SET video_set_cursor()
  217. #endif /* CONFIG_VIDEO_SW_CURSOR */
  218. #ifdef CONFIG_VIDEO_HW_CURSOR
  219. #ifdef CURSOR_ON
  220. #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
  221. #endif
  222. #define CURSOR_ON
  223. #define CURSOR_OFF
  224. #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \
  225. (console_row * VIDEO_FONT_HEIGHT) + video_logo_height)
  226. #endif /* CONFIG_VIDEO_HW_CURSOR */
  227. #ifdef CONFIG_VIDEO_LOGO
  228. #ifdef CONFIG_VIDEO_BMP_LOGO
  229. #include <bmp_logo.h>
  230. #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH
  231. #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT
  232. #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET
  233. #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS
  234. #else /* CONFIG_VIDEO_BMP_LOGO */
  235. #define LINUX_LOGO_WIDTH 80
  236. #define LINUX_LOGO_HEIGHT 80
  237. #define LINUX_LOGO_COLORS 214
  238. #define LINUX_LOGO_LUT_OFFSET 0x20
  239. #define __initdata
  240. #include <linux_logo.h>
  241. #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH
  242. #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT
  243. #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET
  244. #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS
  245. #endif /* CONFIG_VIDEO_BMP_LOGO */
  246. #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH)
  247. #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2)
  248. #else /* CONFIG_VIDEO_LOGO */
  249. #define VIDEO_LOGO_WIDTH 0
  250. #define VIDEO_LOGO_HEIGHT 0
  251. #endif /* CONFIG_VIDEO_LOGO */
  252. #define VIDEO_COLS VIDEO_VISIBLE_COLS
  253. #define VIDEO_ROWS VIDEO_VISIBLE_ROWS
  254. #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
  255. #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2)
  256. #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE)
  257. #define VIDEO_BURST_LEN (VIDEO_COLS/8)
  258. #ifdef CONFIG_VIDEO_LOGO
  259. #define CONSOLE_ROWS ((VIDEO_ROWS - video_logo_height) / VIDEO_FONT_HEIGHT)
  260. #else
  261. #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT)
  262. #endif
  263. #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH)
  264. #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN)
  265. #define CONSOLE_ROW_FIRST (video_console_address)
  266. #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE)
  267. #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
  268. #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
  269. #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
  270. /* Macros */
  271. #ifdef VIDEO_FB_LITTLE_ENDIAN
  272. #define SWAP16(x) ((((x) & 0x00ff) << 8) | ( (x) >> 8))
  273. #define SWAP32(x) ((((x) & 0x000000ff) << 24) | (((x) & 0x0000ff00) << 8)|\
  274. (((x) & 0x00ff0000) >> 8) | (((x) & 0xff000000) >> 24) )
  275. #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | (((x) & 0x0000ff00) >> 8)|\
  276. (((x) & 0x00ff0000) << 8) | (((x) & 0xff000000) >> 8) )
  277. #else
  278. #define SWAP16(x) (x)
  279. #define SWAP32(x) (x)
  280. #if defined(VIDEO_FB_16BPP_WORD_SWAP)
  281. #define SHORTSWAP32(x) ( ((x) >> 16) | ((x) << 16) )
  282. #else
  283. #define SHORTSWAP32(x) (x)
  284. #endif
  285. #endif
  286. #if defined(DEBUG) || defined(DEBUG_CFB_CONSOLE)
  287. #define PRINTD(x) printf(x)
  288. #else
  289. #define PRINTD(x)
  290. #endif
  291. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  292. extern void video_get_info_str ( /* setup a board string: type, speed, etc. */
  293. int line_number, /* location to place info string beside logo */
  294. char *info /* buffer for info string */
  295. );
  296. #endif
  297. /* Locals */
  298. static GraphicDevice *pGD; /* Pointer to Graphic array */
  299. static void *video_fb_address; /* frame buffer address */
  300. static void *video_console_address; /* console buffer start address */
  301. static int video_logo_height = VIDEO_LOGO_HEIGHT;
  302. static int console_col = 0; /* cursor col */
  303. static int console_row = 0; /* cursor row */
  304. static u32 eorx, fgx, bgx; /* color pats */
  305. static const int video_font_draw_table8[] = {
  306. 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
  307. 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
  308. 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
  309. 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff };
  310. static const int video_font_draw_table15[] = {
  311. 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff };
  312. static const int video_font_draw_table16[] = {
  313. 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff };
  314. static const int video_font_draw_table24[16][3] = {
  315. { 0x00000000, 0x00000000, 0x00000000 },
  316. { 0x00000000, 0x00000000, 0x00ffffff },
  317. { 0x00000000, 0x0000ffff, 0xff000000 },
  318. { 0x00000000, 0x0000ffff, 0xffffffff },
  319. { 0x000000ff, 0xffff0000, 0x00000000 },
  320. { 0x000000ff, 0xffff0000, 0x00ffffff },
  321. { 0x000000ff, 0xffffffff, 0xff000000 },
  322. { 0x000000ff, 0xffffffff, 0xffffffff },
  323. { 0xffffff00, 0x00000000, 0x00000000 },
  324. { 0xffffff00, 0x00000000, 0x00ffffff },
  325. { 0xffffff00, 0x0000ffff, 0xff000000 },
  326. { 0xffffff00, 0x0000ffff, 0xffffffff },
  327. { 0xffffffff, 0xffff0000, 0x00000000 },
  328. { 0xffffffff, 0xffff0000, 0x00ffffff },
  329. { 0xffffffff, 0xffffffff, 0xff000000 },
  330. { 0xffffffff, 0xffffffff, 0xffffffff } };
  331. static const int video_font_draw_table32[16][4] = {
  332. { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
  333. { 0x00000000, 0x00000000, 0x00000000, 0x00ffffff },
  334. { 0x00000000, 0x00000000, 0x00ffffff, 0x00000000 },
  335. { 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff },
  336. { 0x00000000, 0x00ffffff, 0x00000000, 0x00000000 },
  337. { 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff },
  338. { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000 },
  339. { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff },
  340. { 0x00ffffff, 0x00000000, 0x00000000, 0x00000000 },
  341. { 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff },
  342. { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000 },
  343. { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff },
  344. { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000 },
  345. { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff },
  346. { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000 },
  347. { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff } };
  348. /******************************************************************************/
  349. static void video_drawchars (int xx, int yy, unsigned char *s, int count)
  350. {
  351. u8 *cdat, *dest, *dest0;
  352. int rows, offset, c;
  353. offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE;
  354. dest0 = video_fb_address + offset;
  355. switch (VIDEO_DATA_FORMAT) {
  356. case GDF__8BIT_INDEX:
  357. case GDF__8BIT_332RGB:
  358. while (count--) {
  359. c = *s;
  360. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  361. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  362. rows--;
  363. dest += VIDEO_LINE_LEN) {
  364. u8 bits = *cdat++;
  365. ((u32 *) dest)[0] = (video_font_draw_table8[bits >> 4] & eorx) ^ bgx;
  366. ((u32 *) dest)[1] = (video_font_draw_table8[bits & 15] & eorx) ^ bgx;
  367. }
  368. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  369. s++;
  370. }
  371. break;
  372. case GDF_15BIT_555RGB:
  373. while (count--) {
  374. c = *s;
  375. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  376. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  377. rows--;
  378. dest += VIDEO_LINE_LEN) {
  379. u8 bits = *cdat++;
  380. ((u32 *) dest)[0] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 6] & eorx) ^ bgx);
  381. ((u32 *) dest)[1] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 4 & 3] & eorx) ^ bgx);
  382. ((u32 *) dest)[2] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 2 & 3] & eorx) ^ bgx);
  383. ((u32 *) dest)[3] = SHORTSWAP32 ((video_font_draw_table15 [bits & 3] & eorx) ^ bgx);
  384. }
  385. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  386. s++;
  387. }
  388. break;
  389. case GDF_16BIT_565RGB:
  390. while (count--) {
  391. c = *s;
  392. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  393. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  394. rows--;
  395. dest += VIDEO_LINE_LEN) {
  396. u8 bits = *cdat++;
  397. ((u32 *) dest)[0] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 6] & eorx) ^ bgx);
  398. ((u32 *) dest)[1] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 4 & 3] & eorx) ^ bgx);
  399. ((u32 *) dest)[2] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 2 & 3] & eorx) ^ bgx);
  400. ((u32 *) dest)[3] = SHORTSWAP32 ((video_font_draw_table16 [bits & 3] & eorx) ^ bgx);
  401. }
  402. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  403. s++;
  404. }
  405. break;
  406. case GDF_32BIT_X888RGB:
  407. while (count--) {
  408. c = *s;
  409. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  410. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  411. rows--;
  412. dest += VIDEO_LINE_LEN) {
  413. u8 bits = *cdat++;
  414. ((u32 *) dest)[0] = SWAP32 ((video_font_draw_table32 [bits >> 4][0] & eorx) ^ bgx);
  415. ((u32 *) dest)[1] = SWAP32 ((video_font_draw_table32 [bits >> 4][1] & eorx) ^ bgx);
  416. ((u32 *) dest)[2] = SWAP32 ((video_font_draw_table32 [bits >> 4][2] & eorx) ^ bgx);
  417. ((u32 *) dest)[3] = SWAP32 ((video_font_draw_table32 [bits >> 4][3] & eorx) ^ bgx);
  418. ((u32 *) dest)[4] = SWAP32 ((video_font_draw_table32 [bits & 15][0] & eorx) ^ bgx);
  419. ((u32 *) dest)[5] = SWAP32 ((video_font_draw_table32 [bits & 15][1] & eorx) ^ bgx);
  420. ((u32 *) dest)[6] = SWAP32 ((video_font_draw_table32 [bits & 15][2] & eorx) ^ bgx);
  421. ((u32 *) dest)[7] = SWAP32 ((video_font_draw_table32 [bits & 15][3] & eorx) ^ bgx);
  422. }
  423. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  424. s++;
  425. }
  426. break;
  427. case GDF_24BIT_888RGB:
  428. while (count--) {
  429. c = *s;
  430. cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
  431. for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
  432. rows--;
  433. dest += VIDEO_LINE_LEN) {
  434. u8 bits = *cdat++;
  435. ((u32 *) dest)[0] = (video_font_draw_table24[bits >> 4][0] & eorx) ^ bgx;
  436. ((u32 *) dest)[1] = (video_font_draw_table24[bits >> 4][1] & eorx) ^ bgx;
  437. ((u32 *) dest)[2] = (video_font_draw_table24[bits >> 4][2] & eorx) ^ bgx;
  438. ((u32 *) dest)[3] = (video_font_draw_table24[bits & 15][0] & eorx) ^ bgx;
  439. ((u32 *) dest)[4] = (video_font_draw_table24[bits & 15][1] & eorx) ^ bgx;
  440. ((u32 *) dest)[5] = (video_font_draw_table24[bits & 15][2] & eorx) ^ bgx;
  441. }
  442. dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
  443. s++;
  444. }
  445. break;
  446. }
  447. }
  448. /*****************************************************************************/
  449. static inline void video_drawstring (int xx, int yy, unsigned char *s)
  450. {
  451. video_drawchars (xx, yy, s, strlen ((char *)s));
  452. }
  453. /*****************************************************************************/
  454. static void video_putchar (int xx, int yy, unsigned char c)
  455. {
  456. video_drawchars (xx, yy + video_logo_height, &c, 1);
  457. }
  458. /*****************************************************************************/
  459. #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
  460. static void video_set_cursor (void)
  461. {
  462. /* swap drawing colors */
  463. eorx = fgx;
  464. fgx = bgx;
  465. bgx = eorx;
  466. eorx = fgx ^ bgx;
  467. /* draw cursor */
  468. video_putchar (console_col * VIDEO_FONT_WIDTH,
  469. console_row * VIDEO_FONT_HEIGHT,
  470. ' ');
  471. /* restore drawing colors */
  472. eorx = fgx;
  473. fgx = bgx;
  474. bgx = eorx;
  475. eorx = fgx ^ bgx;
  476. }
  477. #endif
  478. /*****************************************************************************/
  479. #ifdef CONFIG_CONSOLE_CURSOR
  480. void console_cursor (int state)
  481. {
  482. static int last_state = 0;
  483. #ifdef CONFIG_CONSOLE_TIME
  484. struct rtc_time tm;
  485. char info[16];
  486. /* time update only if cursor is on (faster scroll) */
  487. if (state) {
  488. rtc_get (&tm);
  489. sprintf (info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,
  490. tm.tm_sec);
  491. video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
  492. VIDEO_INFO_Y, (uchar *)info);
  493. sprintf (info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,
  494. tm.tm_year);
  495. video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
  496. VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, (uchar *)info);
  497. }
  498. #endif
  499. if (state && (last_state != state)) {
  500. video_set_cursor ();
  501. }
  502. if (!state && (last_state != state)) {
  503. /* clear cursor */
  504. video_putchar (console_col * VIDEO_FONT_WIDTH,
  505. console_row * VIDEO_FONT_HEIGHT,
  506. ' ');
  507. }
  508. last_state = state;
  509. }
  510. #endif
  511. /*****************************************************************************/
  512. #ifndef VIDEO_HW_RECTFILL
  513. static void memsetl (int *p, int c, int v)
  514. {
  515. while (c--)
  516. *(p++) = v;
  517. }
  518. #endif
  519. /*****************************************************************************/
  520. #ifndef VIDEO_HW_BITBLT
  521. static void memcpyl (int *d, int *s, int c)
  522. {
  523. while (c--)
  524. *(d++) = *(s++);
  525. }
  526. #endif
  527. /*****************************************************************************/
  528. static void console_scrollup (void)
  529. {
  530. /* copy up rows ignoring the first one */
  531. #ifdef VIDEO_HW_BITBLT
  532. video_hw_bitblt (VIDEO_PIXEL_SIZE, /* bytes per pixel */
  533. 0, /* source pos x */
  534. video_logo_height + VIDEO_FONT_HEIGHT, /* source pos y */
  535. 0, /* dest pos x */
  536. video_logo_height, /* dest pos y */
  537. VIDEO_VISIBLE_COLS, /* frame width */
  538. VIDEO_VISIBLE_ROWS - video_logo_height - VIDEO_FONT_HEIGHT /* frame height */
  539. );
  540. #else
  541. memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND,
  542. CONSOLE_SCROLL_SIZE >> 2);
  543. #endif
  544. /* clear the last one */
  545. #ifdef VIDEO_HW_RECTFILL
  546. video_hw_rectfill (VIDEO_PIXEL_SIZE, /* bytes per pixel */
  547. 0, /* dest pos x */
  548. VIDEO_VISIBLE_ROWS - VIDEO_FONT_HEIGHT, /* dest pos y */
  549. VIDEO_VISIBLE_COLS, /* frame width */
  550. VIDEO_FONT_HEIGHT, /* frame height */
  551. CONSOLE_BG_COL /* fill color */
  552. );
  553. #else
  554. memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
  555. #endif
  556. }
  557. /*****************************************************************************/
  558. static void console_back (void)
  559. {
  560. CURSOR_OFF;
  561. console_col--;
  562. if (console_col < 0) {
  563. console_col = CONSOLE_COLS - 1;
  564. console_row--;
  565. if (console_row < 0)
  566. console_row = 0;
  567. }
  568. video_putchar (console_col * VIDEO_FONT_WIDTH,
  569. console_row * VIDEO_FONT_HEIGHT,
  570. ' ');
  571. }
  572. /*****************************************************************************/
  573. static void console_newline (void)
  574. {
  575. /* Check if last character in the line was just drawn. If so, cursor was
  576. overwriten and need not to be cleared. Cursor clearing without this
  577. check causes overwriting the 1st character of the line if line lenght
  578. is >= CONSOLE_COLS
  579. */
  580. if (console_col < CONSOLE_COLS)
  581. CURSOR_OFF;
  582. console_row++;
  583. console_col = 0;
  584. /* Check if we need to scroll the terminal */
  585. if (console_row >= CONSOLE_ROWS) {
  586. /* Scroll everything up */
  587. console_scrollup ();
  588. /* Decrement row number */
  589. console_row--;
  590. }
  591. }
  592. static void console_cr (void)
  593. {
  594. CURSOR_OFF;
  595. console_col = 0;
  596. }
  597. /*****************************************************************************/
  598. void video_putc (const char c)
  599. {
  600. static int nl = 1;
  601. switch (c) {
  602. case 13: /* back to first column */
  603. console_cr ();
  604. break;
  605. case '\n': /* next line */
  606. if (console_col || (!console_col && nl))
  607. console_newline ();
  608. nl = 1;
  609. break;
  610. case 9: /* tab 8 */
  611. CURSOR_OFF;
  612. console_col |= 0x0008;
  613. console_col &= ~0x0007;
  614. if (console_col >= CONSOLE_COLS)
  615. console_newline ();
  616. break;
  617. case 8: /* backspace */
  618. console_back ();
  619. break;
  620. default: /* draw the char */
  621. video_putchar (console_col * VIDEO_FONT_WIDTH,
  622. console_row * VIDEO_FONT_HEIGHT,
  623. c);
  624. console_col++;
  625. /* check for newline */
  626. if (console_col >= CONSOLE_COLS) {
  627. console_newline ();
  628. nl = 0;
  629. }
  630. }
  631. CURSOR_SET;
  632. }
  633. /*****************************************************************************/
  634. void video_puts (const char *s)
  635. {
  636. int count = strlen (s);
  637. while (count--)
  638. video_putc (*s++);
  639. }
  640. /*****************************************************************************/
  641. /*
  642. * Do not enforce drivers (or board code) to provide empty
  643. * video_set_lut() if they do not support 8 bpp format.
  644. * Implement weak default function instead.
  645. */
  646. void __video_set_lut (unsigned int index, unsigned char r,
  647. unsigned char g, unsigned char b)
  648. {
  649. }
  650. void video_set_lut (unsigned int, unsigned char, unsigned char, unsigned char)
  651. __attribute__((weak, alias("__video_set_lut")));
  652. #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
  653. #define FILL_8BIT_332RGB(r,g,b) { \
  654. *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6); \
  655. fb ++; \
  656. }
  657. #define FILL_15BIT_555RGB(r,g,b) { \
  658. *(unsigned short *)fb = SWAP16((unsigned short)(((r>>3)<<10) | ((g>>3)<<5) | (b>>3))); \
  659. fb += 2; \
  660. }
  661. #define FILL_16BIT_565RGB(r,g,b) { \
  662. *(unsigned short *)fb = SWAP16((unsigned short)((((r)>>3)<<11) | (((g)>>2)<<5) | ((b)>>3))); \
  663. fb += 2; \
  664. }
  665. #define FILL_32BIT_X888RGB(r,g,b) { \
  666. *(unsigned long *)fb = SWAP32((unsigned long)(((r<<16) | (g<<8) | b))); \
  667. fb += 4; \
  668. }
  669. #ifdef VIDEO_FB_LITTLE_ENDIAN
  670. #define FILL_24BIT_888RGB(r,g,b) { \
  671. fb[0] = b; \
  672. fb[1] = g; \
  673. fb[2] = r; \
  674. fb += 3; \
  675. }
  676. #else
  677. #define FILL_24BIT_888RGB(r,g,b) { \
  678. fb[0] = r; \
  679. fb[1] = g; \
  680. fb[2] = b; \
  681. fb += 3; \
  682. }
  683. #endif
  684. #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
  685. static void inline fill_555rgb_pswap(uchar *fb, int x,
  686. u8 r, u8 g, u8 b)
  687. {
  688. ushort *dst = (ushort *)fb;
  689. ushort color = (ushort)(((r >> 3) << 10) |
  690. ((g >> 3) << 5) |
  691. (b >> 3));
  692. if (x & 1)
  693. *(--dst) = color;
  694. else
  695. *(++dst) = color;
  696. }
  697. #endif
  698. /*
  699. * RLE8 bitmap support
  700. */
  701. #ifdef CONFIG_VIDEO_BMP_RLE8
  702. /* Pre-calculated color table entry */
  703. struct palette {
  704. union {
  705. unsigned short w; /* word */
  706. unsigned int dw; /* double word */
  707. } ce; /* color entry */
  708. };
  709. /*
  710. * Helper to draw encoded/unencoded run.
  711. */
  712. static void draw_bitmap (uchar **fb, uchar *bm, struct palette *p,
  713. int cnt, int enc)
  714. {
  715. ulong addr = (ulong)*fb;
  716. int *off;
  717. int enc_off = 1;
  718. int i;
  719. /*
  720. * Setup offset of the color index in the bitmap.
  721. * Color index of encoded run is at offset 1.
  722. */
  723. off = enc ? &enc_off : &i;
  724. switch (VIDEO_DATA_FORMAT) {
  725. case GDF__8BIT_INDEX:
  726. for (i = 0; i < cnt; i++)
  727. *(unsigned char *)addr++ = bm[*off];
  728. break;
  729. case GDF_15BIT_555RGB:
  730. case GDF_16BIT_565RGB:
  731. /* differences handled while pre-calculating palette */
  732. for (i = 0; i < cnt; i++) {
  733. *(unsigned short *)addr = p[bm[*off]].ce.w;
  734. addr += 2;
  735. }
  736. break;
  737. case GDF_32BIT_X888RGB:
  738. for (i = 0; i < cnt; i++) {
  739. *(unsigned long *)addr = p[bm[*off]].ce.dw;
  740. addr += 4;
  741. }
  742. break;
  743. }
  744. *fb = (uchar *)addr; /* return modified address */
  745. }
  746. static int display_rle8_bitmap (bmp_image_t *img, int xoff, int yoff,
  747. int width, int height)
  748. {
  749. unsigned char *bm;
  750. unsigned char *fbp;
  751. unsigned int cnt, runlen;
  752. int decode = 1;
  753. int x, y, bpp, i, ncolors;
  754. struct palette p[256];
  755. bmp_color_table_entry_t cte;
  756. int green_shift, red_off;
  757. x = 0;
  758. y = __le32_to_cpu(img->header.height) - 1;
  759. ncolors = __le32_to_cpu(img->header.colors_used);
  760. bpp = VIDEO_PIXEL_SIZE;
  761. fbp = (unsigned char *)((unsigned int)video_fb_address +
  762. (((y + yoff) * VIDEO_COLS) + xoff) * bpp);
  763. bm = (uchar *)img + __le32_to_cpu(img->header.data_offset);
  764. /* pre-calculate and setup palette */
  765. switch (VIDEO_DATA_FORMAT) {
  766. case GDF__8BIT_INDEX:
  767. for (i = 0; i < ncolors; i++) {
  768. cte = img->color_table[i];
  769. video_set_lut (i, cte.red, cte.green, cte.blue);
  770. }
  771. break;
  772. case GDF_15BIT_555RGB:
  773. case GDF_16BIT_565RGB:
  774. if (VIDEO_DATA_FORMAT == GDF_15BIT_555RGB) {
  775. green_shift = 3;
  776. red_off = 10;
  777. } else {
  778. green_shift = 2;
  779. red_off = 11;
  780. }
  781. for (i = 0; i < ncolors; i++) {
  782. cte = img->color_table[i];
  783. p[i].ce.w = SWAP16((unsigned short)
  784. (((cte.red >> 3) << red_off) |
  785. ((cte.green >> green_shift) << 5) |
  786. cte.blue >> 3));
  787. }
  788. break;
  789. case GDF_32BIT_X888RGB:
  790. for (i = 0; i < ncolors; i++) {
  791. cte = img->color_table[i];
  792. p[i].ce.dw = SWAP32((cte.red << 16) | (cte.green << 8) |
  793. cte.blue);
  794. }
  795. break;
  796. default:
  797. printf("RLE Bitmap unsupported in video mode 0x%x\n",
  798. VIDEO_DATA_FORMAT);
  799. return -1;
  800. }
  801. while (decode) {
  802. switch (bm[0]) {
  803. case 0:
  804. switch (bm[1]) {
  805. case 0:
  806. /* scan line end marker */
  807. bm += 2;
  808. x = 0;
  809. y--;
  810. fbp = (unsigned char *)
  811. ((unsigned int)video_fb_address +
  812. (((y + yoff) * VIDEO_COLS) +
  813. xoff) * bpp);
  814. continue;
  815. case 1:
  816. /* end of bitmap data marker */
  817. decode = 0;
  818. break;
  819. case 2:
  820. /* run offset marker */
  821. x += bm[2];
  822. y -= bm[3];
  823. fbp = (unsigned char *)
  824. ((unsigned int)video_fb_address +
  825. (((y + yoff) * VIDEO_COLS) +
  826. x + xoff) * bpp);
  827. bm += 4;
  828. break;
  829. default:
  830. /* unencoded run */
  831. cnt = bm[1];
  832. runlen = cnt;
  833. bm += 2;
  834. if (y < height) {
  835. if (x >= width) {
  836. x += runlen;
  837. goto next_run;
  838. }
  839. if (x + runlen > width)
  840. cnt = width - x;
  841. draw_bitmap (&fbp, bm, p, cnt, 0);
  842. x += runlen;
  843. }
  844. next_run:
  845. bm += runlen;
  846. if (runlen & 1)
  847. bm++; /* 0 padding if length is odd */
  848. }
  849. break;
  850. default:
  851. /* encoded run */
  852. if (y < height) { /* only draw into visible area */
  853. cnt = bm[0];
  854. runlen = cnt;
  855. if (x >= width) {
  856. x += runlen;
  857. bm += 2;
  858. continue;
  859. }
  860. if (x + runlen > width)
  861. cnt = width - x;
  862. draw_bitmap (&fbp, bm, p, cnt, 1);
  863. x += runlen;
  864. }
  865. bm += 2;
  866. break;
  867. }
  868. }
  869. return 0;
  870. }
  871. #endif
  872. /*
  873. * Display the BMP file located at address bmp_image.
  874. */
  875. int video_display_bitmap (ulong bmp_image, int x, int y)
  876. {
  877. ushort xcount, ycount;
  878. uchar *fb;
  879. bmp_image_t *bmp = (bmp_image_t *) bmp_image;
  880. uchar *bmap;
  881. ushort padded_line;
  882. unsigned long width, height, bpp;
  883. unsigned colors;
  884. unsigned long compression;
  885. bmp_color_table_entry_t cte;
  886. #ifdef CONFIG_VIDEO_BMP_GZIP
  887. unsigned char *dst = NULL;
  888. ulong len;
  889. #endif
  890. WATCHDOG_RESET ();
  891. if (!((bmp->header.signature[0] == 'B') &&
  892. (bmp->header.signature[1] == 'M'))) {
  893. #ifdef CONFIG_VIDEO_BMP_GZIP
  894. /*
  895. * Could be a gzipped bmp image, try to decrompress...
  896. */
  897. len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
  898. dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
  899. if (dst == NULL) {
  900. printf("Error: malloc in gunzip failed!\n");
  901. return(1);
  902. }
  903. if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)bmp_image, &len) != 0) {
  904. printf ("Error: no valid bmp or bmp.gz image at %lx\n", bmp_image);
  905. free(dst);
  906. return 1;
  907. }
  908. if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) {
  909. printf("Image could be truncated (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
  910. }
  911. /*
  912. * Set addr to decompressed image
  913. */
  914. bmp = (bmp_image_t *)dst;
  915. if (!((bmp->header.signature[0] == 'B') &&
  916. (bmp->header.signature[1] == 'M'))) {
  917. printf ("Error: no valid bmp.gz image at %lx\n", bmp_image);
  918. free(dst);
  919. return 1;
  920. }
  921. #else
  922. printf ("Error: no valid bmp image at %lx\n", bmp_image);
  923. return 1;
  924. #endif /* CONFIG_VIDEO_BMP_GZIP */
  925. }
  926. width = le32_to_cpu (bmp->header.width);
  927. height = le32_to_cpu (bmp->header.height);
  928. bpp = le16_to_cpu (bmp->header.bit_count);
  929. colors = le32_to_cpu (bmp->header.colors_used);
  930. compression = le32_to_cpu (bmp->header.compression);
  931. debug ("Display-bmp: %d x %d with %d colors\n",
  932. width, height, colors);
  933. if (compression != BMP_BI_RGB
  934. #ifdef CONFIG_VIDEO_BMP_RLE8
  935. && compression != BMP_BI_RLE8
  936. #endif
  937. ) {
  938. printf ("Error: compression type %ld not supported\n",
  939. compression);
  940. #ifdef CONFIG_VIDEO_BMP_GZIP
  941. if (dst)
  942. free(dst);
  943. #endif
  944. return 1;
  945. }
  946. padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3;
  947. #ifdef CONFIG_SPLASH_SCREEN_ALIGN
  948. if (x == BMP_ALIGN_CENTER)
  949. x = max(0, (VIDEO_VISIBLE_COLS - width) / 2);
  950. else if (x < 0)
  951. x = max(0, VIDEO_VISIBLE_COLS - width + x + 1);
  952. if (y == BMP_ALIGN_CENTER)
  953. y = max(0, (VIDEO_VISIBLE_ROWS - height) / 2);
  954. else if (y < 0)
  955. y = max(0, VIDEO_VISIBLE_ROWS - height + y + 1);
  956. #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
  957. if ((x + width) > VIDEO_VISIBLE_COLS)
  958. width = VIDEO_VISIBLE_COLS - x;
  959. if ((y + height) > VIDEO_VISIBLE_ROWS)
  960. height = VIDEO_VISIBLE_ROWS - y;
  961. bmap = (uchar *) bmp + le32_to_cpu (bmp->header.data_offset);
  962. fb = (uchar *) (video_fb_address +
  963. ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
  964. x * VIDEO_PIXEL_SIZE);
  965. #ifdef CONFIG_VIDEO_BMP_RLE8
  966. if (compression == BMP_BI_RLE8) {
  967. return display_rle8_bitmap(bmp,
  968. x, y, width, height);
  969. }
  970. #endif
  971. /* We handle only 4, 8, or 24 bpp bitmaps */
  972. switch (le16_to_cpu (bmp->header.bit_count)) {
  973. case 4:
  974. padded_line -= width / 2;
  975. ycount = height;
  976. switch (VIDEO_DATA_FORMAT) {
  977. case GDF_32BIT_X888RGB:
  978. while (ycount--) {
  979. WATCHDOG_RESET ();
  980. /*
  981. * Don't assume that 'width' is an
  982. * even number
  983. */
  984. for (xcount = 0; xcount < width; xcount++) {
  985. uchar idx;
  986. if (xcount & 1) {
  987. idx = *bmap & 0xF;
  988. bmap++;
  989. } else
  990. idx = *bmap >> 4;
  991. cte = bmp->color_table[idx];
  992. FILL_32BIT_X888RGB(cte.red, cte.green,
  993. cte.blue);
  994. }
  995. bmap += padded_line;
  996. fb -= (VIDEO_VISIBLE_COLS + width) *
  997. VIDEO_PIXEL_SIZE;
  998. }
  999. break;
  1000. default:
  1001. puts("4bpp bitmap unsupported with current "
  1002. "video mode\n");
  1003. break;
  1004. }
  1005. break;
  1006. case 8:
  1007. padded_line -= width;
  1008. if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
  1009. /* Copy colormap */
  1010. for (xcount = 0; xcount < colors; ++xcount) {
  1011. cte = bmp->color_table[xcount];
  1012. video_set_lut (xcount, cte.red, cte.green, cte.blue);
  1013. }
  1014. }
  1015. ycount = height;
  1016. switch (VIDEO_DATA_FORMAT) {
  1017. case GDF__8BIT_INDEX:
  1018. while (ycount--) {
  1019. WATCHDOG_RESET ();
  1020. xcount = width;
  1021. while (xcount--) {
  1022. *fb++ = *bmap++;
  1023. }
  1024. bmap += padded_line;
  1025. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1026. }
  1027. break;
  1028. case GDF__8BIT_332RGB:
  1029. while (ycount--) {
  1030. WATCHDOG_RESET ();
  1031. xcount = width;
  1032. while (xcount--) {
  1033. cte = bmp->color_table[*bmap++];
  1034. FILL_8BIT_332RGB (cte.red, cte.green, cte.blue);
  1035. }
  1036. bmap += padded_line;
  1037. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1038. }
  1039. break;
  1040. case GDF_15BIT_555RGB:
  1041. while (ycount--) {
  1042. #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
  1043. int xpos = x;
  1044. #endif
  1045. WATCHDOG_RESET ();
  1046. xcount = width;
  1047. while (xcount--) {
  1048. cte = bmp->color_table[*bmap++];
  1049. #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
  1050. fill_555rgb_pswap (fb, xpos++, cte.red,
  1051. cte.green, cte.blue);
  1052. fb += 2;
  1053. #else
  1054. FILL_15BIT_555RGB (cte.red, cte.green, cte.blue);
  1055. #endif
  1056. }
  1057. bmap += padded_line;
  1058. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1059. }
  1060. break;
  1061. case GDF_16BIT_565RGB:
  1062. while (ycount--) {
  1063. WATCHDOG_RESET ();
  1064. xcount = width;
  1065. while (xcount--) {
  1066. cte = bmp->color_table[*bmap++];
  1067. FILL_16BIT_565RGB (cte.red, cte.green, cte.blue);
  1068. }
  1069. bmap += padded_line;
  1070. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1071. }
  1072. break;
  1073. case GDF_32BIT_X888RGB:
  1074. while (ycount--) {
  1075. WATCHDOG_RESET ();
  1076. xcount = width;
  1077. while (xcount--) {
  1078. cte = bmp->color_table[*bmap++];
  1079. FILL_32BIT_X888RGB (cte.red, cte.green, cte.blue);
  1080. }
  1081. bmap += padded_line;
  1082. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1083. }
  1084. break;
  1085. case GDF_24BIT_888RGB:
  1086. while (ycount--) {
  1087. WATCHDOG_RESET ();
  1088. xcount = width;
  1089. while (xcount--) {
  1090. cte = bmp->color_table[*bmap++];
  1091. FILL_24BIT_888RGB (cte.red, cte.green, cte.blue);
  1092. }
  1093. bmap += padded_line;
  1094. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1095. }
  1096. break;
  1097. }
  1098. break;
  1099. case 24:
  1100. padded_line -= 3 * width;
  1101. ycount = height;
  1102. switch (VIDEO_DATA_FORMAT) {
  1103. case GDF__8BIT_332RGB:
  1104. while (ycount--) {
  1105. WATCHDOG_RESET ();
  1106. xcount = width;
  1107. while (xcount--) {
  1108. FILL_8BIT_332RGB (bmap[2], bmap[1], bmap[0]);
  1109. bmap += 3;
  1110. }
  1111. bmap += padded_line;
  1112. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1113. }
  1114. break;
  1115. case GDF_15BIT_555RGB:
  1116. while (ycount--) {
  1117. #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
  1118. int xpos = x;
  1119. #endif
  1120. WATCHDOG_RESET ();
  1121. xcount = width;
  1122. while (xcount--) {
  1123. #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
  1124. fill_555rgb_pswap (fb, xpos++, bmap[2],
  1125. bmap[1], bmap[0]);
  1126. fb += 2;
  1127. #else
  1128. FILL_15BIT_555RGB (bmap[2], bmap[1], bmap[0]);
  1129. #endif
  1130. bmap += 3;
  1131. }
  1132. bmap += padded_line;
  1133. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1134. }
  1135. break;
  1136. case GDF_16BIT_565RGB:
  1137. while (ycount--) {
  1138. WATCHDOG_RESET ();
  1139. xcount = width;
  1140. while (xcount--) {
  1141. FILL_16BIT_565RGB (bmap[2], bmap[1], bmap[0]);
  1142. bmap += 3;
  1143. }
  1144. bmap += padded_line;
  1145. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1146. }
  1147. break;
  1148. case GDF_32BIT_X888RGB:
  1149. while (ycount--) {
  1150. WATCHDOG_RESET ();
  1151. xcount = width;
  1152. while (xcount--) {
  1153. FILL_32BIT_X888RGB (bmap[2], bmap[1], bmap[0]);
  1154. bmap += 3;
  1155. }
  1156. bmap += padded_line;
  1157. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1158. }
  1159. break;
  1160. case GDF_24BIT_888RGB:
  1161. while (ycount--) {
  1162. WATCHDOG_RESET ();
  1163. xcount = width;
  1164. while (xcount--) {
  1165. FILL_24BIT_888RGB (bmap[2], bmap[1], bmap[0]);
  1166. bmap += 3;
  1167. }
  1168. bmap += padded_line;
  1169. fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE;
  1170. }
  1171. break;
  1172. default:
  1173. printf ("Error: 24 bits/pixel bitmap incompatible with current video mode\n");
  1174. break;
  1175. }
  1176. break;
  1177. default:
  1178. printf ("Error: %d bit/pixel bitmaps not supported by U-Boot\n",
  1179. le16_to_cpu (bmp->header.bit_count));
  1180. break;
  1181. }
  1182. #ifdef CONFIG_VIDEO_BMP_GZIP
  1183. if (dst) {
  1184. free(dst);
  1185. }
  1186. #endif
  1187. return (0);
  1188. }
  1189. #endif
  1190. /*****************************************************************************/
  1191. #ifdef CONFIG_VIDEO_LOGO
  1192. void logo_plot (void *screen, int width, int x, int y)
  1193. {
  1194. int xcount, i;
  1195. int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
  1196. int ycount = video_logo_height;
  1197. unsigned char r, g, b, *logo_red, *logo_blue, *logo_green;
  1198. unsigned char *source;
  1199. unsigned char *dest = (unsigned char *)screen +
  1200. ((y * width * VIDEO_PIXEL_SIZE) +
  1201. x * VIDEO_PIXEL_SIZE);
  1202. #ifdef CONFIG_VIDEO_BMP_LOGO
  1203. source = bmp_logo_bitmap;
  1204. /* Allocate temporary space for computing colormap */
  1205. logo_red = malloc (BMP_LOGO_COLORS);
  1206. logo_green = malloc (BMP_LOGO_COLORS);
  1207. logo_blue = malloc (BMP_LOGO_COLORS);
  1208. /* Compute color map */
  1209. for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
  1210. logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4;
  1211. logo_green[i] = (bmp_logo_palette[i] & 0x00f0);
  1212. logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4;
  1213. }
  1214. #else
  1215. source = linux_logo;
  1216. logo_red = linux_logo_red;
  1217. logo_green = linux_logo_green;
  1218. logo_blue = linux_logo_blue;
  1219. #endif
  1220. if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
  1221. for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
  1222. video_set_lut (i + VIDEO_LOGO_LUT_OFFSET,
  1223. logo_red[i], logo_green[i], logo_blue[i]);
  1224. }
  1225. }
  1226. while (ycount--) {
  1227. #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
  1228. int xpos = x;
  1229. #endif
  1230. xcount = VIDEO_LOGO_WIDTH;
  1231. while (xcount--) {
  1232. r = logo_red[*source - VIDEO_LOGO_LUT_OFFSET];
  1233. g = logo_green[*source - VIDEO_LOGO_LUT_OFFSET];
  1234. b = logo_blue[*source - VIDEO_LOGO_LUT_OFFSET];
  1235. switch (VIDEO_DATA_FORMAT) {
  1236. case GDF__8BIT_INDEX:
  1237. *dest = *source;
  1238. break;
  1239. case GDF__8BIT_332RGB:
  1240. *dest = ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
  1241. break;
  1242. case GDF_15BIT_555RGB:
  1243. #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
  1244. fill_555rgb_pswap (dest, xpos++, r, g, b);
  1245. #else
  1246. *(unsigned short *) dest =
  1247. SWAP16 ((unsigned short) (((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3)));
  1248. #endif
  1249. break;
  1250. case GDF_16BIT_565RGB:
  1251. *(unsigned short *) dest =
  1252. SWAP16 ((unsigned short) (((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)));
  1253. break;
  1254. case GDF_32BIT_X888RGB:
  1255. *(unsigned long *) dest =
  1256. SWAP32 ((unsigned long) ((r << 16) | (g << 8) | b));
  1257. break;
  1258. case GDF_24BIT_888RGB:
  1259. #ifdef VIDEO_FB_LITTLE_ENDIAN
  1260. dest[0] = b;
  1261. dest[1] = g;
  1262. dest[2] = r;
  1263. #else
  1264. dest[0] = r;
  1265. dest[1] = g;
  1266. dest[2] = b;
  1267. #endif
  1268. break;
  1269. }
  1270. source++;
  1271. dest += VIDEO_PIXEL_SIZE;
  1272. }
  1273. dest += skip;
  1274. }
  1275. #ifdef CONFIG_VIDEO_BMP_LOGO
  1276. free (logo_red);
  1277. free (logo_green);
  1278. free (logo_blue);
  1279. #endif
  1280. }
  1281. /*****************************************************************************/
  1282. static void *video_logo (void)
  1283. {
  1284. char info[128];
  1285. extern char version_string;
  1286. int space, len, y_off = 0;
  1287. #ifdef CONFIG_SPLASH_SCREEN
  1288. char *s;
  1289. ulong addr;
  1290. if ((s = getenv ("splashimage")) != NULL) {
  1291. int x = 0, y = 0;
  1292. addr = simple_strtoul (s, NULL, 16);
  1293. #ifdef CONFIG_SPLASH_SCREEN_ALIGN
  1294. if ((s = getenv ("splashpos")) != NULL) {
  1295. if (s[0] == 'm')
  1296. x = BMP_ALIGN_CENTER;
  1297. else
  1298. x = simple_strtol (s, NULL, 0);
  1299. if ((s = strchr (s + 1, ',')) != NULL) {
  1300. if (s[1] == 'm')
  1301. y = BMP_ALIGN_CENTER;
  1302. else
  1303. y = simple_strtol (s + 1, NULL, 0);
  1304. }
  1305. }
  1306. #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
  1307. if (video_display_bitmap (addr, x, y) == 0) {
  1308. video_logo_height = 0;
  1309. return ((void *) (video_fb_address));
  1310. }
  1311. }
  1312. #endif /* CONFIG_SPLASH_SCREEN */
  1313. logo_plot (video_fb_address, VIDEO_COLS, 0, 0);
  1314. sprintf (info, " %s", &version_string);
  1315. space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
  1316. len = strlen(info);
  1317. if (len > space) {
  1318. video_drawchars (VIDEO_INFO_X, VIDEO_INFO_Y,
  1319. (uchar *)info, space);
  1320. video_drawchars (VIDEO_INFO_X + VIDEO_FONT_WIDTH,
  1321. VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,
  1322. (uchar *)info + space, len - space);
  1323. y_off = 1;
  1324. } else
  1325. video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *)info);
  1326. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  1327. {
  1328. int i, n = ((video_logo_height - VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT);
  1329. for (i = 1; i < n; i++) {
  1330. video_get_info_str (i, info);
  1331. if (!*info)
  1332. continue;
  1333. len = strlen(info);
  1334. if (len > space) {
  1335. video_drawchars (VIDEO_INFO_X,
  1336. VIDEO_INFO_Y +
  1337. (i + y_off) * VIDEO_FONT_HEIGHT,
  1338. (uchar *)info, space);
  1339. y_off++;
  1340. video_drawchars (VIDEO_INFO_X + VIDEO_FONT_WIDTH,
  1341. VIDEO_INFO_Y +
  1342. (i + y_off) * VIDEO_FONT_HEIGHT,
  1343. (uchar *)info + space,
  1344. len - space);
  1345. } else {
  1346. video_drawstring (VIDEO_INFO_X,
  1347. VIDEO_INFO_Y +
  1348. (i + y_off) * VIDEO_FONT_HEIGHT,
  1349. (uchar *)info);
  1350. }
  1351. }
  1352. }
  1353. #endif
  1354. return (video_fb_address + video_logo_height * VIDEO_LINE_LEN);
  1355. }
  1356. #endif
  1357. /*****************************************************************************/
  1358. static int video_init (void)
  1359. {
  1360. unsigned char color8;
  1361. if ((pGD = video_hw_init ()) == NULL)
  1362. return -1;
  1363. video_fb_address = (void *) VIDEO_FB_ADRS;
  1364. #ifdef CONFIG_VIDEO_HW_CURSOR
  1365. video_init_hw_cursor (VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
  1366. #endif
  1367. /* Init drawing pats */
  1368. switch (VIDEO_DATA_FORMAT) {
  1369. case GDF__8BIT_INDEX:
  1370. video_set_lut (0x01, CONSOLE_FG_COL, CONSOLE_FG_COL, CONSOLE_FG_COL);
  1371. video_set_lut (0x00, CONSOLE_BG_COL, CONSOLE_BG_COL, CONSOLE_BG_COL);
  1372. fgx = 0x01010101;
  1373. bgx = 0x00000000;
  1374. break;
  1375. case GDF__8BIT_332RGB:
  1376. color8 = ((CONSOLE_FG_COL & 0xe0) |
  1377. ((CONSOLE_FG_COL >> 3) & 0x1c) | CONSOLE_FG_COL >> 6);
  1378. fgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | color8;
  1379. color8 = ((CONSOLE_BG_COL & 0xe0) |
  1380. ((CONSOLE_BG_COL >> 3) & 0x1c) | CONSOLE_BG_COL >> 6);
  1381. bgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | color8;
  1382. break;
  1383. case GDF_15BIT_555RGB:
  1384. fgx = (((CONSOLE_FG_COL >> 3) << 26) |
  1385. ((CONSOLE_FG_COL >> 3) << 21) | ((CONSOLE_FG_COL >> 3) << 16) |
  1386. ((CONSOLE_FG_COL >> 3) << 10) | ((CONSOLE_FG_COL >> 3) << 5) |
  1387. (CONSOLE_FG_COL >> 3));
  1388. bgx = (((CONSOLE_BG_COL >> 3) << 26) |
  1389. ((CONSOLE_BG_COL >> 3) << 21) | ((CONSOLE_BG_COL >> 3) << 16) |
  1390. ((CONSOLE_BG_COL >> 3) << 10) | ((CONSOLE_BG_COL >> 3) << 5) |
  1391. (CONSOLE_BG_COL >> 3));
  1392. break;
  1393. case GDF_16BIT_565RGB:
  1394. fgx = (((CONSOLE_FG_COL >> 3) << 27) |
  1395. ((CONSOLE_FG_COL >> 2) << 21) | ((CONSOLE_FG_COL >> 3) << 16) |
  1396. ((CONSOLE_FG_COL >> 3) << 11) | ((CONSOLE_FG_COL >> 2) << 5) |
  1397. (CONSOLE_FG_COL >> 3));
  1398. bgx = (((CONSOLE_BG_COL >> 3) << 27) |
  1399. ((CONSOLE_BG_COL >> 2) << 21) | ((CONSOLE_BG_COL >> 3) << 16) |
  1400. ((CONSOLE_BG_COL >> 3) << 11) | ((CONSOLE_BG_COL >> 2) << 5) |
  1401. (CONSOLE_BG_COL >> 3));
  1402. break;
  1403. case GDF_32BIT_X888RGB:
  1404. fgx = (CONSOLE_FG_COL << 16) | (CONSOLE_FG_COL << 8) | CONSOLE_FG_COL;
  1405. bgx = (CONSOLE_BG_COL << 16) | (CONSOLE_BG_COL << 8) | CONSOLE_BG_COL;
  1406. break;
  1407. case GDF_24BIT_888RGB:
  1408. fgx = (CONSOLE_FG_COL << 24) | (CONSOLE_FG_COL << 16) |
  1409. (CONSOLE_FG_COL << 8) | CONSOLE_FG_COL;
  1410. bgx = (CONSOLE_BG_COL << 24) | (CONSOLE_BG_COL << 16) |
  1411. (CONSOLE_BG_COL << 8) | CONSOLE_BG_COL;
  1412. break;
  1413. }
  1414. eorx = fgx ^ bgx;
  1415. #ifdef CONFIG_VIDEO_LOGO
  1416. /* Plot the logo and get start point of console */
  1417. PRINTD ("Video: Drawing the logo ...\n");
  1418. video_console_address = video_logo ();
  1419. #else
  1420. video_console_address = video_fb_address;
  1421. #endif
  1422. /* Initialize the console */
  1423. console_col = 0;
  1424. console_row = 0;
  1425. return 0;
  1426. }
  1427. /*****************************************************************************/
  1428. /*
  1429. * Implement a weak default function for boards that optionally
  1430. * need to skip the video initialization.
  1431. */
  1432. int __board_video_skip(void)
  1433. {
  1434. /* As default, don't skip test */
  1435. return 0;
  1436. }
  1437. int board_video_skip(void) __attribute__((weak, alias("__board_video_skip")));
  1438. int drv_video_init (void)
  1439. {
  1440. int skip_dev_init;
  1441. struct stdio_dev console_dev;
  1442. /* Check if video initialization should be skipped */
  1443. if (board_video_skip())
  1444. return 0;
  1445. /* Init video chip - returns with framebuffer cleared */
  1446. skip_dev_init = (video_init () == -1);
  1447. #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
  1448. PRINTD ("KBD: Keyboard init ...\n");
  1449. skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
  1450. #endif
  1451. if (skip_dev_init)
  1452. return 0;
  1453. /* Init vga device */
  1454. memset (&console_dev, 0, sizeof (console_dev));
  1455. strcpy (console_dev.name, "vga");
  1456. console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
  1457. console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
  1458. console_dev.putc = video_putc; /* 'putc' function */
  1459. console_dev.puts = video_puts; /* 'puts' function */
  1460. console_dev.tstc = NULL; /* 'tstc' function */
  1461. console_dev.getc = NULL; /* 'getc' function */
  1462. #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
  1463. /* Also init console device */
  1464. console_dev.flags |= DEV_FLAGS_INPUT;
  1465. console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
  1466. console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
  1467. #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
  1468. if (stdio_register (&console_dev) != 0)
  1469. return 0;
  1470. /* Return success */
  1471. return 1;
  1472. }