2 * (C) Copyright 2002 ELTEC Elektronik AG
3 * Frank Gottschling <fgottschling@eltec.de>
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
27 * Color Framebuffer Console driver for 8/15/16/24/32 bits per pixel.
29 * At the moment only the 8x16 font is tested and the font fore- and
30 * background color is limited to black/white/gray colors. The Linux
31 * logo can be placed in the upper left corner and additional board
32 * information strings (that normally goes to serial port) can be drawn.
34 * The console driver can use the standard PC keyboard interface (i8042)
35 * for character input. Character output goes to a memory mapped video
36 * framebuffer with little or big-endian organisation.
37 * With environment setting 'console=serial' the console i/o can be
38 * forced to serial port.
40 * The driver uses graphic specific defines/parameters/functions:
42 * (for SMI LynxE graphic chip)
44 * CONFIG_VIDEO_SMI_LYNXEM - use graphic driver for SMI 710,712,810
45 * VIDEO_FB_LITTLE_ENDIAN - framebuffer organisation default: big endian
46 * VIDEO_HW_RECTFILL - graphic driver supports hardware rectangle fill
47 * VIDEO_HW_BITBLT - graphic driver supports hardware bit blt
49 * Console Parameters are set by graphic drivers global struct:
51 * VIDEO_VISIBLE_COLS - x resolution
52 * VIDEO_VISIBLE_ROWS - y resolution
53 * VIDEO_PIXEL_SIZE - storage size in byte per pixel
54 * VIDEO_DATA_FORMAT - graphical data format GDF
55 * VIDEO_FB_ADRS - start of video memory
57 * CONFIG_I8042_KBD - AT Keyboard driver for i8042
58 * VIDEO_KBD_INIT_FCT - init function for keyboard
59 * VIDEO_TSTC_FCT - keyboard_tstc function
60 * VIDEO_GETC_FCT - keyboard_getc function
62 * CONFIG_CONSOLE_CURSOR - on/off drawing cursor is done with
63 * delay loop in VIDEO_TSTC_FCT (i8042)
65 * CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
66 * CONFIG_CONSOLE_TIME - display time/date in upper right
67 * corner, needs CONFIG_CMD_DATE and
68 * CONFIG_CONSOLE_CURSOR
69 * CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner
70 * CONFIG_VIDEO_BMP_LOGO - use bmp_logo instead of linux_logo
71 * CONFIG_CONSOLE_EXTRA_INFO - display additional board information
72 * strings that normaly goes to serial
73 * port. This define requires a board
75 * video_drawstring (VIDEO_INFO_X,
76 * VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT,
78 * that fills a info buffer at i=row.
79 * s.a: board/eltec/bab7xx.
80 * CONFIG_VGA_AS_SINGLE_DEVICE - If set the framebuffer device will be
81 * initialized as an output only device.
82 * The Keyboard driver will not be
83 * set-up. This may be used, if you have
84 * no or more than one Keyboard devices
85 * (USB Keyboard, AT Keyboard).
87 * CONFIG_VIDEO_SW_CURSOR: - Draws a cursor after the last
88 * character. No blinking is provided.
89 * Uses the macros CURSOR_SET and
92 * CONFIG_VIDEO_HW_CURSOR: - Uses the hardware cursor capability
93 * of the graphic chip. Uses the macro
94 * CURSOR_SET. ATTENTION: If booting an
95 * OS, the display driver must disable
96 * the hardware register of the graphic
97 * chip. Otherwise a blinking field is
104 #include <linux/compiler.h>
107 * Console device defines with SMI graphic
108 * Any other graphic must change this section
111 #ifdef CONFIG_VIDEO_SMI_LYNXEM
113 #define VIDEO_FB_LITTLE_ENDIAN
114 #define VIDEO_HW_RECTFILL
115 #define VIDEO_HW_BITBLT
119 * Defines for the CT69000 driver
121 #ifdef CONFIG_VIDEO_CT69000
123 #define VIDEO_FB_LITTLE_ENDIAN
124 #define VIDEO_HW_RECTFILL
125 #define VIDEO_HW_BITBLT
129 * Defines for the SED13806 driver
131 #ifdef CONFIG_VIDEO_SED13806
133 #ifndef CONFIG_TOTAL5200
134 #define VIDEO_FB_LITTLE_ENDIAN
136 #define VIDEO_HW_RECTFILL
137 #define VIDEO_HW_BITBLT
141 * Defines for the SED13806 driver
143 #ifdef CONFIG_VIDEO_SM501
146 #define VIDEO_FB_LITTLE_ENDIAN
151 * Defines for the MB862xx driver
153 #ifdef CONFIG_VIDEO_MB862xx
155 #ifdef CONFIG_VIDEO_CORALP
156 #define VIDEO_FB_LITTLE_ENDIAN
158 #ifdef CONFIG_VIDEO_MB862xx_ACCEL
159 #define VIDEO_HW_RECTFILL
160 #define VIDEO_HW_BITBLT
165 * Defines for the i.MX31 driver (mx3fb.c)
167 #ifdef CONFIG_VIDEO_MX3
168 #define VIDEO_FB_16BPP_WORD_SWAP
172 * Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc.
174 #include <video_fb.h>
179 #define VIDEO_VISIBLE_COLS (pGD->winSizeX)
180 #define VIDEO_VISIBLE_ROWS (pGD->winSizeY)
181 #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP)
182 #define VIDEO_DATA_FORMAT (pGD->gdfIndex)
183 #define VIDEO_FB_ADRS (pGD->frameAdrs)
186 * Console device defines with i8042 keyboard controller
187 * Any other keyboard controller must change this section
190 #ifdef CONFIG_I8042_KBD
193 #define VIDEO_KBD_INIT_FCT i8042_kbd_init()
194 #define VIDEO_TSTC_FCT i8042_tstc
195 #define VIDEO_GETC_FCT i8042_getc
203 #include <linux/types.h>
204 #include <stdio_dev.h>
205 #include <video_font.h>
207 #if defined(CONFIG_CMD_DATE)
211 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
212 #include <watchdog.h>
213 #include <bmp_layout.h>
215 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
216 #define BMP_ALIGN_CENTER 0x7FFF
223 * CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c)
224 * to let the cursor blink. Uses the macros
225 * CURSOR_OFF and CURSOR_ON.
226 * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No
227 * blinking is provided. Uses the macros CURSOR_SET
229 * CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the
230 * graphic chip. Uses the macro CURSOR_SET.
231 * ATTENTION: If booting an OS, the display driver
232 * must disable the hardware register of the graphic
233 * chip. Otherwise a blinking field is displayed
235 #if !defined(CONFIG_CONSOLE_CURSOR) && \
236 !defined(CONFIG_VIDEO_SW_CURSOR) && \
237 !defined(CONFIG_VIDEO_HW_CURSOR)
238 /* no Cursor defined */
244 #ifdef CONFIG_CONSOLE_CURSOR
246 #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
247 or CONFIG_VIDEO_HW_CURSOR can be defined
249 void console_cursor(int state);
251 #define CURSOR_ON console_cursor(1)
252 #define CURSOR_OFF console_cursor(0)
254 #ifndef CONFIG_I8042_KBD
255 #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
258 #ifdef CONFIG_CONSOLE_TIME
259 #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
261 #endif /* CONFIG_CONSOLE_CURSOR */
263 #ifdef CONFIG_VIDEO_SW_CURSOR
265 #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
266 or CONFIG_VIDEO_HW_CURSOR can be defined
269 #define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
270 console_row * VIDEO_FONT_HEIGHT, ' ')
271 #define CURSOR_SET video_set_cursor()
272 #endif /* CONFIG_VIDEO_SW_CURSOR */
275 #ifdef CONFIG_VIDEO_HW_CURSOR
277 #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
278 or CONFIG_VIDEO_HW_CURSOR can be defined
282 #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \
283 (console_row * VIDEO_FONT_HEIGHT) + video_logo_height)
284 #endif /* CONFIG_VIDEO_HW_CURSOR */
286 #ifdef CONFIG_VIDEO_LOGO
287 #ifdef CONFIG_VIDEO_BMP_LOGO
288 #include <bmp_logo.h>
289 #include <bmp_logo_data.h>
290 #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH
291 #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT
292 #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET
293 #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS
295 #else /* CONFIG_VIDEO_BMP_LOGO */
296 #define LINUX_LOGO_WIDTH 80
297 #define LINUX_LOGO_HEIGHT 80
298 #define LINUX_LOGO_COLORS 214
299 #define LINUX_LOGO_LUT_OFFSET 0x20
301 #include <linux_logo.h>
302 #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH
303 #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT
304 #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET
305 #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS
306 #endif /* CONFIG_VIDEO_BMP_LOGO */
307 #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH)
308 #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2)
309 #else /* CONFIG_VIDEO_LOGO */
310 #define VIDEO_LOGO_WIDTH 0
311 #define VIDEO_LOGO_HEIGHT 0
312 #endif /* CONFIG_VIDEO_LOGO */
314 #define VIDEO_COLS VIDEO_VISIBLE_COLS
315 #define VIDEO_ROWS VIDEO_VISIBLE_ROWS
316 #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
317 #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2)
318 #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE)
319 #define VIDEO_BURST_LEN (VIDEO_COLS/8)
321 #ifdef CONFIG_VIDEO_LOGO
322 #define CONSOLE_ROWS ((VIDEO_ROWS - video_logo_height) / VIDEO_FONT_HEIGHT)
324 #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT)
327 #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH)
328 #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN)
329 #define CONSOLE_ROW_FIRST (video_console_address)
330 #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE)
331 #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
332 #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
333 #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
336 #ifdef VIDEO_FB_LITTLE_ENDIAN
337 #define SWAP16(x) ((((x) & 0x00ff) << 8) | \
340 #define SWAP32(x) ((((x) & 0x000000ff) << 24) | \
341 (((x) & 0x0000ff00) << 8) | \
342 (((x) & 0x00ff0000) >> 8) | \
343 (((x) & 0xff000000) >> 24) \
345 #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | \
346 (((x) & 0x0000ff00) >> 8) | \
347 (((x) & 0x00ff0000) << 8) | \
348 (((x) & 0xff000000) >> 8) \
351 #define SWAP16(x) (x)
352 #define SWAP32(x) (x)
353 #if defined(VIDEO_FB_16BPP_WORD_SWAP)
354 #define SHORTSWAP32(x) (((x) >> 16) | ((x) << 16))
356 #define SHORTSWAP32(x) (x)
360 #ifdef CONFIG_CONSOLE_EXTRA_INFO
362 * setup a board string: type, speed, etc.
364 * line_number: location to place info string beside logo
365 * info: buffer for info string
367 extern void video_get_info_str(int line_number, char *info);
371 static GraphicDevice *pGD; /* Pointer to Graphic array */
373 static void *video_fb_address; /* frame buffer address */
374 static void *video_console_address; /* console buffer start address */
376 static int video_logo_height = VIDEO_LOGO_HEIGHT;
378 static int console_col; /* cursor col */
379 static int console_row; /* cursor row */
381 static u32 eorx, fgx, bgx; /* color pats */
383 static const int video_font_draw_table8[] = {
384 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
385 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
386 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
387 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff
390 static const int video_font_draw_table15[] = {
391 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff
394 static const int video_font_draw_table16[] = {
395 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
398 static const int video_font_draw_table24[16][3] = {
399 {0x00000000, 0x00000000, 0x00000000},
400 {0x00000000, 0x00000000, 0x00ffffff},
401 {0x00000000, 0x0000ffff, 0xff000000},
402 {0x00000000, 0x0000ffff, 0xffffffff},
403 {0x000000ff, 0xffff0000, 0x00000000},
404 {0x000000ff, 0xffff0000, 0x00ffffff},
405 {0x000000ff, 0xffffffff, 0xff000000},
406 {0x000000ff, 0xffffffff, 0xffffffff},
407 {0xffffff00, 0x00000000, 0x00000000},
408 {0xffffff00, 0x00000000, 0x00ffffff},
409 {0xffffff00, 0x0000ffff, 0xff000000},
410 {0xffffff00, 0x0000ffff, 0xffffffff},
411 {0xffffffff, 0xffff0000, 0x00000000},
412 {0xffffffff, 0xffff0000, 0x00ffffff},
413 {0xffffffff, 0xffffffff, 0xff000000},
414 {0xffffffff, 0xffffffff, 0xffffffff}
417 static const int video_font_draw_table32[16][4] = {
418 {0x00000000, 0x00000000, 0x00000000, 0x00000000},
419 {0x00000000, 0x00000000, 0x00000000, 0x00ffffff},
420 {0x00000000, 0x00000000, 0x00ffffff, 0x00000000},
421 {0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff},
422 {0x00000000, 0x00ffffff, 0x00000000, 0x00000000},
423 {0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff},
424 {0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000},
425 {0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff},
426 {0x00ffffff, 0x00000000, 0x00000000, 0x00000000},
427 {0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff},
428 {0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000},
429 {0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff},
430 {0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000},
431 {0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff},
432 {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000},
433 {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff}
437 static void video_drawchars(int xx, int yy, unsigned char *s, int count)
439 u8 *cdat, *dest, *dest0;
442 offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE;
443 dest0 = video_fb_address + offset;
445 switch (VIDEO_DATA_FORMAT) {
446 case GDF__8BIT_INDEX:
447 case GDF__8BIT_332RGB:
450 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
451 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
452 rows--; dest += VIDEO_LINE_LEN) {
456 (video_font_draw_table8[bits >> 4] &
459 (video_font_draw_table8[bits & 15] &
462 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
467 case GDF_15BIT_555RGB:
470 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
471 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
472 rows--; dest += VIDEO_LINE_LEN) {
476 SHORTSWAP32((video_font_draw_table15
477 [bits >> 6] & eorx) ^
480 SHORTSWAP32((video_font_draw_table15
481 [bits >> 4 & 3] & eorx) ^
484 SHORTSWAP32((video_font_draw_table15
485 [bits >> 2 & 3] & eorx) ^
488 SHORTSWAP32((video_font_draw_table15
492 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
497 case GDF_16BIT_565RGB:
500 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
501 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
502 rows--; dest += VIDEO_LINE_LEN) {
506 SHORTSWAP32((video_font_draw_table16
507 [bits >> 6] & eorx) ^
510 SHORTSWAP32((video_font_draw_table16
511 [bits >> 4 & 3] & eorx) ^
514 SHORTSWAP32((video_font_draw_table16
515 [bits >> 2 & 3] & eorx) ^
518 SHORTSWAP32((video_font_draw_table16
522 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
527 case GDF_32BIT_X888RGB:
530 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
531 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
532 rows--; dest += VIDEO_LINE_LEN) {
536 SWAP32((video_font_draw_table32
537 [bits >> 4][0] & eorx) ^ bgx);
539 SWAP32((video_font_draw_table32
540 [bits >> 4][1] & eorx) ^ bgx);
542 SWAP32((video_font_draw_table32
543 [bits >> 4][2] & eorx) ^ bgx);
545 SWAP32((video_font_draw_table32
546 [bits >> 4][3] & eorx) ^ bgx);
548 SWAP32((video_font_draw_table32
549 [bits & 15][0] & eorx) ^ bgx);
551 SWAP32((video_font_draw_table32
552 [bits & 15][1] & eorx) ^ bgx);
554 SWAP32((video_font_draw_table32
555 [bits & 15][2] & eorx) ^ bgx);
557 SWAP32((video_font_draw_table32
558 [bits & 15][3] & eorx) ^ bgx);
560 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
565 case GDF_24BIT_888RGB:
568 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
569 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
570 rows--; dest += VIDEO_LINE_LEN) {
574 (video_font_draw_table24[bits >> 4][0]
577 (video_font_draw_table24[bits >> 4][1]
580 (video_font_draw_table24[bits >> 4][2]
583 (video_font_draw_table24[bits & 15][0]
586 (video_font_draw_table24[bits & 15][1]
589 (video_font_draw_table24[bits & 15][2]
592 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
599 static inline void video_drawstring(int xx, int yy, unsigned char *s)
601 video_drawchars(xx, yy, s, strlen((char *) s));
604 static void video_putchar(int xx, int yy, unsigned char c)
606 video_drawchars(xx, yy + video_logo_height, &c, 1);
609 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
610 static void video_set_cursor(void)
612 /* swap drawing colors */
618 video_putchar(console_col * VIDEO_FONT_WIDTH,
619 console_row * VIDEO_FONT_HEIGHT, ' ');
620 /* restore drawing colors */
628 #ifdef CONFIG_CONSOLE_CURSOR
629 void console_cursor(int state)
631 static int last_state = 0;
633 #ifdef CONFIG_CONSOLE_TIME
637 /* time update only if cursor is on (faster scroll) */
641 sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,
643 video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
644 VIDEO_INFO_Y, (uchar *) info);
646 sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,
648 video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
649 VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT,
654 if (state && (last_state != state)) {
658 if (!state && (last_state != state)) {
660 video_putchar(console_col * VIDEO_FONT_WIDTH,
661 console_row * VIDEO_FONT_HEIGHT, ' ');
668 #ifndef VIDEO_HW_RECTFILL
669 static void memsetl(int *p, int c, int v)
676 #ifndef VIDEO_HW_BITBLT
677 static void memcpyl(int *d, int *s, int c)
684 static void console_scrollup(void)
686 /* copy up rows ignoring the first one */
688 #ifdef VIDEO_HW_BITBLT
689 video_hw_bitblt(VIDEO_PIXEL_SIZE, /* bytes per pixel */
690 0, /* source pos x */
692 VIDEO_FONT_HEIGHT, /* source pos y */
694 video_logo_height, /* dest pos y */
695 VIDEO_VISIBLE_COLS, /* frame width */
698 - VIDEO_FONT_HEIGHT /* frame height */
701 memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND,
702 CONSOLE_SCROLL_SIZE >> 2);
705 /* clear the last one */
706 #ifdef VIDEO_HW_RECTFILL
707 video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */
710 - VIDEO_FONT_HEIGHT, /* dest pos y */
711 VIDEO_VISIBLE_COLS, /* frame width */
712 VIDEO_FONT_HEIGHT, /* frame height */
713 CONSOLE_BG_COL /* fill color */
716 memsetl(CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
720 static void console_back(void)
725 if (console_col < 0) {
726 console_col = CONSOLE_COLS - 1;
731 video_putchar(console_col * VIDEO_FONT_WIDTH,
732 console_row * VIDEO_FONT_HEIGHT, ' ');
735 static void console_newline(void)
737 /* Check if last character in the line was just drawn. If so, cursor was
738 overwriten and need not to be cleared. Cursor clearing without this
739 check causes overwriting the 1st character of the line if line lenght
742 if (console_col < CONSOLE_COLS)
747 /* Check if we need to scroll the terminal */
748 if (console_row >= CONSOLE_ROWS) {
749 /* Scroll everything up */
752 /* Decrement row number */
757 static void console_cr(void)
763 void video_putc(const char c)
768 case 13: /* back to first column */
772 case '\n': /* next line */
773 if (console_col || (!console_col && nl))
780 console_col |= 0x0008;
781 console_col &= ~0x0007;
783 if (console_col >= CONSOLE_COLS)
787 case 8: /* backspace */
791 default: /* draw the char */
792 video_putchar(console_col * VIDEO_FONT_WIDTH,
793 console_row * VIDEO_FONT_HEIGHT, c);
796 /* check for newline */
797 if (console_col >= CONSOLE_COLS) {
805 void video_puts(const char *s)
807 int count = strlen(s);
814 * Do not enforce drivers (or board code) to provide empty
815 * video_set_lut() if they do not support 8 bpp format.
816 * Implement weak default function instead.
818 void __video_set_lut(unsigned int index, unsigned char r,
819 unsigned char g, unsigned char b)
823 void video_set_lut(unsigned int, unsigned char, unsigned char, unsigned char)
824 __attribute__ ((weak, alias("__video_set_lut")));
826 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
828 #define FILL_8BIT_332RGB(r,g,b) { \
829 *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6); \
833 #define FILL_15BIT_555RGB(r,g,b) { \
834 *(unsigned short *)fb = \
835 SWAP16((unsigned short)(((r>>3)<<10) | \
841 #define FILL_16BIT_565RGB(r,g,b) { \
842 *(unsigned short *)fb = \
843 SWAP16((unsigned short)((((r)>>3)<<11)| \
849 #define FILL_32BIT_X888RGB(r,g,b) { \
850 *(unsigned long *)fb = \
851 SWAP32((unsigned long)(((r<<16) | \
857 #ifdef VIDEO_FB_LITTLE_ENDIAN
858 #define FILL_24BIT_888RGB(r,g,b) { \
865 #define FILL_24BIT_888RGB(r,g,b) { \
873 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
874 static inline void fill_555rgb_pswap(uchar *fb, int x, u8 r, u8 g, u8 b)
876 ushort *dst = (ushort *) fb;
877 ushort color = (ushort) (((r >> 3) << 10) |
888 * RLE8 bitmap support
891 #ifdef CONFIG_VIDEO_BMP_RLE8
892 /* Pre-calculated color table entry */
895 unsigned short w; /* word */
896 unsigned int dw; /* double word */
897 } ce; /* color entry */
901 * Helper to draw encoded/unencoded run.
903 static void draw_bitmap(uchar **fb, uchar *bm, struct palette *p,
906 ulong addr = (ulong) *fb;
912 * Setup offset of the color index in the bitmap.
913 * Color index of encoded run is at offset 1.
915 off = enc ? &enc_off : &i;
917 switch (VIDEO_DATA_FORMAT) {
918 case GDF__8BIT_INDEX:
919 for (i = 0; i < cnt; i++)
920 *(unsigned char *) addr++ = bm[*off];
922 case GDF_15BIT_555RGB:
923 case GDF_16BIT_565RGB:
924 /* differences handled while pre-calculating palette */
925 for (i = 0; i < cnt; i++) {
926 *(unsigned short *) addr = p[bm[*off]].ce.w;
930 case GDF_32BIT_X888RGB:
931 for (i = 0; i < cnt; i++) {
932 *(unsigned long *) addr = p[bm[*off]].ce.dw;
937 *fb = (uchar *) addr; /* return modified address */
940 static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff,
941 int width, int height)
945 unsigned int cnt, runlen;
947 int x, y, bpp, i, ncolors;
948 struct palette p[256];
949 bmp_color_table_entry_t cte;
950 int green_shift, red_off;
951 int limit = VIDEO_COLS * VIDEO_ROWS;
955 y = __le32_to_cpu(img->header.height) - 1;
956 ncolors = __le32_to_cpu(img->header.colors_used);
957 bpp = VIDEO_PIXEL_SIZE;
958 fbp = (unsigned char *) ((unsigned int) video_fb_address +
959 (((y + yoff) * VIDEO_COLS) + xoff) * bpp);
961 bm = (uchar *) img + __le32_to_cpu(img->header.data_offset);
963 /* pre-calculate and setup palette */
964 switch (VIDEO_DATA_FORMAT) {
965 case GDF__8BIT_INDEX:
966 for (i = 0; i < ncolors; i++) {
967 cte = img->color_table[i];
968 video_set_lut(i, cte.red, cte.green, cte.blue);
971 case GDF_15BIT_555RGB:
972 case GDF_16BIT_565RGB:
973 if (VIDEO_DATA_FORMAT == GDF_15BIT_555RGB) {
980 for (i = 0; i < ncolors; i++) {
981 cte = img->color_table[i];
982 p[i].ce.w = SWAP16((unsigned short)
983 (((cte.red >> 3) << red_off) |
984 ((cte.green >> green_shift) << 5) |
988 case GDF_32BIT_X888RGB:
989 for (i = 0; i < ncolors; i++) {
990 cte = img->color_table[i];
991 p[i].ce.dw = SWAP32((cte.red << 16) |
997 printf("RLE Bitmap unsupported in video mode 0x%x\n",
1007 /* scan line end marker */
1011 fbp = (unsigned char *)
1012 ((unsigned int) video_fb_address +
1013 (((y + yoff) * VIDEO_COLS) +
1017 /* end of bitmap data marker */
1021 /* run offset marker */
1024 fbp = (unsigned char *)
1025 ((unsigned int) video_fb_address +
1026 (((y + yoff) * VIDEO_COLS) +
1044 if (x + runlen > width)
1046 draw_bitmap(&fbp, bm, p, cnt, 0);
1052 bm++; /* 0 padding if length is odd */
1063 if (y < height) { /* only draw into visible area */
1069 if (x + runlen > width)
1071 draw_bitmap(&fbp, bm, p, cnt, 1);
1080 printf("Error: Too much encoded pixel data, validate your bitmap\n");
1086 * Display the BMP file located at address bmp_image.
1088 int video_display_bitmap(ulong bmp_image, int x, int y)
1090 ushort xcount, ycount;
1092 bmp_image_t *bmp = (bmp_image_t *) bmp_image;
1095 unsigned long width, height, bpp;
1097 unsigned long compression;
1098 bmp_color_table_entry_t cte;
1100 #ifdef CONFIG_VIDEO_BMP_GZIP
1101 unsigned char *dst = NULL;
1107 if (!((bmp->header.signature[0] == 'B') &&
1108 (bmp->header.signature[1] == 'M'))) {
1110 #ifdef CONFIG_VIDEO_BMP_GZIP
1112 * Could be a gzipped bmp image, try to decrompress...
1114 len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
1115 dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
1117 printf("Error: malloc in gunzip failed!\n");
1120 if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE,
1121 (uchar *) bmp_image,
1123 printf("Error: no valid bmp or bmp.gz image at %lx\n",
1128 if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) {
1129 printf("Image could be truncated "
1130 "(increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
1134 * Set addr to decompressed image
1136 bmp = (bmp_image_t *) dst;
1138 if (!((bmp->header.signature[0] == 'B') &&
1139 (bmp->header.signature[1] == 'M'))) {
1140 printf("Error: no valid bmp.gz image at %lx\n",
1146 printf("Error: no valid bmp image at %lx\n", bmp_image);
1148 #endif /* CONFIG_VIDEO_BMP_GZIP */
1151 width = le32_to_cpu(bmp->header.width);
1152 height = le32_to_cpu(bmp->header.height);
1153 bpp = le16_to_cpu(bmp->header.bit_count);
1154 colors = le32_to_cpu(bmp->header.colors_used);
1155 compression = le32_to_cpu(bmp->header.compression);
1157 debug("Display-bmp: %ld x %ld with %d colors\n",
1158 width, height, colors);
1160 if (compression != BMP_BI_RGB
1161 #ifdef CONFIG_VIDEO_BMP_RLE8
1162 && compression != BMP_BI_RLE8
1165 printf("Error: compression type %ld not supported\n",
1167 #ifdef CONFIG_VIDEO_BMP_GZIP
1174 padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3;
1176 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
1177 if (x == BMP_ALIGN_CENTER)
1178 x = max(0, (VIDEO_VISIBLE_COLS - width) / 2);
1180 x = max(0, VIDEO_VISIBLE_COLS - width + x + 1);
1182 if (y == BMP_ALIGN_CENTER)
1183 y = max(0, (VIDEO_VISIBLE_ROWS - height) / 2);
1185 y = max(0, VIDEO_VISIBLE_ROWS - height + y + 1);
1186 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
1188 if ((x + width) > VIDEO_VISIBLE_COLS)
1189 width = VIDEO_VISIBLE_COLS - x;
1190 if ((y + height) > VIDEO_VISIBLE_ROWS)
1191 height = VIDEO_VISIBLE_ROWS - y;
1193 bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
1194 fb = (uchar *) (video_fb_address +
1195 ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
1196 x * VIDEO_PIXEL_SIZE);
1198 #ifdef CONFIG_VIDEO_BMP_RLE8
1199 if (compression == BMP_BI_RLE8) {
1200 return display_rle8_bitmap(bmp, x, y, width, height);
1204 /* We handle only 4, 8, or 24 bpp bitmaps */
1205 switch (le16_to_cpu(bmp->header.bit_count)) {
1207 padded_line -= width / 2;
1210 switch (VIDEO_DATA_FORMAT) {
1211 case GDF_32BIT_X888RGB:
1215 * Don't assume that 'width' is an
1218 for (xcount = 0; xcount < width; xcount++) {
1226 cte = bmp->color_table[idx];
1227 FILL_32BIT_X888RGB(cte.red, cte.green,
1230 bmap += padded_line;
1231 fb -= (VIDEO_VISIBLE_COLS + width) *
1236 puts("4bpp bitmap unsupported with current "
1243 padded_line -= width;
1244 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
1246 for (xcount = 0; xcount < colors; ++xcount) {
1247 cte = bmp->color_table[xcount];
1248 video_set_lut(xcount, cte.red, cte.green,
1253 switch (VIDEO_DATA_FORMAT) {
1254 case GDF__8BIT_INDEX:
1261 bmap += padded_line;
1262 fb -= (VIDEO_VISIBLE_COLS + width) *
1266 case GDF__8BIT_332RGB:
1271 cte = bmp->color_table[*bmap++];
1272 FILL_8BIT_332RGB(cte.red, cte.green,
1275 bmap += padded_line;
1276 fb -= (VIDEO_VISIBLE_COLS + width) *
1280 case GDF_15BIT_555RGB:
1282 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1288 cte = bmp->color_table[*bmap++];
1289 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1290 fill_555rgb_pswap(fb, xpos++, cte.red,
1295 FILL_15BIT_555RGB(cte.red, cte.green,
1299 bmap += padded_line;
1300 fb -= (VIDEO_VISIBLE_COLS + width) *
1304 case GDF_16BIT_565RGB:
1309 cte = bmp->color_table[*bmap++];
1310 FILL_16BIT_565RGB(cte.red, cte.green,
1313 bmap += padded_line;
1314 fb -= (VIDEO_VISIBLE_COLS + width) *
1318 case GDF_32BIT_X888RGB:
1323 cte = bmp->color_table[*bmap++];
1324 FILL_32BIT_X888RGB(cte.red, cte.green,
1327 bmap += padded_line;
1328 fb -= (VIDEO_VISIBLE_COLS + width) *
1332 case GDF_24BIT_888RGB:
1337 cte = bmp->color_table[*bmap++];
1338 FILL_24BIT_888RGB(cte.red, cte.green,
1341 bmap += padded_line;
1342 fb -= (VIDEO_VISIBLE_COLS + width) *
1349 padded_line -= 3 * width;
1351 switch (VIDEO_DATA_FORMAT) {
1352 case GDF__8BIT_332RGB:
1357 FILL_8BIT_332RGB(bmap[2], bmap[1],
1361 bmap += padded_line;
1362 fb -= (VIDEO_VISIBLE_COLS + width) *
1366 case GDF_15BIT_555RGB:
1368 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1374 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1375 fill_555rgb_pswap(fb, xpos++, bmap[2],
1379 FILL_15BIT_555RGB(bmap[2], bmap[1],
1384 bmap += padded_line;
1385 fb -= (VIDEO_VISIBLE_COLS + width) *
1389 case GDF_16BIT_565RGB:
1394 FILL_16BIT_565RGB(bmap[2], bmap[1],
1398 bmap += padded_line;
1399 fb -= (VIDEO_VISIBLE_COLS + width) *
1403 case GDF_32BIT_X888RGB:
1408 FILL_32BIT_X888RGB(bmap[2], bmap[1],
1412 bmap += padded_line;
1413 fb -= (VIDEO_VISIBLE_COLS + width) *
1417 case GDF_24BIT_888RGB:
1422 FILL_24BIT_888RGB(bmap[2], bmap[1],
1426 bmap += padded_line;
1427 fb -= (VIDEO_VISIBLE_COLS + width) *
1432 printf("Error: 24 bits/pixel bitmap incompatible "
1433 "with current video mode\n");
1438 printf("Error: %d bit/pixel bitmaps not supported by U-Boot\n",
1439 le16_to_cpu(bmp->header.bit_count));
1443 #ifdef CONFIG_VIDEO_BMP_GZIP
1454 #ifdef CONFIG_VIDEO_LOGO
1455 void logo_plot(void *screen, int width, int x, int y)
1459 int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
1460 int ycount = video_logo_height;
1461 unsigned char r, g, b, *logo_red, *logo_blue, *logo_green;
1462 unsigned char *source;
1463 unsigned char *dest = (unsigned char *) screen +
1464 ((y * width * VIDEO_PIXEL_SIZE) + x * VIDEO_PIXEL_SIZE);
1466 #ifdef CONFIG_VIDEO_BMP_LOGO
1467 source = bmp_logo_bitmap;
1469 /* Allocate temporary space for computing colormap */
1470 logo_red = malloc(BMP_LOGO_COLORS);
1471 logo_green = malloc(BMP_LOGO_COLORS);
1472 logo_blue = malloc(BMP_LOGO_COLORS);
1473 /* Compute color map */
1474 for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
1475 logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4;
1476 logo_green[i] = (bmp_logo_palette[i] & 0x00f0);
1477 logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4;
1480 source = linux_logo;
1481 logo_red = linux_logo_red;
1482 logo_green = linux_logo_green;
1483 logo_blue = linux_logo_blue;
1486 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
1487 for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
1488 video_set_lut(i + VIDEO_LOGO_LUT_OFFSET,
1489 logo_red[i], logo_green[i],
1495 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1498 xcount = VIDEO_LOGO_WIDTH;
1500 r = logo_red[*source - VIDEO_LOGO_LUT_OFFSET];
1501 g = logo_green[*source - VIDEO_LOGO_LUT_OFFSET];
1502 b = logo_blue[*source - VIDEO_LOGO_LUT_OFFSET];
1504 switch (VIDEO_DATA_FORMAT) {
1505 case GDF__8BIT_INDEX:
1508 case GDF__8BIT_332RGB:
1509 *dest = ((r >> 5) << 5) |
1513 case GDF_15BIT_555RGB:
1514 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1515 fill_555rgb_pswap(dest, xpos++, r, g, b);
1517 *(unsigned short *) dest =
1518 SWAP16((unsigned short) (
1524 case GDF_16BIT_565RGB:
1525 *(unsigned short *) dest =
1526 SWAP16((unsigned short) (
1531 case GDF_32BIT_X888RGB:
1532 *(unsigned long *) dest =
1533 SWAP32((unsigned long) (
1538 case GDF_24BIT_888RGB:
1539 #ifdef VIDEO_FB_LITTLE_ENDIAN
1551 dest += VIDEO_PIXEL_SIZE;
1555 #ifdef CONFIG_VIDEO_BMP_LOGO
1562 static void *video_logo(void)
1566 __maybe_unused int y_off = 0;
1568 #ifdef CONFIG_SPLASH_SCREEN
1572 s = getenv("splashimage");
1576 addr = simple_strtoul(s, NULL, 16);
1577 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
1578 s = getenv("splashpos");
1581 x = BMP_ALIGN_CENTER;
1583 x = simple_strtol(s, NULL, 0);
1585 s = strchr(s + 1, ',');
1588 y = BMP_ALIGN_CENTER;
1590 y = simple_strtol(s + 1, NULL, 0);
1593 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
1595 if (video_display_bitmap(addr, x, y) == 0) {
1596 video_logo_height = 0;
1597 return ((void *) (video_fb_address));
1600 #endif /* CONFIG_SPLASH_SCREEN */
1602 logo_plot(video_fb_address, VIDEO_COLS, 0, 0);
1604 sprintf(info, " %s", version_string);
1606 space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
1610 video_drawchars(VIDEO_INFO_X, VIDEO_INFO_Y,
1611 (uchar *) info, space);
1612 video_drawchars(VIDEO_INFO_X + VIDEO_FONT_WIDTH,
1613 VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,
1614 (uchar *) info + space, len - space);
1617 video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info);
1619 #ifdef CONFIG_CONSOLE_EXTRA_INFO
1622 ((video_logo_height -
1623 VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT);
1625 for (i = 1; i < n; i++) {
1626 video_get_info_str(i, info);
1632 video_drawchars(VIDEO_INFO_X,
1636 (uchar *) info, space);
1638 video_drawchars(VIDEO_INFO_X +
1643 (uchar *) info + space,
1646 video_drawstring(VIDEO_INFO_X,
1656 return (video_fb_address + video_logo_height * VIDEO_LINE_LEN);
1660 static int video_init(void)
1662 unsigned char color8;
1664 pGD = video_hw_init();
1668 video_fb_address = (void *) VIDEO_FB_ADRS;
1669 #ifdef CONFIG_VIDEO_HW_CURSOR
1670 video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
1673 /* Init drawing pats */
1674 switch (VIDEO_DATA_FORMAT) {
1675 case GDF__8BIT_INDEX:
1676 video_set_lut(0x01, CONSOLE_FG_COL, CONSOLE_FG_COL,
1678 video_set_lut(0x00, CONSOLE_BG_COL, CONSOLE_BG_COL,
1683 case GDF__8BIT_332RGB:
1684 color8 = ((CONSOLE_FG_COL & 0xe0) |
1685 ((CONSOLE_FG_COL >> 3) & 0x1c) |
1686 CONSOLE_FG_COL >> 6);
1687 fgx = (color8 << 24) | (color8 << 16) | (color8 << 8) |
1689 color8 = ((CONSOLE_BG_COL & 0xe0) |
1690 ((CONSOLE_BG_COL >> 3) & 0x1c) |
1691 CONSOLE_BG_COL >> 6);
1692 bgx = (color8 << 24) | (color8 << 16) | (color8 << 8) |
1695 case GDF_15BIT_555RGB:
1696 fgx = (((CONSOLE_FG_COL >> 3) << 26) |
1697 ((CONSOLE_FG_COL >> 3) << 21) |
1698 ((CONSOLE_FG_COL >> 3) << 16) |
1699 ((CONSOLE_FG_COL >> 3) << 10) |
1700 ((CONSOLE_FG_COL >> 3) << 5) |
1701 (CONSOLE_FG_COL >> 3));
1702 bgx = (((CONSOLE_BG_COL >> 3) << 26) |
1703 ((CONSOLE_BG_COL >> 3) << 21) |
1704 ((CONSOLE_BG_COL >> 3) << 16) |
1705 ((CONSOLE_BG_COL >> 3) << 10) |
1706 ((CONSOLE_BG_COL >> 3) << 5) |
1707 (CONSOLE_BG_COL >> 3));
1709 case GDF_16BIT_565RGB:
1710 fgx = (((CONSOLE_FG_COL >> 3) << 27) |
1711 ((CONSOLE_FG_COL >> 2) << 21) |
1712 ((CONSOLE_FG_COL >> 3) << 16) |
1713 ((CONSOLE_FG_COL >> 3) << 11) |
1714 ((CONSOLE_FG_COL >> 2) << 5) |
1715 (CONSOLE_FG_COL >> 3));
1716 bgx = (((CONSOLE_BG_COL >> 3) << 27) |
1717 ((CONSOLE_BG_COL >> 2) << 21) |
1718 ((CONSOLE_BG_COL >> 3) << 16) |
1719 ((CONSOLE_BG_COL >> 3) << 11) |
1720 ((CONSOLE_BG_COL >> 2) << 5) |
1721 (CONSOLE_BG_COL >> 3));
1723 case GDF_32BIT_X888RGB:
1724 fgx = (CONSOLE_FG_COL << 16) |
1725 (CONSOLE_FG_COL << 8) |
1727 bgx = (CONSOLE_BG_COL << 16) |
1728 (CONSOLE_BG_COL << 8) |
1731 case GDF_24BIT_888RGB:
1732 fgx = (CONSOLE_FG_COL << 24) |
1733 (CONSOLE_FG_COL << 16) |
1734 (CONSOLE_FG_COL << 8) |
1736 bgx = (CONSOLE_BG_COL << 24) |
1737 (CONSOLE_BG_COL << 16) |
1738 (CONSOLE_BG_COL << 8) |
1744 #ifdef CONFIG_VIDEO_LOGO
1745 /* Plot the logo and get start point of console */
1746 debug("Video: Drawing the logo ...\n");
1747 video_console_address = video_logo();
1749 video_console_address = video_fb_address;
1752 /* Initialize the console */
1760 * Implement a weak default function for boards that optionally
1761 * need to skip the video initialization.
1763 int __board_video_skip(void)
1765 /* As default, don't skip test */
1769 int board_video_skip(void)
1770 __attribute__ ((weak, alias("__board_video_skip")));
1772 int drv_video_init(void)
1775 struct stdio_dev console_dev;
1777 /* Check if video initialization should be skipped */
1778 if (board_video_skip())
1781 /* Init video chip - returns with framebuffer cleared */
1782 skip_dev_init = (video_init() == -1);
1784 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
1785 debug("KBD: Keyboard init ...\n");
1786 skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
1792 /* Init vga device */
1793 memset(&console_dev, 0, sizeof(console_dev));
1794 strcpy(console_dev.name, "vga");
1795 console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
1796 console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
1797 console_dev.putc = video_putc; /* 'putc' function */
1798 console_dev.puts = video_puts; /* 'puts' function */
1799 console_dev.tstc = NULL; /* 'tstc' function */
1800 console_dev.getc = NULL; /* 'getc' function */
1802 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
1803 /* Also init console device */
1804 console_dev.flags |= DEV_FLAGS_INPUT;
1805 console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
1806 console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
1807 #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
1809 if (stdio_register(&console_dev) != 0)
1812 /* Return success */