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