cfb_console.c 44 KB

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