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