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 | |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 154 | #ifdef CONFIG_VIDEO_MXS |
| 155 | #define VIDEO_FB_16BPP_WORD_SWAP |
| 156 | #endif |
| 157 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 158 | /* |
| 159 | * Defines for the MB862xx driver |
| 160 | */ |
Anatolij Gustschin | bed5375 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 161 | #ifdef CONFIG_VIDEO_MB862xx |
| 162 | |
| 163 | #ifdef CONFIG_VIDEO_CORALP |
| 164 | #define VIDEO_FB_LITTLE_ENDIAN |
| 165 | #endif |
Anatolij Gustschin | 5d16ca8 | 2009-10-23 12:03:14 +0200 | [diff] [blame] | 166 | #ifdef CONFIG_VIDEO_MB862xx_ACCEL |
Anatolij Gustschin | bed5375 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 167 | #define VIDEO_HW_RECTFILL |
| 168 | #define VIDEO_HW_BITBLT |
| 169 | #endif |
Anatolij Gustschin | 5d16ca8 | 2009-10-23 12:03:14 +0200 | [diff] [blame] | 170 | #endif |
Anatolij Gustschin | bed5375 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 171 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 172 | /* |
Helmut Raiger | 62a22dc | 2011-10-12 23:16:29 +0000 | [diff] [blame] | 173 | * Defines for the i.MX31 driver (mx3fb.c) |
| 174 | */ |
Fabio Estevam | 695af9a | 2012-05-31 07:23:56 +0000 | [diff] [blame] | 175 | #if defined(CONFIG_VIDEO_MX3) || defined(CONFIG_VIDEO_IPUV3) |
Helmut Raiger | 62a22dc | 2011-10-12 23:16:29 +0000 | [diff] [blame] | 176 | #define VIDEO_FB_16BPP_WORD_SWAP |
| 177 | #endif |
| 178 | |
| 179 | /* |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 180 | * Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc. |
| 181 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 182 | #include <video_fb.h> |
| 183 | |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame^] | 184 | #include <splash.h> |
| 185 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 186 | /* |
| 187 | * some Macros |
| 188 | */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 189 | #define VIDEO_VISIBLE_COLS (pGD->winSizeX) |
| 190 | #define VIDEO_VISIBLE_ROWS (pGD->winSizeY) |
| 191 | #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP) |
| 192 | #define VIDEO_DATA_FORMAT (pGD->gdfIndex) |
| 193 | #define VIDEO_FB_ADRS (pGD->frameAdrs) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 194 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 195 | /* |
| 196 | * Console device defines with i8042 keyboard controller |
| 197 | * Any other keyboard controller must change this section |
| 198 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 199 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 200 | #ifdef CONFIG_I8042_KBD |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 201 | #include <i8042.h> |
| 202 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 203 | #define VIDEO_KBD_INIT_FCT i8042_kbd_init() |
| 204 | #define VIDEO_TSTC_FCT i8042_tstc |
| 205 | #define VIDEO_GETC_FCT i8042_getc |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 206 | #endif |
| 207 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 208 | /* |
| 209 | * Console device |
| 210 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 211 | |
| 212 | #include <version.h> |
| 213 | #include <linux/types.h> |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 214 | #include <stdio_dev.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 215 | #include <video_font.h> |
Che-Liang Chiou | d3983ee | 2011-10-21 17:04:21 +0800 | [diff] [blame] | 216 | #include <video_font_data.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 217 | |
Jon Loeliger | ddb5d86f | 2007-07-10 11:13:21 -0500 | [diff] [blame] | 218 | #if defined(CONFIG_CMD_DATE) |
| 219 | #include <rtc.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 220 | #endif |
| 221 | |
Jon Loeliger | 07d38a1 | 2007-07-09 17:30:01 -0500 | [diff] [blame] | 222 | #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 223 | #include <watchdog.h> |
| 224 | #include <bmp_layout.h> |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 225 | |
| 226 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
| 227 | #define BMP_ALIGN_CENTER 0x7FFF |
| 228 | #endif |
| 229 | |
Jon Loeliger | 07d38a1 | 2007-07-09 17:30:01 -0500 | [diff] [blame] | 230 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 231 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 232 | /* |
| 233 | * Cursor definition: |
| 234 | * CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c) |
| 235 | * to let the cursor blink. Uses the macros |
| 236 | * CURSOR_OFF and CURSOR_ON. |
| 237 | * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No |
| 238 | * blinking is provided. Uses the macros CURSOR_SET |
| 239 | * and CURSOR_OFF. |
| 240 | * CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the |
| 241 | * graphic chip. Uses the macro CURSOR_SET. |
| 242 | * ATTENTION: If booting an OS, the display driver |
| 243 | * must disable the hardware register of the graphic |
| 244 | * chip. Otherwise a blinking field is displayed |
| 245 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 246 | #if !defined(CONFIG_CONSOLE_CURSOR) && \ |
| 247 | !defined(CONFIG_VIDEO_SW_CURSOR) && \ |
| 248 | !defined(CONFIG_VIDEO_HW_CURSOR) |
| 249 | /* no Cursor defined */ |
| 250 | #define CURSOR_ON |
| 251 | #define CURSOR_OFF |
| 252 | #define CURSOR_SET |
| 253 | #endif |
| 254 | |
Gabe Black | 03d31fc | 2011-11-30 13:50:50 +0000 | [diff] [blame] | 255 | #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR) |
| 256 | #if defined(CURSOR_ON) || \ |
| 257 | (defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR)) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 258 | #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \ |
| 259 | or CONFIG_VIDEO_HW_CURSOR can be defined |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 260 | #endif |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 261 | void console_cursor(int state); |
| 262 | |
Timur Tabi | 6561863 | 2010-08-27 15:45:47 -0500 | [diff] [blame] | 263 | #define CURSOR_ON console_cursor(1) |
| 264 | #define CURSOR_OFF console_cursor(0) |
Gabe Black | 03d31fc | 2011-11-30 13:50:50 +0000 | [diff] [blame] | 265 | #define CURSOR_SET video_set_cursor() |
| 266 | #endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */ |
| 267 | |
| 268 | #ifdef CONFIG_CONSOLE_CURSOR |
| 269 | #ifndef CONFIG_CONSOLE_TIME |
| 270 | #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME |
| 271 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 272 | #ifndef CONFIG_I8042_KBD |
Marcel Ziswiler | 7817cb2 | 2007-12-30 03:30:46 +0100 | [diff] [blame] | 273 | #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] | 274 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 275 | #endif /* CONFIG_CONSOLE_CURSOR */ |
| 276 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 277 | |
| 278 | #ifdef CONFIG_VIDEO_HW_CURSOR |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 279 | #ifdef CURSOR_ON |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 280 | #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \ |
| 281 | or CONFIG_VIDEO_HW_CURSOR can be defined |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 282 | #endif |
| 283 | #define CURSOR_ON |
| 284 | #define CURSOR_OFF |
| 285 | #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \ |
Timur Tabi | 6561863 | 2010-08-27 15:45:47 -0500 | [diff] [blame] | 286 | (console_row * VIDEO_FONT_HEIGHT) + video_logo_height) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 287 | #endif /* CONFIG_VIDEO_HW_CURSOR */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 288 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 289 | #ifdef CONFIG_VIDEO_LOGO |
| 290 | #ifdef CONFIG_VIDEO_BMP_LOGO |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 291 | #include <bmp_logo.h> |
Che-Liang Chiou | c270730 | 2011-10-20 23:04:20 +0000 | [diff] [blame] | 292 | #include <bmp_logo_data.h> |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 293 | #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH |
| 294 | #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT |
| 295 | #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET |
| 296 | #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 297 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 298 | #else /* CONFIG_VIDEO_BMP_LOGO */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 299 | #define LINUX_LOGO_WIDTH 80 |
| 300 | #define LINUX_LOGO_HEIGHT 80 |
| 301 | #define LINUX_LOGO_COLORS 214 |
| 302 | #define LINUX_LOGO_LUT_OFFSET 0x20 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 303 | #define __initdata |
| 304 | #include <linux_logo.h> |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 305 | #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH |
| 306 | #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT |
| 307 | #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET |
| 308 | #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 309 | #endif /* CONFIG_VIDEO_BMP_LOGO */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 310 | #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH) |
| 311 | #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 312 | #else /* CONFIG_VIDEO_LOGO */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 313 | #define VIDEO_LOGO_WIDTH 0 |
| 314 | #define VIDEO_LOGO_HEIGHT 0 |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 315 | #endif /* CONFIG_VIDEO_LOGO */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 316 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 317 | #define VIDEO_COLS VIDEO_VISIBLE_COLS |
| 318 | #define VIDEO_ROWS VIDEO_VISIBLE_ROWS |
| 319 | #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE) |
| 320 | #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2) |
| 321 | #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE) |
| 322 | #define VIDEO_BURST_LEN (VIDEO_COLS/8) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 323 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 324 | #ifdef CONFIG_VIDEO_LOGO |
Matthias Weisser | be129aa | 2010-01-12 12:06:31 +0100 | [diff] [blame] | 325 | #define CONSOLE_ROWS ((VIDEO_ROWS - video_logo_height) / VIDEO_FONT_HEIGHT) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 326 | #else |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 327 | #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 328 | #endif |
| 329 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 330 | #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH) |
| 331 | #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN) |
| 332 | #define CONSOLE_ROW_FIRST (video_console_address) |
| 333 | #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE) |
| 334 | #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
| 335 | #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) |
| 336 | #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 337 | |
| 338 | /* Macros */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 339 | #ifdef VIDEO_FB_LITTLE_ENDIAN |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 340 | #define SWAP16(x) ((((x) & 0x00ff) << 8) | \ |
| 341 | ((x) >> 8) \ |
| 342 | ) |
| 343 | #define SWAP32(x) ((((x) & 0x000000ff) << 24) | \ |
| 344 | (((x) & 0x0000ff00) << 8) | \ |
| 345 | (((x) & 0x00ff0000) >> 8) | \ |
| 346 | (((x) & 0xff000000) >> 24) \ |
| 347 | ) |
| 348 | #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | \ |
| 349 | (((x) & 0x0000ff00) >> 8) | \ |
| 350 | (((x) & 0x00ff0000) << 8) | \ |
| 351 | (((x) & 0xff000000) >> 8) \ |
| 352 | ) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 353 | #else |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 354 | #define SWAP16(x) (x) |
| 355 | #define SWAP32(x) (x) |
Wolfgang Grandegger | 229b6dc | 2009-10-23 12:03:15 +0200 | [diff] [blame] | 356 | #if defined(VIDEO_FB_16BPP_WORD_SWAP) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 357 | #define SHORTSWAP32(x) (((x) >> 16) | ((x) << 16)) |
Andrew Dyer | cc34780 | 2008-08-29 12:30:39 -0500 | [diff] [blame] | 358 | #else |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 359 | #define SHORTSWAP32(x) (x) |
Anatolij Gustschin | bed5375 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 360 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 361 | #endif |
| 362 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 363 | #ifdef CONFIG_CONSOLE_EXTRA_INFO |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 364 | /* |
| 365 | * setup a board string: type, speed, etc. |
| 366 | * |
| 367 | * line_number: location to place info string beside logo |
| 368 | * info: buffer for info string |
| 369 | */ |
| 370 | extern void video_get_info_str(int line_number, char *info); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 371 | #endif |
| 372 | |
Anatolij Gustschin | bfd4be8 | 2012-06-05 09:19:18 +0200 | [diff] [blame] | 373 | DECLARE_GLOBAL_DATA_PTR; |
| 374 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 375 | /* Locals */ |
| 376 | static GraphicDevice *pGD; /* Pointer to Graphic array */ |
| 377 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 378 | static void *video_fb_address; /* frame buffer address */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 379 | static void *video_console_address; /* console buffer start address */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 380 | |
Matthias Weisser | be129aa | 2010-01-12 12:06:31 +0100 | [diff] [blame] | 381 | static int video_logo_height = VIDEO_LOGO_HEIGHT; |
| 382 | |
Anatolij Gustschin | a45adde | 2011-12-07 03:58:10 +0000 | [diff] [blame] | 383 | static int __maybe_unused cursor_state; |
| 384 | static int __maybe_unused old_col; |
| 385 | static int __maybe_unused old_row; |
Gabe Black | 03d31fc | 2011-11-30 13:50:50 +0000 | [diff] [blame] | 386 | |
Wolfgang Denk | 5791293 | 2011-07-30 12:48:09 +0000 | [diff] [blame] | 387 | static int console_col; /* cursor col */ |
| 388 | static int console_row; /* cursor row */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 389 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 390 | static u32 eorx, fgx, bgx; /* color pats */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 391 | |
Anatolij Gustschin | bfd4be8 | 2012-06-05 09:19:18 +0200 | [diff] [blame] | 392 | static int cfb_do_flush_cache; |
| 393 | |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 394 | #ifdef CONFIG_CFB_CONSOLE_ANSI |
| 395 | static char ansi_buf[10]; |
| 396 | static int ansi_buf_size; |
| 397 | static int ansi_colors_need_revert; |
| 398 | static int ansi_cursor_hidden; |
| 399 | #endif |
| 400 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 401 | static const int video_font_draw_table8[] = { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 402 | 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, |
| 403 | 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, |
| 404 | 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, |
| 405 | 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff |
| 406 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 407 | |
| 408 | static const int video_font_draw_table15[] = { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 409 | 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff |
| 410 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 411 | |
| 412 | static const int video_font_draw_table16[] = { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 413 | 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff |
| 414 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 415 | |
| 416 | static const int video_font_draw_table24[16][3] = { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 417 | {0x00000000, 0x00000000, 0x00000000}, |
| 418 | {0x00000000, 0x00000000, 0x00ffffff}, |
| 419 | {0x00000000, 0x0000ffff, 0xff000000}, |
| 420 | {0x00000000, 0x0000ffff, 0xffffffff}, |
| 421 | {0x000000ff, 0xffff0000, 0x00000000}, |
| 422 | {0x000000ff, 0xffff0000, 0x00ffffff}, |
| 423 | {0x000000ff, 0xffffffff, 0xff000000}, |
| 424 | {0x000000ff, 0xffffffff, 0xffffffff}, |
| 425 | {0xffffff00, 0x00000000, 0x00000000}, |
| 426 | {0xffffff00, 0x00000000, 0x00ffffff}, |
| 427 | {0xffffff00, 0x0000ffff, 0xff000000}, |
| 428 | {0xffffff00, 0x0000ffff, 0xffffffff}, |
| 429 | {0xffffffff, 0xffff0000, 0x00000000}, |
| 430 | {0xffffffff, 0xffff0000, 0x00ffffff}, |
| 431 | {0xffffffff, 0xffffffff, 0xff000000}, |
| 432 | {0xffffffff, 0xffffffff, 0xffffffff} |
| 433 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 434 | |
| 435 | static const int video_font_draw_table32[16][4] = { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 436 | {0x00000000, 0x00000000, 0x00000000, 0x00000000}, |
| 437 | {0x00000000, 0x00000000, 0x00000000, 0x00ffffff}, |
| 438 | {0x00000000, 0x00000000, 0x00ffffff, 0x00000000}, |
| 439 | {0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff}, |
| 440 | {0x00000000, 0x00ffffff, 0x00000000, 0x00000000}, |
| 441 | {0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff}, |
| 442 | {0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000}, |
| 443 | {0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff}, |
| 444 | {0x00ffffff, 0x00000000, 0x00000000, 0x00000000}, |
| 445 | {0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff}, |
| 446 | {0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000}, |
| 447 | {0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff}, |
| 448 | {0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000}, |
| 449 | {0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff}, |
| 450 | {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000}, |
| 451 | {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff} |
| 452 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 453 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 454 | static void video_drawchars(int xx, int yy, unsigned char *s, int count) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 455 | { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 456 | u8 *cdat, *dest, *dest0; |
| 457 | int rows, offset, c; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 458 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 459 | offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE; |
| 460 | dest0 = video_fb_address + offset; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 461 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 462 | switch (VIDEO_DATA_FORMAT) { |
| 463 | case GDF__8BIT_INDEX: |
| 464 | case GDF__8BIT_332RGB: |
| 465 | while (count--) { |
| 466 | c = *s; |
| 467 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 468 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 469 | rows--; dest += VIDEO_LINE_LEN) { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 470 | u8 bits = *cdat++; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 471 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 472 | ((u32 *) dest)[0] = |
| 473 | (video_font_draw_table8[bits >> 4] & |
| 474 | eorx) ^ bgx; |
| 475 | ((u32 *) dest)[1] = |
| 476 | (video_font_draw_table8[bits & 15] & |
| 477 | eorx) ^ bgx; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 478 | } |
| 479 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 480 | s++; |
| 481 | } |
| 482 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 483 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 484 | case GDF_15BIT_555RGB: |
| 485 | while (count--) { |
| 486 | c = *s; |
| 487 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 488 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 489 | rows--; dest += VIDEO_LINE_LEN) { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 490 | u8 bits = *cdat++; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 491 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 492 | ((u32 *) dest)[0] = |
| 493 | SHORTSWAP32((video_font_draw_table15 |
| 494 | [bits >> 6] & eorx) ^ |
| 495 | bgx); |
| 496 | ((u32 *) dest)[1] = |
| 497 | SHORTSWAP32((video_font_draw_table15 |
| 498 | [bits >> 4 & 3] & eorx) ^ |
| 499 | bgx); |
| 500 | ((u32 *) dest)[2] = |
| 501 | SHORTSWAP32((video_font_draw_table15 |
| 502 | [bits >> 2 & 3] & eorx) ^ |
| 503 | bgx); |
| 504 | ((u32 *) dest)[3] = |
| 505 | SHORTSWAP32((video_font_draw_table15 |
| 506 | [bits & 3] & eorx) ^ |
| 507 | bgx); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 508 | } |
| 509 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 510 | s++; |
| 511 | } |
| 512 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 513 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 514 | case GDF_16BIT_565RGB: |
| 515 | while (count--) { |
| 516 | c = *s; |
| 517 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 518 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 519 | rows--; dest += VIDEO_LINE_LEN) { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 520 | u8 bits = *cdat++; |
| 521 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 522 | ((u32 *) dest)[0] = |
| 523 | SHORTSWAP32((video_font_draw_table16 |
| 524 | [bits >> 6] & eorx) ^ |
| 525 | bgx); |
| 526 | ((u32 *) dest)[1] = |
| 527 | SHORTSWAP32((video_font_draw_table16 |
| 528 | [bits >> 4 & 3] & eorx) ^ |
| 529 | bgx); |
| 530 | ((u32 *) dest)[2] = |
| 531 | SHORTSWAP32((video_font_draw_table16 |
| 532 | [bits >> 2 & 3] & eorx) ^ |
| 533 | bgx); |
| 534 | ((u32 *) dest)[3] = |
| 535 | SHORTSWAP32((video_font_draw_table16 |
| 536 | [bits & 3] & eorx) ^ |
| 537 | bgx); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 538 | } |
| 539 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 540 | s++; |
| 541 | } |
| 542 | break; |
| 543 | |
| 544 | case GDF_32BIT_X888RGB: |
| 545 | while (count--) { |
| 546 | c = *s; |
| 547 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 548 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 549 | rows--; dest += VIDEO_LINE_LEN) { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 550 | u8 bits = *cdat++; |
| 551 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 552 | ((u32 *) dest)[0] = |
| 553 | SWAP32((video_font_draw_table32 |
| 554 | [bits >> 4][0] & eorx) ^ bgx); |
| 555 | ((u32 *) dest)[1] = |
| 556 | SWAP32((video_font_draw_table32 |
| 557 | [bits >> 4][1] & eorx) ^ bgx); |
| 558 | ((u32 *) dest)[2] = |
| 559 | SWAP32((video_font_draw_table32 |
| 560 | [bits >> 4][2] & eorx) ^ bgx); |
| 561 | ((u32 *) dest)[3] = |
| 562 | SWAP32((video_font_draw_table32 |
| 563 | [bits >> 4][3] & eorx) ^ bgx); |
| 564 | ((u32 *) dest)[4] = |
| 565 | SWAP32((video_font_draw_table32 |
| 566 | [bits & 15][0] & eorx) ^ bgx); |
| 567 | ((u32 *) dest)[5] = |
| 568 | SWAP32((video_font_draw_table32 |
| 569 | [bits & 15][1] & eorx) ^ bgx); |
| 570 | ((u32 *) dest)[6] = |
| 571 | SWAP32((video_font_draw_table32 |
| 572 | [bits & 15][2] & eorx) ^ bgx); |
| 573 | ((u32 *) dest)[7] = |
| 574 | SWAP32((video_font_draw_table32 |
| 575 | [bits & 15][3] & eorx) ^ bgx); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 576 | } |
| 577 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 578 | s++; |
| 579 | } |
| 580 | break; |
| 581 | |
| 582 | case GDF_24BIT_888RGB: |
| 583 | while (count--) { |
| 584 | c = *s; |
| 585 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 586 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 587 | rows--; dest += VIDEO_LINE_LEN) { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 588 | u8 bits = *cdat++; |
| 589 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 590 | ((u32 *) dest)[0] = |
| 591 | (video_font_draw_table24[bits >> 4][0] |
| 592 | & eorx) ^ bgx; |
| 593 | ((u32 *) dest)[1] = |
| 594 | (video_font_draw_table24[bits >> 4][1] |
| 595 | & eorx) ^ bgx; |
| 596 | ((u32 *) dest)[2] = |
| 597 | (video_font_draw_table24[bits >> 4][2] |
| 598 | & eorx) ^ bgx; |
| 599 | ((u32 *) dest)[3] = |
| 600 | (video_font_draw_table24[bits & 15][0] |
| 601 | & eorx) ^ bgx; |
| 602 | ((u32 *) dest)[4] = |
| 603 | (video_font_draw_table24[bits & 15][1] |
| 604 | & eorx) ^ bgx; |
| 605 | ((u32 *) dest)[5] = |
| 606 | (video_font_draw_table24[bits & 15][2] |
| 607 | & eorx) ^ bgx; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 608 | } |
| 609 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 610 | s++; |
| 611 | } |
| 612 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 613 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 614 | } |
| 615 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 616 | static inline void video_drawstring(int xx, int yy, unsigned char *s) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 617 | { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 618 | video_drawchars(xx, yy, s, strlen((char *) s)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 619 | } |
| 620 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 621 | static void video_putchar(int xx, int yy, unsigned char c) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 622 | { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 623 | video_drawchars(xx, yy + video_logo_height, &c, 1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 624 | } |
| 625 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 626 | #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 627 | static void video_set_cursor(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 628 | { |
Gabe Black | 03d31fc | 2011-11-30 13:50:50 +0000 | [diff] [blame] | 629 | if (cursor_state) |
| 630 | console_cursor(0); |
| 631 | console_cursor(1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 632 | } |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 633 | |
Anatolij Gustschin | a45adde | 2011-12-07 03:58:10 +0000 | [diff] [blame] | 634 | static void video_invertchar(int xx, int yy) |
| 635 | { |
| 636 | int firstx = xx * VIDEO_PIXEL_SIZE; |
| 637 | int lastx = (xx + VIDEO_FONT_WIDTH) * VIDEO_PIXEL_SIZE; |
| 638 | int firsty = yy * VIDEO_LINE_LEN; |
| 639 | int lasty = (yy + VIDEO_FONT_HEIGHT) * VIDEO_LINE_LEN; |
| 640 | int x, y; |
| 641 | for (y = firsty; y < lasty; y += VIDEO_LINE_LEN) { |
| 642 | for (x = firstx; x < lastx; x++) { |
| 643 | u8 *dest = (u8 *)(video_fb_address) + x + y; |
| 644 | *dest = ~*dest; |
| 645 | } |
| 646 | } |
| 647 | } |
Gabe Black | 03d31fc | 2011-11-30 13:50:50 +0000 | [diff] [blame] | 648 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 649 | void console_cursor(int state) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 650 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 651 | #ifdef CONFIG_CONSOLE_TIME |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 652 | struct rtc_time tm; |
| 653 | char info[16]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 654 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 655 | /* time update only if cursor is on (faster scroll) */ |
| 656 | if (state) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 657 | rtc_get(&tm); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 658 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 659 | sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min, |
| 660 | tm.tm_sec); |
| 661 | video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH, |
| 662 | VIDEO_INFO_Y, (uchar *) info); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 663 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 664 | sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon, |
| 665 | tm.tm_year); |
| 666 | video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH, |
| 667 | VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, |
| 668 | (uchar *) info); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 669 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 670 | #endif |
| 671 | |
Gabe Black | 03d31fc | 2011-11-30 13:50:50 +0000 | [diff] [blame] | 672 | if (cursor_state != state) { |
| 673 | if (cursor_state) { |
| 674 | /* turn off the cursor */ |
| 675 | video_invertchar(old_col * VIDEO_FONT_WIDTH, |
| 676 | old_row * VIDEO_FONT_HEIGHT + |
| 677 | video_logo_height); |
| 678 | } else { |
| 679 | /* turn off the cursor and record where it is */ |
| 680 | video_invertchar(console_col * VIDEO_FONT_WIDTH, |
| 681 | console_row * VIDEO_FONT_HEIGHT + |
| 682 | video_logo_height); |
| 683 | old_col = console_col; |
| 684 | old_row = console_row; |
| 685 | } |
| 686 | cursor_state = state; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 687 | } |
Eric Nelson | db0d47d | 2013-05-06 14:27:28 +0200 | [diff] [blame] | 688 | if (cfb_do_flush_cache) |
| 689 | flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 690 | } |
| 691 | #endif |
| 692 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 693 | #ifndef VIDEO_HW_RECTFILL |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 694 | static void memsetl(int *p, int c, int v) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 695 | { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 696 | while (c--) |
| 697 | *(p++) = v; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 698 | } |
| 699 | #endif |
| 700 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 701 | #ifndef VIDEO_HW_BITBLT |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 702 | static void memcpyl(int *d, int *s, int c) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 703 | { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 704 | while (c--) |
| 705 | *(d++) = *(s++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 706 | } |
| 707 | #endif |
| 708 | |
Pali Rohár | 90f60a8 | 2012-04-28 07:26:44 +0000 | [diff] [blame] | 709 | static void console_clear_line(int line, int begin, int end) |
| 710 | { |
| 711 | #ifdef VIDEO_HW_RECTFILL |
| 712 | video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */ |
| 713 | VIDEO_FONT_WIDTH * begin, /* dest pos x */ |
| 714 | video_logo_height + |
| 715 | VIDEO_FONT_HEIGHT * line, /* dest pos y */ |
| 716 | VIDEO_FONT_WIDTH * (end - begin + 1), /* fr. width */ |
| 717 | VIDEO_FONT_HEIGHT, /* frame height */ |
| 718 | bgx /* fill color */ |
| 719 | ); |
| 720 | #else |
| 721 | if (begin == 0 && (end + 1) == CONSOLE_COLS) { |
| 722 | memsetl(CONSOLE_ROW_FIRST + |
| 723 | CONSOLE_ROW_SIZE * line, /* offset of row */ |
| 724 | CONSOLE_ROW_SIZE >> 2, /* length of row */ |
| 725 | bgx /* fill color */ |
| 726 | ); |
| 727 | } else { |
| 728 | void *offset; |
| 729 | int i, size; |
| 730 | |
| 731 | offset = CONSOLE_ROW_FIRST + |
| 732 | CONSOLE_ROW_SIZE * line + /* offset of row */ |
| 733 | VIDEO_FONT_WIDTH * |
| 734 | VIDEO_PIXEL_SIZE * begin; /* offset of col */ |
| 735 | size = VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE * (end - begin + 1); |
| 736 | size >>= 2; /* length to end for memsetl() */ |
| 737 | /* fill at col offset of i'th line using bgx as fill color */ |
| 738 | for (i = 0; i < VIDEO_FONT_HEIGHT; i++) |
| 739 | memsetl(offset + i * VIDEO_LINE_LEN, size, bgx); |
| 740 | } |
| 741 | #endif |
| 742 | } |
| 743 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 744 | static void console_scrollup(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 745 | { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 746 | /* copy up rows ignoring the first one */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 747 | |
| 748 | #ifdef VIDEO_HW_BITBLT |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 749 | video_hw_bitblt(VIDEO_PIXEL_SIZE, /* bytes per pixel */ |
| 750 | 0, /* source pos x */ |
| 751 | video_logo_height + |
| 752 | VIDEO_FONT_HEIGHT, /* source pos y */ |
| 753 | 0, /* dest pos x */ |
| 754 | video_logo_height, /* dest pos y */ |
| 755 | VIDEO_VISIBLE_COLS, /* frame width */ |
| 756 | VIDEO_VISIBLE_ROWS |
| 757 | - video_logo_height |
| 758 | - VIDEO_FONT_HEIGHT /* frame height */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 759 | ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 760 | #else |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 761 | memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, |
| 762 | CONSOLE_SCROLL_SIZE >> 2); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 763 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 764 | /* clear the last one */ |
Pali Rohár | 90f60a8 | 2012-04-28 07:26:44 +0000 | [diff] [blame] | 765 | console_clear_line(CONSOLE_ROWS - 1, 0, CONSOLE_COLS - 1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 766 | } |
| 767 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 768 | static void console_back(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 769 | { |
Timur Tabi | 6561863 | 2010-08-27 15:45:47 -0500 | [diff] [blame] | 770 | console_col--; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 771 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 772 | if (console_col < 0) { |
| 773 | console_col = CONSOLE_COLS - 1; |
| 774 | console_row--; |
| 775 | if (console_row < 0) |
| 776 | console_row = 0; |
| 777 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 778 | } |
| 779 | |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 780 | #ifdef CONFIG_CFB_CONSOLE_ANSI |
| 781 | |
| 782 | static void console_clear(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 783 | { |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 784 | #ifdef VIDEO_HW_RECTFILL |
| 785 | video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */ |
| 786 | 0, /* dest pos x */ |
| 787 | video_logo_height, /* dest pos y */ |
| 788 | VIDEO_VISIBLE_COLS, /* frame width */ |
| 789 | VIDEO_VISIBLE_ROWS, /* frame height */ |
| 790 | bgx /* fill color */ |
| 791 | ); |
| 792 | #else |
| 793 | memsetl(CONSOLE_ROW_FIRST, CONSOLE_SIZE, bgx); |
| 794 | #endif |
| 795 | } |
| 796 | |
| 797 | static void console_cursor_fix(void) |
| 798 | { |
| 799 | if (console_row < 0) |
| 800 | console_row = 0; |
| 801 | if (console_row >= CONSOLE_ROWS) |
| 802 | console_row = CONSOLE_ROWS - 1; |
| 803 | if (console_col < 0) |
| 804 | console_col = 0; |
| 805 | if (console_col >= CONSOLE_COLS) |
| 806 | console_col = CONSOLE_COLS - 1; |
| 807 | } |
| 808 | |
| 809 | static void console_cursor_up(int n) |
| 810 | { |
| 811 | console_row -= n; |
| 812 | console_cursor_fix(); |
| 813 | } |
| 814 | |
| 815 | static void console_cursor_down(int n) |
| 816 | { |
| 817 | console_row += n; |
| 818 | console_cursor_fix(); |
| 819 | } |
| 820 | |
| 821 | static void console_cursor_left(int n) |
| 822 | { |
| 823 | console_col -= n; |
| 824 | console_cursor_fix(); |
| 825 | } |
| 826 | |
| 827 | static void console_cursor_right(int n) |
| 828 | { |
| 829 | console_col += n; |
| 830 | console_cursor_fix(); |
| 831 | } |
| 832 | |
| 833 | static void console_cursor_set_position(int row, int col) |
| 834 | { |
| 835 | if (console_row != -1) |
| 836 | console_row = row; |
| 837 | if (console_col != -1) |
| 838 | console_col = col; |
| 839 | console_cursor_fix(); |
| 840 | } |
| 841 | |
| 842 | static void console_previousline(int n) |
| 843 | { |
| 844 | /* FIXME: also scroll terminal ? */ |
| 845 | console_row -= n; |
| 846 | console_cursor_fix(); |
| 847 | } |
| 848 | |
| 849 | static void console_swap_colors(void) |
| 850 | { |
| 851 | eorx = fgx; |
| 852 | fgx = bgx; |
| 853 | bgx = eorx; |
| 854 | eorx = fgx ^ bgx; |
| 855 | } |
| 856 | |
| 857 | static inline int console_cursor_is_visible(void) |
| 858 | { |
| 859 | return !ansi_cursor_hidden; |
| 860 | } |
| 861 | #else |
| 862 | static inline int console_cursor_is_visible(void) |
| 863 | { |
| 864 | return 1; |
| 865 | } |
| 866 | #endif |
| 867 | |
| 868 | static void console_newline(int n) |
| 869 | { |
| 870 | console_row += n; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 871 | console_col = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 872 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 873 | /* Check if we need to scroll the terminal */ |
| 874 | if (console_row >= CONSOLE_ROWS) { |
| 875 | /* Scroll everything up */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 876 | console_scrollup(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 877 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 878 | /* Decrement row number */ |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 879 | console_row = CONSOLE_ROWS - 1; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 880 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 881 | } |
| 882 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 883 | static void console_cr(void) |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 884 | { |
Timur Tabi | 6561863 | 2010-08-27 15:45:47 -0500 | [diff] [blame] | 885 | console_col = 0; |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 886 | } |
| 887 | |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 888 | static void parse_putc(const char c) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 889 | { |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 890 | static int nl = 1; |
| 891 | |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 892 | if (console_cursor_is_visible()) |
| 893 | CURSOR_OFF; |
Gabe Black | 03d31fc | 2011-11-30 13:50:50 +0000 | [diff] [blame] | 894 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 895 | switch (c) { |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 896 | case 13: /* back to first column */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 897 | console_cr(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 898 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 899 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 900 | case '\n': /* next line */ |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 901 | if (console_col || (!console_col && nl)) |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 902 | console_newline(1); |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 903 | nl = 1; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 904 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 905 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 906 | case 9: /* tab 8 */ |
Timur Tabi | 6561863 | 2010-08-27 15:45:47 -0500 | [diff] [blame] | 907 | console_col |= 0x0008; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 908 | console_col &= ~0x0007; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 909 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 910 | if (console_col >= CONSOLE_COLS) |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 911 | console_newline(1); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 912 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 913 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 914 | case 8: /* backspace */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 915 | console_back(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 916 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 917 | |
Pali Rohár | 24fe06c | 2012-04-28 07:26:47 +0000 | [diff] [blame] | 918 | case 7: /* bell */ |
| 919 | break; /* ignored */ |
| 920 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 921 | default: /* draw the char */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 922 | video_putchar(console_col * VIDEO_FONT_WIDTH, |
| 923 | console_row * VIDEO_FONT_HEIGHT, c); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 924 | console_col++; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 925 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 926 | /* check for newline */ |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 927 | if (console_col >= CONSOLE_COLS) { |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 928 | console_newline(1); |
Anatolij Gustschin | 20c450e | 2008-01-11 02:39:47 +0100 | [diff] [blame] | 929 | nl = 0; |
| 930 | } |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 931 | } |
Pali Rohár | 33a35bb | 2012-10-19 13:30:09 +0000 | [diff] [blame] | 932 | |
| 933 | if (console_cursor_is_visible()) |
| 934 | CURSOR_SET; |
| 935 | } |
| 936 | |
| 937 | void video_putc(const char c) |
| 938 | { |
| 939 | #ifdef CONFIG_CFB_CONSOLE_ANSI |
| 940 | int i; |
| 941 | |
| 942 | if (c == 27) { |
| 943 | for (i = 0; i < ansi_buf_size; ++i) |
| 944 | parse_putc(ansi_buf[i]); |
| 945 | ansi_buf[0] = 27; |
| 946 | ansi_buf_size = 1; |
| 947 | return; |
| 948 | } |
| 949 | |
| 950 | if (ansi_buf_size > 0) { |
| 951 | /* |
| 952 | * 0 - ESC |
| 953 | * 1 - [ |
| 954 | * 2 - num1 |
| 955 | * 3 - .. |
| 956 | * 4 - ; |
| 957 | * 5 - num2 |
| 958 | * 6 - .. |
| 959 | * - cchar |
| 960 | */ |
| 961 | int next = 0; |
| 962 | |
| 963 | int flush = 0; |
| 964 | int fail = 0; |
| 965 | |
| 966 | int num1 = 0; |
| 967 | int num2 = 0; |
| 968 | int cchar = 0; |
| 969 | |
| 970 | ansi_buf[ansi_buf_size++] = c; |
| 971 | |
| 972 | if (ansi_buf_size >= sizeof(ansi_buf)) |
| 973 | fail = 1; |
| 974 | |
| 975 | for (i = 0; i < ansi_buf_size; ++i) { |
| 976 | if (fail) |
| 977 | break; |
| 978 | |
| 979 | switch (next) { |
| 980 | case 0: |
| 981 | if (ansi_buf[i] == 27) |
| 982 | next = 1; |
| 983 | else |
| 984 | fail = 1; |
| 985 | break; |
| 986 | |
| 987 | case 1: |
| 988 | if (ansi_buf[i] == '[') |
| 989 | next = 2; |
| 990 | else |
| 991 | fail = 1; |
| 992 | break; |
| 993 | |
| 994 | case 2: |
| 995 | if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { |
| 996 | num1 = ansi_buf[i]-'0'; |
| 997 | next = 3; |
| 998 | } else if (ansi_buf[i] != '?') { |
| 999 | --i; |
| 1000 | num1 = 1; |
| 1001 | next = 4; |
| 1002 | } |
| 1003 | break; |
| 1004 | |
| 1005 | case 3: |
| 1006 | if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { |
| 1007 | num1 *= 10; |
| 1008 | num1 += ansi_buf[i]-'0'; |
| 1009 | } else { |
| 1010 | --i; |
| 1011 | next = 4; |
| 1012 | } |
| 1013 | break; |
| 1014 | |
| 1015 | case 4: |
| 1016 | if (ansi_buf[i] != ';') { |
| 1017 | --i; |
| 1018 | next = 7; |
| 1019 | } else |
| 1020 | next = 5; |
| 1021 | break; |
| 1022 | |
| 1023 | case 5: |
| 1024 | if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { |
| 1025 | num2 = ansi_buf[i]-'0'; |
| 1026 | next = 6; |
| 1027 | } else |
| 1028 | fail = 1; |
| 1029 | break; |
| 1030 | |
| 1031 | case 6: |
| 1032 | if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { |
| 1033 | num2 *= 10; |
| 1034 | num2 += ansi_buf[i]-'0'; |
| 1035 | } else { |
| 1036 | --i; |
| 1037 | next = 7; |
| 1038 | } |
| 1039 | break; |
| 1040 | |
| 1041 | case 7: |
| 1042 | if ((ansi_buf[i] >= 'A' && ansi_buf[i] <= 'H') |
| 1043 | || ansi_buf[i] == 'J' |
| 1044 | || ansi_buf[i] == 'K' |
| 1045 | || ansi_buf[i] == 'h' |
| 1046 | || ansi_buf[i] == 'l' |
| 1047 | || ansi_buf[i] == 'm') { |
| 1048 | cchar = ansi_buf[i]; |
| 1049 | flush = 1; |
| 1050 | } else |
| 1051 | fail = 1; |
| 1052 | break; |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | if (fail) { |
| 1057 | for (i = 0; i < ansi_buf_size; ++i) |
| 1058 | parse_putc(ansi_buf[i]); |
| 1059 | ansi_buf_size = 0; |
| 1060 | return; |
| 1061 | } |
| 1062 | |
| 1063 | if (flush) { |
| 1064 | if (!ansi_cursor_hidden) |
| 1065 | CURSOR_OFF; |
| 1066 | ansi_buf_size = 0; |
| 1067 | switch (cchar) { |
| 1068 | case 'A': |
| 1069 | /* move cursor num1 rows up */ |
| 1070 | console_cursor_up(num1); |
| 1071 | break; |
| 1072 | case 'B': |
| 1073 | /* move cursor num1 rows down */ |
| 1074 | console_cursor_down(num1); |
| 1075 | break; |
| 1076 | case 'C': |
| 1077 | /* move cursor num1 columns forward */ |
| 1078 | console_cursor_right(num1); |
| 1079 | break; |
| 1080 | case 'D': |
| 1081 | /* move cursor num1 columns back */ |
| 1082 | console_cursor_left(num1); |
| 1083 | break; |
| 1084 | case 'E': |
| 1085 | /* move cursor num1 rows up at begin of row */ |
| 1086 | console_previousline(num1); |
| 1087 | break; |
| 1088 | case 'F': |
| 1089 | /* move cursor num1 rows down at begin of row */ |
| 1090 | console_newline(num1); |
| 1091 | break; |
| 1092 | case 'G': |
| 1093 | /* move cursor to column num1 */ |
| 1094 | console_cursor_set_position(-1, num1-1); |
| 1095 | break; |
| 1096 | case 'H': |
| 1097 | /* move cursor to row num1, column num2 */ |
| 1098 | console_cursor_set_position(num1-1, num2-1); |
| 1099 | break; |
| 1100 | case 'J': |
| 1101 | /* clear console and move cursor to 0, 0 */ |
| 1102 | console_clear(); |
| 1103 | console_cursor_set_position(0, 0); |
| 1104 | break; |
| 1105 | case 'K': |
| 1106 | /* clear line */ |
| 1107 | if (num1 == 0) |
| 1108 | console_clear_line(console_row, |
| 1109 | console_col, |
| 1110 | CONSOLE_COLS-1); |
| 1111 | else if (num1 == 1) |
| 1112 | console_clear_line(console_row, |
| 1113 | 0, console_col); |
| 1114 | else |
| 1115 | console_clear_line(console_row, |
| 1116 | 0, CONSOLE_COLS-1); |
| 1117 | break; |
| 1118 | case 'h': |
| 1119 | ansi_cursor_hidden = 0; |
| 1120 | break; |
| 1121 | case 'l': |
| 1122 | ansi_cursor_hidden = 1; |
| 1123 | break; |
| 1124 | case 'm': |
| 1125 | if (num1 == 0) { /* reset swapped colors */ |
| 1126 | if (ansi_colors_need_revert) { |
| 1127 | console_swap_colors(); |
| 1128 | ansi_colors_need_revert = 0; |
| 1129 | } |
| 1130 | } else if (num1 == 7) { /* once swap colors */ |
| 1131 | if (!ansi_colors_need_revert) { |
| 1132 | console_swap_colors(); |
| 1133 | ansi_colors_need_revert = 1; |
| 1134 | } |
| 1135 | } |
| 1136 | break; |
| 1137 | } |
| 1138 | if (!ansi_cursor_hidden) |
| 1139 | CURSOR_SET; |
| 1140 | } |
| 1141 | } else { |
| 1142 | parse_putc(c); |
| 1143 | } |
| 1144 | #else |
| 1145 | parse_putc(c); |
| 1146 | #endif |
Eric Nelson | db0d47d | 2013-05-06 14:27:28 +0200 | [diff] [blame] | 1147 | if (cfb_do_flush_cache) |
| 1148 | flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); |
Timur Tabi | 6561863 | 2010-08-27 15:45:47 -0500 | [diff] [blame] | 1149 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1150 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1151 | void video_puts(const char *s) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1152 | { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1153 | int count = strlen(s); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1154 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1155 | while (count--) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1156 | video_putc(*s++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
Anatolij Gustschin | 1054382 | 2010-05-01 22:21:09 +0200 | [diff] [blame] | 1159 | /* |
| 1160 | * Do not enforce drivers (or board code) to provide empty |
| 1161 | * video_set_lut() if they do not support 8 bpp format. |
| 1162 | * Implement weak default function instead. |
| 1163 | */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1164 | void __video_set_lut(unsigned int index, unsigned char r, |
| 1165 | unsigned char g, unsigned char b) |
Anatolij Gustschin | 1054382 | 2010-05-01 22:21:09 +0200 | [diff] [blame] | 1166 | { |
| 1167 | } |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1168 | |
| 1169 | void video_set_lut(unsigned int, unsigned char, unsigned char, unsigned char) |
| 1170 | __attribute__ ((weak, alias("__video_set_lut"))); |
Anatolij Gustschin | 1054382 | 2010-05-01 22:21:09 +0200 | [diff] [blame] | 1171 | |
Jon Loeliger | 07d38a1 | 2007-07-09 17:30:01 -0500 | [diff] [blame] | 1172 | #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1173 | |
| 1174 | #define FILL_8BIT_332RGB(r,g,b) { \ |
| 1175 | *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6); \ |
| 1176 | fb ++; \ |
| 1177 | } |
| 1178 | |
| 1179 | #define FILL_15BIT_555RGB(r,g,b) { \ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1180 | *(unsigned short *)fb = \ |
| 1181 | SWAP16((unsigned short)(((r>>3)<<10) | \ |
| 1182 | ((g>>3)<<5) | \ |
| 1183 | (b>>3))); \ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1184 | fb += 2; \ |
| 1185 | } |
| 1186 | |
| 1187 | #define FILL_16BIT_565RGB(r,g,b) { \ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1188 | *(unsigned short *)fb = \ |
| 1189 | SWAP16((unsigned short)((((r)>>3)<<11)| \ |
| 1190 | (((g)>>2)<<5) | \ |
| 1191 | ((b)>>3))); \ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1192 | fb += 2; \ |
| 1193 | } |
| 1194 | |
| 1195 | #define FILL_32BIT_X888RGB(r,g,b) { \ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1196 | *(unsigned long *)fb = \ |
| 1197 | SWAP32((unsigned long)(((r<<16) | \ |
| 1198 | (g<<8) | \ |
| 1199 | b))); \ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1200 | fb += 4; \ |
| 1201 | } |
| 1202 | |
| 1203 | #ifdef VIDEO_FB_LITTLE_ENDIAN |
| 1204 | #define FILL_24BIT_888RGB(r,g,b) { \ |
| 1205 | fb[0] = b; \ |
| 1206 | fb[1] = g; \ |
| 1207 | fb[2] = r; \ |
| 1208 | fb += 3; \ |
| 1209 | } |
| 1210 | #else |
| 1211 | #define FILL_24BIT_888RGB(r,g,b) { \ |
| 1212 | fb[0] = r; \ |
| 1213 | fb[1] = g; \ |
| 1214 | fb[2] = b; \ |
| 1215 | fb += 3; \ |
| 1216 | } |
| 1217 | #endif |
| 1218 | |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1219 | #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1220 | 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] | 1221 | { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1222 | ushort *dst = (ushort *) fb; |
| 1223 | ushort color = (ushort) (((r >> 3) << 10) | |
| 1224 | ((g >> 3) << 5) | |
| 1225 | (b >> 3)); |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1226 | if (x & 1) |
| 1227 | *(--dst) = color; |
| 1228 | else |
| 1229 | *(++dst) = color; |
| 1230 | } |
| 1231 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1232 | |
| 1233 | /* |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1234 | * RLE8 bitmap support |
| 1235 | */ |
| 1236 | |
| 1237 | #ifdef CONFIG_VIDEO_BMP_RLE8 |
| 1238 | /* Pre-calculated color table entry */ |
| 1239 | struct palette { |
| 1240 | union { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1241 | unsigned short w; /* word */ |
| 1242 | unsigned int dw; /* double word */ |
| 1243 | } ce; /* color entry */ |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1244 | }; |
| 1245 | |
| 1246 | /* |
| 1247 | * Helper to draw encoded/unencoded run. |
| 1248 | */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1249 | static void draw_bitmap(uchar **fb, uchar *bm, struct palette *p, |
| 1250 | int cnt, int enc) |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1251 | { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1252 | ulong addr = (ulong) *fb; |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1253 | int *off; |
| 1254 | int enc_off = 1; |
| 1255 | int i; |
| 1256 | |
| 1257 | /* |
| 1258 | * Setup offset of the color index in the bitmap. |
| 1259 | * Color index of encoded run is at offset 1. |
| 1260 | */ |
| 1261 | off = enc ? &enc_off : &i; |
| 1262 | |
| 1263 | switch (VIDEO_DATA_FORMAT) { |
| 1264 | case GDF__8BIT_INDEX: |
| 1265 | for (i = 0; i < cnt; i++) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1266 | *(unsigned char *) addr++ = bm[*off]; |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1267 | break; |
| 1268 | case GDF_15BIT_555RGB: |
| 1269 | case GDF_16BIT_565RGB: |
| 1270 | /* differences handled while pre-calculating palette */ |
| 1271 | for (i = 0; i < cnt; i++) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1272 | *(unsigned short *) addr = p[bm[*off]].ce.w; |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1273 | addr += 2; |
| 1274 | } |
| 1275 | break; |
| 1276 | case GDF_32BIT_X888RGB: |
| 1277 | for (i = 0; i < cnt; i++) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1278 | *(unsigned long *) addr = p[bm[*off]].ce.dw; |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1279 | addr += 4; |
| 1280 | } |
| 1281 | break; |
| 1282 | } |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1283 | *fb = (uchar *) addr; /* return modified address */ |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1284 | } |
| 1285 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1286 | static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff, |
| 1287 | int width, int height) |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1288 | { |
| 1289 | unsigned char *bm; |
| 1290 | unsigned char *fbp; |
| 1291 | unsigned int cnt, runlen; |
| 1292 | int decode = 1; |
| 1293 | int x, y, bpp, i, ncolors; |
| 1294 | struct palette p[256]; |
| 1295 | bmp_color_table_entry_t cte; |
| 1296 | int green_shift, red_off; |
Anatolij Gustschin | 74446b6 | 2011-02-21 21:33:29 +0100 | [diff] [blame] | 1297 | int limit = VIDEO_COLS * VIDEO_ROWS; |
| 1298 | int pixels = 0; |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1299 | |
| 1300 | x = 0; |
| 1301 | y = __le32_to_cpu(img->header.height) - 1; |
| 1302 | ncolors = __le32_to_cpu(img->header.colors_used); |
| 1303 | bpp = VIDEO_PIXEL_SIZE; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1304 | fbp = (unsigned char *) ((unsigned int) video_fb_address + |
| 1305 | (((y + yoff) * VIDEO_COLS) + xoff) * bpp); |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1306 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1307 | bm = (uchar *) img + __le32_to_cpu(img->header.data_offset); |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1308 | |
| 1309 | /* pre-calculate and setup palette */ |
| 1310 | switch (VIDEO_DATA_FORMAT) { |
| 1311 | case GDF__8BIT_INDEX: |
| 1312 | for (i = 0; i < ncolors; i++) { |
| 1313 | cte = img->color_table[i]; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1314 | video_set_lut(i, cte.red, cte.green, cte.blue); |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1315 | } |
| 1316 | break; |
| 1317 | case GDF_15BIT_555RGB: |
| 1318 | case GDF_16BIT_565RGB: |
| 1319 | if (VIDEO_DATA_FORMAT == GDF_15BIT_555RGB) { |
| 1320 | green_shift = 3; |
| 1321 | red_off = 10; |
| 1322 | } else { |
| 1323 | green_shift = 2; |
| 1324 | red_off = 11; |
| 1325 | } |
| 1326 | for (i = 0; i < ncolors; i++) { |
| 1327 | cte = img->color_table[i]; |
| 1328 | p[i].ce.w = SWAP16((unsigned short) |
| 1329 | (((cte.red >> 3) << red_off) | |
| 1330 | ((cte.green >> green_shift) << 5) | |
| 1331 | cte.blue >> 3)); |
| 1332 | } |
| 1333 | break; |
| 1334 | case GDF_32BIT_X888RGB: |
| 1335 | for (i = 0; i < ncolors; i++) { |
| 1336 | cte = img->color_table[i]; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1337 | p[i].ce.dw = SWAP32((cte.red << 16) | |
| 1338 | (cte.green << 8) | |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1339 | cte.blue); |
| 1340 | } |
| 1341 | break; |
| 1342 | default: |
| 1343 | printf("RLE Bitmap unsupported in video mode 0x%x\n", |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1344 | VIDEO_DATA_FORMAT); |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1345 | return -1; |
| 1346 | } |
| 1347 | |
| 1348 | while (decode) { |
| 1349 | switch (bm[0]) { |
| 1350 | case 0: |
| 1351 | switch (bm[1]) { |
| 1352 | case 0: |
| 1353 | /* scan line end marker */ |
| 1354 | bm += 2; |
| 1355 | x = 0; |
| 1356 | y--; |
| 1357 | fbp = (unsigned char *) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1358 | ((unsigned int) video_fb_address + |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1359 | (((y + yoff) * VIDEO_COLS) + |
| 1360 | xoff) * bpp); |
| 1361 | continue; |
| 1362 | case 1: |
| 1363 | /* end of bitmap data marker */ |
| 1364 | decode = 0; |
| 1365 | break; |
| 1366 | case 2: |
| 1367 | /* run offset marker */ |
| 1368 | x += bm[2]; |
| 1369 | y -= bm[3]; |
| 1370 | fbp = (unsigned char *) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1371 | ((unsigned int) video_fb_address + |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1372 | (((y + yoff) * VIDEO_COLS) + |
| 1373 | x + xoff) * bpp); |
| 1374 | bm += 4; |
| 1375 | break; |
| 1376 | default: |
| 1377 | /* unencoded run */ |
| 1378 | cnt = bm[1]; |
| 1379 | runlen = cnt; |
Anatolij Gustschin | 74446b6 | 2011-02-21 21:33:29 +0100 | [diff] [blame] | 1380 | pixels += cnt; |
| 1381 | if (pixels > limit) |
| 1382 | goto error; |
| 1383 | |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1384 | bm += 2; |
| 1385 | if (y < height) { |
| 1386 | if (x >= width) { |
| 1387 | x += runlen; |
| 1388 | goto next_run; |
| 1389 | } |
| 1390 | if (x + runlen > width) |
| 1391 | cnt = width - x; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1392 | draw_bitmap(&fbp, bm, p, cnt, 0); |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1393 | x += runlen; |
| 1394 | } |
| 1395 | next_run: |
| 1396 | bm += runlen; |
| 1397 | if (runlen & 1) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1398 | bm++; /* 0 padding if length is odd */ |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1399 | } |
| 1400 | break; |
| 1401 | default: |
| 1402 | /* encoded run */ |
Anatolij Gustschin | 74446b6 | 2011-02-21 21:33:29 +0100 | [diff] [blame] | 1403 | cnt = bm[0]; |
| 1404 | runlen = cnt; |
| 1405 | pixels += cnt; |
| 1406 | if (pixels > limit) |
| 1407 | goto error; |
| 1408 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1409 | if (y < height) { /* only draw into visible area */ |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1410 | if (x >= width) { |
| 1411 | x += runlen; |
| 1412 | bm += 2; |
| 1413 | continue; |
| 1414 | } |
| 1415 | if (x + runlen > width) |
| 1416 | cnt = width - x; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1417 | draw_bitmap(&fbp, bm, p, cnt, 1); |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1418 | x += runlen; |
| 1419 | } |
| 1420 | bm += 2; |
| 1421 | break; |
| 1422 | } |
| 1423 | } |
| 1424 | return 0; |
Anatolij Gustschin | 74446b6 | 2011-02-21 21:33:29 +0100 | [diff] [blame] | 1425 | error: |
| 1426 | printf("Error: Too much encoded pixel data, validate your bitmap\n"); |
| 1427 | return -1; |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1428 | } |
| 1429 | #endif |
| 1430 | |
| 1431 | /* |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1432 | * Display the BMP file located at address bmp_image. |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1433 | */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1434 | int video_display_bitmap(ulong bmp_image, int x, int y) |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1435 | { |
| 1436 | ushort xcount, ycount; |
| 1437 | uchar *fb; |
| 1438 | bmp_image_t *bmp = (bmp_image_t *) bmp_image; |
| 1439 | uchar *bmap; |
| 1440 | ushort padded_line; |
| 1441 | unsigned long width, height, bpp; |
| 1442 | unsigned colors; |
| 1443 | unsigned long compression; |
| 1444 | bmp_color_table_entry_t cte; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1445 | |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1446 | #ifdef CONFIG_VIDEO_BMP_GZIP |
| 1447 | unsigned char *dst = NULL; |
| 1448 | ulong len; |
| 1449 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1450 | |
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 | |
| 1453 | if (!((bmp->header.signature[0] == 'B') && |
| 1454 | (bmp->header.signature[1] == 'M'))) { |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1455 | |
| 1456 | #ifdef CONFIG_VIDEO_BMP_GZIP |
| 1457 | /* |
| 1458 | * Could be a gzipped bmp image, try to decrompress... |
| 1459 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1460 | len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; |
| 1461 | dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE); |
Stefan Roese | c29ab9d | 2005-10-08 10:19:07 +0200 | [diff] [blame] | 1462 | if (dst == NULL) { |
| 1463 | printf("Error: malloc in gunzip failed!\n"); |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1464 | return 1; |
Stefan Roese | c29ab9d | 2005-10-08 10:19:07 +0200 | [diff] [blame] | 1465 | } |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1466 | if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, |
| 1467 | (uchar *) bmp_image, |
| 1468 | &len) != 0) { |
| 1469 | printf("Error: no valid bmp or bmp.gz image at %lx\n", |
| 1470 | bmp_image); |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1471 | free(dst); |
| 1472 | return 1; |
| 1473 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1474 | if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1475 | printf("Image could be truncated " |
| 1476 | "(increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); |
Stefan Roese | c29ab9d | 2005-10-08 10:19:07 +0200 | [diff] [blame] | 1477 | } |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1478 | |
| 1479 | /* |
| 1480 | * Set addr to decompressed image |
| 1481 | */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1482 | bmp = (bmp_image_t *) dst; |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1483 | |
| 1484 | if (!((bmp->header.signature[0] == 'B') && |
| 1485 | (bmp->header.signature[1] == 'M'))) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1486 | printf("Error: no valid bmp.gz image at %lx\n", |
| 1487 | bmp_image); |
Matthias Fuchs | a49e0d1 | 2008-04-21 11:19:04 +0200 | [diff] [blame] | 1488 | free(dst); |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1489 | return 1; |
| 1490 | } |
| 1491 | #else |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1492 | printf("Error: no valid bmp image at %lx\n", bmp_image); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1493 | return 1; |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1494 | #endif /* CONFIG_VIDEO_BMP_GZIP */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1495 | } |
| 1496 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1497 | width = le32_to_cpu(bmp->header.width); |
| 1498 | height = le32_to_cpu(bmp->header.height); |
| 1499 | bpp = le16_to_cpu(bmp->header.bit_count); |
| 1500 | colors = le32_to_cpu(bmp->header.colors_used); |
| 1501 | compression = le32_to_cpu(bmp->header.compression); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1502 | |
Marek Vasut | 68da5b1 | 2011-10-21 14:17:04 +0000 | [diff] [blame] | 1503 | debug("Display-bmp: %ld x %ld with %d colors\n", |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1504 | width, height, colors); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1505 | |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1506 | if (compression != BMP_BI_RGB |
| 1507 | #ifdef CONFIG_VIDEO_BMP_RLE8 |
| 1508 | && compression != BMP_BI_RLE8 |
| 1509 | #endif |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1510 | ) { |
| 1511 | printf("Error: compression type %ld not supported\n", |
| 1512 | compression); |
Matthias Fuchs | a49e0d1 | 2008-04-21 11:19:04 +0200 | [diff] [blame] | 1513 | #ifdef CONFIG_VIDEO_BMP_GZIP |
| 1514 | if (dst) |
| 1515 | free(dst); |
| 1516 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1517 | return 1; |
| 1518 | } |
| 1519 | |
| 1520 | padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3; |
| 1521 | |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1522 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
| 1523 | if (x == BMP_ALIGN_CENTER) |
| 1524 | x = max(0, (VIDEO_VISIBLE_COLS - width) / 2); |
| 1525 | else if (x < 0) |
| 1526 | x = max(0, VIDEO_VISIBLE_COLS - width + x + 1); |
| 1527 | |
| 1528 | if (y == BMP_ALIGN_CENTER) |
| 1529 | y = max(0, (VIDEO_VISIBLE_ROWS - height) / 2); |
| 1530 | else if (y < 0) |
| 1531 | y = max(0, VIDEO_VISIBLE_ROWS - height + y + 1); |
| 1532 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
| 1533 | |
Matthias Weisser | acf3baa | 2013-02-15 03:35:12 +0000 | [diff] [blame] | 1534 | /* |
| 1535 | * Just ignore elements which are completely beyond screen |
| 1536 | * dimensions. |
| 1537 | */ |
| 1538 | if ((x >= VIDEO_VISIBLE_COLS) || (y >= VIDEO_VISIBLE_ROWS)) |
| 1539 | return 0; |
| 1540 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1541 | if ((x + width) > VIDEO_VISIBLE_COLS) |
| 1542 | width = VIDEO_VISIBLE_COLS - x; |
| 1543 | if ((y + height) > VIDEO_VISIBLE_ROWS) |
| 1544 | height = VIDEO_VISIBLE_ROWS - y; |
| 1545 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1546 | bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1547 | fb = (uchar *) (video_fb_address + |
| 1548 | ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) + |
| 1549 | x * VIDEO_PIXEL_SIZE); |
| 1550 | |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1551 | #ifdef CONFIG_VIDEO_BMP_RLE8 |
| 1552 | if (compression == BMP_BI_RLE8) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1553 | return display_rle8_bitmap(bmp, x, y, width, height); |
Anatolij Gustschin | d501176 | 2010-03-15 14:50:25 +0100 | [diff] [blame] | 1554 | } |
| 1555 | #endif |
| 1556 | |
Timur Tabi | 68f6618 | 2010-08-23 16:58:00 -0500 | [diff] [blame] | 1557 | /* We handle only 4, 8, or 24 bpp bitmaps */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1558 | switch (le16_to_cpu(bmp->header.bit_count)) { |
Timur Tabi | 68f6618 | 2010-08-23 16:58:00 -0500 | [diff] [blame] | 1559 | case 4: |
| 1560 | padded_line -= width / 2; |
| 1561 | ycount = height; |
| 1562 | |
| 1563 | switch (VIDEO_DATA_FORMAT) { |
| 1564 | case GDF_32BIT_X888RGB: |
| 1565 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1566 | WATCHDOG_RESET(); |
Timur Tabi | 68f6618 | 2010-08-23 16:58:00 -0500 | [diff] [blame] | 1567 | /* |
| 1568 | * Don't assume that 'width' is an |
| 1569 | * even number |
| 1570 | */ |
| 1571 | for (xcount = 0; xcount < width; xcount++) { |
| 1572 | uchar idx; |
| 1573 | |
| 1574 | if (xcount & 1) { |
| 1575 | idx = *bmap & 0xF; |
| 1576 | bmap++; |
| 1577 | } else |
| 1578 | idx = *bmap >> 4; |
| 1579 | cte = bmp->color_table[idx]; |
| 1580 | FILL_32BIT_X888RGB(cte.red, cte.green, |
| 1581 | cte.blue); |
| 1582 | } |
| 1583 | bmap += padded_line; |
| 1584 | fb -= (VIDEO_VISIBLE_COLS + width) * |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1585 | VIDEO_PIXEL_SIZE; |
Timur Tabi | 68f6618 | 2010-08-23 16:58:00 -0500 | [diff] [blame] | 1586 | } |
| 1587 | break; |
| 1588 | default: |
| 1589 | puts("4bpp bitmap unsupported with current " |
| 1590 | "video mode\n"); |
| 1591 | break; |
| 1592 | } |
| 1593 | break; |
| 1594 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1595 | case 8: |
| 1596 | padded_line -= width; |
| 1597 | if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) { |
Anatolij Gustschin | 7c050f8 | 2010-06-19 20:41:56 +0200 | [diff] [blame] | 1598 | /* Copy colormap */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1599 | for (xcount = 0; xcount < colors; ++xcount) { |
| 1600 | cte = bmp->color_table[xcount]; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1601 | video_set_lut(xcount, cte.red, cte.green, |
| 1602 | cte.blue); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1603 | } |
| 1604 | } |
| 1605 | ycount = height; |
| 1606 | switch (VIDEO_DATA_FORMAT) { |
| 1607 | case GDF__8BIT_INDEX: |
| 1608 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1609 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1610 | xcount = width; |
| 1611 | while (xcount--) { |
| 1612 | *fb++ = *bmap++; |
| 1613 | } |
| 1614 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1615 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1616 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1617 | } |
| 1618 | break; |
| 1619 | case GDF__8BIT_332RGB: |
| 1620 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1621 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1622 | xcount = width; |
| 1623 | while (xcount--) { |
| 1624 | cte = bmp->color_table[*bmap++]; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1625 | FILL_8BIT_332RGB(cte.red, cte.green, |
| 1626 | cte.blue); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1627 | } |
| 1628 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1629 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1630 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1631 | } |
| 1632 | break; |
| 1633 | case GDF_15BIT_555RGB: |
| 1634 | while (ycount--) { |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1635 | #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) |
| 1636 | int xpos = x; |
| 1637 | #endif |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1638 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1639 | xcount = width; |
| 1640 | while (xcount--) { |
| 1641 | cte = bmp->color_table[*bmap++]; |
Andrew Dyer | cc34780 | 2008-08-29 12:30:39 -0500 | [diff] [blame] | 1642 | #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1643 | fill_555rgb_pswap(fb, xpos++, cte.red, |
| 1644 | cte.green, |
| 1645 | cte.blue); |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1646 | fb += 2; |
Andrew Dyer | cc34780 | 2008-08-29 12:30:39 -0500 | [diff] [blame] | 1647 | #else |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1648 | FILL_15BIT_555RGB(cte.red, cte.green, |
| 1649 | cte.blue); |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1650 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1651 | } |
| 1652 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1653 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1654 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1655 | } |
| 1656 | break; |
| 1657 | case GDF_16BIT_565RGB: |
| 1658 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1659 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1660 | xcount = width; |
| 1661 | while (xcount--) { |
| 1662 | cte = bmp->color_table[*bmap++]; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1663 | FILL_16BIT_565RGB(cte.red, cte.green, |
| 1664 | cte.blue); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1665 | } |
| 1666 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1667 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1668 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1669 | } |
| 1670 | break; |
| 1671 | case GDF_32BIT_X888RGB: |
| 1672 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1673 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1674 | xcount = width; |
| 1675 | while (xcount--) { |
| 1676 | cte = bmp->color_table[*bmap++]; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1677 | FILL_32BIT_X888RGB(cte.red, cte.green, |
| 1678 | cte.blue); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1679 | } |
| 1680 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1681 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1682 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1683 | } |
| 1684 | break; |
| 1685 | case GDF_24BIT_888RGB: |
| 1686 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1687 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1688 | xcount = width; |
| 1689 | while (xcount--) { |
| 1690 | cte = bmp->color_table[*bmap++]; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1691 | FILL_24BIT_888RGB(cte.red, cte.green, |
| 1692 | cte.blue); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1693 | } |
| 1694 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1695 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1696 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1697 | } |
| 1698 | break; |
| 1699 | } |
| 1700 | break; |
| 1701 | case 24: |
| 1702 | padded_line -= 3 * width; |
| 1703 | ycount = height; |
| 1704 | switch (VIDEO_DATA_FORMAT) { |
| 1705 | case GDF__8BIT_332RGB: |
| 1706 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1707 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1708 | xcount = width; |
| 1709 | while (xcount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1710 | FILL_8BIT_332RGB(bmap[2], bmap[1], |
| 1711 | bmap[0]); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1712 | bmap += 3; |
| 1713 | } |
| 1714 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1715 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1716 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1717 | } |
| 1718 | break; |
| 1719 | case GDF_15BIT_555RGB: |
| 1720 | while (ycount--) { |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1721 | #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) |
| 1722 | int xpos = x; |
| 1723 | #endif |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1724 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1725 | xcount = width; |
| 1726 | while (xcount--) { |
Andrew Dyer | cc34780 | 2008-08-29 12:30:39 -0500 | [diff] [blame] | 1727 | #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1728 | fill_555rgb_pswap(fb, xpos++, bmap[2], |
| 1729 | bmap[1], bmap[0]); |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1730 | fb += 2; |
Andrew Dyer | cc34780 | 2008-08-29 12:30:39 -0500 | [diff] [blame] | 1731 | #else |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1732 | FILL_15BIT_555RGB(bmap[2], bmap[1], |
| 1733 | bmap[0]); |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1734 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1735 | bmap += 3; |
| 1736 | } |
| 1737 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1738 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1739 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1740 | } |
| 1741 | break; |
| 1742 | case GDF_16BIT_565RGB: |
| 1743 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1744 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1745 | xcount = width; |
| 1746 | while (xcount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1747 | FILL_16BIT_565RGB(bmap[2], bmap[1], |
| 1748 | bmap[0]); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1749 | bmap += 3; |
| 1750 | } |
| 1751 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1752 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1753 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1754 | } |
| 1755 | break; |
| 1756 | case GDF_32BIT_X888RGB: |
| 1757 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1758 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1759 | xcount = width; |
| 1760 | while (xcount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1761 | FILL_32BIT_X888RGB(bmap[2], bmap[1], |
| 1762 | bmap[0]); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1763 | bmap += 3; |
| 1764 | } |
| 1765 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1766 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1767 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1768 | } |
| 1769 | break; |
| 1770 | case GDF_24BIT_888RGB: |
| 1771 | while (ycount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1772 | WATCHDOG_RESET(); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1773 | xcount = width; |
| 1774 | while (xcount--) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1775 | FILL_24BIT_888RGB(bmap[2], bmap[1], |
| 1776 | bmap[0]); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1777 | bmap += 3; |
| 1778 | } |
| 1779 | bmap += padded_line; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1780 | fb -= (VIDEO_VISIBLE_COLS + width) * |
| 1781 | VIDEO_PIXEL_SIZE; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1782 | } |
| 1783 | break; |
| 1784 | default: |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1785 | printf("Error: 24 bits/pixel bitmap incompatible " |
| 1786 | "with current video mode\n"); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1787 | break; |
| 1788 | } |
| 1789 | break; |
| 1790 | default: |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1791 | printf("Error: %d bit/pixel bitmaps not supported by U-Boot\n", |
| 1792 | le16_to_cpu(bmp->header.bit_count)); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1793 | break; |
| 1794 | } |
Stefan Roese | 98f4a3d | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 1795 | |
| 1796 | #ifdef CONFIG_VIDEO_BMP_GZIP |
| 1797 | if (dst) { |
| 1798 | free(dst); |
| 1799 | } |
| 1800 | #endif |
| 1801 | |
Eric Nelson | db0d47d | 2013-05-06 14:27:28 +0200 | [diff] [blame] | 1802 | if (cfb_do_flush_cache) |
| 1803 | flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1804 | return (0); |
| 1805 | } |
Jon Loeliger | 07d38a1 | 2007-07-09 17:30:01 -0500 | [diff] [blame] | 1806 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1807 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1808 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1809 | #ifdef CONFIG_VIDEO_LOGO |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 1810 | static int video_logo_xpos; |
| 1811 | static int video_logo_ypos; |
| 1812 | |
Bastian Ruppert | 4b7d3a0 | 2012-09-13 22:29:02 +0000 | [diff] [blame] | 1813 | static void plot_logo_or_black(void *screen, int width, int x, int y, \ |
| 1814 | int black); |
| 1815 | |
| 1816 | static void logo_plot(void *screen, int width, int x, int y) |
| 1817 | { |
| 1818 | plot_logo_or_black(screen, width, x, y, 0); |
| 1819 | } |
| 1820 | |
| 1821 | static void logo_black(void) |
| 1822 | { |
| 1823 | plot_logo_or_black(video_fb_address, \ |
| 1824 | VIDEO_COLS, \ |
| 1825 | video_logo_xpos, \ |
| 1826 | video_logo_ypos, \ |
| 1827 | 1); |
| 1828 | } |
| 1829 | |
| 1830 | static int do_clrlogo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 1831 | { |
| 1832 | if (argc != 1) |
| 1833 | return cmd_usage(cmdtp); |
| 1834 | |
| 1835 | logo_black(); |
| 1836 | return 0; |
| 1837 | } |
| 1838 | |
| 1839 | U_BOOT_CMD( |
| 1840 | clrlogo, 1, 0, do_clrlogo, |
| 1841 | "fill the boot logo area with black", |
| 1842 | " " |
| 1843 | ); |
| 1844 | |
| 1845 | 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] | 1846 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1847 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1848 | int xcount, i; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1849 | int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE; |
Matthias Weisser | be129aa | 2010-01-12 12:06:31 +0100 | [diff] [blame] | 1850 | int ycount = video_logo_height; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1851 | unsigned char r, g, b, *logo_red, *logo_blue, *logo_green; |
| 1852 | unsigned char *source; |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 1853 | unsigned char *dest; |
| 1854 | |
| 1855 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
| 1856 | if (x == BMP_ALIGN_CENTER) |
| 1857 | x = max(0, (VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH) / 2); |
| 1858 | else if (x < 0) |
| 1859 | x = max(0, VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH + x + 1); |
| 1860 | |
| 1861 | if (y == BMP_ALIGN_CENTER) |
| 1862 | y = max(0, (VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT) / 2); |
| 1863 | else if (y < 0) |
| 1864 | y = max(0, VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1); |
| 1865 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
| 1866 | |
| 1867 | dest = (unsigned char *)screen + (y * width + x) * VIDEO_PIXEL_SIZE; |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 1868 | |
| 1869 | #ifdef CONFIG_VIDEO_BMP_LOGO |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1870 | source = bmp_logo_bitmap; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1871 | |
Anatolij Gustschin | 7c050f8 | 2010-06-19 20:41:56 +0200 | [diff] [blame] | 1872 | /* Allocate temporary space for computing colormap */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1873 | logo_red = malloc(BMP_LOGO_COLORS); |
| 1874 | logo_green = malloc(BMP_LOGO_COLORS); |
| 1875 | logo_blue = malloc(BMP_LOGO_COLORS); |
Anatolij Gustschin | 7c050f8 | 2010-06-19 20:41:56 +0200 | [diff] [blame] | 1876 | /* Compute color map */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1877 | for (i = 0; i < VIDEO_LOGO_COLORS; i++) { |
| 1878 | logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4; |
| 1879 | logo_green[i] = (bmp_logo_palette[i] & 0x00f0); |
| 1880 | logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4; |
| 1881 | } |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 1882 | #else |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1883 | source = linux_logo; |
| 1884 | logo_red = linux_logo_red; |
| 1885 | logo_green = linux_logo_green; |
| 1886 | logo_blue = linux_logo_blue; |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 1887 | #endif |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1888 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1889 | if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) { |
| 1890 | for (i = 0; i < VIDEO_LOGO_COLORS; i++) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1891 | video_set_lut(i + VIDEO_LOGO_LUT_OFFSET, |
| 1892 | logo_red[i], logo_green[i], |
| 1893 | logo_blue[i]); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1894 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1895 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1896 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1897 | while (ycount--) { |
Anatolij Gustschin | e84d568 | 2008-08-08 18:00:40 +0200 | [diff] [blame] | 1898 | #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) |
| 1899 | int xpos = x; |
| 1900 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1901 | xcount = VIDEO_LOGO_WIDTH; |
| 1902 | while (xcount--) { |
Bastian Ruppert | 4b7d3a0 | 2012-09-13 22:29:02 +0000 | [diff] [blame] | 1903 | if (black) { |
| 1904 | r = 0x00; |
| 1905 | g = 0x00; |
| 1906 | b = 0x00; |
| 1907 | } else { |
| 1908 | r = logo_red[*source - VIDEO_LOGO_LUT_OFFSET]; |
| 1909 | g = logo_green[*source - VIDEO_LOGO_LUT_OFFSET]; |
| 1910 | b = logo_blue[*source - VIDEO_LOGO_LUT_OFFSET]; |
| 1911 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1912 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1913 | switch (VIDEO_DATA_FORMAT) { |
| 1914 | case GDF__8BIT_INDEX: |
| 1915 | *dest = *source; |
| 1916 | break; |
| 1917 | case GDF__8BIT_332RGB: |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1918 | *dest = ((r >> 5) << 5) | |
| 1919 | ((g >> 5) << 2) | |
| 1920 | (b >> 6); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1921 | break; |
| 1922 | case GDF_15BIT_555RGB: |
Andrew Dyer | cc34780 | 2008-08-29 12:30:39 -0500 | [diff] [blame] | 1923 | #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1924 | fill_555rgb_pswap(dest, xpos++, r, g, b); |
Andrew Dyer | cc34780 | 2008-08-29 12:30:39 -0500 | [diff] [blame] | 1925 | #else |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1926 | *(unsigned short *) dest = |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1927 | SWAP16((unsigned short) ( |
| 1928 | ((r >> 3) << 10) | |
| 1929 | ((g >> 3) << 5) | |
| 1930 | (b >> 3))); |
Anatolij Gustschin | bed5375 | 2008-01-11 14:30:01 +0100 | [diff] [blame] | 1931 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1932 | break; |
| 1933 | case GDF_16BIT_565RGB: |
| 1934 | *(unsigned short *) dest = |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1935 | SWAP16((unsigned short) ( |
| 1936 | ((r >> 3) << 11) | |
| 1937 | ((g >> 2) << 5) | |
| 1938 | (b >> 3))); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1939 | break; |
| 1940 | case GDF_32BIT_X888RGB: |
| 1941 | *(unsigned long *) dest = |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1942 | SWAP32((unsigned long) ( |
| 1943 | (r << 16) | |
| 1944 | (g << 8) | |
| 1945 | b)); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1946 | break; |
| 1947 | case GDF_24BIT_888RGB: |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1948 | #ifdef VIDEO_FB_LITTLE_ENDIAN |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1949 | dest[0] = b; |
| 1950 | dest[1] = g; |
| 1951 | dest[2] = r; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1952 | #else |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1953 | dest[0] = r; |
| 1954 | dest[1] = g; |
| 1955 | dest[2] = b; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1956 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1957 | break; |
| 1958 | } |
| 1959 | source++; |
| 1960 | dest += VIDEO_PIXEL_SIZE; |
| 1961 | } |
| 1962 | dest += skip; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1963 | } |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 1964 | #ifdef CONFIG_VIDEO_BMP_LOGO |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1965 | free(logo_red); |
| 1966 | free(logo_green); |
| 1967 | free(logo_blue); |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 1968 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1969 | } |
| 1970 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 1971 | static void *video_logo(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1972 | { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1973 | char info[128]; |
Wolfgang Denk | a9a62af | 2011-11-04 15:55:20 +0000 | [diff] [blame] | 1974 | int space, len; |
| 1975 | __maybe_unused int y_off = 0; |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 1976 | __maybe_unused ulong addr; |
| 1977 | __maybe_unused char *s; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1978 | |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1979 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 1980 | s = getenv("splashpos"); |
| 1981 | if (s != NULL) { |
| 1982 | if (s[0] == 'm') |
| 1983 | video_logo_xpos = BMP_ALIGN_CENTER; |
| 1984 | else |
| 1985 | video_logo_xpos = simple_strtol(s, NULL, 0); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1986 | |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 1987 | s = strchr(s + 1, ','); |
| 1988 | if (s != NULL) { |
| 1989 | if (s[1] == 'm') |
| 1990 | video_logo_ypos = BMP_ALIGN_CENTER; |
| 1991 | else |
| 1992 | video_logo_ypos = simple_strtol(s + 1, NULL, 0); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1993 | } |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 1994 | } |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1995 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
| 1996 | |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 1997 | #ifdef CONFIG_SPLASH_SCREEN |
| 1998 | s = getenv("splashimage"); |
| 1999 | if (s != NULL) { |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame^] | 2000 | splash_screen_prepare(); |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 2001 | addr = simple_strtoul(s, NULL, 16); |
| 2002 | |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 2003 | if (video_display_bitmap(addr, |
| 2004 | video_logo_xpos, |
| 2005 | video_logo_ypos) == 0) { |
Matthias Weisser | be129aa | 2010-01-12 12:06:31 +0100 | [diff] [blame] | 2006 | video_logo_height = 0; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2007 | return ((void *) (video_fb_address)); |
| 2008 | } |
| 2009 | } |
| 2010 | #endif /* CONFIG_SPLASH_SCREEN */ |
| 2011 | |
Bastian Ruppert | 1e681f9 | 2012-09-13 22:29:01 +0000 | [diff] [blame] | 2012 | logo_plot(video_fb_address, VIDEO_COLS, |
| 2013 | video_logo_xpos, video_logo_ypos); |
| 2014 | |
| 2015 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
| 2016 | /* |
| 2017 | * when using splashpos for video_logo, skip any info |
| 2018 | * output on video console if the logo is not at 0,0 |
| 2019 | */ |
| 2020 | if (video_logo_xpos || video_logo_ypos) { |
| 2021 | /* |
| 2022 | * video_logo_height is used in text and cursor offset |
| 2023 | * calculations. Since the console is below the logo, |
| 2024 | * we need to adjust the logo height |
| 2025 | */ |
| 2026 | if (video_logo_ypos == BMP_ALIGN_CENTER) |
| 2027 | video_logo_height += max(0, (VIDEO_VISIBLE_ROWS - \ |
| 2028 | VIDEO_LOGO_HEIGHT) / 2); |
| 2029 | else if (video_logo_ypos > 0) |
| 2030 | video_logo_height += video_logo_ypos; |
| 2031 | |
| 2032 | return video_fb_address + video_logo_height * VIDEO_LINE_LEN; |
| 2033 | } |
| 2034 | #endif |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2035 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2036 | sprintf(info, " %s", version_string); |
Anatolij Gustschin | 3dcbe62 | 2009-04-23 12:35:22 +0200 | [diff] [blame] | 2037 | |
| 2038 | space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH; |
| 2039 | len = strlen(info); |
| 2040 | |
| 2041 | if (len > space) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2042 | video_drawchars(VIDEO_INFO_X, VIDEO_INFO_Y, |
| 2043 | (uchar *) info, space); |
| 2044 | video_drawchars(VIDEO_INFO_X + VIDEO_FONT_WIDTH, |
| 2045 | VIDEO_INFO_Y + VIDEO_FONT_HEIGHT, |
| 2046 | (uchar *) info + space, len - space); |
Anatolij Gustschin | 3dcbe62 | 2009-04-23 12:35:22 +0200 | [diff] [blame] | 2047 | y_off = 1; |
| 2048 | } else |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2049 | video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2050 | |
| 2051 | #ifdef CONFIG_CONSOLE_EXTRA_INFO |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2052 | { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2053 | int i, n = |
| 2054 | ((video_logo_height - |
| 2055 | VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2056 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2057 | for (i = 1; i < n; i++) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2058 | video_get_info_str(i, info); |
Anatolij Gustschin | 3dcbe62 | 2009-04-23 12:35:22 +0200 | [diff] [blame] | 2059 | if (!*info) |
| 2060 | continue; |
| 2061 | |
| 2062 | len = strlen(info); |
| 2063 | if (len > space) { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2064 | video_drawchars(VIDEO_INFO_X, |
| 2065 | VIDEO_INFO_Y + |
| 2066 | (i + y_off) * |
| 2067 | VIDEO_FONT_HEIGHT, |
| 2068 | (uchar *) info, space); |
Anatolij Gustschin | 3dcbe62 | 2009-04-23 12:35:22 +0200 | [diff] [blame] | 2069 | y_off++; |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2070 | video_drawchars(VIDEO_INFO_X + |
| 2071 | VIDEO_FONT_WIDTH, |
| 2072 | VIDEO_INFO_Y + |
| 2073 | (i + y_off) * |
| 2074 | VIDEO_FONT_HEIGHT, |
| 2075 | (uchar *) info + space, |
| 2076 | len - space); |
Anatolij Gustschin | 3dcbe62 | 2009-04-23 12:35:22 +0200 | [diff] [blame] | 2077 | } else { |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2078 | video_drawstring(VIDEO_INFO_X, |
| 2079 | VIDEO_INFO_Y + |
| 2080 | (i + y_off) * |
| 2081 | VIDEO_FONT_HEIGHT, |
| 2082 | (uchar *) info); |
Anatolij Gustschin | 3dcbe62 | 2009-04-23 12:35:22 +0200 | [diff] [blame] | 2083 | } |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2084 | } |
| 2085 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2086 | #endif |
| 2087 | |
Matthias Weisser | be129aa | 2010-01-12 12:06:31 +0100 | [diff] [blame] | 2088 | return (video_fb_address + video_logo_height * VIDEO_LINE_LEN); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2089 | } |
| 2090 | #endif |
| 2091 | |
Anatolij Gustschin | bfd4be8 | 2012-06-05 09:19:18 +0200 | [diff] [blame] | 2092 | static int cfb_fb_is_in_dram(void) |
| 2093 | { |
| 2094 | bd_t *bd = gd->bd; |
| 2095 | #if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32) || \ |
| 2096 | defined(CONFIG_SANDBOX) || defined(CONFIG_X86) |
| 2097 | ulong start, end; |
| 2098 | int i; |
| 2099 | |
| 2100 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { |
| 2101 | start = bd->bi_dram[i].start; |
| 2102 | end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1; |
| 2103 | if ((ulong)video_fb_address >= start && |
| 2104 | (ulong)video_fb_address < end) |
| 2105 | return 1; |
| 2106 | } |
| 2107 | #else |
| 2108 | if ((ulong)video_fb_address >= bd->bi_memstart && |
| 2109 | (ulong)video_fb_address < bd->bi_memstart + bd->bi_memsize) |
| 2110 | return 1; |
| 2111 | #endif |
| 2112 | return 0; |
| 2113 | } |
| 2114 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2115 | static int video_init(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2116 | { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2117 | unsigned char color8; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2118 | |
Wolfgang Denk | 5791293 | 2011-07-30 12:48:09 +0000 | [diff] [blame] | 2119 | pGD = video_hw_init(); |
| 2120 | if (pGD == NULL) |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2121 | return -1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2122 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2123 | video_fb_address = (void *) VIDEO_FB_ADRS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2124 | #ifdef CONFIG_VIDEO_HW_CURSOR |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2125 | video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2126 | #endif |
| 2127 | |
Anatolij Gustschin | bfd4be8 | 2012-06-05 09:19:18 +0200 | [diff] [blame] | 2128 | cfb_do_flush_cache = cfb_fb_is_in_dram() && dcache_status(); |
| 2129 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2130 | /* Init drawing pats */ |
| 2131 | switch (VIDEO_DATA_FORMAT) { |
| 2132 | case GDF__8BIT_INDEX: |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2133 | video_set_lut(0x01, CONSOLE_FG_COL, CONSOLE_FG_COL, |
| 2134 | CONSOLE_FG_COL); |
| 2135 | video_set_lut(0x00, CONSOLE_BG_COL, CONSOLE_BG_COL, |
| 2136 | CONSOLE_BG_COL); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2137 | fgx = 0x01010101; |
| 2138 | bgx = 0x00000000; |
| 2139 | break; |
| 2140 | case GDF__8BIT_332RGB: |
| 2141 | color8 = ((CONSOLE_FG_COL & 0xe0) | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2142 | ((CONSOLE_FG_COL >> 3) & 0x1c) | |
| 2143 | CONSOLE_FG_COL >> 6); |
| 2144 | fgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | |
| 2145 | color8; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2146 | color8 = ((CONSOLE_BG_COL & 0xe0) | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2147 | ((CONSOLE_BG_COL >> 3) & 0x1c) | |
| 2148 | CONSOLE_BG_COL >> 6); |
| 2149 | bgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | |
| 2150 | color8; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2151 | break; |
| 2152 | case GDF_15BIT_555RGB: |
| 2153 | fgx = (((CONSOLE_FG_COL >> 3) << 26) | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2154 | ((CONSOLE_FG_COL >> 3) << 21) | |
| 2155 | ((CONSOLE_FG_COL >> 3) << 16) | |
| 2156 | ((CONSOLE_FG_COL >> 3) << 10) | |
| 2157 | ((CONSOLE_FG_COL >> 3) << 5) | |
| 2158 | (CONSOLE_FG_COL >> 3)); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2159 | bgx = (((CONSOLE_BG_COL >> 3) << 26) | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2160 | ((CONSOLE_BG_COL >> 3) << 21) | |
| 2161 | ((CONSOLE_BG_COL >> 3) << 16) | |
| 2162 | ((CONSOLE_BG_COL >> 3) << 10) | |
| 2163 | ((CONSOLE_BG_COL >> 3) << 5) | |
| 2164 | (CONSOLE_BG_COL >> 3)); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2165 | break; |
| 2166 | case GDF_16BIT_565RGB: |
| 2167 | fgx = (((CONSOLE_FG_COL >> 3) << 27) | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2168 | ((CONSOLE_FG_COL >> 2) << 21) | |
| 2169 | ((CONSOLE_FG_COL >> 3) << 16) | |
| 2170 | ((CONSOLE_FG_COL >> 3) << 11) | |
| 2171 | ((CONSOLE_FG_COL >> 2) << 5) | |
| 2172 | (CONSOLE_FG_COL >> 3)); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2173 | bgx = (((CONSOLE_BG_COL >> 3) << 27) | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2174 | ((CONSOLE_BG_COL >> 2) << 21) | |
| 2175 | ((CONSOLE_BG_COL >> 3) << 16) | |
| 2176 | ((CONSOLE_BG_COL >> 3) << 11) | |
| 2177 | ((CONSOLE_BG_COL >> 2) << 5) | |
| 2178 | (CONSOLE_BG_COL >> 3)); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2179 | break; |
| 2180 | case GDF_32BIT_X888RGB: |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2181 | fgx = (CONSOLE_FG_COL << 16) | |
| 2182 | (CONSOLE_FG_COL << 8) | |
| 2183 | CONSOLE_FG_COL; |
| 2184 | bgx = (CONSOLE_BG_COL << 16) | |
| 2185 | (CONSOLE_BG_COL << 8) | |
| 2186 | CONSOLE_BG_COL; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2187 | break; |
| 2188 | case GDF_24BIT_888RGB: |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2189 | fgx = (CONSOLE_FG_COL << 24) | |
| 2190 | (CONSOLE_FG_COL << 16) | |
| 2191 | (CONSOLE_FG_COL << 8) | |
| 2192 | CONSOLE_FG_COL; |
| 2193 | bgx = (CONSOLE_BG_COL << 24) | |
| 2194 | (CONSOLE_BG_COL << 16) | |
| 2195 | (CONSOLE_BG_COL << 8) | |
| 2196 | CONSOLE_BG_COL; |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2197 | break; |
| 2198 | } |
| 2199 | eorx = fgx ^ bgx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2200 | |
| 2201 | #ifdef CONFIG_VIDEO_LOGO |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2202 | /* Plot the logo and get start point of console */ |
Wolfgang Denk | 72c65f6 | 2011-07-29 09:55:28 +0000 | [diff] [blame] | 2203 | debug("Video: Drawing the logo ...\n"); |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2204 | video_console_address = video_logo(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2205 | #else |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2206 | video_console_address = video_fb_address; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2207 | #endif |
| 2208 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2209 | /* Initialize the console */ |
| 2210 | console_col = 0; |
| 2211 | console_row = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2212 | |
Eric Nelson | db0d47d | 2013-05-06 14:27:28 +0200 | [diff] [blame] | 2213 | if (cfb_do_flush_cache) |
| 2214 | flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); |
| 2215 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2216 | return 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2217 | } |
| 2218 | |
Wolfgang Denk | 6cc7ba9 | 2009-05-15 10:07:43 +0200 | [diff] [blame] | 2219 | /* |
| 2220 | * Implement a weak default function for boards that optionally |
| 2221 | * need to skip the video initialization. |
| 2222 | */ |
| 2223 | int __board_video_skip(void) |
| 2224 | { |
| 2225 | /* As default, don't skip test */ |
| 2226 | return 0; |
| 2227 | } |
Wolfgang Denk | 6cc7ba9 | 2009-05-15 10:07:43 +0200 | [diff] [blame] | 2228 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2229 | int board_video_skip(void) |
| 2230 | __attribute__ ((weak, alias("__board_video_skip"))); |
| 2231 | |
| 2232 | int drv_video_init(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2233 | { |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 2234 | int skip_dev_init; |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 2235 | struct stdio_dev console_dev; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2236 | |
Wolfgang Denk | 6cc7ba9 | 2009-05-15 10:07:43 +0200 | [diff] [blame] | 2237 | /* Check if video initialization should be skipped */ |
| 2238 | if (board_video_skip()) |
| 2239 | return 0; |
| 2240 | |
wdenk | 8105092 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 2241 | /* Init video chip - returns with framebuffer cleared */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2242 | skip_dev_init = (video_init() == -1); |
wdenk | 8105092 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 2243 | |
Wolfgang Denk | f62f646 | 2009-05-15 10:07:42 +0200 | [diff] [blame] | 2244 | #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE) |
Wolfgang Denk | 72c65f6 | 2011-07-29 09:55:28 +0000 | [diff] [blame] | 2245 | debug("KBD: Keyboard init ...\n"); |
Wolfgang Denk | f62f646 | 2009-05-15 10:07:42 +0200 | [diff] [blame] | 2246 | skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1); |
| 2247 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2248 | |
Wolfgang Denk | f62f646 | 2009-05-15 10:07:42 +0200 | [diff] [blame] | 2249 | if (skip_dev_init) |
| 2250 | return 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2251 | |
Wolfgang Denk | f62f646 | 2009-05-15 10:07:42 +0200 | [diff] [blame] | 2252 | /* Init vga device */ |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2253 | memset(&console_dev, 0, sizeof(console_dev)); |
| 2254 | strcpy(console_dev.name, "vga"); |
Wolfgang Denk | f62f646 | 2009-05-15 10:07:42 +0200 | [diff] [blame] | 2255 | console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */ |
| 2256 | console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM; |
| 2257 | console_dev.putc = video_putc; /* 'putc' function */ |
| 2258 | console_dev.puts = video_puts; /* 'puts' function */ |
| 2259 | console_dev.tstc = NULL; /* 'tstc' function */ |
| 2260 | console_dev.getc = NULL; /* 'getc' function */ |
| 2261 | |
| 2262 | #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE) |
| 2263 | /* Also init console device */ |
| 2264 | console_dev.flags |= DEV_FLAGS_INPUT; |
| 2265 | console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */ |
| 2266 | console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2267 | #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */ |
Wolfgang Denk | f62f646 | 2009-05-15 10:07:42 +0200 | [diff] [blame] | 2268 | |
Wolfgang Denk | 64e40d7 | 2011-07-29 09:55:27 +0000 | [diff] [blame] | 2269 | if (stdio_register(&console_dev) != 0) |
Wolfgang Denk | f62f646 | 2009-05-15 10:07:42 +0200 | [diff] [blame] | 2270 | return 0; |
| 2271 | |
| 2272 | /* Return success */ |
| 2273 | return 1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2274 | } |
Stefan Reinauer | c20ee07 | 2012-09-28 15:11:12 +0000 | [diff] [blame] | 2275 | |
| 2276 | void video_position_cursor(unsigned col, unsigned row) |
| 2277 | { |
| 2278 | console_col = min(col, CONSOLE_COLS - 1); |
| 2279 | console_row = min(row, CONSOLE_ROWS - 1); |
| 2280 | } |
| 2281 | |
| 2282 | int video_get_pixel_width(void) |
| 2283 | { |
| 2284 | return VIDEO_VISIBLE_COLS; |
| 2285 | } |
| 2286 | |
| 2287 | int video_get_pixel_height(void) |
| 2288 | { |
| 2289 | return VIDEO_VISIBLE_ROWS; |
| 2290 | } |
| 2291 | |
| 2292 | int video_get_screen_rows(void) |
| 2293 | { |
| 2294 | return CONSOLE_ROWS; |
| 2295 | } |
| 2296 | |
| 2297 | int video_get_screen_columns(void) |
| 2298 | { |
| 2299 | return CONSOLE_COLS; |
| 2300 | } |
| 2301 | |
| 2302 | void video_clear(void) |
| 2303 | { |
Duncan Laurie | ae63057 | 2012-11-03 11:41:40 +0000 | [diff] [blame] | 2304 | if (!video_fb_address) |
| 2305 | return; |
Stefan Reinauer | c20ee07 | 2012-09-28 15:11:12 +0000 | [diff] [blame] | 2306 | #ifdef VIDEO_HW_RECTFILL |
| 2307 | video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */ |
| 2308 | 0, /* dest pos x */ |
| 2309 | 0, /* dest pos y */ |
| 2310 | VIDEO_VISIBLE_COLS, /* frame width */ |
| 2311 | VIDEO_VISIBLE_ROWS, /* frame height */ |
| 2312 | bgx /* fill color */ |
| 2313 | ); |
| 2314 | #else |
| 2315 | memsetl(video_fb_address, |
| 2316 | (VIDEO_VISIBLE_ROWS * VIDEO_LINE_LEN) / sizeof(int), bgx); |
| 2317 | #endif |
| 2318 | } |