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 normaly goes to serial port) can be drawed.
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 delay
63 loop in VIDEO_TSTC_FCT (i8042)
64 CFG_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
65 CONFIG_CONSOLE_TIME - display time/date in upper right corner,
66 needs CFG_CMD_DATE and CONFIG_CONSOLE_CURSOR
67 CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner
68 CONFIG_CONSOLE_EXTRA_INFO - display additional board information strings
69 that normaly goes to serial port. This define
70 requires a board specific function:
71 video_drawstring (VIDEO_INFO_X,
72 VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT,
74 that fills a info buffer at i=row.
75 s.a: board/eltec/bab7xx.
76 CONFIG_VGA_AS_SINGLE_DEVICE - If set the framebuffer device will be initialised
77 as an output only device. The Keyboard driver
78 will not be set-up. This may be used, if you
79 have none or more than one Keyboard devices
80 (USB Keyboard, AT Keyboard).
82 CONFIG_VIDEO_SW_CURSOR: - Draws a cursor after the last character. No
83 blinking is provided. Uses the macros CURSOR_SET
85 CONFIG_VIDEO_HW_CURSOR: - Uses the hardware cursor capability of the
86 graphic chip. Uses the macro CURSOR_SET.
87 ATTENTION: If booting an OS, the display driver
88 must disable the hardware register of the graphic
89 chip. Otherwise a blinking field is displayed
94 #ifdef CONFIG_CFB_CONSOLE
96 /*****************************************************************************/
97 /* Console device defines with SMI graphic */
98 /* Any other graphic must change this section */
99 /*****************************************************************************/
101 #ifdef CONFIG_VIDEO_SMI_LYNXEM
103 #define VIDEO_FB_LITTLE_ENDIAN
104 #define VIDEO_HW_RECTFILL
105 #define VIDEO_HW_BITBLT
108 /*****************************************************************************/
109 /* Defines for the CT69000 driver */
110 /*****************************************************************************/
111 #ifdef CONFIG_VIDEO_CT69000
113 #define VIDEO_FB_LITTLE_ENDIAN
114 #define VIDEO_HW_RECTFILL
115 #define VIDEO_HW_BITBLT
118 /*****************************************************************************/
119 /* Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc */
120 /*****************************************************************************/
121 #include <video_fb.h>
123 /*****************************************************************************/
125 /*****************************************************************************/
126 #define VIDEO_VISIBLE_COLS (pGD->winSizeX)
127 #define VIDEO_VISIBLE_ROWS (pGD->winSizeY)
128 #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP)
129 #define VIDEO_DATA_FORMAT (pGD->gdfIndex)
130 #define VIDEO_FB_ADRS (pGD->frameAdrs)
132 /*****************************************************************************/
133 /* Console device defines with i8042 keyboard controller */
134 /* Any other keyboard controller must change this section */
135 /*****************************************************************************/
137 #ifdef CONFIG_I8042_KBD
140 #define VIDEO_KBD_INIT_FCT i8042_kbd_init()
141 #define VIDEO_TSTC_FCT i8042_tstc
142 #define VIDEO_GETC_FCT i8042_getc
145 /*****************************************************************************/
147 /*****************************************************************************/
150 #include <linux/types.h>
152 #include <video_font.h>
158 /*****************************************************************************/
159 /* Cursor definition: */
160 /* CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/i8042.c) to */
161 /* let the cursor blink. Uses the macros CURSOR_OFF */
163 /* CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No */
164 /* blinking is provided. Uses the macros CURSOR_SET */
165 /* and CURSOR_OFF. */
166 /* CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the */
167 /* graphic chip. Uses the macro CURSOR_SET. */
168 /* ATTENTION: If booting an OS, the display driver */
169 /* must disable the hardware register of the graphic */
170 /* chip. Otherwise a blinking field is displayed */
171 /*****************************************************************************/
172 #if !defined(CONFIG_CONSOLE_CURSOR) && \
173 !defined(CONFIG_VIDEO_SW_CURSOR) && \
174 !defined(CONFIG_VIDEO_HW_CURSOR)
175 /* no Cursor defined */
181 #ifdef CONFIG_CONSOLE_CURSOR
183 #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
185 void console_cursor (int state);
186 #define CURSOR_ON console_cursor(1);
187 #define CURSOR_OFF console_cursor(0);
189 #ifndef CONFIG_I8042_KBD
190 #warning Cursor drawing on/off needs timer function s.a. drivers/i8042.c
193 #ifdef CONFIG_CONSOLE_TIME
194 #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
196 #endif /* CONFIG_CONSOLE_CURSOR */
198 #ifdef CONFIG_VIDEO_SW_CURSOR
200 #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
203 #define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
204 console_row * VIDEO_FONT_HEIGHT, ' ');
205 #define CURSOR_SET video_set_cursor();
206 #endif /* CONFIG_VIDEO_SW_CURSOR */
209 #ifdef CONFIG_VIDEO_HW_CURSOR
211 #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
215 #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \
216 (console_row * VIDEO_FONT_HEIGHT) + VIDEO_LOGO_HEIGHT);
217 #endif /* CONFIG_VIDEO_HW_CURSOR */
219 #ifdef CONFIG_VIDEO_LOGO
220 #define LINUX_LOGO_WIDTH 80
221 #define LINUX_LOGO_HEIGHT 80
222 #define LINUX_LOGO_COLORS 214
223 #define LINUX_LOGO_LUT_OFFSET 0x20
225 #include <linux_logo.h>
226 #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH
227 #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT
229 #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH)
230 #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2)
232 #define VIDEO_LOGO_WIDTH 0
233 #define VIDEO_LOGO_HEIGHT 0
236 #define VIDEO_COLS VIDEO_VISIBLE_COLS
237 #define VIDEO_ROWS VIDEO_VISIBLE_ROWS
238 #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
239 #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2)
240 #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE)
241 #define VIDEO_BURST_LEN (VIDEO_COLS/8)
243 #ifdef CONFIG_VIDEO_LOGO
244 #define CONSOLE_ROWS ((VIDEO_ROWS - VIDEO_LOGO_HEIGHT) / VIDEO_FONT_HEIGHT)
246 #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT)
249 #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH)
250 #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN)
251 #define CONSOLE_ROW_FIRST (video_console_address)
252 #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE)
253 #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
254 #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
255 #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
258 #ifdef VIDEO_FB_LITTLE_ENDIAN
259 #define SWAP16(x) ((((x) & 0x00ff) << 8) | ( (x) >> 8))
260 #define SWAP32(x) ((((x) & 0x000000ff) << 24) | (((x) & 0x0000ff00) << 8)|\
261 (((x) & 0x00ff0000) >> 8) | (((x) & 0xff000000) >> 24) )
262 #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | (((x) & 0x0000ff00) >> 8)|\
263 (((x) & 0x00ff0000) << 8) | (((x) & 0xff000000) >> 8) )
265 #define SWAP16(x) (x)
266 #define SWAP32(x) (x)
267 #define SHORTSWAP32(x) (x)
270 #if defined(DEBUG) || defined(DEBUG_CFB_CONSOLE)
271 #define PRINTD(x) printf(x)
277 #ifdef CONFIG_CONSOLE_EXTRA_INFO
278 extern void video_get_info_str ( /* setup a board string: type, speed, etc. */
279 int line_number, /* location to place info string beside logo */
280 char *info /* buffer for info string */
286 static GraphicDevice *pGD; /* Pointer to Graphic array */
288 static void *video_fb_address; /* frame buffer address */
289 static void *video_console_address; /* console buffer start address */
291 static int console_col = 0; /* cursor col */
292 static int console_row = 0; /* cursor row */
294 static u32 eorx, fgx, bgx; /* color pats */
296 static const int video_font_draw_table8[] = {
297 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
298 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
299 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
300 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff };
302 static const int video_font_draw_table15[] = {
303 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff };
305 static const int video_font_draw_table16[] = {
306 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff };
308 static const int video_font_draw_table24[16][3] = {
309 { 0x00000000, 0x00000000, 0x00000000 },
310 { 0x00000000, 0x00000000, 0x00ffffff },
311 { 0x00000000, 0x0000ffff, 0xff000000 },
312 { 0x00000000, 0x0000ffff, 0xffffffff },
313 { 0x000000ff, 0xffff0000, 0x00000000 },
314 { 0x000000ff, 0xffff0000, 0x00ffffff },
315 { 0x000000ff, 0xffffffff, 0xff000000 },
316 { 0x000000ff, 0xffffffff, 0xffffffff },
317 { 0xffffff00, 0x00000000, 0x00000000 },
318 { 0xffffff00, 0x00000000, 0x00ffffff },
319 { 0xffffff00, 0x0000ffff, 0xff000000 },
320 { 0xffffff00, 0x0000ffff, 0xffffffff },
321 { 0xffffffff, 0xffff0000, 0x00000000 },
322 { 0xffffffff, 0xffff0000, 0x00ffffff },
323 { 0xffffffff, 0xffffffff, 0xff000000 },
324 { 0xffffffff, 0xffffffff, 0xffffffff } };
326 static const int video_font_draw_table32[16][4] = {
327 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
328 { 0x00000000, 0x00000000, 0x00000000, 0x00ffffff },
329 { 0x00000000, 0x00000000, 0x00ffffff, 0x00000000 },
330 { 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff },
331 { 0x00000000, 0x00ffffff, 0x00000000, 0x00000000 },
332 { 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff },
333 { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000 },
334 { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff },
335 { 0x00ffffff, 0x00000000, 0x00000000, 0x00000000 },
336 { 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff },
337 { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000 },
338 { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff },
339 { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000 },
340 { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff },
341 { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000 },
342 { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff } };
345 /******************************************************************************/
348 static void video_drawchars (int xx, int yy, unsigned char *s, int count)
350 u8 *cdat, *dest, *dest0;
353 offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE;
354 dest0 = video_fb_address + offset;
356 switch (VIDEO_DATA_FORMAT)
358 case GDF__8BIT_INDEX:
359 case GDF__8BIT_332RGB:
363 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
364 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
367 ((u32 *)dest)[0] = (video_font_draw_table8[bits >> 4] & eorx) ^ bgx;
368 ((u32 *)dest)[1] = (video_font_draw_table8[bits & 15] & eorx) ^ bgx;
370 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
375 case GDF_15BIT_555RGB:
379 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
380 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
383 ((u32 *)dest)[0] = SHORTSWAP32((video_font_draw_table15[bits >> 6] & eorx) ^ bgx);
384 ((u32 *)dest)[1] = SHORTSWAP32((video_font_draw_table15[bits >> 4 & 3] & eorx) ^ bgx);
385 ((u32 *)dest)[2] = SHORTSWAP32((video_font_draw_table15[bits >> 2 & 3] & eorx) ^ bgx);
386 ((u32 *)dest)[3] = SHORTSWAP32((video_font_draw_table15[bits & 3] & eorx) ^ bgx);
388 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
393 case GDF_16BIT_565RGB:
397 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
398 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
401 ((u32 *)dest)[0] = SHORTSWAP32((video_font_draw_table16[bits >> 6] & eorx) ^ bgx);
402 ((u32 *)dest)[1] = SHORTSWAP32((video_font_draw_table16[bits >> 4 & 3] & eorx) ^ bgx);
403 ((u32 *)dest)[2] = SHORTSWAP32((video_font_draw_table16[bits >> 2 & 3] & eorx) ^ bgx);
404 ((u32 *)dest)[3] = SHORTSWAP32((video_font_draw_table16[bits & 3] & eorx) ^ bgx);
406 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
411 case GDF_32BIT_X888RGB:
415 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
416 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
419 ((u32 *)dest)[0] = SWAP32((video_font_draw_table32[bits >> 4][0] & eorx) ^ bgx);
420 ((u32 *)dest)[1] = SWAP32((video_font_draw_table32[bits >> 4][1] & eorx) ^ bgx);
421 ((u32 *)dest)[2] = SWAP32((video_font_draw_table32[bits >> 4][2] & eorx) ^ bgx);
422 ((u32 *)dest)[3] = SWAP32((video_font_draw_table32[bits >> 4][3] & eorx) ^ bgx);
423 ((u32 *)dest)[4] = SWAP32((video_font_draw_table32[bits & 15][0] & eorx) ^ bgx);
424 ((u32 *)dest)[5] = SWAP32((video_font_draw_table32[bits & 15][1] & eorx) ^ bgx);
425 ((u32 *)dest)[6] = SWAP32((video_font_draw_table32[bits & 15][2] & eorx) ^ bgx);
426 ((u32 *)dest)[7] = SWAP32((video_font_draw_table32[bits & 15][3] & eorx) ^ bgx);
428 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
433 case GDF_24BIT_888RGB:
437 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
438 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
441 ((u32 *)dest)[0] = (video_font_draw_table24[bits >> 4][0] & eorx) ^ bgx;
442 ((u32 *)dest)[1] = (video_font_draw_table24[bits >> 4][1] & eorx) ^ bgx;
443 ((u32 *)dest)[2] = (video_font_draw_table24[bits >> 4][2] & eorx) ^ bgx;
444 ((u32 *)dest)[3] = (video_font_draw_table24[bits & 15][0] & eorx) ^ bgx;
445 ((u32 *)dest)[4] = (video_font_draw_table24[bits & 15][1] & eorx) ^ bgx;
446 ((u32 *)dest)[5] = (video_font_draw_table24[bits & 15][2] & eorx) ^ bgx;
448 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
455 /*****************************************************************************/
457 static inline void video_drawstring(int xx, int yy, unsigned char *s)
459 video_drawchars (xx, yy, s, strlen(s));
462 /*****************************************************************************/
464 static void video_putchar(int xx, int yy, unsigned char c)
466 #ifdef CONFIG_VIDEO_LOGO
467 video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1);
469 video_drawchars (xx, yy, &c, 1);
473 /*****************************************************************************/
474 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
475 static void video_set_cursor(void)
477 /* swap drawing colors */
483 video_putchar (console_col * VIDEO_FONT_WIDTH,
484 console_row * VIDEO_FONT_HEIGHT, ' ');
485 /* restore drawing colors */
492 /*****************************************************************************/
493 #ifdef CONFIG_CONSOLE_CURSOR
494 void console_cursor (int state)
496 static int last_state = 0;
497 #ifdef CONFIG_CONSOLE_TIME
501 /* time update only if cursor is on (faster scroll) */
506 sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min, tm.tm_sec);
507 video_drawstring(VIDEO_VISIBLE_COLS-10*VIDEO_FONT_WIDTH,
510 sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon, tm.tm_year);
511 video_drawstring(VIDEO_VISIBLE_COLS-10*VIDEO_FONT_WIDTH,
512 VIDEO_INFO_Y+1*VIDEO_FONT_HEIGHT, info);
516 if (state && (last_state != state))
521 if (!state && (last_state != state))
524 video_putchar (console_col * VIDEO_FONT_WIDTH,
525 console_row * VIDEO_FONT_HEIGHT, ' ');
532 /*****************************************************************************/
534 #ifndef VIDEO_HW_RECTFILL
535 static void memsetl (int *p, int c, int v)
542 /*****************************************************************************/
544 #ifndef VIDEO_HW_BITBLT
545 static void memcpyl (int *d, int *s, int c)
552 /*****************************************************************************/
554 static void console_scrollup (void)
556 /* copy up rows ignoring the first one */
558 #ifdef VIDEO_HW_BITBLT
560 VIDEO_PIXEL_SIZE, /* bytes per pixel */
561 0, /* source pos x */
562 VIDEO_LOGO_HEIGHT + VIDEO_FONT_HEIGHT, /* source pos y */
564 VIDEO_LOGO_HEIGHT, /* dest pos y */
565 VIDEO_VISIBLE_COLS, /* frame width */
566 VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT - VIDEO_FONT_HEIGHT /* frame height */
569 memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE >> 2);
572 /* clear the last one */
573 #ifdef VIDEO_HW_RECTFILL
575 VIDEO_PIXEL_SIZE, /* bytes per pixel */
577 VIDEO_VISIBLE_ROWS - VIDEO_FONT_HEIGHT, /* dest pos y */
578 VIDEO_VISIBLE_COLS, /* frame width */
579 VIDEO_FONT_HEIGHT, /* frame height */
580 CONSOLE_BG_COL /* fill color */
583 memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
587 /*****************************************************************************/
589 static void console_back (void)
596 console_col = CONSOLE_COLS - 1;
601 video_putchar (console_col * VIDEO_FONT_WIDTH,
602 console_row * VIDEO_FONT_HEIGHT, ' ');
605 /*****************************************************************************/
607 static void console_newline (void)
613 /* Check if we need to scroll the terminal */
614 if (console_row >= CONSOLE_ROWS)
616 /* Scroll everything up */
619 /* Decrement row number */
624 /*****************************************************************************/
626 void video_putc (const char c)
630 case 13: /* ignore */
633 case '\n': /* next line */
639 console_col |= 0x0008;
640 console_col &= ~0x0007;
642 if (console_col >= CONSOLE_COLS)
646 case 8: /* backspace */
650 default: /* draw the char */
651 video_putchar (console_col * VIDEO_FONT_WIDTH,
652 console_row * VIDEO_FONT_HEIGHT, c);
655 /* check for newline */
656 if (console_col >= CONSOLE_COLS)
664 /*****************************************************************************/
666 void video_puts (const char *s)
668 int count = strlen(s);
674 /*****************************************************************************/
676 #ifdef CONFIG_VIDEO_LOGO
677 void logo_plot (void *screen, int width, int x, int y)
679 int skip = (width - LINUX_LOGO_WIDTH) * VIDEO_PIXEL_SIZE,
681 ycount = LINUX_LOGO_HEIGHT;
683 *source = linux_logo,
684 *dest = (unsigned char *) screen + ((y * width * VIDEO_PIXEL_SIZE) + x),
687 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX)
689 for (i = 0; i < LINUX_LOGO_COLORS; i++)
691 r = (unsigned char)linux_logo_red [i];
692 g = (unsigned char)linux_logo_green[i];
693 b = (unsigned char)linux_logo_blue [i];
694 video_set_lut (LINUX_LOGO_LUT_OFFSET + i, r, g, b);
700 xcount = LINUX_LOGO_WIDTH;
703 r = (unsigned char)linux_logo_red [*source - LINUX_LOGO_LUT_OFFSET];
704 g = (unsigned char)linux_logo_green[*source - LINUX_LOGO_LUT_OFFSET];
705 b = (unsigned char)linux_logo_blue [*source - LINUX_LOGO_LUT_OFFSET];
707 switch (VIDEO_DATA_FORMAT)
709 case GDF__8BIT_INDEX:
712 case GDF__8BIT_332RGB:
713 *dest = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6);
715 case GDF_15BIT_555RGB:
716 *(unsigned short *)dest =
717 SWAP16((unsigned short)(((r>>3)<<10) | ((g>>3)<<5) | (b>>3)));
719 case GDF_16BIT_565RGB:
720 *(unsigned short *)dest =
721 SWAP16((unsigned short)(((r>>3)<<11) | ((g>>2)<<5) | (b>>3)));
723 case GDF_32BIT_X888RGB:
724 *(unsigned long *)dest =
725 SWAP32((unsigned long)((r<<16) | (g<<8) | b));
727 case GDF_24BIT_888RGB:
728 #ifdef VIDEO_FB_LITTLE_ENDIAN
740 dest += VIDEO_PIXEL_SIZE;
747 /*****************************************************************************/
749 static void *video_logo (void)
753 logo_plot (video_fb_address, VIDEO_COLS, 0, 0);
755 sprintf(info, " %s (%s - %s)", U_BOOT_VERSION, __DATE__, __TIME__);
756 video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info);
758 #ifdef CONFIG_CONSOLE_EXTRA_INFO
760 int i, n = ((VIDEO_LOGO_HEIGHT-VIDEO_FONT_HEIGHT)/VIDEO_FONT_HEIGHT);
762 for (i = 1; i < n; i++)
764 video_get_info_str (i, info);
766 video_drawstring (VIDEO_INFO_X,
767 VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT, info);
772 return (video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN);
777 /*****************************************************************************/
779 static int video_init(void)
781 unsigned char color8;
783 if ((pGD=video_hw_init()) == NULL)
786 video_fb_address = (void*)VIDEO_FB_ADRS;
787 #ifdef CONFIG_VIDEO_HW_CURSOR
788 video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
791 /* Init drawing pats */
792 switch (VIDEO_DATA_FORMAT)
794 case GDF__8BIT_INDEX:
795 video_set_lut (0x01, CONSOLE_FG_COL, CONSOLE_FG_COL, CONSOLE_FG_COL);
796 video_set_lut (0x00, CONSOLE_BG_COL, CONSOLE_BG_COL, CONSOLE_BG_COL);
800 case GDF__8BIT_332RGB:
801 color8 = ((CONSOLE_FG_COL & 0xe0) | ((CONSOLE_FG_COL>>3) & 0x1c) | CONSOLE_FG_COL>>6);
802 fgx = (color8<<24) | (color8<<16) | (color8<<8) | color8;
803 color8 = ((CONSOLE_BG_COL & 0xe0) | ((CONSOLE_BG_COL>>3) & 0x1c) | CONSOLE_BG_COL>>6);
804 bgx = (color8<<24) | (color8<<16) | (color8<<8) | color8;
806 case GDF_15BIT_555RGB:
807 fgx = (((CONSOLE_FG_COL>>3)<<26) | ((CONSOLE_FG_COL>>3)<<21) | ((CONSOLE_FG_COL>>3)<<16) |
808 ((CONSOLE_FG_COL>>3)<<10) | ((CONSOLE_FG_COL>>3)<<5) | (CONSOLE_FG_COL>>3));
809 bgx = (((CONSOLE_BG_COL>>3)<<26) | ((CONSOLE_BG_COL>>3)<<21) | ((CONSOLE_BG_COL>>3)<<16) |
810 ((CONSOLE_BG_COL>>3)<<10) | ((CONSOLE_BG_COL>>3)<<5) | (CONSOLE_BG_COL>>3));
812 case GDF_16BIT_565RGB:
813 fgx = (((CONSOLE_FG_COL>>3)<<27) | ((CONSOLE_FG_COL>>2)<<21) | ((CONSOLE_FG_COL>>3)<<16) |
814 ((CONSOLE_FG_COL>>3)<<11) | ((CONSOLE_FG_COL>>2)<<5) | (CONSOLE_FG_COL>>3));
815 bgx = (((CONSOLE_BG_COL>>3)<<27) | ((CONSOLE_BG_COL>>2)<<21) | ((CONSOLE_BG_COL>>3)<<16) |
816 ((CONSOLE_BG_COL>>3)<<11) | ((CONSOLE_BG_COL>>2)<<5) | (CONSOLE_BG_COL>>3));
818 case GDF_32BIT_X888RGB:
819 fgx = (CONSOLE_FG_COL<<16) | (CONSOLE_FG_COL<<8) | CONSOLE_FG_COL;
820 bgx = (CONSOLE_BG_COL<<16) | (CONSOLE_BG_COL<<8) | CONSOLE_BG_COL;
822 case GDF_24BIT_888RGB:
823 fgx = (CONSOLE_FG_COL<<24) | (CONSOLE_FG_COL<<16) | (CONSOLE_FG_COL<<8) | CONSOLE_FG_COL;
824 bgx = (CONSOLE_BG_COL<<24) | (CONSOLE_BG_COL<<16) | (CONSOLE_BG_COL<<8) | CONSOLE_BG_COL;
829 #ifdef CONFIG_VIDEO_LOGO
830 /* Plot the logo and get start point of console */
831 PRINTD("Video: Drawing the logo ...\n");
832 video_console_address = video_logo();
834 video_console_address = video_fb_address;
837 /* Initialize the console */
845 /*****************************************************************************/
847 int drv_video_init (void)
850 device_t console_dev;
855 /* Force console i/o to serial ? */
856 if ((penv = getenv ("console")) != NULL)
857 if (strcmp (penv, "serial") == 0)
860 /* Init video chip - returns with framebuffer cleared */
861 if (video_init() == -1)
863 #ifdef CONFIG_VGA_AS_SINGLE_DEVICE
864 /* Devices VGA and Keyboard will be assigned seperately */
865 /* Init vga device */
868 memset (&console_dev, 0, sizeof(console_dev));
869 strcpy(console_dev.name, "vga");
870 console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
871 console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
872 console_dev.putc = video_putc; /* 'putc' function */
873 console_dev.puts = video_puts; /* 'puts' function */
874 console_dev.tstc = NULL; /* 'tstc' function */
875 console_dev.getc = NULL; /* 'getc' function */
877 if (device_register (&console_dev) == 0)
881 PRINTD("KBD: Keyboard init ...\n");
882 if (VIDEO_KBD_INIT_FCT == -1)
885 /* Init console device */
888 memset (&console_dev, 0, sizeof(console_dev));
889 strcpy(console_dev.name, "console");
890 console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
891 console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
892 console_dev.putc = video_putc; /* 'putc' function */
893 console_dev.puts = video_puts; /* 'puts' function */
894 console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
895 console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
897 if (device_register (&console_dev) == 0)
900 #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
901 /* No console dev available */
905 #endif /* CONFIG_CFB_CONSOLE */