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