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