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_VIDEO_BMP_LOGO - use bmp_logo instead of linux_logo
69 CONFIG_CONSOLE_EXTRA_INFO - display additional board information strings
70 that normaly goes to serial port. This define
71 requires a board specific function:
72 video_drawstring (VIDEO_INFO_X,
73 VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT,
75 that fills a info buffer at i=row.
76 s.a: board/eltec/bab7xx.
77 CONFIG_VGA_AS_SINGLE_DEVICE - If set the framebuffer device will be initialised
78 as an output only device. The Keyboard driver
79 will not be set-up. This may be used, if you
80 have none or more than one Keyboard devices
81 (USB Keyboard, AT Keyboard).
83 CONFIG_VIDEO_SW_CURSOR: - Draws a cursor after the last character. No
84 blinking is provided. Uses the macros CURSOR_SET
86 CONFIG_VIDEO_HW_CURSOR: - Uses the hardware cursor capability of the
87 graphic chip. Uses the macro CURSOR_SET.
88 ATTENTION: If booting an OS, the display driver
89 must disable the hardware register of the graphic
90 chip. Otherwise a blinking field is displayed
95 #ifdef CONFIG_CFB_CONSOLE
99 /*****************************************************************************/
100 /* Console device defines with SMI graphic */
101 /* Any other graphic must change this section */
102 /*****************************************************************************/
104 #ifdef CONFIG_VIDEO_SMI_LYNXEM
106 #define VIDEO_FB_LITTLE_ENDIAN
107 #define VIDEO_HW_RECTFILL
108 #define VIDEO_HW_BITBLT
111 /*****************************************************************************/
112 /* Defines for the CT69000 driver */
113 /*****************************************************************************/
114 #ifdef CONFIG_VIDEO_CT69000
116 #define VIDEO_FB_LITTLE_ENDIAN
117 #define VIDEO_HW_RECTFILL
118 #define VIDEO_HW_BITBLT
121 /*****************************************************************************/
122 /* Defines for the SED13806 driver */
123 /*****************************************************************************/
124 #ifdef CONFIG_VIDEO_SED13806
126 #define VIDEO_FB_LITTLE_ENDIAN
127 #define VIDEO_HW_RECTFILL
128 #define VIDEO_HW_BITBLT
131 /*****************************************************************************/
132 /* Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc */
133 /*****************************************************************************/
134 #include <video_fb.h>
136 /*****************************************************************************/
138 /*****************************************************************************/
139 #define VIDEO_VISIBLE_COLS (pGD->winSizeX)
140 #define VIDEO_VISIBLE_ROWS (pGD->winSizeY)
141 #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP)
142 #define VIDEO_DATA_FORMAT (pGD->gdfIndex)
143 #define VIDEO_FB_ADRS (pGD->frameAdrs)
145 /*****************************************************************************/
146 /* Console device defines with i8042 keyboard controller */
147 /* Any other keyboard controller must change this section */
148 /*****************************************************************************/
150 #ifdef CONFIG_I8042_KBD
153 #define VIDEO_KBD_INIT_FCT i8042_kbd_init()
154 #define VIDEO_TSTC_FCT i8042_tstc
155 #define VIDEO_GETC_FCT i8042_getc
158 /*****************************************************************************/
160 /*****************************************************************************/
163 #include <linux/types.h>
165 #include <video_font.h>
171 /*****************************************************************************/
172 /* Cursor definition: */
173 /* CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/i8042.c) to */
174 /* let the cursor blink. Uses the macros CURSOR_OFF */
176 /* CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No */
177 /* blinking is provided. Uses the macros CURSOR_SET */
178 /* and CURSOR_OFF. */
179 /* CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the */
180 /* graphic chip. Uses the macro CURSOR_SET. */
181 /* ATTENTION: If booting an OS, the display driver */
182 /* must disable the hardware register of the graphic */
183 /* chip. Otherwise a blinking field is displayed */
184 /*****************************************************************************/
185 #if !defined(CONFIG_CONSOLE_CURSOR) && \
186 !defined(CONFIG_VIDEO_SW_CURSOR) && \
187 !defined(CONFIG_VIDEO_HW_CURSOR)
188 /* no Cursor defined */
194 #ifdef CONFIG_CONSOLE_CURSOR
196 #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
198 void console_cursor (int state);
199 #define CURSOR_ON console_cursor(1);
200 #define CURSOR_OFF console_cursor(0);
202 #ifndef CONFIG_I8042_KBD
203 #warning Cursor drawing on/off needs timer function s.a. drivers/i8042.c
206 #ifdef CONFIG_CONSOLE_TIME
207 #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
209 #endif /* CONFIG_CONSOLE_CURSOR */
211 #ifdef CONFIG_VIDEO_SW_CURSOR
213 #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
216 #define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
217 console_row * VIDEO_FONT_HEIGHT, ' ');
218 #define CURSOR_SET video_set_cursor();
219 #endif /* CONFIG_VIDEO_SW_CURSOR */
222 #ifdef CONFIG_VIDEO_HW_CURSOR
224 #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
228 #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \
229 (console_row * VIDEO_FONT_HEIGHT) + VIDEO_LOGO_HEIGHT);
230 #endif /* CONFIG_VIDEO_HW_CURSOR */
232 #ifdef CONFIG_VIDEO_LOGO
233 #ifdef CONFIG_VIDEO_BMP_LOGO
234 #include <bmp_logo.h>
235 #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH
236 #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT
237 #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET
238 #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS
240 #else /* CONFIG_VIDEO_BMP_LOGO */
241 #define LINUX_LOGO_WIDTH 80
242 #define LINUX_LOGO_HEIGHT 80
243 #define LINUX_LOGO_COLORS 214
244 #define LINUX_LOGO_LUT_OFFSET 0x20
246 #include <linux_logo.h>
247 #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH
248 #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT
249 #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET
250 #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS
251 #endif /* CONFIG_VIDEO_BMP_LOGO */
252 #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH)
253 #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2)
254 #else /* CONFIG_VIDEO_LOGO */
255 #define VIDEO_LOGO_WIDTH 0
256 #define VIDEO_LOGO_HEIGHT 0
257 #endif /* CONFIG_VIDEO_LOGO */
259 #define VIDEO_COLS VIDEO_VISIBLE_COLS
260 #define VIDEO_ROWS VIDEO_VISIBLE_ROWS
261 #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
262 #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2)
263 #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE)
264 #define VIDEO_BURST_LEN (VIDEO_COLS/8)
266 #ifdef CONFIG_VIDEO_LOGO
267 #define CONSOLE_ROWS ((VIDEO_ROWS - VIDEO_LOGO_HEIGHT) / VIDEO_FONT_HEIGHT)
269 #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT)
272 #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH)
273 #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN)
274 #define CONSOLE_ROW_FIRST (video_console_address)
275 #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE)
276 #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
277 #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
278 #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
281 #ifdef VIDEO_FB_LITTLE_ENDIAN
282 #define SWAP16(x) ((((x) & 0x00ff) << 8) | ( (x) >> 8))
283 #define SWAP32(x) ((((x) & 0x000000ff) << 24) | (((x) & 0x0000ff00) << 8)|\
284 (((x) & 0x00ff0000) >> 8) | (((x) & 0xff000000) >> 24) )
285 #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | (((x) & 0x0000ff00) >> 8)|\
286 (((x) & 0x00ff0000) << 8) | (((x) & 0xff000000) >> 8) )
288 #define SWAP16(x) (x)
289 #define SWAP32(x) (x)
290 #define SHORTSWAP32(x) (x)
293 #if defined(DEBUG) || defined(DEBUG_CFB_CONSOLE)
294 #define PRINTD(x) printf(x)
300 #ifdef CONFIG_CONSOLE_EXTRA_INFO
301 extern void video_get_info_str ( /* setup a board string: type, speed, etc. */
302 int line_number, /* location to place info string beside logo */
303 char *info /* buffer for info string */
309 static GraphicDevice *pGD; /* Pointer to Graphic array */
311 static void *video_fb_address; /* frame buffer address */
312 static void *video_console_address; /* console buffer start address */
314 static int console_col = 0; /* cursor col */
315 static int console_row = 0; /* cursor row */
317 static u32 eorx, fgx, bgx; /* color pats */
319 static const int video_font_draw_table8[] = {
320 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
321 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
322 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
323 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff };
325 static const int video_font_draw_table15[] = {
326 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff };
328 static const int video_font_draw_table16[] = {
329 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff };
331 static const int video_font_draw_table24[16][3] = {
332 { 0x00000000, 0x00000000, 0x00000000 },
333 { 0x00000000, 0x00000000, 0x00ffffff },
334 { 0x00000000, 0x0000ffff, 0xff000000 },
335 { 0x00000000, 0x0000ffff, 0xffffffff },
336 { 0x000000ff, 0xffff0000, 0x00000000 },
337 { 0x000000ff, 0xffff0000, 0x00ffffff },
338 { 0x000000ff, 0xffffffff, 0xff000000 },
339 { 0x000000ff, 0xffffffff, 0xffffffff },
340 { 0xffffff00, 0x00000000, 0x00000000 },
341 { 0xffffff00, 0x00000000, 0x00ffffff },
342 { 0xffffff00, 0x0000ffff, 0xff000000 },
343 { 0xffffff00, 0x0000ffff, 0xffffffff },
344 { 0xffffffff, 0xffff0000, 0x00000000 },
345 { 0xffffffff, 0xffff0000, 0x00ffffff },
346 { 0xffffffff, 0xffffffff, 0xff000000 },
347 { 0xffffffff, 0xffffffff, 0xffffffff } };
349 static const int video_font_draw_table32[16][4] = {
350 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
351 { 0x00000000, 0x00000000, 0x00000000, 0x00ffffff },
352 { 0x00000000, 0x00000000, 0x00ffffff, 0x00000000 },
353 { 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff },
354 { 0x00000000, 0x00ffffff, 0x00000000, 0x00000000 },
355 { 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff },
356 { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000 },
357 { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff },
358 { 0x00ffffff, 0x00000000, 0x00000000, 0x00000000 },
359 { 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff },
360 { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000 },
361 { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff },
362 { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000 },
363 { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff },
364 { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000 },
365 { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff } };
368 /******************************************************************************/
371 static void video_drawchars (int xx, int yy, unsigned char *s, int count)
373 u8 *cdat, *dest, *dest0;
376 offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE;
377 dest0 = video_fb_address + offset;
379 switch (VIDEO_DATA_FORMAT)
381 case GDF__8BIT_INDEX:
382 case GDF__8BIT_332RGB:
386 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
387 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
390 ((u32 *)dest)[0] = (video_font_draw_table8[bits >> 4] & eorx) ^ bgx;
391 ((u32 *)dest)[1] = (video_font_draw_table8[bits & 15] & eorx) ^ bgx;
393 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
398 case GDF_15BIT_555RGB:
402 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
403 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
406 ((u32 *)dest)[0] = SHORTSWAP32((video_font_draw_table15[bits >> 6] & eorx) ^ bgx);
407 ((u32 *)dest)[1] = SHORTSWAP32((video_font_draw_table15[bits >> 4 & 3] & eorx) ^ bgx);
408 ((u32 *)dest)[2] = SHORTSWAP32((video_font_draw_table15[bits >> 2 & 3] & eorx) ^ bgx);
409 ((u32 *)dest)[3] = SHORTSWAP32((video_font_draw_table15[bits & 3] & eorx) ^ bgx);
411 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
416 case GDF_16BIT_565RGB:
420 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
421 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
424 ((u32 *)dest)[0] = SHORTSWAP32((video_font_draw_table16[bits >> 6] & eorx) ^ bgx);
425 ((u32 *)dest)[1] = SHORTSWAP32((video_font_draw_table16[bits >> 4 & 3] & eorx) ^ bgx);
426 ((u32 *)dest)[2] = SHORTSWAP32((video_font_draw_table16[bits >> 2 & 3] & eorx) ^ bgx);
427 ((u32 *)dest)[3] = SHORTSWAP32((video_font_draw_table16[bits & 3] & eorx) ^ bgx);
429 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
434 case GDF_32BIT_X888RGB:
438 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
439 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
442 ((u32 *)dest)[0] = SWAP32((video_font_draw_table32[bits >> 4][0] & eorx) ^ bgx);
443 ((u32 *)dest)[1] = SWAP32((video_font_draw_table32[bits >> 4][1] & eorx) ^ bgx);
444 ((u32 *)dest)[2] = SWAP32((video_font_draw_table32[bits >> 4][2] & eorx) ^ bgx);
445 ((u32 *)dest)[3] = SWAP32((video_font_draw_table32[bits >> 4][3] & eorx) ^ bgx);
446 ((u32 *)dest)[4] = SWAP32((video_font_draw_table32[bits & 15][0] & eorx) ^ bgx);
447 ((u32 *)dest)[5] = SWAP32((video_font_draw_table32[bits & 15][1] & eorx) ^ bgx);
448 ((u32 *)dest)[6] = SWAP32((video_font_draw_table32[bits & 15][2] & eorx) ^ bgx);
449 ((u32 *)dest)[7] = SWAP32((video_font_draw_table32[bits & 15][3] & eorx) ^ bgx);
451 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
456 case GDF_24BIT_888RGB:
460 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
461 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; dest += VIDEO_LINE_LEN)
464 ((u32 *)dest)[0] = (video_font_draw_table24[bits >> 4][0] & eorx) ^ bgx;
465 ((u32 *)dest)[1] = (video_font_draw_table24[bits >> 4][1] & eorx) ^ bgx;
466 ((u32 *)dest)[2] = (video_font_draw_table24[bits >> 4][2] & eorx) ^ bgx;
467 ((u32 *)dest)[3] = (video_font_draw_table24[bits & 15][0] & eorx) ^ bgx;
468 ((u32 *)dest)[4] = (video_font_draw_table24[bits & 15][1] & eorx) ^ bgx;
469 ((u32 *)dest)[5] = (video_font_draw_table24[bits & 15][2] & eorx) ^ bgx;
471 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
478 /*****************************************************************************/
480 static inline void video_drawstring(int xx, int yy, unsigned char *s)
482 video_drawchars (xx, yy, s, strlen(s));
485 /*****************************************************************************/
487 static void video_putchar(int xx, int yy, unsigned char c)
489 video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1);
492 /*****************************************************************************/
493 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
494 static void video_set_cursor(void)
496 /* swap drawing colors */
502 video_putchar (console_col * VIDEO_FONT_WIDTH,
503 console_row * VIDEO_FONT_HEIGHT, ' ');
504 /* restore drawing colors */
511 /*****************************************************************************/
512 #ifdef CONFIG_CONSOLE_CURSOR
513 void console_cursor (int state)
515 static int last_state = 0;
516 #ifdef CONFIG_CONSOLE_TIME
520 /* time update only if cursor is on (faster scroll) */
525 sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min, tm.tm_sec);
526 video_drawstring(VIDEO_VISIBLE_COLS-10*VIDEO_FONT_WIDTH,
529 sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon, tm.tm_year);
530 video_drawstring(VIDEO_VISIBLE_COLS-10*VIDEO_FONT_WIDTH,
531 VIDEO_INFO_Y+1*VIDEO_FONT_HEIGHT, info);
535 if (state && (last_state != state))
540 if (!state && (last_state != state))
543 video_putchar (console_col * VIDEO_FONT_WIDTH,
544 console_row * VIDEO_FONT_HEIGHT, ' ');
551 /*****************************************************************************/
553 #ifndef VIDEO_HW_RECTFILL
554 static void memsetl (int *p, int c, int v)
561 /*****************************************************************************/
563 #ifndef VIDEO_HW_BITBLT
564 static void memcpyl (int *d, int *s, int c)
571 /*****************************************************************************/
573 static void console_scrollup (void)
575 /* copy up rows ignoring the first one */
577 #ifdef VIDEO_HW_BITBLT
579 VIDEO_PIXEL_SIZE, /* bytes per pixel */
580 0, /* source pos x */
581 VIDEO_LOGO_HEIGHT + VIDEO_FONT_HEIGHT, /* source pos y */
583 VIDEO_LOGO_HEIGHT, /* dest pos y */
584 VIDEO_VISIBLE_COLS, /* frame width */
585 VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT - VIDEO_FONT_HEIGHT /* frame height */
588 memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE >> 2);
591 /* clear the last one */
592 #ifdef VIDEO_HW_RECTFILL
594 VIDEO_PIXEL_SIZE, /* bytes per pixel */
596 VIDEO_VISIBLE_ROWS - VIDEO_FONT_HEIGHT, /* dest pos y */
597 VIDEO_VISIBLE_COLS, /* frame width */
598 VIDEO_FONT_HEIGHT, /* frame height */
599 CONSOLE_BG_COL /* fill color */
602 memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
606 /*****************************************************************************/
608 static void console_back (void)
615 console_col = CONSOLE_COLS - 1;
620 video_putchar (console_col * VIDEO_FONT_WIDTH,
621 console_row * VIDEO_FONT_HEIGHT, ' ');
624 /*****************************************************************************/
626 static void console_newline (void)
632 /* Check if we need to scroll the terminal */
633 if (console_row >= CONSOLE_ROWS)
635 /* Scroll everything up */
638 /* Decrement row number */
643 /*****************************************************************************/
645 void video_putc (const char c)
649 case 13: /* ignore */
652 case '\n': /* next line */
658 console_col |= 0x0008;
659 console_col &= ~0x0007;
661 if (console_col >= CONSOLE_COLS)
665 case 8: /* backspace */
669 default: /* draw the char */
670 video_putchar (console_col * VIDEO_FONT_WIDTH,
671 console_row * VIDEO_FONT_HEIGHT, c);
674 /* check for newline */
675 if (console_col >= CONSOLE_COLS)
682 /*****************************************************************************/
684 void video_puts (const char *s)
686 int count = strlen(s);
692 /*****************************************************************************/
694 #ifdef CONFIG_VIDEO_LOGO
695 void logo_plot (void *screen, int width, int x, int y)
698 int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE,
700 ycount = VIDEO_LOGO_HEIGHT;
703 *dest = (unsigned char *) screen + ((y * width * VIDEO_PIXEL_SIZE) + x),
704 r, g, b, *logo_red, *logo_blue, *logo_green;
706 #ifdef CONFIG_VIDEO_BMP_LOGO
707 source = bmp_logo_bitmap;
709 /* Allocate temporary space for computing colormap */
710 logo_red = malloc (BMP_LOGO_COLORS);
711 logo_green = malloc (BMP_LOGO_COLORS);
712 logo_blue = malloc (BMP_LOGO_COLORS);
713 /* Compute color map */
714 for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
715 logo_red [i] = (bmp_logo_palette [i] & 0x0f00) >> 4;
716 logo_green [i] = (bmp_logo_palette [i] & 0x00f0);
717 logo_blue [i] = (bmp_logo_palette [i] & 0x000f) << 4;
721 logo_red = linux_logo_red;
722 logo_green = linux_logo_green;
723 logo_blue = linux_logo_blue;
726 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX)
728 for (i = 0; i < VIDEO_LOGO_COLORS; i++)
730 video_set_lut (i + VIDEO_LOGO_LUT_OFFSET,
731 logo_red [i], logo_green [i], logo_blue [i]);
737 xcount = VIDEO_LOGO_WIDTH;
740 r = logo_red [*source - VIDEO_LOGO_LUT_OFFSET];
741 g = logo_green [*source - VIDEO_LOGO_LUT_OFFSET];
742 b = logo_blue [*source - VIDEO_LOGO_LUT_OFFSET];
744 switch (VIDEO_DATA_FORMAT)
746 case GDF__8BIT_INDEX:
749 case GDF__8BIT_332RGB:
750 *dest = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6);
752 case GDF_15BIT_555RGB:
753 *(unsigned short *)dest =
754 SWAP16((unsigned short)(((r>>3)<<10) | ((g>>3)<<5) | (b>>3)));
756 case GDF_16BIT_565RGB:
757 *(unsigned short *)dest =
758 SWAP16((unsigned short)(((r>>3)<<11) | ((g>>2)<<5) | (b>>3)));
760 case GDF_32BIT_X888RGB:
761 *(unsigned long *)dest =
762 SWAP32((unsigned long)((r<<16) | (g<<8) | b));
764 case GDF_24BIT_888RGB:
765 #ifdef VIDEO_FB_LITTLE_ENDIAN
777 dest += VIDEO_PIXEL_SIZE;
781 #ifdef CONFIG_VIDEO_BMP_LOGO
788 /*****************************************************************************/
790 static void *video_logo (void)
793 extern char version_string;
795 logo_plot (video_fb_address, VIDEO_COLS, 0, 0);
797 sprintf(info, " %s", &version_string);
798 video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info);
800 #ifdef CONFIG_CONSOLE_EXTRA_INFO
802 int i, n = ((VIDEO_LOGO_HEIGHT-VIDEO_FONT_HEIGHT)/VIDEO_FONT_HEIGHT);
804 for (i = 1; i < n; i++)
806 video_get_info_str (i, info);
808 video_drawstring (VIDEO_INFO_X,
809 VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT, info);
814 return (video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN);
819 /*****************************************************************************/
821 static int video_init(void)
823 unsigned char color8;
825 if ((pGD=video_hw_init()) == NULL)
828 video_fb_address = (void*)VIDEO_FB_ADRS;
829 #ifdef CONFIG_VIDEO_HW_CURSOR
830 video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
833 /* Init drawing pats */
834 switch (VIDEO_DATA_FORMAT)
836 case GDF__8BIT_INDEX:
837 video_set_lut (0x01, CONSOLE_FG_COL, CONSOLE_FG_COL, CONSOLE_FG_COL);
838 video_set_lut (0x00, CONSOLE_BG_COL, CONSOLE_BG_COL, CONSOLE_BG_COL);
842 case GDF__8BIT_332RGB:
843 color8 = ((CONSOLE_FG_COL & 0xe0) | ((CONSOLE_FG_COL>>3) & 0x1c) | CONSOLE_FG_COL>>6);
844 fgx = (color8<<24) | (color8<<16) | (color8<<8) | color8;
845 color8 = ((CONSOLE_BG_COL & 0xe0) | ((CONSOLE_BG_COL>>3) & 0x1c) | CONSOLE_BG_COL>>6);
846 bgx = (color8<<24) | (color8<<16) | (color8<<8) | color8;
848 case GDF_15BIT_555RGB:
849 fgx = (((CONSOLE_FG_COL>>3)<<26) | ((CONSOLE_FG_COL>>3)<<21) | ((CONSOLE_FG_COL>>3)<<16) |
850 ((CONSOLE_FG_COL>>3)<<10) | ((CONSOLE_FG_COL>>3)<<5) | (CONSOLE_FG_COL>>3));
851 bgx = (((CONSOLE_BG_COL>>3)<<26) | ((CONSOLE_BG_COL>>3)<<21) | ((CONSOLE_BG_COL>>3)<<16) |
852 ((CONSOLE_BG_COL>>3)<<10) | ((CONSOLE_BG_COL>>3)<<5) | (CONSOLE_BG_COL>>3));
854 case GDF_16BIT_565RGB:
855 fgx = (((CONSOLE_FG_COL>>3)<<27) | ((CONSOLE_FG_COL>>2)<<21) | ((CONSOLE_FG_COL>>3)<<16) |
856 ((CONSOLE_FG_COL>>3)<<11) | ((CONSOLE_FG_COL>>2)<<5) | (CONSOLE_FG_COL>>3));
857 bgx = (((CONSOLE_BG_COL>>3)<<27) | ((CONSOLE_BG_COL>>2)<<21) | ((CONSOLE_BG_COL>>3)<<16) |
858 ((CONSOLE_BG_COL>>3)<<11) | ((CONSOLE_BG_COL>>2)<<5) | (CONSOLE_BG_COL>>3));
860 case GDF_32BIT_X888RGB:
861 fgx = (CONSOLE_FG_COL<<16) | (CONSOLE_FG_COL<<8) | CONSOLE_FG_COL;
862 bgx = (CONSOLE_BG_COL<<16) | (CONSOLE_BG_COL<<8) | CONSOLE_BG_COL;
864 case GDF_24BIT_888RGB:
865 fgx = (CONSOLE_FG_COL<<24) | (CONSOLE_FG_COL<<16) | (CONSOLE_FG_COL<<8) | CONSOLE_FG_COL;
866 bgx = (CONSOLE_BG_COL<<24) | (CONSOLE_BG_COL<<16) | (CONSOLE_BG_COL<<8) | CONSOLE_BG_COL;
871 #ifdef CONFIG_VIDEO_LOGO
872 /* Plot the logo and get start point of console */
873 PRINTD("Video: Drawing the logo ...\n");
874 video_console_address = video_logo();
876 video_console_address = video_fb_address;
879 /* Initialize the console */
887 /*****************************************************************************/
889 int drv_video_init (void)
892 device_t console_dev;
897 /* Force console i/o to serial ? */
898 if ((penv = getenv ("console")) != NULL)
899 if (strcmp (penv, "serial") == 0)
902 /* Init video chip - returns with framebuffer cleared */
903 if (video_init() == -1)
905 #ifdef CONFIG_VGA_AS_SINGLE_DEVICE
906 /* Devices VGA and Keyboard will be assigned seperately */
907 /* Init vga device */
910 memset (&console_dev, 0, sizeof(console_dev));
911 strcpy(console_dev.name, "vga");
912 console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
913 console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
914 console_dev.putc = video_putc; /* 'putc' function */
915 console_dev.puts = video_puts; /* 'puts' function */
916 console_dev.tstc = NULL; /* 'tstc' function */
917 console_dev.getc = NULL; /* 'getc' function */
919 if (device_register (&console_dev) == 0)
923 PRINTD("KBD: Keyboard init ...\n");
924 if (VIDEO_KBD_INIT_FCT == -1)
927 /* Init console device */
930 memset (&console_dev, 0, sizeof(console_dev));
931 strcpy(console_dev.name, "console");
932 console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
933 console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
934 console_dev.putc = video_putc; /* 'putc' function */
935 console_dev.puts = video_puts; /* 'puts' function */
936 console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
937 console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
939 if (device_register (&console_dev) == 0)
942 #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
943 /* No console dev available */
947 #endif /* CONFIG_CFB_CONSOLE */