wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 ELTEC Elektronik AG |
| 3 | * Frank Gottschling <fgottschling@eltec.de> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * cfb_console.c |
| 26 | * |
| 27 | * Color Framebuffer Console driver for 8/15/16/24/32 bits per pixel. |
| 28 | * |
| 29 | * At the moment only the 8x16 font is tested and the font fore- and |
| 30 | * background color is limited to black/white/gray colors. The Linux |
| 31 | * logo can be placed in the upper left corner and additional board |
| 32 | * information strings (that normaly goes to serial port) can be drawed. |
| 33 | * |
| 34 | * The console driver can use the standard PC keyboard interface (i8042) |
| 35 | * for character input. Character output goes to a memory mapped video |
| 36 | * framebuffer with little or big-endian organisation. |
| 37 | * With environment setting 'console=serial' the console i/o can be |
| 38 | * forced to serial port. |
| 39 | |
| 40 | The driver uses graphic specific defines/parameters/functions: |
| 41 | |
| 42 | (for SMI LynxE graphic chip) |
| 43 | |
| 44 | CONFIG_VIDEO_SMI_LYNXEM - use graphic driver for SMI 710,712,810 |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 45 | VIDEO_FB_LITTLE_ENDIAN - framebuffer organisation default: big endian |
| 46 | VIDEO_HW_RECTFILL - graphic driver supports hardware rectangle fill |
| 47 | VIDEO_HW_BITBLT - graphic driver supports hardware bit blt |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 48 | |
| 49 | Console Parameters are set by graphic drivers global struct: |
| 50 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 51 | VIDEO_VISIBLE_COLS - x resolution |
| 52 | VIDEO_VISIBLE_ROWS - y resolution |
| 53 | VIDEO_PIXEL_SIZE - storage size in byte per pixel |
| 54 | VIDEO_DATA_FORMAT - graphical data format GDF |
| 55 | VIDEO_FB_ADRS - start of video memory |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 56 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 57 | CONFIG_I8042_KBD - AT Keyboard driver for i8042 |
| 58 | VIDEO_KBD_INIT_FCT - init function for keyboard |
| 59 | VIDEO_TSTC_FCT - keyboard_tstc function |
| 60 | VIDEO_GETC_FCT - keyboard_getc function |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 61 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 62 | CONFIG_CONSOLE_CURSOR - on/off drawing cursor is done with delay |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 63 | loop in VIDEO_TSTC_FCT (i8042) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 64 | CFG_CONSOLE_BLINK_COUNT - value for delay loop - blink rate |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 65 | CONFIG_CONSOLE_TIME - display time/date in upper right corner, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 66 | needs CFG_CMD_DATE and CONFIG_CONSOLE_CURSOR |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 67 | CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner |
| 68 | CONFIG_VIDEO_BMP_LOGO - use bmp_logo instead of linux_logo |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 69 | CONFIG_CONSOLE_EXTRA_INFO - display additional board information strings |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 70 | that normaly goes to serial port. This define |
| 71 | requires a board specific function: |
| 72 | video_drawstring (VIDEO_INFO_X, |
| 73 | VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT, |
| 74 | info); |
| 75 | that fills a info buffer at i=row. |
| 76 | s.a: board/eltec/bab7xx. |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 77 | CONFIG_VGA_AS_SINGLE_DEVICE - If set the framebuffer device will be initialised |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 78 | as an output only device. The Keyboard driver |
| 79 | will not be set-up. This may be used, if you |
| 80 | have none or more than one Keyboard devices |
| 81 | (USB Keyboard, AT Keyboard). |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 82 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 83 | CONFIG_VIDEO_SW_CURSOR: - Draws a cursor after the last character. No |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 84 | blinking is provided. Uses the macros CURSOR_SET |
| 85 | and CURSOR_OFF. |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 86 | CONFIG_VIDEO_HW_CURSOR: - Uses the hardware cursor capability of the |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 87 | graphic chip. Uses the macro CURSOR_SET. |
| 88 | ATTENTION: If booting an OS, the display driver |
| 89 | must disable the hardware register of the graphic |
| 90 | chip. Otherwise a blinking field is displayed |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 91 | */ |
| 92 | |
| 93 | #include <common.h> |
| 94 | |
| 95 | #ifdef CONFIG_CFB_CONSOLE |
| 96 | |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 97 | #include <malloc.h> |
| 98 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 99 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 100 | /* Console device defines with SMI graphic */ |
| 101 | /* Any other graphic must change this section */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 102 | /*****************************************************************************/ |
| 103 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 104 | #ifdef CONFIG_VIDEO_SMI_LYNXEM |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 105 | |
| 106 | #define VIDEO_FB_LITTLE_ENDIAN |
| 107 | #define VIDEO_HW_RECTFILL |
| 108 | #define VIDEO_HW_BITBLT |
| 109 | #endif |
| 110 | |
| 111 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 112 | /* Defines for the CT69000 driver */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 113 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 114 | #ifdef CONFIG_VIDEO_CT69000 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 115 | |
| 116 | #define VIDEO_FB_LITTLE_ENDIAN |
| 117 | #define VIDEO_HW_RECTFILL |
| 118 | #define VIDEO_HW_BITBLT |
| 119 | #endif |
| 120 | |
| 121 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 122 | /* Defines for the SED13806 driver */ |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 123 | /*****************************************************************************/ |
| 124 | #ifdef CONFIG_VIDEO_SED13806 |
| 125 | |
wdenk | da54bc9 | 2004-08-04 21:56:49 +0000 | [diff] [blame] | 126 | #ifndef CONFIG_TOTAL5200 |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 127 | #define VIDEO_FB_LITTLE_ENDIAN |
wdenk | da54bc9 | 2004-08-04 21:56:49 +0000 | [diff] [blame] | 128 | #endif |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 129 | #define VIDEO_HW_RECTFILL |
| 130 | #define VIDEO_HW_BITBLT |
| 131 | #endif |
| 132 | |
| 133 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 134 | /* Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | /*****************************************************************************/ |
| 136 | #include <video_fb.h> |
| 137 | |
| 138 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 139 | /* some Macros */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 140 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 141 | #define VIDEO_VISIBLE_COLS (pGD->winSizeX) |
| 142 | #define VIDEO_VISIBLE_ROWS (pGD->winSizeY) |
| 143 | #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP) |
| 144 | #define VIDEO_DATA_FORMAT (pGD->gdfIndex) |
| 145 | #define VIDEO_FB_ADRS (pGD->frameAdrs) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 146 | |
| 147 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 148 | /* Console device defines with i8042 keyboard controller */ |
| 149 | /* Any other keyboard controller must change this section */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 150 | /*****************************************************************************/ |
| 151 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 152 | #ifdef CONFIG_I8042_KBD |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 153 | #include <i8042.h> |
| 154 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 155 | #define VIDEO_KBD_INIT_FCT i8042_kbd_init() |
| 156 | #define VIDEO_TSTC_FCT i8042_tstc |
| 157 | #define VIDEO_GETC_FCT i8042_getc |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 158 | #endif |
| 159 | |
| 160 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 161 | /* Console device */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 162 | /*****************************************************************************/ |
| 163 | |
| 164 | #include <version.h> |
| 165 | #include <linux/types.h> |
| 166 | #include <devices.h> |
| 167 | #include <video_font.h> |
| 168 | #ifdef CFG_CMD_DATE |
| 169 | #include <rtc.h> |
| 170 | |
| 171 | #endif |
| 172 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 173 | #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
| 174 | #include <watchdog.h> |
| 175 | #include <bmp_layout.h> |
| 176 | #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ |
| 177 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 178 | /*****************************************************************************/ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 179 | /* Cursor definition: */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 180 | /* CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/i8042.c) to */ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 181 | /* let the cursor blink. Uses the macros CURSOR_OFF */ |
| 182 | /* and CURSOR_ON. */ |
| 183 | /* CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No */ |
| 184 | /* blinking is provided. Uses the macros CURSOR_SET */ |
| 185 | /* and CURSOR_OFF. */ |
| 186 | /* CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the */ |
| 187 | /* graphic chip. Uses the macro CURSOR_SET. */ |
| 188 | /* ATTENTION: If booting an OS, the display driver */ |
| 189 | /* must disable the hardware register of the graphic */ |
| 190 | /* chip. Otherwise a blinking field is displayed */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 191 | /*****************************************************************************/ |
| 192 | #if !defined(CONFIG_CONSOLE_CURSOR) && \ |
| 193 | !defined(CONFIG_VIDEO_SW_CURSOR) && \ |
| 194 | !defined(CONFIG_VIDEO_HW_CURSOR) |
| 195 | /* no Cursor defined */ |
| 196 | #define CURSOR_ON |
| 197 | #define CURSOR_OFF |
| 198 | #define CURSOR_SET |
| 199 | #endif |
| 200 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 201 | #ifdef CONFIG_CONSOLE_CURSOR |
| 202 | #ifdef CURSOR_ON |
| 203 | #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 204 | #endif |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 205 | void console_cursor (int state); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 206 | #define CURSOR_ON console_cursor(1); |
| 207 | #define CURSOR_OFF console_cursor(0); |
| 208 | #define CURSOR_SET |
| 209 | #ifndef CONFIG_I8042_KBD |
| 210 | #warning Cursor drawing on/off needs timer function s.a. drivers/i8042.c |
| 211 | #endif |
| 212 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 213 | #ifdef CONFIG_CONSOLE_TIME |
| 214 | #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 215 | #endif |
| 216 | #endif /* CONFIG_CONSOLE_CURSOR */ |
| 217 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 218 | #ifdef CONFIG_VIDEO_SW_CURSOR |
| 219 | #ifdef CURSOR_ON |
| 220 | #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 221 | #endif |
| 222 | #define CURSOR_ON |
| 223 | #define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 224 | console_row * VIDEO_FONT_HEIGHT, ' '); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 225 | #define CURSOR_SET video_set_cursor(); |
| 226 | #endif /* CONFIG_VIDEO_SW_CURSOR */ |
| 227 | |
| 228 | |
| 229 | #ifdef CONFIG_VIDEO_HW_CURSOR |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 230 | #ifdef CURSOR_ON |
| 231 | #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 232 | #endif |
| 233 | #define CURSOR_ON |
| 234 | #define CURSOR_OFF |
| 235 | #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 236 | (console_row * VIDEO_FONT_HEIGHT) + VIDEO_LOGO_HEIGHT); |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 237 | #endif /* CONFIG_VIDEO_HW_CURSOR */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 238 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 239 | #ifdef CONFIG_VIDEO_LOGO |
| 240 | #ifdef CONFIG_VIDEO_BMP_LOGO |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 241 | #include <bmp_logo.h> |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 242 | #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH |
| 243 | #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT |
| 244 | #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET |
| 245 | #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 246 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 247 | #else /* CONFIG_VIDEO_BMP_LOGO */ |
| 248 | #define LINUX_LOGO_WIDTH 80 |
| 249 | #define LINUX_LOGO_HEIGHT 80 |
| 250 | #define LINUX_LOGO_COLORS 214 |
| 251 | #define LINUX_LOGO_LUT_OFFSET 0x20 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 252 | #define __initdata |
| 253 | #include <linux_logo.h> |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 254 | #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH |
| 255 | #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT |
| 256 | #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET |
| 257 | #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS |
| 258 | #endif /* CONFIG_VIDEO_BMP_LOGO */ |
| 259 | #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH) |
| 260 | #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2) |
| 261 | #else /* CONFIG_VIDEO_LOGO */ |
| 262 | #define VIDEO_LOGO_WIDTH 0 |
| 263 | #define VIDEO_LOGO_HEIGHT 0 |
| 264 | #endif /* CONFIG_VIDEO_LOGO */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 265 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 266 | #define VIDEO_COLS VIDEO_VISIBLE_COLS |
| 267 | #define VIDEO_ROWS VIDEO_VISIBLE_ROWS |
| 268 | #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE) |
| 269 | #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2) |
| 270 | #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE) |
| 271 | #define VIDEO_BURST_LEN (VIDEO_COLS/8) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 272 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 273 | #ifdef CONFIG_VIDEO_LOGO |
| 274 | #define CONSOLE_ROWS ((VIDEO_ROWS - VIDEO_LOGO_HEIGHT) / VIDEO_FONT_HEIGHT) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 275 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 276 | #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 277 | #endif |
| 278 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 279 | #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH) |
| 280 | #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN) |
| 281 | #define CONSOLE_ROW_FIRST (video_console_address) |
| 282 | #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE) |
| 283 | #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
| 284 | #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) |
| 285 | #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 286 | |
| 287 | /* Macros */ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 288 | #ifdef VIDEO_FB_LITTLE_ENDIAN |
| 289 | #define SWAP16(x) ((((x) & 0x00ff) << 8) | ( (x) >> 8)) |
| 290 | #define SWAP32(x) ((((x) & 0x000000ff) << 24) | (((x) & 0x0000ff00) << 8)|\ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 291 | (((x) & 0x00ff0000) >> 8) | (((x) & 0xff000000) >> 24) ) |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 292 | #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | (((x) & 0x0000ff00) >> 8)|\ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 293 | (((x) & 0x00ff0000) << 8) | (((x) & 0xff000000) >> 8) ) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 294 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 295 | #define SWAP16(x) (x) |
| 296 | #define SWAP32(x) (x) |
| 297 | #define SHORTSWAP32(x) (x) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 298 | #endif |
| 299 | |
| 300 | #if defined(DEBUG) || defined(DEBUG_CFB_CONSOLE) |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 301 | #define PRINTD(x) printf(x) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 302 | #else |
| 303 | #define PRINTD(x) |
| 304 | #endif |
| 305 | |
| 306 | |
| 307 | #ifdef CONFIG_CONSOLE_EXTRA_INFO |
| 308 | extern void video_get_info_str ( /* setup a board string: type, speed, etc. */ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 309 | int line_number, /* location to place info string beside logo */ |
| 310 | char *info /* buffer for info string */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 311 | ); |
| 312 | |
| 313 | #endif |
| 314 | |
| 315 | /* Locals */ |
| 316 | static GraphicDevice *pGD; /* Pointer to Graphic array */ |
| 317 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 318 | static void *video_fb_address; /* frame buffer address */ |
| 319 | static void *video_console_address; /* console buffer start address */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 320 | |
| 321 | static int console_col = 0; /* cursor col */ |
| 322 | static int console_row = 0; /* cursor row */ |
| 323 | |
| 324 | static u32 eorx, fgx, bgx; /* color pats */ |
| 325 | |
| 326 | static const int video_font_draw_table8[] = { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 327 | 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, |
| 328 | 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, |
| 329 | 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, |
| 330 | 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 331 | |
| 332 | static const int video_font_draw_table15[] = { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 333 | 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 334 | |
| 335 | static const int video_font_draw_table16[] = { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 336 | 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 337 | |
| 338 | static const int video_font_draw_table24[16][3] = { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 339 | { 0x00000000, 0x00000000, 0x00000000 }, |
| 340 | { 0x00000000, 0x00000000, 0x00ffffff }, |
| 341 | { 0x00000000, 0x0000ffff, 0xff000000 }, |
| 342 | { 0x00000000, 0x0000ffff, 0xffffffff }, |
| 343 | { 0x000000ff, 0xffff0000, 0x00000000 }, |
| 344 | { 0x000000ff, 0xffff0000, 0x00ffffff }, |
| 345 | { 0x000000ff, 0xffffffff, 0xff000000 }, |
| 346 | { 0x000000ff, 0xffffffff, 0xffffffff }, |
| 347 | { 0xffffff00, 0x00000000, 0x00000000 }, |
| 348 | { 0xffffff00, 0x00000000, 0x00ffffff }, |
| 349 | { 0xffffff00, 0x0000ffff, 0xff000000 }, |
| 350 | { 0xffffff00, 0x0000ffff, 0xffffffff }, |
| 351 | { 0xffffffff, 0xffff0000, 0x00000000 }, |
| 352 | { 0xffffffff, 0xffff0000, 0x00ffffff }, |
| 353 | { 0xffffffff, 0xffffffff, 0xff000000 }, |
| 354 | { 0xffffffff, 0xffffffff, 0xffffffff } }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 355 | |
| 356 | static const int video_font_draw_table32[16][4] = { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 357 | { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, |
| 358 | { 0x00000000, 0x00000000, 0x00000000, 0x00ffffff }, |
| 359 | { 0x00000000, 0x00000000, 0x00ffffff, 0x00000000 }, |
| 360 | { 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff }, |
| 361 | { 0x00000000, 0x00ffffff, 0x00000000, 0x00000000 }, |
| 362 | { 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff }, |
| 363 | { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000 }, |
| 364 | { 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff }, |
| 365 | { 0x00ffffff, 0x00000000, 0x00000000, 0x00000000 }, |
| 366 | { 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff }, |
| 367 | { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000 }, |
| 368 | { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff }, |
| 369 | { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000 }, |
| 370 | { 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff }, |
| 371 | { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000 }, |
| 372 | { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff } }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 373 | |
| 374 | |
| 375 | /******************************************************************************/ |
| 376 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 377 | static void video_drawchars (int xx, int yy, unsigned char *s, int count) |
| 378 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 379 | u8 *cdat, *dest, *dest0; |
| 380 | int rows, offset, c; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 381 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 382 | offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE; |
| 383 | dest0 = video_fb_address + offset; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 384 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 385 | switch (VIDEO_DATA_FORMAT) { |
| 386 | case GDF__8BIT_INDEX: |
| 387 | case GDF__8BIT_332RGB: |
| 388 | while (count--) { |
| 389 | c = *s; |
| 390 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 391 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
| 392 | rows--; |
| 393 | dest += VIDEO_LINE_LEN) { |
| 394 | u8 bits = *cdat++; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 395 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 396 | ((u32 *) dest)[0] = (video_font_draw_table8[bits >> 4] & eorx) ^ bgx; |
| 397 | ((u32 *) dest)[1] = (video_font_draw_table8[bits & 15] & eorx) ^ bgx; |
| 398 | } |
| 399 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 400 | s++; |
| 401 | } |
| 402 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 403 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 404 | case GDF_15BIT_555RGB: |
| 405 | while (count--) { |
| 406 | c = *s; |
| 407 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 408 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
| 409 | rows--; |
| 410 | dest += VIDEO_LINE_LEN) { |
| 411 | u8 bits = *cdat++; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 412 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 413 | ((u32 *) dest)[0] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 6] & eorx) ^ bgx); |
| 414 | ((u32 *) dest)[1] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 4 & 3] & eorx) ^ bgx); |
| 415 | ((u32 *) dest)[2] = SHORTSWAP32 ((video_font_draw_table15 [bits >> 2 & 3] & eorx) ^ bgx); |
| 416 | ((u32 *) dest)[3] = SHORTSWAP32 ((video_font_draw_table15 [bits & 3] & eorx) ^ bgx); |
| 417 | } |
| 418 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 419 | s++; |
| 420 | } |
| 421 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 422 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 423 | case GDF_16BIT_565RGB: |
| 424 | while (count--) { |
| 425 | c = *s; |
| 426 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 427 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
| 428 | rows--; |
| 429 | dest += VIDEO_LINE_LEN) { |
| 430 | u8 bits = *cdat++; |
| 431 | |
| 432 | ((u32 *) dest)[0] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 6] & eorx) ^ bgx); |
| 433 | ((u32 *) dest)[1] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 4 & 3] & eorx) ^ bgx); |
| 434 | ((u32 *) dest)[2] = SHORTSWAP32 ((video_font_draw_table16 [bits >> 2 & 3] & eorx) ^ bgx); |
| 435 | ((u32 *) dest)[3] = SHORTSWAP32 ((video_font_draw_table16 [bits & 3] & eorx) ^ bgx); |
| 436 | } |
| 437 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 438 | s++; |
| 439 | } |
| 440 | break; |
| 441 | |
| 442 | case GDF_32BIT_X888RGB: |
| 443 | while (count--) { |
| 444 | c = *s; |
| 445 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 446 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
| 447 | rows--; |
| 448 | dest += VIDEO_LINE_LEN) { |
| 449 | u8 bits = *cdat++; |
| 450 | |
| 451 | ((u32 *) dest)[0] = SWAP32 ((video_font_draw_table32 [bits >> 4][0] & eorx) ^ bgx); |
| 452 | ((u32 *) dest)[1] = SWAP32 ((video_font_draw_table32 [bits >> 4][1] & eorx) ^ bgx); |
| 453 | ((u32 *) dest)[2] = SWAP32 ((video_font_draw_table32 [bits >> 4][2] & eorx) ^ bgx); |
| 454 | ((u32 *) dest)[3] = SWAP32 ((video_font_draw_table32 [bits >> 4][3] & eorx) ^ bgx); |
| 455 | ((u32 *) dest)[4] = SWAP32 ((video_font_draw_table32 [bits & 15][0] & eorx) ^ bgx); |
| 456 | ((u32 *) dest)[5] = SWAP32 ((video_font_draw_table32 [bits & 15][1] & eorx) ^ bgx); |
| 457 | ((u32 *) dest)[6] = SWAP32 ((video_font_draw_table32 [bits & 15][2] & eorx) ^ bgx); |
| 458 | ((u32 *) dest)[7] = SWAP32 ((video_font_draw_table32 [bits & 15][3] & eorx) ^ bgx); |
| 459 | } |
| 460 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 461 | s++; |
| 462 | } |
| 463 | break; |
| 464 | |
| 465 | case GDF_24BIT_888RGB: |
| 466 | while (count--) { |
| 467 | c = *s; |
| 468 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 469 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
| 470 | rows--; |
| 471 | dest += VIDEO_LINE_LEN) { |
| 472 | u8 bits = *cdat++; |
| 473 | |
| 474 | ((u32 *) dest)[0] = (video_font_draw_table24[bits >> 4][0] & eorx) ^ bgx; |
| 475 | ((u32 *) dest)[1] = (video_font_draw_table24[bits >> 4][1] & eorx) ^ bgx; |
| 476 | ((u32 *) dest)[2] = (video_font_draw_table24[bits >> 4][2] & eorx) ^ bgx; |
| 477 | ((u32 *) dest)[3] = (video_font_draw_table24[bits & 15][0] & eorx) ^ bgx; |
| 478 | ((u32 *) dest)[4] = (video_font_draw_table24[bits & 15][1] & eorx) ^ bgx; |
| 479 | ((u32 *) dest)[5] = (video_font_draw_table24[bits & 15][2] & eorx) ^ bgx; |
| 480 | } |
| 481 | dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; |
| 482 | s++; |
| 483 | } |
| 484 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 485 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | /*****************************************************************************/ |
| 489 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 490 | static inline void video_drawstring (int xx, int yy, unsigned char *s) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 491 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 492 | video_drawchars (xx, yy, s, strlen (s)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | /*****************************************************************************/ |
| 496 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 497 | static void video_putchar (int xx, int yy, unsigned char c) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 498 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 499 | video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | /*****************************************************************************/ |
| 503 | #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR) |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 504 | static void video_set_cursor (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 505 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 506 | /* swap drawing colors */ |
| 507 | eorx = fgx; |
| 508 | fgx = bgx; |
| 509 | bgx = eorx; |
| 510 | eorx = fgx ^ bgx; |
| 511 | /* draw cursor */ |
| 512 | video_putchar (console_col * VIDEO_FONT_WIDTH, |
| 513 | console_row * VIDEO_FONT_HEIGHT, |
| 514 | ' '); |
| 515 | /* restore drawing colors */ |
| 516 | eorx = fgx; |
| 517 | fgx = bgx; |
| 518 | bgx = eorx; |
| 519 | eorx = fgx ^ bgx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 520 | } |
| 521 | #endif |
| 522 | /*****************************************************************************/ |
| 523 | #ifdef CONFIG_CONSOLE_CURSOR |
| 524 | void console_cursor (int state) |
| 525 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 526 | static int last_state = 0; |
| 527 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 528 | #ifdef CONFIG_CONSOLE_TIME |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 529 | struct rtc_time tm; |
| 530 | char info[16]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 531 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 532 | /* time update only if cursor is on (faster scroll) */ |
| 533 | if (state) { |
| 534 | rtc_get (&tm); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 535 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 536 | sprintf (info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min, |
| 537 | tm.tm_sec); |
| 538 | video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH, |
| 539 | VIDEO_INFO_Y, info); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 540 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 541 | sprintf (info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon, |
| 542 | tm.tm_year); |
| 543 | video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH, |
| 544 | VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, info); |
| 545 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 546 | #endif |
| 547 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 548 | if (state && (last_state != state)) { |
| 549 | video_set_cursor (); |
| 550 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 551 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 552 | if (!state && (last_state != state)) { |
| 553 | /* clear cursor */ |
| 554 | video_putchar (console_col * VIDEO_FONT_WIDTH, |
| 555 | console_row * VIDEO_FONT_HEIGHT, |
| 556 | ' '); |
| 557 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 558 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 559 | last_state = state; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 560 | } |
| 561 | #endif |
| 562 | |
| 563 | /*****************************************************************************/ |
| 564 | |
| 565 | #ifndef VIDEO_HW_RECTFILL |
| 566 | static void memsetl (int *p, int c, int v) |
| 567 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 568 | while (c--) |
| 569 | *(p++) = v; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 570 | } |
| 571 | #endif |
| 572 | |
| 573 | /*****************************************************************************/ |
| 574 | |
| 575 | #ifndef VIDEO_HW_BITBLT |
| 576 | static void memcpyl (int *d, int *s, int c) |
| 577 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 578 | while (c--) |
| 579 | *(d++) = *(s++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 580 | } |
| 581 | #endif |
| 582 | |
| 583 | /*****************************************************************************/ |
| 584 | |
| 585 | static void console_scrollup (void) |
| 586 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 587 | /* copy up rows ignoring the first one */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 588 | |
| 589 | #ifdef VIDEO_HW_BITBLT |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 590 | video_hw_bitblt (VIDEO_PIXEL_SIZE, /* bytes per pixel */ |
| 591 | 0, /* source pos x */ |
| 592 | VIDEO_LOGO_HEIGHT + VIDEO_FONT_HEIGHT, /* source pos y */ |
| 593 | 0, /* dest pos x */ |
| 594 | VIDEO_LOGO_HEIGHT, /* dest pos y */ |
| 595 | VIDEO_VISIBLE_COLS, /* frame width */ |
| 596 | VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT - VIDEO_FONT_HEIGHT /* frame height */ |
| 597 | ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 598 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 599 | memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, |
| 600 | CONSOLE_SCROLL_SIZE >> 2); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 601 | #endif |
| 602 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 603 | /* clear the last one */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 604 | #ifdef VIDEO_HW_RECTFILL |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 605 | video_hw_rectfill (VIDEO_PIXEL_SIZE, /* bytes per pixel */ |
| 606 | 0, /* dest pos x */ |
| 607 | VIDEO_VISIBLE_ROWS - VIDEO_FONT_HEIGHT, /* dest pos y */ |
| 608 | VIDEO_VISIBLE_COLS, /* frame width */ |
| 609 | VIDEO_FONT_HEIGHT, /* frame height */ |
| 610 | CONSOLE_BG_COL /* fill color */ |
| 611 | ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 612 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 613 | memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 614 | #endif |
| 615 | } |
| 616 | |
| 617 | /*****************************************************************************/ |
| 618 | |
| 619 | static void console_back (void) |
| 620 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 621 | CURSOR_OFF console_col--; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 622 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 623 | if (console_col < 0) { |
| 624 | console_col = CONSOLE_COLS - 1; |
| 625 | console_row--; |
| 626 | if (console_row < 0) |
| 627 | console_row = 0; |
| 628 | } |
| 629 | video_putchar (console_col * VIDEO_FONT_WIDTH, |
| 630 | console_row * VIDEO_FONT_HEIGHT, |
| 631 | ' '); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | /*****************************************************************************/ |
| 635 | |
| 636 | static void console_newline (void) |
| 637 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 638 | CURSOR_OFF console_row++; |
| 639 | console_col = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 640 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 641 | /* Check if we need to scroll the terminal */ |
| 642 | if (console_row >= CONSOLE_ROWS) { |
| 643 | /* Scroll everything up */ |
| 644 | console_scrollup (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 645 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 646 | /* Decrement row number */ |
| 647 | console_row--; |
| 648 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | /*****************************************************************************/ |
| 652 | |
| 653 | void video_putc (const char c) |
| 654 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 655 | switch (c) { |
| 656 | case 13: /* ignore */ |
| 657 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 658 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 659 | case '\n': /* next line */ |
| 660 | console_newline (); |
| 661 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 662 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 663 | case 9: /* tab 8 */ |
| 664 | CURSOR_OFF console_col |= 0x0008; |
| 665 | console_col &= ~0x0007; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 666 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 667 | if (console_col >= CONSOLE_COLS) |
| 668 | console_newline (); |
| 669 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 670 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 671 | case 8: /* backspace */ |
| 672 | console_back (); |
| 673 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 674 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 675 | default: /* draw the char */ |
| 676 | video_putchar (console_col * VIDEO_FONT_WIDTH, |
| 677 | console_row * VIDEO_FONT_HEIGHT, |
| 678 | c); |
| 679 | console_col++; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 680 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 681 | /* check for newline */ |
| 682 | if (console_col >= CONSOLE_COLS) |
| 683 | console_newline (); |
| 684 | } |
| 685 | CURSOR_SET} |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 686 | |
| 687 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 688 | /*****************************************************************************/ |
| 689 | |
| 690 | void video_puts (const char *s) |
| 691 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 692 | int count = strlen (s); |
| 693 | |
| 694 | while (count--) |
| 695 | video_putc (*s++); |
| 696 | } |
| 697 | |
| 698 | /*****************************************************************************/ |
| 699 | |
| 700 | #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
| 701 | |
| 702 | #define FILL_8BIT_332RGB(r,g,b) { \ |
| 703 | *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6); \ |
| 704 | fb ++; \ |
| 705 | } |
| 706 | |
| 707 | #define FILL_15BIT_555RGB(r,g,b) { \ |
| 708 | *(unsigned short *)fb = SWAP16((unsigned short)(((r>>3)<<10) | ((g>>3)<<5) | (b>>3))); \ |
| 709 | fb += 2; \ |
| 710 | } |
| 711 | |
| 712 | #define FILL_16BIT_565RGB(r,g,b) { \ |
| 713 | *(unsigned short *)fb = SWAP16((unsigned short)((((r)>>3)<<11) | (((g)>>2)<<5) | ((b)>>3))); \ |
| 714 | fb += 2; \ |
| 715 | } |
| 716 | |
| 717 | #define FILL_32BIT_X888RGB(r,g,b) { \ |
| 718 | *(unsigned long *)fb = SWAP32((unsigned long)(((r<<16) | (g<<8) | b))); \ |
| 719 | fb += 4; \ |
| 720 | } |
| 721 | |
| 722 | #ifdef VIDEO_FB_LITTLE_ENDIAN |
| 723 | #define FILL_24BIT_888RGB(r,g,b) { \ |
| 724 | fb[0] = b; \ |
| 725 | fb[1] = g; \ |
| 726 | fb[2] = r; \ |
| 727 | fb += 3; \ |
| 728 | } |
| 729 | #else |
| 730 | #define FILL_24BIT_888RGB(r,g,b) { \ |
| 731 | fb[0] = r; \ |
| 732 | fb[1] = g; \ |
| 733 | fb[2] = b; \ |
| 734 | fb += 3; \ |
| 735 | } |
| 736 | #endif |
| 737 | |
| 738 | |
| 739 | /* |
| 740 | * Display the BMP file located at address bmp_image. |
| 741 | * Only uncompressed |
| 742 | */ |
| 743 | int video_display_bitmap (ulong bmp_image, int x, int y) |
| 744 | { |
| 745 | ushort xcount, ycount; |
| 746 | uchar *fb; |
| 747 | bmp_image_t *bmp = (bmp_image_t *) bmp_image; |
| 748 | uchar *bmap; |
| 749 | ushort padded_line; |
| 750 | unsigned long width, height, bpp; |
| 751 | unsigned colors; |
| 752 | unsigned long compression; |
| 753 | bmp_color_table_entry_t cte; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 754 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 755 | WATCHDOG_RESET (); |
| 756 | |
| 757 | if (!((bmp->header.signature[0] == 'B') && |
| 758 | (bmp->header.signature[1] == 'M'))) { |
| 759 | printf ("Error: no valid bmp image at %lx\n", bmp_image); |
| 760 | return 1; |
| 761 | } |
| 762 | |
| 763 | width = le32_to_cpu (bmp->header.width); |
| 764 | height = le32_to_cpu (bmp->header.height); |
| 765 | bpp = le16_to_cpu (bmp->header.bit_count); |
| 766 | colors = le32_to_cpu (bmp->header.colors_used); |
| 767 | compression = le32_to_cpu (bmp->header.compression); |
| 768 | |
| 769 | debug ("Display-bmp: %d x %d with %d colors\n", |
| 770 | width, height, colors); |
| 771 | |
| 772 | if (compression != BMP_BI_RGB) { |
| 773 | printf ("Error: compression type %ld not supported\n", |
| 774 | compression); |
| 775 | return 1; |
| 776 | } |
| 777 | |
| 778 | padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3; |
| 779 | |
| 780 | if ((x + width) > VIDEO_VISIBLE_COLS) |
| 781 | width = VIDEO_VISIBLE_COLS - x; |
| 782 | if ((y + height) > VIDEO_VISIBLE_ROWS) |
| 783 | height = VIDEO_VISIBLE_ROWS - y; |
| 784 | |
| 785 | bmap = (uchar *) bmp + le32_to_cpu (bmp->header.data_offset); |
| 786 | fb = (uchar *) (video_fb_address + |
| 787 | ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) + |
| 788 | x * VIDEO_PIXEL_SIZE); |
| 789 | |
| 790 | /* We handle only 8bpp or 24 bpp bitmap */ |
| 791 | switch (le16_to_cpu (bmp->header.bit_count)) { |
| 792 | case 8: |
| 793 | padded_line -= width; |
| 794 | if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) { |
| 795 | /* Copy colormap */ |
| 796 | for (xcount = 0; xcount < colors; ++xcount) { |
| 797 | cte = bmp->color_table[xcount]; |
| 798 | video_set_lut (xcount, cte.red, cte.green, cte.blue); |
| 799 | } |
| 800 | } |
| 801 | ycount = height; |
| 802 | switch (VIDEO_DATA_FORMAT) { |
| 803 | case GDF__8BIT_INDEX: |
| 804 | while (ycount--) { |
| 805 | WATCHDOG_RESET (); |
| 806 | xcount = width; |
| 807 | while (xcount--) { |
| 808 | *fb++ = *bmap++; |
| 809 | } |
| 810 | bmap += padded_line; |
| 811 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 812 | } |
| 813 | break; |
| 814 | case GDF__8BIT_332RGB: |
| 815 | while (ycount--) { |
| 816 | WATCHDOG_RESET (); |
| 817 | xcount = width; |
| 818 | while (xcount--) { |
| 819 | cte = bmp->color_table[*bmap++]; |
| 820 | FILL_8BIT_332RGB (cte.red, cte.green, cte.blue); |
| 821 | } |
| 822 | bmap += padded_line; |
| 823 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 824 | } |
| 825 | break; |
| 826 | case GDF_15BIT_555RGB: |
| 827 | while (ycount--) { |
| 828 | WATCHDOG_RESET (); |
| 829 | xcount = width; |
| 830 | while (xcount--) { |
| 831 | cte = bmp->color_table[*bmap++]; |
| 832 | FILL_15BIT_555RGB (cte.red, cte.green, cte.blue); |
| 833 | } |
| 834 | bmap += padded_line; |
| 835 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 836 | } |
| 837 | break; |
| 838 | case GDF_16BIT_565RGB: |
| 839 | while (ycount--) { |
| 840 | WATCHDOG_RESET (); |
| 841 | xcount = width; |
| 842 | while (xcount--) { |
| 843 | cte = bmp->color_table[*bmap++]; |
| 844 | FILL_16BIT_565RGB (cte.red, cte.green, cte.blue); |
| 845 | } |
| 846 | bmap += padded_line; |
| 847 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 848 | } |
| 849 | break; |
| 850 | case GDF_32BIT_X888RGB: |
| 851 | while (ycount--) { |
| 852 | WATCHDOG_RESET (); |
| 853 | xcount = width; |
| 854 | while (xcount--) { |
| 855 | cte = bmp->color_table[*bmap++]; |
| 856 | FILL_32BIT_X888RGB (cte.red, cte.green, cte.blue); |
| 857 | } |
| 858 | bmap += padded_line; |
| 859 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 860 | } |
| 861 | break; |
| 862 | case GDF_24BIT_888RGB: |
| 863 | while (ycount--) { |
| 864 | WATCHDOG_RESET (); |
| 865 | xcount = width; |
| 866 | while (xcount--) { |
| 867 | cte = bmp->color_table[*bmap++]; |
| 868 | FILL_24BIT_888RGB (cte.red, cte.green, cte.blue); |
| 869 | } |
| 870 | bmap += padded_line; |
| 871 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 872 | } |
| 873 | break; |
| 874 | } |
| 875 | break; |
| 876 | case 24: |
| 877 | padded_line -= 3 * width; |
| 878 | ycount = height; |
| 879 | switch (VIDEO_DATA_FORMAT) { |
| 880 | case GDF__8BIT_332RGB: |
| 881 | while (ycount--) { |
| 882 | WATCHDOG_RESET (); |
| 883 | xcount = width; |
| 884 | while (xcount--) { |
| 885 | FILL_8BIT_332RGB (bmap[2], bmap[1], bmap[0]); |
| 886 | bmap += 3; |
| 887 | } |
| 888 | bmap += padded_line; |
| 889 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 890 | } |
| 891 | break; |
| 892 | case GDF_15BIT_555RGB: |
| 893 | while (ycount--) { |
| 894 | WATCHDOG_RESET (); |
| 895 | xcount = width; |
| 896 | while (xcount--) { |
| 897 | FILL_15BIT_555RGB (bmap[2], bmap[1], bmap[0]); |
| 898 | bmap += 3; |
| 899 | } |
| 900 | bmap += padded_line; |
| 901 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 902 | } |
| 903 | break; |
| 904 | case GDF_16BIT_565RGB: |
| 905 | while (ycount--) { |
| 906 | WATCHDOG_RESET (); |
| 907 | xcount = width; |
| 908 | while (xcount--) { |
| 909 | FILL_16BIT_565RGB (bmap[2], bmap[1], bmap[0]); |
| 910 | bmap += 3; |
| 911 | } |
| 912 | bmap += padded_line; |
| 913 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 914 | } |
| 915 | break; |
| 916 | case GDF_32BIT_X888RGB: |
| 917 | while (ycount--) { |
| 918 | WATCHDOG_RESET (); |
| 919 | xcount = width; |
| 920 | while (xcount--) { |
| 921 | FILL_32BIT_X888RGB (bmap[2], bmap[1], bmap[0]); |
| 922 | bmap += 3; |
| 923 | } |
| 924 | bmap += padded_line; |
| 925 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 926 | } |
| 927 | break; |
| 928 | case GDF_24BIT_888RGB: |
| 929 | while (ycount--) { |
| 930 | WATCHDOG_RESET (); |
| 931 | xcount = width; |
| 932 | while (xcount--) { |
| 933 | FILL_24BIT_888RGB (bmap[2], bmap[1], bmap[0]); |
| 934 | bmap += 3; |
| 935 | } |
| 936 | bmap += padded_line; |
| 937 | fb -= (VIDEO_VISIBLE_COLS + width) * VIDEO_PIXEL_SIZE; |
| 938 | } |
| 939 | break; |
| 940 | default: |
| 941 | printf ("Error: 24 bits/pixel bitmap incompatible with current video mode\n"); |
| 942 | break; |
| 943 | } |
| 944 | break; |
| 945 | default: |
| 946 | printf ("Error: %d bit/pixel bitmaps not supported by U-Boot\n", |
| 947 | le16_to_cpu (bmp->header.bit_count)); |
| 948 | break; |
| 949 | } |
| 950 | return (0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 951 | } |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 952 | #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 953 | |
| 954 | /*****************************************************************************/ |
| 955 | |
| 956 | #ifdef CONFIG_VIDEO_LOGO |
| 957 | void logo_plot (void *screen, int width, int x, int y) |
| 958 | { |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 959 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 960 | int xcount, i; |
| 961 | int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE; |
| 962 | int ycount = VIDEO_LOGO_HEIGHT; |
| 963 | unsigned char r, g, b, *logo_red, *logo_blue, *logo_green; |
| 964 | unsigned char *source; |
| 965 | unsigned char *dest = (unsigned char *)screen + ((y * width * VIDEO_PIXEL_SIZE) + x); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 966 | |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 967 | #ifdef CONFIG_VIDEO_BMP_LOGO |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 968 | source = bmp_logo_bitmap; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 969 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 970 | /* Allocate temporary space for computing colormap */ |
| 971 | logo_red = malloc (BMP_LOGO_COLORS); |
| 972 | logo_green = malloc (BMP_LOGO_COLORS); |
| 973 | logo_blue = malloc (BMP_LOGO_COLORS); |
| 974 | /* Compute color map */ |
| 975 | for (i = 0; i < VIDEO_LOGO_COLORS; i++) { |
| 976 | logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4; |
| 977 | logo_green[i] = (bmp_logo_palette[i] & 0x00f0); |
| 978 | logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4; |
| 979 | } |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 980 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 981 | source = linux_logo; |
| 982 | logo_red = linux_logo_red; |
| 983 | logo_green = linux_logo_green; |
| 984 | logo_blue = linux_logo_blue; |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 985 | #endif |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 986 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 987 | if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) { |
| 988 | for (i = 0; i < VIDEO_LOGO_COLORS; i++) { |
| 989 | video_set_lut (i + VIDEO_LOGO_LUT_OFFSET, |
| 990 | logo_red[i], logo_green[i], logo_blue[i]); |
| 991 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 992 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 993 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 994 | while (ycount--) { |
| 995 | xcount = VIDEO_LOGO_WIDTH; |
| 996 | while (xcount--) { |
| 997 | r = logo_red[*source - VIDEO_LOGO_LUT_OFFSET]; |
| 998 | g = logo_green[*source - VIDEO_LOGO_LUT_OFFSET]; |
| 999 | b = logo_blue[*source - VIDEO_LOGO_LUT_OFFSET]; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1000 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1001 | switch (VIDEO_DATA_FORMAT) { |
| 1002 | case GDF__8BIT_INDEX: |
| 1003 | *dest = *source; |
| 1004 | break; |
| 1005 | case GDF__8BIT_332RGB: |
| 1006 | *dest = ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6); |
| 1007 | break; |
| 1008 | case GDF_15BIT_555RGB: |
| 1009 | *(unsigned short *) dest = |
| 1010 | SWAP16 ((unsigned short) (((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3))); |
| 1011 | break; |
| 1012 | case GDF_16BIT_565RGB: |
| 1013 | *(unsigned short *) dest = |
| 1014 | SWAP16 ((unsigned short) (((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3))); |
| 1015 | break; |
| 1016 | case GDF_32BIT_X888RGB: |
| 1017 | *(unsigned long *) dest = |
| 1018 | SWAP32 ((unsigned long) ((r << 16) | (g << 8) | b)); |
| 1019 | break; |
| 1020 | case GDF_24BIT_888RGB: |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1021 | #ifdef VIDEO_FB_LITTLE_ENDIAN |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1022 | dest[0] = b; |
| 1023 | dest[1] = g; |
| 1024 | dest[2] = r; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1025 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1026 | dest[0] = r; |
| 1027 | dest[1] = g; |
| 1028 | dest[2] = b; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1029 | #endif |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1030 | break; |
| 1031 | } |
| 1032 | source++; |
| 1033 | dest += VIDEO_PIXEL_SIZE; |
| 1034 | } |
| 1035 | dest += skip; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1036 | } |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 1037 | #ifdef CONFIG_VIDEO_BMP_LOGO |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1038 | free (logo_red); |
| 1039 | free (logo_green); |
| 1040 | free (logo_blue); |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 1041 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1044 | /*****************************************************************************/ |
| 1045 | |
| 1046 | static void *video_logo (void) |
| 1047 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1048 | char info[128]; |
| 1049 | extern char version_string; |
| 1050 | |
| 1051 | #ifdef CONFIG_SPLASH_SCREEN |
| 1052 | char *s; |
| 1053 | ulong addr; |
| 1054 | |
| 1055 | if ((s = getenv ("splashimage")) != NULL) { |
| 1056 | addr = simple_strtoul (s, NULL, 16); |
| 1057 | |
| 1058 | if (video_display_bitmap (addr, 0, 0) == 0) { |
| 1059 | return ((void *) (video_fb_address)); |
| 1060 | } |
| 1061 | } |
| 1062 | #endif /* CONFIG_SPLASH_SCREEN */ |
| 1063 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1064 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1065 | logo_plot (video_fb_address, VIDEO_COLS, 0, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1066 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1067 | sprintf (info, " %s", &version_string); |
| 1068 | video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1069 | |
| 1070 | #ifdef CONFIG_CONSOLE_EXTRA_INFO |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1071 | { |
| 1072 | int i, n = ((VIDEO_LOGO_HEIGHT - VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1073 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1074 | for (i = 1; i < n; i++) { |
| 1075 | video_get_info_str (i, info); |
| 1076 | if (*info) |
| 1077 | video_drawstring (VIDEO_INFO_X, |
| 1078 | VIDEO_INFO_Y + i * VIDEO_FONT_HEIGHT, |
| 1079 | info); |
| 1080 | } |
| 1081 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1082 | #endif |
| 1083 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1084 | return (video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1085 | } |
| 1086 | #endif |
| 1087 | |
| 1088 | |
| 1089 | /*****************************************************************************/ |
| 1090 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1091 | static int video_init (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1092 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1093 | unsigned char color8; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1094 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1095 | if ((pGD = video_hw_init ()) == NULL) |
| 1096 | return -1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1097 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1098 | video_fb_address = (void *) VIDEO_FB_ADRS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1099 | #ifdef CONFIG_VIDEO_HW_CURSOR |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1100 | video_init_hw_cursor (VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1101 | #endif |
| 1102 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1103 | /* Init drawing pats */ |
| 1104 | switch (VIDEO_DATA_FORMAT) { |
| 1105 | case GDF__8BIT_INDEX: |
| 1106 | video_set_lut (0x01, CONSOLE_FG_COL, CONSOLE_FG_COL, CONSOLE_FG_COL); |
| 1107 | video_set_lut (0x00, CONSOLE_BG_COL, CONSOLE_BG_COL, CONSOLE_BG_COL); |
| 1108 | fgx = 0x01010101; |
| 1109 | bgx = 0x00000000; |
| 1110 | break; |
| 1111 | case GDF__8BIT_332RGB: |
| 1112 | color8 = ((CONSOLE_FG_COL & 0xe0) | |
| 1113 | ((CONSOLE_FG_COL >> 3) & 0x1c) | CONSOLE_FG_COL >> 6); |
| 1114 | fgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | color8; |
| 1115 | color8 = ((CONSOLE_BG_COL & 0xe0) | |
| 1116 | ((CONSOLE_BG_COL >> 3) & 0x1c) | CONSOLE_BG_COL >> 6); |
| 1117 | bgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | color8; |
| 1118 | break; |
| 1119 | case GDF_15BIT_555RGB: |
| 1120 | fgx = (((CONSOLE_FG_COL >> 3) << 26) | |
| 1121 | ((CONSOLE_FG_COL >> 3) << 21) | ((CONSOLE_FG_COL >> 3) << 16) | |
| 1122 | ((CONSOLE_FG_COL >> 3) << 10) | ((CONSOLE_FG_COL >> 3) << 5) | |
| 1123 | (CONSOLE_FG_COL >> 3)); |
| 1124 | bgx = (((CONSOLE_BG_COL >> 3) << 26) | |
| 1125 | ((CONSOLE_BG_COL >> 3) << 21) | ((CONSOLE_BG_COL >> 3) << 16) | |
| 1126 | ((CONSOLE_BG_COL >> 3) << 10) | ((CONSOLE_BG_COL >> 3) << 5) | |
| 1127 | (CONSOLE_BG_COL >> 3)); |
| 1128 | break; |
| 1129 | case GDF_16BIT_565RGB: |
| 1130 | fgx = (((CONSOLE_FG_COL >> 3) << 27) | |
| 1131 | ((CONSOLE_FG_COL >> 2) << 21) | ((CONSOLE_FG_COL >> 3) << 16) | |
| 1132 | ((CONSOLE_FG_COL >> 3) << 11) | ((CONSOLE_FG_COL >> 2) << 5) | |
| 1133 | (CONSOLE_FG_COL >> 3)); |
| 1134 | bgx = (((CONSOLE_BG_COL >> 3) << 27) | |
| 1135 | ((CONSOLE_BG_COL >> 2) << 21) | ((CONSOLE_BG_COL >> 3) << 16) | |
| 1136 | ((CONSOLE_BG_COL >> 3) << 11) | ((CONSOLE_BG_COL >> 2) << 5) | |
| 1137 | (CONSOLE_BG_COL >> 3)); |
| 1138 | break; |
| 1139 | case GDF_32BIT_X888RGB: |
| 1140 | fgx = (CONSOLE_FG_COL << 16) | (CONSOLE_FG_COL << 8) | CONSOLE_FG_COL; |
| 1141 | bgx = (CONSOLE_BG_COL << 16) | (CONSOLE_BG_COL << 8) | CONSOLE_BG_COL; |
| 1142 | break; |
| 1143 | case GDF_24BIT_888RGB: |
| 1144 | fgx = (CONSOLE_FG_COL << 24) | (CONSOLE_FG_COL << 16) | |
| 1145 | (CONSOLE_FG_COL << 8) | CONSOLE_FG_COL; |
| 1146 | bgx = (CONSOLE_BG_COL << 24) | (CONSOLE_BG_COL << 16) | |
| 1147 | (CONSOLE_BG_COL << 8) | CONSOLE_BG_COL; |
| 1148 | break; |
| 1149 | } |
| 1150 | eorx = fgx ^ bgx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1151 | |
| 1152 | #ifdef CONFIG_VIDEO_LOGO |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1153 | /* Plot the logo and get start point of console */ |
| 1154 | PRINTD ("Video: Drawing the logo ...\n"); |
| 1155 | video_console_address = video_logo (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1156 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1157 | video_console_address = video_fb_address; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1158 | #endif |
| 1159 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1160 | /* Initialize the console */ |
| 1161 | console_col = 0; |
| 1162 | console_row = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1163 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1164 | return 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | /*****************************************************************************/ |
| 1169 | |
| 1170 | int drv_video_init (void) |
| 1171 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1172 | int skip_dev_init; |
| 1173 | device_t console_dev; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1174 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1175 | skip_dev_init = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1176 | |
wdenk | 7dd1329 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 1177 | /* Init video chip - returns with framebuffer cleared */ |
| 1178 | if (video_init () == -1) |
| 1179 | skip_dev_init = 1; |
| 1180 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1181 | #ifdef CONFIG_VGA_AS_SINGLE_DEVICE |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1182 | /* Devices VGA and Keyboard will be assigned seperately */ |
| 1183 | /* Init vga device */ |
| 1184 | if (!skip_dev_init) { |
| 1185 | memset (&console_dev, 0, sizeof (console_dev)); |
| 1186 | strcpy (console_dev.name, "vga"); |
| 1187 | console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */ |
| 1188 | console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM; |
| 1189 | console_dev.putc = video_putc; /* 'putc' function */ |
| 1190 | console_dev.puts = video_puts; /* 'puts' function */ |
| 1191 | console_dev.tstc = NULL; /* 'tstc' function */ |
| 1192 | console_dev.getc = NULL; /* 'getc' function */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1193 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1194 | if (device_register (&console_dev) == 0) |
| 1195 | return 1; |
| 1196 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1197 | #else |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1198 | PRINTD ("KBD: Keyboard init ...\n"); |
| 1199 | if (VIDEO_KBD_INIT_FCT == -1) |
| 1200 | skip_dev_init = 1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1201 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1202 | /* Init console device */ |
| 1203 | if (!skip_dev_init) { |
| 1204 | memset (&console_dev, 0, sizeof (console_dev)); |
wdenk | a8c13d4 | 2004-07-11 21:49:42 +0000 | [diff] [blame] | 1205 | strcpy (console_dev.name, "vga"); |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1206 | console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */ |
| 1207 | console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; |
| 1208 | console_dev.putc = video_putc; /* 'putc' function */ |
| 1209 | console_dev.puts = video_puts; /* 'puts' function */ |
| 1210 | console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */ |
| 1211 | console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1212 | |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1213 | if (device_register (&console_dev) == 0) |
| 1214 | return 1; |
| 1215 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1216 | #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1217 | /* No console dev available */ |
| 1218 | return 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1219 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1220 | #endif /* CONFIG_CFB_CONSOLE */ |