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