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