cfb_console.c 44 KB

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