cfb_console.c 44 KB

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