cfb_console.c 44 KB

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