cfb_console.c 44 KB

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