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