cfb_console.c 44 KB

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