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