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