wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it |
| 4 | * (C) Copyright 2002 |
| 5 | * Wolfgang Denk, wd@denx.de |
| 6 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 10 | /* #define DEBUG */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 11 | |
| 12 | /************************************************************************/ |
| 13 | /* ** HEADER FILES */ |
| 14 | /************************************************************************/ |
| 15 | |
| 16 | #include <stdarg.h> |
| 17 | #include <common.h> |
| 18 | #include <config.h> |
| 19 | #include <version.h> |
| 20 | #include <i2c.h> |
| 21 | #include <linux/types.h> |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 22 | #include <stdio_dev.h> |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 23 | |
| 24 | #ifdef CONFIG_VIDEO |
| 25 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 28 | /************************************************************************/ |
| 29 | /* ** DEBUG SETTINGS */ |
| 30 | /************************************************************************/ |
| 31 | |
| 32 | #if 0 |
| 33 | #define VIDEO_DEBUG_COLORBARS /* Force colorbars output */ |
| 34 | #endif |
| 35 | |
| 36 | /************************************************************************/ |
| 37 | /* ** VIDEO MODE SETTINGS */ |
| 38 | /************************************************************************/ |
| 39 | |
| 40 | #if 0 |
| 41 | #define VIDEO_MODE_EXTENDED /* Allow screen size bigger than visible area */ |
| 42 | #define VIDEO_MODE_NTSC |
| 43 | #endif |
| 44 | |
| 45 | #define VIDEO_MODE_PAL |
| 46 | |
| 47 | #if 0 |
| 48 | #define VIDEO_BLINK /* This enables cursor blinking (under construction) */ |
| 49 | #endif |
| 50 | |
| 51 | #define VIDEO_INFO /* Show U-Boot information */ |
| 52 | #define VIDEO_INFO_X VIDEO_LOGO_WIDTH+8 |
| 53 | #define VIDEO_INFO_Y 16 |
| 54 | |
| 55 | /************************************************************************/ |
| 56 | /* ** VIDEO ENCODER CONSTANTS */ |
| 57 | /************************************************************************/ |
| 58 | |
| 59 | #ifdef CONFIG_VIDEO_ENCODER_AD7176 |
| 60 | |
| 61 | #include <video_ad7176.h> /* Sets encoder data, mode, and visible and active area */ |
| 62 | |
| 63 | #define VIDEO_I2C 1 |
| 64 | #define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7176_ADDR |
| 65 | #endif |
| 66 | |
| 67 | #ifdef CONFIG_VIDEO_ENCODER_AD7177 |
| 68 | |
| 69 | #include <video_ad7177.h> /* Sets encoder data, mode, and visible and active area */ |
| 70 | |
| 71 | #define VIDEO_I2C 1 |
| 72 | #define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7177_ADDR |
| 73 | #endif |
| 74 | |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 75 | #ifdef CONFIG_VIDEO_ENCODER_AD7179 |
| 76 | |
| 77 | #include <video_ad7179.h> /* Sets encoder data, mode, and visible and active area */ |
| 78 | |
| 79 | #define VIDEO_I2C 1 |
| 80 | #define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7179_ADDR |
| 81 | #endif |
| 82 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 83 | /************************************************************************/ |
| 84 | /* ** VIDEO MODE CONSTANTS */ |
| 85 | /************************************************************************/ |
| 86 | |
| 87 | #ifdef VIDEO_MODE_EXTENDED |
| 88 | #define VIDEO_COLS VIDEO_ACTIVE_COLS |
| 89 | #define VIDEO_ROWS VIDEO_ACTIVE_ROWS |
| 90 | #else |
| 91 | #define VIDEO_COLS VIDEO_VISIBLE_COLS |
| 92 | #define VIDEO_ROWS VIDEO_VISIBLE_ROWS |
| 93 | #endif |
| 94 | |
| 95 | #define VIDEO_PIXEL_SIZE (VIDEO_MODE_BPP/8) |
| 96 | #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE) /* Total size of buffer */ |
| 97 | #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2) /* Number of ints */ |
| 98 | #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE) /* Number of bytes per line */ |
| 99 | #define VIDEO_BURST_LEN (VIDEO_COLS/8) |
| 100 | |
| 101 | #ifdef VIDEO_MODE_YUYV |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 102 | #define VIDEO_BG_COL 0x80D880D8 /* Background color in YUYV format */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 103 | #else |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 104 | #define VIDEO_BG_COL 0xF8F8F8F8 /* Background color in RGB format */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 105 | #endif |
| 106 | |
| 107 | /************************************************************************/ |
| 108 | /* ** FONT AND LOGO DATA */ |
| 109 | /************************************************************************/ |
| 110 | |
| 111 | #include <video_font.h> /* Get font data, width and height */ |
Che-Liang Chiou | d3983ee | 2011-10-21 17:04:21 +0800 | [diff] [blame] | 112 | #include <video_font_data.h> |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 113 | |
| 114 | #ifdef CONFIG_VIDEO_LOGO |
| 115 | #include <video_logo.h> /* Get logo data, width and height */ |
| 116 | |
| 117 | #define VIDEO_LOGO_WIDTH DEF_U_BOOT_LOGO_WIDTH |
| 118 | #define VIDEO_LOGO_HEIGHT DEF_U_BOOT_LOGO_HEIGHT |
| 119 | #define VIDEO_LOGO_ADDR &u_boot_logo |
| 120 | #endif |
| 121 | |
| 122 | /************************************************************************/ |
| 123 | /* ** VIDEO CONTROLLER CONSTANTS */ |
| 124 | /************************************************************************/ |
| 125 | |
| 126 | /* VCCR - VIDEO CONTROLLER CONFIGURATION REGISTER */ |
| 127 | |
| 128 | #define VIDEO_VCCR_VON 0 /* Video controller ON */ |
| 129 | #define VIDEO_VCCR_CSRC 1 /* Clock source */ |
| 130 | #define VIDEO_VCCR_PDF 13 /* Pixel display format */ |
| 131 | #define VIDEO_VCCR_IEN 11 /* Interrupt enable */ |
| 132 | |
| 133 | /* VSR - VIDEO STATUS REGISTER */ |
| 134 | |
| 135 | #define VIDEO_VSR_CAS 6 /* Active set */ |
| 136 | #define VIDEO_VSR_EOF 0 /* End of frame */ |
| 137 | |
| 138 | /* VCMR - VIDEO COMMAND REGISTER */ |
| 139 | |
| 140 | #define VIDEO_VCMR_BD 0 /* Blank display */ |
| 141 | #define VIDEO_VCMR_ASEL 1 /* Active set selection */ |
| 142 | |
| 143 | /* VBCB - VIDEO BACKGROUND COLOR BUFFER REGISTER */ |
| 144 | |
| 145 | #define VIDEO_BCSR4_RESET_BIT 21 /* BCSR4 - Extern video encoder reset */ |
| 146 | #define VIDEO_BCSR4_EXTCLK_BIT 22 /* BCSR4 - Extern clock enable */ |
| 147 | #define VIDEO_BCSR4_VIDLED_BIT 23 /* BCSR4 - Video led disable */ |
| 148 | |
| 149 | /************************************************************************/ |
| 150 | /* ** CONSOLE CONSTANTS */ |
| 151 | /************************************************************************/ |
| 152 | |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 153 | #ifdef CONFIG_VIDEO_LOGO |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 154 | #define CONSOLE_ROWS ((VIDEO_ROWS - VIDEO_LOGO_HEIGHT) / VIDEO_FONT_HEIGHT) |
| 155 | #define VIDEO_LOGO_SKIP (VIDEO_COLS - VIDEO_LOGO_WIDTH) |
| 156 | #else |
| 157 | #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT) |
| 158 | #endif |
| 159 | |
| 160 | #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH) |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 161 | #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 162 | #define CONSOLE_ROW_FIRST (video_console_address) |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 163 | #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 164 | #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 165 | #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 166 | #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
| 167 | |
| 168 | /* |
| 169 | * Simple color definitions |
| 170 | */ |
| 171 | #define CONSOLE_COLOR_BLACK 0 |
| 172 | #define CONSOLE_COLOR_RED 1 |
| 173 | #define CONSOLE_COLOR_GREEN 2 |
| 174 | #define CONSOLE_COLOR_YELLOW 3 |
| 175 | #define CONSOLE_COLOR_BLUE 4 |
| 176 | #define CONSOLE_COLOR_MAGENTA 5 |
| 177 | #define CONSOLE_COLOR_CYAN 6 |
| 178 | #define CONSOLE_COLOR_GREY 13 |
| 179 | #define CONSOLE_COLOR_GREY2 14 |
| 180 | #define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */ |
| 181 | |
| 182 | /************************************************************************/ |
| 183 | /* ** BITOPS MACROS */ |
| 184 | /************************************************************************/ |
| 185 | |
| 186 | #define HISHORT(i) ((i >> 16)&0xffff) |
| 187 | #define LOSHORT(i) (i & 0xffff) |
| 188 | #define HICHAR(s) ((i >> 8)&0xff) |
| 189 | #define LOCHAR(s) (i & 0xff) |
| 190 | #define HI(c) ((c >> 4)&0xf) |
| 191 | #define LO(c) (c & 0xf) |
| 192 | #define SWAPINT(i) (HISHORT(i) | (LOSHORT(i) << 16)) |
| 193 | #define SWAPSHORT(s) (HICHAR(s) | (LOCHAR(s) << 8)) |
| 194 | #define SWAPCHAR(c) (HI(c) | (LO(c) << 4)) |
| 195 | #define BITMASK(b) (1 << (b)) |
| 196 | #define GETBIT(v,b) (((v) & BITMASK(b)) > 0) |
| 197 | #define SETBIT(v,b,d) (v = (((d)>0) ? (v) | BITMASK(b): (v) & ~BITMASK(b))) |
| 198 | |
| 199 | /************************************************************************/ |
| 200 | /* ** STRUCTURES */ |
| 201 | /************************************************************************/ |
| 202 | |
| 203 | typedef struct { |
| 204 | unsigned char V, Y1, U, Y2; |
| 205 | } tYUYV; |
| 206 | |
| 207 | /* This structure is based on the Video Ram in the MPC823. */ |
| 208 | typedef struct VRAM { |
| 209 | unsigned hx:2, /* Horizontal sync */ |
| 210 | vx:2, /* Vertical sync */ |
| 211 | fx:2, /* Frame */ |
| 212 | bx:2, /* Blank */ |
| 213 | res1:6, /* Reserved */ |
| 214 | vds:2, /* Video Data Select */ |
| 215 | inter:1, /* Interrupt */ |
| 216 | res2:2, /* Reserved */ |
| 217 | lcyc:11, /* Loop/video cycles */ |
| 218 | lp:1, /* Loop start/end */ |
| 219 | lst:1; /* Last entry */ |
| 220 | } VRAM; |
| 221 | |
| 222 | /************************************************************************/ |
| 223 | /* ** VARIABLES */ |
| 224 | /************************************************************************/ |
| 225 | |
| 226 | static int |
| 227 | video_panning_range_x = 0, /* Video mode invisible pixels x range */ |
| 228 | video_panning_range_y = 0, /* Video mode invisible pixels y range */ |
| 229 | video_panning_value_x = 0, /* Video mode x panning value (absolute) */ |
| 230 | video_panning_value_y = 0, /* Video mode y panning value (absolute) */ |
| 231 | video_panning_factor_x = 0, /* Video mode x panning value (-127 +127) */ |
| 232 | video_panning_factor_y = 0, /* Video mode y panning value (-127 +127) */ |
| 233 | console_col = 0, /* Cursor col */ |
| 234 | console_row = 0, /* Cursor row */ |
| 235 | video_palette[16]; /* Our palette */ |
| 236 | |
| 237 | static const int video_font_draw_table[] = |
| 238 | { 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff }; |
| 239 | |
| 240 | static char |
| 241 | video_color_fg = 0, /* Current fg color index (0-15) */ |
| 242 | video_color_bg = 0, /* Current bg color index (0-15) */ |
| 243 | video_enable = 0; /* Video has been initialized? */ |
| 244 | |
| 245 | static void |
| 246 | *video_fb_address, /* Frame buffer address */ |
| 247 | *video_console_address; /* Console frame buffer start address */ |
| 248 | |
| 249 | /************************************************************************/ |
| 250 | /* ** MEMORY FUNCTIONS (32bit) */ |
| 251 | /************************************************************************/ |
| 252 | |
| 253 | static void memsetl (int *p, int c, int v) |
| 254 | { |
| 255 | while (c--) |
| 256 | *(p++) = v; |
| 257 | } |
| 258 | |
| 259 | static void memcpyl (int *d, int *s, int c) |
| 260 | { |
| 261 | while (c--) |
| 262 | *(d++) = *(s++); |
| 263 | } |
| 264 | |
| 265 | /************************************************************************/ |
| 266 | /* ** VIDEO DRAWING AND COLOR FUNCTIONS */ |
| 267 | /************************************************************************/ |
| 268 | |
| 269 | static int video_maprgb (int r, int g, int b) |
| 270 | { |
| 271 | #ifdef VIDEO_MODE_YUYV |
| 272 | unsigned int pR, pG, pB; |
| 273 | tYUYV YUYV; |
| 274 | unsigned int *ret = (unsigned int *) &YUYV; |
| 275 | |
| 276 | /* Transform (0-255) components to (0-100) */ |
| 277 | |
| 278 | pR = r * 100 / 255; |
| 279 | pG = g * 100 / 255; |
| 280 | pB = b * 100 / 255; |
| 281 | |
| 282 | /* Calculate YUV values (0-255) from RGB beetween 0-100 */ |
| 283 | |
| 284 | YUYV.Y1 = YUYV.Y2 = 209 * (pR + pG + pB) / 300 + 16; |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 285 | YUYV.U = pR - (pG * 3 / 4) - (pB / 4) + 128; |
| 286 | YUYV.V = pB - (pR / 4) - (pG * 3 / 4) + 128; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 287 | return *ret; |
| 288 | #endif |
| 289 | #ifdef VIDEO_MODE_RGB |
| 290 | return ((r >> 3) << 11) | ((g > 2) << 6) | (b >> 3); |
| 291 | #endif |
| 292 | } |
| 293 | |
| 294 | static void video_setpalette (int color, int r, int g, int b) |
| 295 | { |
| 296 | color &= 0xf; |
| 297 | |
| 298 | video_palette[color] = video_maprgb (r, g, b); |
| 299 | |
| 300 | /* Swap values if our panning offset is odd */ |
| 301 | if (video_panning_value_x & 1) |
| 302 | video_palette[color] = SWAPINT (video_palette[color]); |
| 303 | } |
| 304 | |
| 305 | static void video_fill (int color) |
| 306 | { |
| 307 | memsetl (video_fb_address, VIDEO_PIX_BLOCKS, color); |
| 308 | } |
| 309 | |
| 310 | static void video_setfgcolor (int i) |
| 311 | { |
| 312 | video_color_fg = i & 0xf; |
| 313 | } |
| 314 | |
| 315 | static void video_setbgcolor (int i) |
| 316 | { |
| 317 | video_color_bg = i & 0xf; |
| 318 | } |
| 319 | |
| 320 | static int video_pickcolor (int i) |
| 321 | { |
| 322 | return video_palette[i & 0xf]; |
| 323 | } |
| 324 | |
| 325 | /* Absolute console plotting functions */ |
| 326 | |
| 327 | #ifdef VIDEO_BLINK |
| 328 | static void video_revchar (int xx, int yy) |
| 329 | { |
| 330 | int rows; |
| 331 | u8 *dest; |
| 332 | |
| 333 | dest = video_fb_address + yy * VIDEO_LINE_LEN + xx * 2; |
| 334 | |
| 335 | for (rows = VIDEO_FONT_HEIGHT; rows--; dest += VIDEO_LINE_LEN) { |
| 336 | switch (VIDEO_FONT_WIDTH) { |
| 337 | case 16: |
| 338 | ((u32 *) dest)[6] ^= 0xffffffff; |
| 339 | ((u32 *) dest)[7] ^= 0xffffffff; |
| 340 | /* FALL THROUGH */ |
| 341 | case 12: |
| 342 | ((u32 *) dest)[4] ^= 0xffffffff; |
| 343 | ((u32 *) dest)[5] ^= 0xffffffff; |
| 344 | /* FALL THROUGH */ |
| 345 | case 8: |
| 346 | ((u32 *) dest)[2] ^= 0xffffffff; |
| 347 | ((u32 *) dest)[3] ^= 0xffffffff; |
| 348 | /* FALL THROUGH */ |
| 349 | case 4: |
| 350 | ((u32 *) dest)[0] ^= 0xffffffff; |
| 351 | ((u32 *) dest)[1] ^= 0xffffffff; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | #endif |
| 356 | |
| 357 | static void video_drawchars (int xx, int yy, unsigned char *s, int count) |
| 358 | { |
| 359 | u8 *cdat, *dest, *dest0; |
| 360 | int rows, offset, c; |
| 361 | u32 eorx, fgx, bgx; |
| 362 | |
| 363 | offset = yy * VIDEO_LINE_LEN + xx * 2; |
| 364 | dest0 = video_fb_address + offset; |
| 365 | |
| 366 | fgx = video_pickcolor (video_color_fg); |
| 367 | bgx = video_pickcolor (video_color_bg); |
| 368 | |
| 369 | if (xx & 1) { |
| 370 | fgx = SWAPINT (fgx); |
| 371 | bgx = SWAPINT (bgx); |
| 372 | } |
| 373 | |
| 374 | eorx = fgx ^ bgx; |
| 375 | |
| 376 | switch (VIDEO_FONT_WIDTH) { |
| 377 | case 4: |
| 378 | case 8: |
| 379 | while (count--) { |
| 380 | c = *s; |
| 381 | cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; |
| 382 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; |
| 383 | rows--; |
| 384 | dest += VIDEO_LINE_LEN) { |
| 385 | u8 bits = *cdat++; |
| 386 | |
| 387 | ((u32 *) dest)[0] = |
| 388 | (video_font_draw_table[bits >> 6] & eorx) ^ bgx; |
| 389 | ((u32 *) dest)[1] = |
| 390 | (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx; |
| 391 | if (VIDEO_FONT_WIDTH == 8) { |
| 392 | ((u32 *) dest)[2] = |
| 393 | (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx; |
| 394 | ((u32 *) dest)[3] = |
| 395 | (video_font_draw_table[bits & 3] & eorx) ^ bgx; |
| 396 | } |
| 397 | } |
| 398 | dest0 += VIDEO_FONT_WIDTH * 2; |
| 399 | s++; |
| 400 | } |
| 401 | break; |
| 402 | case 12: |
| 403 | case 16: |
| 404 | while (count--) { |
| 405 | cdat = video_fontdata + (*s) * (VIDEO_FONT_HEIGHT << 1); |
| 406 | for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--; |
| 407 | dest += VIDEO_LINE_LEN) { |
| 408 | u8 bits = *cdat++; |
| 409 | |
| 410 | ((u32 *) dest)[0] = |
| 411 | (video_font_draw_table[bits >> 6] & eorx) ^ bgx; |
| 412 | ((u32 *) dest)[1] = |
| 413 | (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx; |
| 414 | ((u32 *) dest)[2] = |
| 415 | (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx; |
| 416 | ((u32 *) dest)[3] = |
| 417 | (video_font_draw_table[bits & 3] & eorx) ^ bgx; |
| 418 | bits = *cdat++; |
| 419 | ((u32 *) dest)[4] = |
| 420 | (video_font_draw_table[bits >> 6] & eorx) ^ bgx; |
| 421 | ((u32 *) dest)[5] = |
| 422 | (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx; |
| 423 | if (VIDEO_FONT_WIDTH == 16) { |
| 424 | ((u32 *) dest)[6] = |
| 425 | (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx; |
| 426 | ((u32 *) dest)[7] = |
| 427 | (video_font_draw_table[bits & 3] & eorx) ^ bgx; |
| 428 | } |
| 429 | } |
| 430 | s++; |
| 431 | dest0 += VIDEO_FONT_WIDTH * 2; |
| 432 | } |
| 433 | break; |
| 434 | } |
| 435 | } |
| 436 | |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 437 | static inline void video_drawstring (int xx, int yy, char *s) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 438 | { |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 439 | video_drawchars (xx, yy, (unsigned char *)s, strlen (s)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | /* Relative to console plotting functions */ |
| 443 | |
| 444 | static void video_putchars (int xx, int yy, unsigned char *s, int count) |
| 445 | { |
| 446 | #ifdef CONFIG_VIDEO_LOGO |
| 447 | video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, s, count); |
| 448 | #else |
| 449 | video_drawchars (xx, yy, s, count); |
| 450 | #endif |
| 451 | } |
| 452 | |
| 453 | static void video_putchar (int xx, int yy, unsigned char c) |
| 454 | { |
| 455 | #ifdef CONFIG_VIDEO_LOGO |
| 456 | video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1); |
| 457 | #else |
| 458 | video_drawchars (xx, yy, &c, 1); |
| 459 | #endif |
| 460 | } |
| 461 | |
| 462 | static inline void video_putstring (int xx, int yy, unsigned char *s) |
| 463 | { |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 464 | video_putchars (xx, yy, (unsigned char *)s, strlen ((char *)s)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | /************************************************************************/ |
| 468 | /* ** VIDEO CONTROLLER LOW-LEVEL FUNCTIONS */ |
| 469 | /************************************************************************/ |
| 470 | |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 471 | #if !defined(CONFIG_RRVISION) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 472 | static void video_mode_dupefield (VRAM * source, VRAM * dest, int entries) |
| 473 | { |
| 474 | int i; |
| 475 | |
| 476 | for (i = 0; i < entries; i++) { |
| 477 | dest[i] = source[i]; /* Copy the entire record */ |
| 478 | dest[i].fx = (!dest[i].fx) * 3; /* Negate field bit */ |
| 479 | } |
| 480 | |
| 481 | dest[0].lcyc++; /* Add a cycle to the first entry */ |
| 482 | dest[entries - 1].lst = 1; /* Set end of ram entries */ |
| 483 | } |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 484 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 485 | |
| 486 | static void inline video_mode_addentry (VRAM * vr, |
| 487 | int Hx, int Vx, int Fx, int Bx, |
| 488 | int VDS, int INT, int LCYC, int LP, int LST) |
| 489 | { |
| 490 | vr->hx = Hx; |
| 491 | vr->vx = Vx; |
| 492 | vr->fx = Fx; |
| 493 | vr->bx = Bx; |
| 494 | vr->vds = VDS; |
| 495 | vr->inter = INT; |
| 496 | vr->lcyc = LCYC; |
| 497 | vr->lp = LP; |
| 498 | vr->lst = LST; |
| 499 | } |
| 500 | |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 501 | #define ADDENTRY(a,b,c,d,e,f,g,h,i) video_mode_addentry(&vr[entry++],a,b,c,d,e,f,g,h,i) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 502 | |
| 503 | static int video_mode_generate (void) |
| 504 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 505 | immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 506 | VRAM *vr = (VRAM *) (((void *) immap) + 0xb00); /* Pointer to the VRAM table */ |
| 507 | int DX, X1, X2, DY, Y1, Y2, entry = 0, fifo; |
| 508 | |
| 509 | /* CHECKING PARAMETERS */ |
| 510 | |
| 511 | if (video_panning_factor_y < -128) |
| 512 | video_panning_factor_y = -128; |
| 513 | |
| 514 | if (video_panning_factor_y > 128) |
| 515 | video_panning_factor_y = 128; |
| 516 | |
| 517 | if (video_panning_factor_x < -128) |
| 518 | video_panning_factor_x = -128; |
| 519 | |
| 520 | if (video_panning_factor_x > 128) |
| 521 | video_panning_factor_x = 128; |
| 522 | |
| 523 | /* Setting panning */ |
| 524 | |
| 525 | DX = video_panning_range_x = (VIDEO_ACTIVE_COLS - VIDEO_COLS) * 2; |
| 526 | DY = video_panning_range_y = (VIDEO_ACTIVE_ROWS - VIDEO_ROWS) / 2; |
| 527 | |
| 528 | video_panning_value_x = (video_panning_factor_x + 128) * DX / 256; |
| 529 | video_panning_value_y = (video_panning_factor_y + 128) * DY / 256; |
| 530 | |
| 531 | /* We assume these are burst units (multiplied by 2, we need it pari) */ |
| 532 | X1 = video_panning_value_x & 0xfffe; |
| 533 | X2 = DX - X1; |
| 534 | |
| 535 | /* We assume these are field line units (divided by 2, we need it pari) */ |
| 536 | Y1 = video_panning_value_y & 0xfffe; |
| 537 | Y2 = DY - Y1; |
| 538 | |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 539 | debug("X1=%d, X2=%d, Y1=%d, Y2=%d, DX=%d, DY=%d VIDEO_COLS=%d \n", |
| 540 | X1, X2, Y1, Y2, DX, DY, VIDEO_COLS); |
| 541 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 542 | #ifdef VIDEO_MODE_NTSC |
| 543 | /* |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 544 | * Hx Vx Fx Bx VDS INT LCYC LP LST |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 545 | * |
| 546 | * Retrace blanking |
| 547 | */ |
| 548 | ADDENTRY (0, 0, 3, 0, 1, 0, 3, 1, 0); |
| 549 | ADDENTRY (3, 0, 3, 0, 1, 0, 243, 0, 0); |
| 550 | ADDENTRY (3, 0, 3, 0, 1, 0, 1440, 0, 0); |
| 551 | ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0); |
| 552 | /* |
| 553 | * Vertical blanking |
| 554 | */ |
| 555 | ADDENTRY (0, 0, 0, 0, 1, 0, 18, 1, 0); |
| 556 | ADDENTRY (3, 0, 0, 0, 1, 0, 243, 0, 0); |
| 557 | ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0); |
| 558 | ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0); |
| 559 | /* |
| 560 | * Odd field active area (TOP) |
| 561 | */ |
| 562 | if (Y1 > 0) { |
| 563 | ADDENTRY (0, 0, 0, 0, 1, 0, Y1, 1, 0); |
| 564 | ADDENTRY (3, 0, 0, 0, 1, 0, 235, 0, 0); |
| 565 | ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0); |
| 566 | ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0); |
| 567 | } |
| 568 | /* |
| 569 | * Odd field active area |
| 570 | */ |
| 571 | ADDENTRY (0, 0, 0, 0, 1, 0, 240 - DY, 1, 0); |
| 572 | ADDENTRY (3, 0, 0, 0, 1, 0, 235, 0, 0); |
| 573 | ADDENTRY (3, 0, 0, 3, 1, 0, 8 + X1, 0, 0); |
| 574 | ADDENTRY (3, 0, 0, 3, 0, 0, VIDEO_COLS * 2, 0, 0); |
| 575 | |
| 576 | if (X2 > 0) |
| 577 | ADDENTRY (3, 0, 0, 3, 1, 0, X2, 0, 0); |
| 578 | |
| 579 | ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0); |
| 580 | |
| 581 | /* |
| 582 | * Odd field active area (BOTTOM) |
| 583 | */ |
| 584 | if (Y1 > 0) { |
| 585 | ADDENTRY (0, 0, 0, 0, 1, 0, Y2, 1, 0); |
| 586 | ADDENTRY (3, 0, 0, 0, 1, 0, 235, 0, 0); |
| 587 | ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0); |
| 588 | ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0); |
| 589 | } |
| 590 | /* |
| 591 | * Vertical blanking |
| 592 | */ |
| 593 | ADDENTRY (0, 0, 0, 0, 1, 0, 4, 1, 0); |
| 594 | ADDENTRY (3, 0, 0, 0, 1, 0, 243, 0, 0); |
| 595 | ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0); |
| 596 | ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0); |
| 597 | /* |
| 598 | * Vertical blanking |
| 599 | */ |
| 600 | ADDENTRY (0, 0, 3, 0, 1, 0, 19, 1, 0); |
| 601 | ADDENTRY (3, 0, 3, 0, 1, 0, 243, 0, 0); |
| 602 | ADDENTRY (3, 0, 3, 0, 1, 0, 1440, 0, 0); |
| 603 | ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0); |
| 604 | /* |
| 605 | * Even field active area (TOP) |
| 606 | */ |
| 607 | if (Y1 > 0) { |
| 608 | ADDENTRY (0, 0, 3, 0, 1, 0, Y1, 1, 0); |
| 609 | ADDENTRY (3, 0, 3, 0, 1, 0, 235, 0, 0); |
| 610 | ADDENTRY (3, 0, 3, 3, 1, 0, 1448, 0, 0); |
| 611 | ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0); |
| 612 | } |
| 613 | /* |
| 614 | * Even field active area (CENTER) |
| 615 | */ |
| 616 | ADDENTRY (0, 0, 3, 0, 1, 0, 240 - DY, 1, 0); |
| 617 | ADDENTRY (3, 0, 3, 0, 1, 0, 235, 0, 0); |
| 618 | ADDENTRY (3, 0, 3, 3, 1, 0, 8 + X1, 0, 0); |
| 619 | ADDENTRY (3, 0, 3, 3, 0, 0, VIDEO_COLS * 2, 0, 0); |
| 620 | |
| 621 | if (X2 > 0) |
| 622 | ADDENTRY (3, 0, 3, 3, 1, 0, X2, 0, 0); |
| 623 | |
| 624 | ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0); |
| 625 | /* |
| 626 | * Even field active area (BOTTOM) |
| 627 | */ |
| 628 | if (Y1 > 0) { |
| 629 | ADDENTRY (0, 0, 3, 0, 1, 0, Y2, 1, 0); |
| 630 | ADDENTRY (3, 0, 3, 0, 1, 0, 235, 0, 0); |
| 631 | ADDENTRY (3, 0, 3, 3, 1, 0, 1448, 0, 0); |
| 632 | ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0); |
| 633 | } |
| 634 | /* |
| 635 | * Vertical blanking |
| 636 | */ |
| 637 | ADDENTRY (0, 0, 3, 0, 1, 0, 1, 1, 0); |
| 638 | ADDENTRY (3, 0, 3, 0, 1, 0, 243, 0, 0); |
| 639 | ADDENTRY (3, 0, 3, 0, 1, 0, 1440, 0, 0); |
| 640 | ADDENTRY (3, 0, 3, 0, 1, 1, 32, 1, 1); |
| 641 | #endif |
| 642 | |
| 643 | #ifdef VIDEO_MODE_PAL |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 644 | |
| 645 | #if defined(CONFIG_RRVISION) |
| 646 | |
| 647 | #define HPW 160 /* horizontal pulse width (was 139) */ |
| 648 | #define VPW 2 /* vertical pulse width */ |
| 649 | #define HBP 104 /* horizontal back porch (was 112) */ |
| 650 | #define VBP 19 /* vertical back porch (was 19) */ |
| 651 | #define VID_R 240 /* number of rows */ |
| 652 | |
| 653 | debug ("[VIDEO CTRL] Starting to add controller entries..."); |
| 654 | /* |
| 655 | * Even field |
| 656 | */ |
| 657 | ADDENTRY (0, 3, 0, 3, 1, 0, 2, 0, 0); |
| 658 | ADDENTRY (0, 0, 0, 3, 1, 0, HPW, 0, 0); |
| 659 | ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 0, 0); |
| 660 | |
| 661 | ADDENTRY (0, 0, 0, 3, 1, 0, VPW, 1, 0); |
| 662 | ADDENTRY (0, 0, 0, 3, 1, 0, HPW-1, 0, 0); |
| 663 | ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0); |
| 664 | |
| 665 | ADDENTRY (0, 3, 0, 3, 1, 0, VBP, 1, 0); |
| 666 | ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0); |
| 667 | ADDENTRY (3, 3, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0); |
| 668 | /* |
| 669 | * Active area |
| 670 | */ |
| 671 | ADDENTRY (0, 3, 0, 3, 1, 0, VID_R , 1, 0); |
| 672 | ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0); |
| 673 | ADDENTRY (3, 3, 0, 3, 1, 0, HBP, 0, 0); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 674 | ADDENTRY (3, 3, 0, 3, 0, 0, VIDEO_COLS*2, 0, 0); |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 675 | ADDENTRY (3, 3, 0, 3, 1, 0, 72, 1, 1); |
| 676 | |
| 677 | ADDENTRY (0, 3, 0, 3, 1, 0, 51, 1, 0); |
| 678 | ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0); |
| 679 | ADDENTRY (3, 3, 0, 3, 1, 0, HBP +(VIDEO_COLS * 2) + 72 , 1, 0); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 680 | /* |
| 681 | * Odd field |
| 682 | */ |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 683 | ADDENTRY (0, 3, 0, 3, 1, 0, 2, 0, 0); |
| 684 | ADDENTRY (0, 0, 0, 3, 1, 0, HPW, 0, 0); |
| 685 | ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 0, 0); |
| 686 | |
| 687 | ADDENTRY (0, 0, 0, 3, 1, 0, VPW+1, 1, 0); |
| 688 | ADDENTRY (0, 0, 0, 3, 1, 0, HPW-1, 0, 0); |
| 689 | ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0); |
| 690 | |
| 691 | ADDENTRY (0, 3, 0, 3, 1, 0, VBP, 1, 0); |
| 692 | ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0); |
| 693 | ADDENTRY (3, 3, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0); |
| 694 | /* |
| 695 | * Active area |
| 696 | */ |
| 697 | ADDENTRY (0, 3, 0, 3, 1, 0, VID_R , 1, 0); |
| 698 | ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0); |
| 699 | ADDENTRY (3, 3, 0, 3, 1, 0, HBP, 0, 0); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 700 | ADDENTRY (3, 3, 0, 3, 0, 0, VIDEO_COLS*2, 0, 0); |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 701 | ADDENTRY (3, 3, 0, 3, 1, 0, 72, 1, 1); |
| 702 | |
| 703 | ADDENTRY (0, 3, 0, 3, 1, 0, 51, 1, 0); |
| 704 | ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0); |
| 705 | ADDENTRY (3, 3, 0, 3, 1, 0, HBP +(VIDEO_COLS * 2) + 72 , 1, 0); |
| 706 | |
| 707 | debug ("done\n"); |
| 708 | |
| 709 | #else /* !CONFIG_RRVISION */ |
| 710 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 711 | /* |
| 712 | * Hx Vx Fx Bx VDS INT LCYC LP LST |
| 713 | * |
| 714 | * vertical; blanking |
| 715 | */ |
| 716 | ADDENTRY (0, 0, 0, 0, 1, 0, 22, 1, 0); |
| 717 | ADDENTRY (3, 0, 0, 0, 1, 0, 263, 0, 0); |
| 718 | ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0); |
| 719 | ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0); |
| 720 | /* |
| 721 | * active area (TOP) |
| 722 | */ |
| 723 | if (Y1 > 0) { |
| 724 | ADDENTRY (0, 0, 0, 0, 1, 0, Y1, 1, 0); /* 11? */ |
| 725 | ADDENTRY (3, 0, 0, 0, 1, 0, 255, 0, 0); |
| 726 | ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0); |
| 727 | ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0); |
| 728 | } |
| 729 | /* |
| 730 | * field active area (CENTER) |
| 731 | */ |
| 732 | ADDENTRY (0, 0, 0, 0, 1, 0, 288 - DY, 1, 0); /* 265? */ |
| 733 | ADDENTRY (3, 0, 0, 0, 1, 0, 255, 0, 0); |
| 734 | ADDENTRY (3, 0, 0, 3, 1, 0, 8 + X1, 0, 0); |
| 735 | ADDENTRY (3, 0, 0, 3, 0, 0, VIDEO_COLS * 2, 0, 0); |
| 736 | |
| 737 | if (X2 > 0) |
| 738 | ADDENTRY (3, 0, 0, 1, 1, 0, X2, 0, 0); |
| 739 | |
| 740 | ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0); |
| 741 | /* |
| 742 | * field active area (BOTTOM) |
| 743 | */ |
| 744 | if (Y2 > 0) { |
| 745 | ADDENTRY (0, 0, 0, 0, 1, 0, Y2, 1, 0); /* 12? */ |
| 746 | ADDENTRY (3, 0, 0, 0, 1, 0, 255, 0, 0); |
| 747 | ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0); |
| 748 | ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0); |
| 749 | } |
| 750 | /* |
| 751 | * field vertical; blanking |
| 752 | */ |
| 753 | ADDENTRY (0, 0, 0, 0, 1, 0, 2, 1, 0); |
| 754 | ADDENTRY (3, 0, 0, 0, 1, 0, 263, 0, 0); |
| 755 | ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0); |
| 756 | ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0); |
| 757 | /* |
| 758 | * Create the other field (like this, but whit other field selected, |
| 759 | * one more cycle loop and a last identifier) |
| 760 | */ |
| 761 | video_mode_dupefield (vr, &vr[entry], entry); |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 762 | #endif /* CONFIG_RRVISION */ |
| 763 | |
| 764 | #endif /* VIDEO_MODE_PAL */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 765 | |
| 766 | /* See what FIFO are we using */ |
| 767 | fifo = GETBIT (immap->im_vid.vid_vsr, VIDEO_VSR_CAS); |
| 768 | |
| 769 | /* Set number of lines and burst (only one frame for now) */ |
| 770 | if (fifo) { |
| 771 | immap->im_vid.vid_vfcr0 = VIDEO_BURST_LEN | |
| 772 | (VIDEO_BURST_LEN << 8) | ((VIDEO_ROWS / 2) << 19); |
| 773 | } else { |
| 774 | immap->im_vid.vid_vfcr1 = VIDEO_BURST_LEN | |
| 775 | (VIDEO_BURST_LEN << 8) | ((VIDEO_ROWS / 2) << 19); |
| 776 | } |
| 777 | |
| 778 | SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_ASEL, !fifo); |
| 779 | |
| 780 | /* |
| 781 | * Wait until changes are applied (not done) |
| 782 | * while (GETBIT(immap->im_vid.vid_vsr, VIDEO_VSR_CAS) == fifo) ; |
| 783 | */ |
| 784 | |
| 785 | /* Return number of VRAM entries */ |
| 786 | return entry * 2; |
| 787 | } |
| 788 | |
| 789 | static void video_encoder_init (void) |
| 790 | { |
| 791 | #ifdef VIDEO_I2C |
| 792 | int rc; |
| 793 | |
| 794 | /* Initialize the I2C */ |
| 795 | debug ("[VIDEO ENCODER] Initializing I2C bus...\n"); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 796 | i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 797 | |
| 798 | #ifdef CONFIG_FADS |
| 799 | /* Reset ADV7176 chip */ |
| 800 | debug ("[VIDEO ENCODER] Resetting encoder...\n"); |
| 801 | (*(int *) BCSR4) &= ~(1 << 21); |
| 802 | |
| 803 | /* Wait for 5 ms inside the reset */ |
| 804 | debug ("[VIDEO ENCODER] Waiting for encoder reset...\n"); |
| 805 | udelay (5000); |
| 806 | |
| 807 | /* Take ADV7176 out of reset */ |
| 808 | (*(int *) BCSR4) |= 1 << 21; |
| 809 | |
| 810 | /* Wait for 5 ms after the reset */ |
| 811 | udelay (5000); |
| 812 | #endif /* CONFIG_FADS */ |
| 813 | |
| 814 | /* Send configuration */ |
| 815 | #ifdef DEBUG |
| 816 | { |
| 817 | int i; |
| 818 | |
| 819 | puts ("[VIDEO ENCODER] Configuring the encoder...\n"); |
| 820 | |
Wolfgang Denk | b64f190 | 2008-07-14 15:06:35 +0200 | [diff] [blame] | 821 | printf ("Sending %zu bytes (@ %08lX) to I2C 0x%lX:\n ", |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 822 | sizeof(video_encoder_data), |
| 823 | (ulong)video_encoder_data, |
Wolfgang Denk | b64f190 | 2008-07-14 15:06:35 +0200 | [diff] [blame] | 824 | (ulong)VIDEO_I2C_ADDR); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 825 | for (i=0; i<sizeof(video_encoder_data); ++i) { |
| 826 | printf(" %02X", video_encoder_data[i]); |
| 827 | } |
| 828 | putc ('\n'); |
| 829 | } |
| 830 | #endif /* DEBUG */ |
| 831 | |
| 832 | if ((rc = i2c_write (VIDEO_I2C_ADDR, 0, 1, |
| 833 | video_encoder_data, |
| 834 | sizeof(video_encoder_data))) != 0) { |
| 835 | printf ("i2c_send error: rc=%d\n", rc); |
| 836 | return; |
| 837 | } |
| 838 | #endif /* VIDEO_I2C */ |
| 839 | return; |
| 840 | } |
| 841 | |
| 842 | static void video_ctrl_init (void *memptr) |
| 843 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 844 | immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 845 | |
| 846 | video_fb_address = memptr; |
| 847 | |
| 848 | /* Set background */ |
| 849 | debug ("[VIDEO CTRL] Setting background color...\n"); |
| 850 | immap->im_vid.vid_vbcb = VIDEO_BG_COL; |
| 851 | |
| 852 | /* Show the background */ |
| 853 | debug ("[VIDEO CTRL] Forcing background...\n"); |
| 854 | SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 1); |
| 855 | |
| 856 | /* Turn off video controller */ |
| 857 | debug ("[VIDEO CTRL] Turning off video controller...\n"); |
| 858 | SETBIT (immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 0); |
| 859 | |
| 860 | #ifdef CONFIG_FADS |
| 861 | /* Turn on Video Port LED */ |
| 862 | debug ("[VIDEO CTRL] Turning off video port led...\n"); |
| 863 | SETBIT (*(int *) BCSR4, VIDEO_BCSR4_VIDLED_BIT, 1); |
| 864 | |
| 865 | /* Disable internal clock */ |
| 866 | debug ("[VIDEO CTRL] Disabling internal clock...\n"); |
| 867 | SETBIT (*(int *) BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 0); |
| 868 | #endif |
| 869 | |
| 870 | /* Generate and make active a new video mode */ |
| 871 | debug ("[VIDEO CTRL] Generating video mode...\n"); |
| 872 | video_mode_generate (); |
| 873 | |
| 874 | /* Start of frame buffer (even and odd frame, to make it working with */ |
| 875 | /* any selected active set) */ |
| 876 | debug ("[VIDEO CTRL] Setting frame buffer address...\n"); |
| 877 | immap->im_vid.vid_vfaa1 = |
| 878 | immap->im_vid.vid_vfaa0 = (u32) video_fb_address; |
| 879 | immap->im_vid.vid_vfba1 = |
| 880 | immap->im_vid.vid_vfba0 = |
| 881 | (u32) video_fb_address + VIDEO_LINE_LEN; |
| 882 | |
| 883 | /* YUV, Big endian, SHIFT/CLK/CLK input (BEFORE ENABLING 27MHZ EXT CLOCK) */ |
| 884 | debug ("[VIDEO CTRL] Setting pixel mode and clocks...\n"); |
| 885 | immap->im_vid.vid_vccr = 0x2042; |
| 886 | |
| 887 | /* Configure port pins */ |
| 888 | debug ("[VIDEO CTRL] Configuring input/output pins...\n"); |
| 889 | immap->im_ioport.iop_pdpar = 0x1fff; |
| 890 | immap->im_ioport.iop_pddir = 0x0000; |
| 891 | |
| 892 | #ifdef CONFIG_FADS |
| 893 | /* Turn on Video Port Clock - ONLY AFTER SET VCCR TO ENABLE EXTERNAL CLOCK */ |
| 894 | debug ("[VIDEO CTRL] Turning on video clock...\n"); |
| 895 | SETBIT (*(int *) BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 1); |
| 896 | |
| 897 | /* Turn on Video Port LED */ |
| 898 | debug ("[VIDEO CTRL] Turning on video port led...\n"); |
| 899 | SETBIT (*(int *) BCSR4, VIDEO_BCSR4_VIDLED_BIT, 0); |
| 900 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 901 | #ifdef CONFIG_RRVISION |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 902 | debug ("PC5->Output(1): enable PAL clock"); |
| 903 | immap->im_ioport.iop_pcpar &= ~(0x0400); |
| 904 | immap->im_ioport.iop_pcdir |= 0x0400 ; |
| 905 | immap->im_ioport.iop_pcdat |= 0x0400 ; |
| 906 | debug ("PDPAR=0x%04X PDDIR=0x%04X PDDAT=0x%04X\n", |
| 907 | immap->im_ioport.iop_pdpar, |
| 908 | immap->im_ioport.iop_pddir, |
| 909 | immap->im_ioport.iop_pddat); |
| 910 | debug ("PCPAR=0x%04X PCDIR=0x%04X PCDAT=0x%04X\n", |
| 911 | immap->im_ioport.iop_pcpar, |
| 912 | immap->im_ioport.iop_pcdir, |
| 913 | immap->im_ioport.iop_pcdat); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 914 | #endif /* CONFIG_RRVISION */ |
| 915 | |
| 916 | /* Blanking the screen. */ |
| 917 | debug ("[VIDEO CTRL] Blanking the screen...\n"); |
| 918 | video_fill (VIDEO_BG_COL); |
| 919 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 920 | /* |
| 921 | * Turns on Aggressive Mode. Normally, turning on the caches |
| 922 | * will cause the screen to flicker when the caches try to |
| 923 | * fill. This gives the FIFO's for the Video Controller |
| 924 | * higher priority and prevents flickering because of |
| 925 | * underrun. This may still be an issue when using FLASH, |
| 926 | * since accessing data from Flash is so slow. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 927 | */ |
| 928 | debug ("[VIDEO CTRL] Turning on aggressive mode...\n"); |
| 929 | immap->im_siu_conf.sc_sdcr = 0x40; |
| 930 | |
| 931 | /* Turn on video controller */ |
| 932 | debug ("[VIDEO CTRL] Turning on video controller...\n"); |
| 933 | SETBIT (immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 1); |
| 934 | |
| 935 | /* Show the display */ |
| 936 | debug ("[VIDEO CTRL] Enabling the video...\n"); |
| 937 | SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 0); |
| 938 | } |
| 939 | |
| 940 | /************************************************************************/ |
| 941 | /* ** CONSOLE FUNCTIONS */ |
| 942 | /************************************************************************/ |
| 943 | |
| 944 | static void console_scrollup (void) |
| 945 | { |
| 946 | /* Copy up rows ignoring the first one */ |
| 947 | memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE >> 2); |
| 948 | |
| 949 | /* Clear the last one */ |
| 950 | memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, VIDEO_BG_COL); |
| 951 | } |
| 952 | |
| 953 | static inline void console_back (void) |
| 954 | { |
| 955 | console_col--; |
| 956 | |
| 957 | if (console_col < 0) { |
| 958 | console_col = CONSOLE_COLS - 1; |
| 959 | console_row--; |
| 960 | if (console_row < 0) |
| 961 | console_row = 0; |
| 962 | } |
| 963 | |
| 964 | video_putchar ( console_col * VIDEO_FONT_WIDTH, |
| 965 | console_row * VIDEO_FONT_HEIGHT, ' '); |
| 966 | } |
| 967 | |
| 968 | static inline void console_newline (void) |
| 969 | { |
| 970 | console_row++; |
| 971 | console_col = 0; |
| 972 | |
| 973 | /* Check if we need to scroll the terminal */ |
| 974 | if (console_row >= CONSOLE_ROWS) { |
| 975 | /* Scroll everything up */ |
| 976 | console_scrollup (); |
| 977 | |
| 978 | /* Decrement row number */ |
| 979 | console_row--; |
| 980 | } |
| 981 | } |
| 982 | |
| 983 | void video_putc (const char c) |
| 984 | { |
| 985 | if (!video_enable) { |
| 986 | serial_putc (c); |
| 987 | return; |
| 988 | } |
| 989 | |
| 990 | switch (c) { |
| 991 | case 13: /* Simply ignore this */ |
| 992 | break; |
| 993 | |
| 994 | case '\n': /* Next line, please */ |
| 995 | console_newline (); |
| 996 | break; |
| 997 | |
| 998 | case 9: /* Tab (8 chars alignment) */ |
| 999 | console_col |= 0x0008; /* Next 8 chars boundary */ |
| 1000 | console_col &= ~0x0007; /* Set this bit to zero */ |
| 1001 | |
| 1002 | if (console_col >= CONSOLE_COLS) |
| 1003 | console_newline (); |
| 1004 | break; |
| 1005 | |
| 1006 | case 8: /* Eat last character */ |
| 1007 | console_back (); |
| 1008 | break; |
| 1009 | |
| 1010 | default: /* Add to the console */ |
| 1011 | video_putchar ( console_col * VIDEO_FONT_WIDTH, |
| 1012 | console_row * VIDEO_FONT_HEIGHT, c); |
| 1013 | console_col++; |
| 1014 | /* Check if we need to go to next row */ |
| 1015 | if (console_col >= CONSOLE_COLS) |
| 1016 | console_newline (); |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | void video_puts (const char *s) |
| 1021 | { |
| 1022 | int count = strlen (s); |
| 1023 | |
| 1024 | if (!video_enable) |
| 1025 | while (count--) |
| 1026 | serial_putc (*s++); |
| 1027 | else |
| 1028 | while (count--) |
| 1029 | video_putc (*s++); |
| 1030 | } |
| 1031 | |
| 1032 | /************************************************************************/ |
| 1033 | /* ** CURSOR BLINKING FUNCTIONS */ |
| 1034 | /************************************************************************/ |
| 1035 | |
| 1036 | #ifdef VIDEO_BLINK |
| 1037 | |
| 1038 | #define BLINK_TIMER_ID 0 |
| 1039 | #define BLINK_TIMER_HZ 2 |
| 1040 | |
| 1041 | static unsigned char blink_enabled = 0; |
| 1042 | static timer_t blink_timer; |
| 1043 | |
| 1044 | static void blink_update (void) |
| 1045 | { |
| 1046 | static int blink_row = -1, blink_col = -1, blink_old = 0; |
| 1047 | |
| 1048 | /* Check if we have a new position to invert */ |
| 1049 | if ((console_row != blink_row) || (console_col != blink_col)) { |
| 1050 | /* Check if we need to reverse last character */ |
| 1051 | if (blink_old) |
| 1052 | video_revchar ( blink_col * VIDEO_FONT_WIDTH, |
| 1053 | (blink_row |
| 1054 | #ifdef CONFIG_VIDEO_LOGO |
| 1055 | + VIDEO_LOGO_HEIGHT |
| 1056 | #endif |
| 1057 | ) * VIDEO_FONT_HEIGHT); |
| 1058 | |
| 1059 | /* Update values */ |
| 1060 | blink_row = console_row; |
| 1061 | blink_col = console_col; |
| 1062 | blink_old = 0; |
| 1063 | } |
| 1064 | |
| 1065 | /* Reverse this character */ |
| 1066 | blink_old = !blink_old; |
| 1067 | video_revchar ( console_col * VIDEO_FONT_WIDTH, |
| 1068 | (console_row |
| 1069 | #ifdef CONFIG_VIDEO_LOGO |
| 1070 | + VIDEO_LOGO_HEIGHT |
| 1071 | #endif |
| 1072 | ) * VIDEO_FONT_HEIGHT); |
| 1073 | |
| 1074 | } |
| 1075 | |
| 1076 | /* |
| 1077 | * Handler for blinking cursor |
| 1078 | */ |
| 1079 | static void blink_handler (void *arg) |
| 1080 | { |
| 1081 | /* Blink */ |
| 1082 | blink_update (); |
| 1083 | /* Ack the timer */ |
| 1084 | timer_ack (&blink_timer); |
| 1085 | } |
| 1086 | |
| 1087 | int blink_set (int blink) |
| 1088 | { |
| 1089 | int ret = blink_enabled; |
| 1090 | |
| 1091 | if (blink) |
| 1092 | timer_enable (&blink_timer); |
| 1093 | else |
| 1094 | timer_disable (&blink_timer); |
| 1095 | |
| 1096 | blink_enabled = blink; |
| 1097 | |
| 1098 | return ret; |
| 1099 | } |
| 1100 | |
| 1101 | static inline void blink_close (void) |
| 1102 | { |
| 1103 | timer_close (&blink_timer); |
| 1104 | } |
| 1105 | |
| 1106 | static inline void blink_init (void) |
| 1107 | { |
| 1108 | timer_init (&blink_timer, |
| 1109 | BLINK_TIMER_ID, BLINK_TIMER_HZ, |
| 1110 | blink_handler); |
| 1111 | } |
| 1112 | #endif |
| 1113 | |
| 1114 | /************************************************************************/ |
| 1115 | /* ** LOGO PLOTTING FUNCTIONS */ |
| 1116 | /************************************************************************/ |
| 1117 | |
| 1118 | #ifdef CONFIG_VIDEO_LOGO |
| 1119 | void easylogo_plot (fastimage_t * image, void *screen, int width, int x, |
| 1120 | int y) |
| 1121 | { |
| 1122 | int skip = width - image->width, xcount, ycount = image->height; |
| 1123 | |
| 1124 | #ifdef VIDEO_MODE_YUYV |
| 1125 | ushort *source = (ushort *) image->data; |
| 1126 | ushort *dest = (ushort *) screen + y * width + x; |
| 1127 | |
| 1128 | while (ycount--) { |
| 1129 | xcount = image->width; |
| 1130 | while (xcount--) |
| 1131 | *dest++ = *source++; |
| 1132 | dest += skip; |
| 1133 | } |
| 1134 | #endif |
| 1135 | #ifdef VIDEO_MODE_RGB |
| 1136 | unsigned char |
| 1137 | *source = (unsigned short *) image->data, |
| 1138 | *dest = (unsigned short *) screen + ((y * width) + x) * 3; |
| 1139 | |
| 1140 | while (ycount--) { |
| 1141 | xcount = image->width * 3; |
| 1142 | memcpy (dest, source, xcount); |
| 1143 | source += xcount; |
| 1144 | dest += ycount; |
| 1145 | } |
| 1146 | #endif |
| 1147 | } |
| 1148 | |
| 1149 | static void *video_logo (void) |
| 1150 | { |
| 1151 | u16 *screen = video_fb_address, width = VIDEO_COLS; |
| 1152 | #ifdef VIDEO_INFO |
| 1153 | # ifndef CONFIG_FADS |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1154 | char temp[32]; |
| 1155 | # endif |
| 1156 | char info[80]; |
| 1157 | #endif /* VIDEO_INFO */ |
| 1158 | |
| 1159 | easylogo_plot (VIDEO_LOGO_ADDR, screen, width, 0, 0); |
| 1160 | |
| 1161 | #ifdef VIDEO_INFO |
Peter Tyser | 561858e | 2008-11-03 09:30:59 -0600 | [diff] [blame] | 1162 | sprintf (info, "%s (%s - %s) ", |
| 1163 | U_BOOT_VERSION, U_BOOT_DATE, U_BOOT_TIME); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1164 | video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info); |
| 1165 | |
| 1166 | sprintf (info, "(C) 2002 DENX Software Engineering"); |
| 1167 | video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT, |
| 1168 | info); |
| 1169 | |
| 1170 | sprintf (info, " Wolfgang DENK, wd@denx.de"); |
| 1171 | video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 2, |
| 1172 | info); |
| 1173 | #ifndef CONFIG_FADS /* all normal boards */ |
| 1174 | /* leave one blank line */ |
| 1175 | |
| 1176 | sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash", |
| 1177 | strmhz(temp, gd->cpu_clk), |
| 1178 | gd->ram_size >> 20, |
| 1179 | gd->bd->bi_flashsize >> 20 ); |
| 1180 | video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 4, |
| 1181 | info); |
| 1182 | #else /* FADS :-( */ |
| 1183 | sprintf (info, "MPC823 CPU at 50 MHz on FADS823 board"); |
| 1184 | video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT, |
| 1185 | info); |
| 1186 | |
| 1187 | sprintf (info, "2MB FLASH - 8MB DRAM - 4MB SRAM"); |
| 1188 | video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 2, |
| 1189 | info); |
| 1190 | #endif |
| 1191 | #endif |
| 1192 | |
| 1193 | return video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN; |
| 1194 | } |
| 1195 | #endif |
| 1196 | |
| 1197 | /************************************************************************/ |
| 1198 | /* ** VIDEO HIGH-LEVEL FUNCTIONS */ |
| 1199 | /************************************************************************/ |
| 1200 | |
| 1201 | static int video_init (void *videobase) |
| 1202 | { |
| 1203 | /* Initialize the encoder */ |
| 1204 | debug ("[VIDEO] Initializing video encoder...\n"); |
| 1205 | video_encoder_init (); |
| 1206 | |
| 1207 | /* Initialize the video controller */ |
| 1208 | debug ("[VIDEO] Initializing video controller at %08x...\n", |
| 1209 | (int) videobase); |
| 1210 | video_ctrl_init (videobase); |
| 1211 | |
| 1212 | /* Setting the palette */ |
| 1213 | video_setpalette (CONSOLE_COLOR_BLACK, 0, 0, 0); |
| 1214 | video_setpalette (CONSOLE_COLOR_RED, 0xFF, 0, 0); |
| 1215 | video_setpalette (CONSOLE_COLOR_GREEN, 0, 0xFF, 0); |
| 1216 | video_setpalette (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); |
| 1217 | video_setpalette (CONSOLE_COLOR_BLUE, 0, 0, 0xFF); |
| 1218 | video_setpalette (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); |
| 1219 | video_setpalette (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); |
| 1220 | video_setpalette (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); |
| 1221 | video_setpalette (CONSOLE_COLOR_GREY2, 0xF8, 0xF8, 0xF8); |
| 1222 | video_setpalette (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); |
| 1223 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1224 | #ifndef CONFIG_SYS_WHITE_ON_BLACK |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1225 | video_setfgcolor (CONSOLE_COLOR_BLACK); |
| 1226 | video_setbgcolor (CONSOLE_COLOR_GREY2); |
| 1227 | #else |
| 1228 | video_setfgcolor (CONSOLE_COLOR_GREY2); |
| 1229 | video_setbgcolor (CONSOLE_COLOR_BLACK); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1230 | #endif /* CONFIG_SYS_WHITE_ON_BLACK */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1231 | |
| 1232 | #ifdef CONFIG_VIDEO_LOGO |
| 1233 | /* Paint the logo and retrieve tv base address */ |
| 1234 | debug ("[VIDEO] Drawing the logo...\n"); |
| 1235 | video_console_address = video_logo (); |
| 1236 | #else |
| 1237 | video_console_address = video_fb_address; |
| 1238 | #endif |
| 1239 | |
| 1240 | #ifdef VIDEO_BLINK |
| 1241 | /* Enable the blinking (under construction) */ |
| 1242 | blink_init (); |
| 1243 | blink_set (0); /* To Fix! */ |
| 1244 | #endif |
| 1245 | |
| 1246 | /* Initialize the console */ |
| 1247 | console_col = 0; |
| 1248 | console_row = 0; |
| 1249 | video_enable = 1; |
| 1250 | |
| 1251 | #ifdef VIDEO_MODE_PAL |
| 1252 | # define VIDEO_MODE_TMP1 "PAL" |
| 1253 | #endif |
| 1254 | #ifdef VIDEO_MODE_NTSC |
| 1255 | # define VIDEO_MODE_TMP1 "NTSC" |
| 1256 | #endif |
| 1257 | #ifdef VIDEO_MODE_YUYV |
| 1258 | # define VIDEO_MODE_TMP2 "YCbYCr" |
| 1259 | #endif |
| 1260 | #ifdef VIDEO_MODE_RGB |
| 1261 | # define VIDEO_MODE_TMP2 "RGB" |
| 1262 | #endif |
| 1263 | debug ( VIDEO_MODE_TMP1 |
| 1264 | " %dx%dx%d (" VIDEO_MODE_TMP2 ") on %s - console %dx%d\n", |
| 1265 | VIDEO_COLS, VIDEO_ROWS, VIDEO_MODE_BPP, |
| 1266 | VIDEO_ENCODER_NAME, CONSOLE_COLS, CONSOLE_ROWS); |
| 1267 | return 0; |
| 1268 | } |
| 1269 | |
| 1270 | int drv_video_init (void) |
| 1271 | { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1272 | int error, devices = 1; |
| 1273 | |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 1274 | struct stdio_dev videodev; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1275 | |
| 1276 | video_init ((void *)(gd->fb_base)); /* Video initialization */ |
| 1277 | |
| 1278 | /* Device initialization */ |
| 1279 | |
| 1280 | memset (&videodev, 0, sizeof (videodev)); |
| 1281 | |
| 1282 | strcpy (videodev.name, "video"); |
| 1283 | videodev.ext = DEV_EXT_VIDEO; /* Video extensions */ |
| 1284 | videodev.flags = DEV_FLAGS_OUTPUT; /* Output only */ |
| 1285 | videodev.putc = video_putc; /* 'putc' function */ |
| 1286 | videodev.puts = video_puts; /* 'puts' function */ |
| 1287 | |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 1288 | error = stdio_register (&videodev); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1289 | |
| 1290 | return (error == 0) ? devices : error; |
| 1291 | } |
| 1292 | |
| 1293 | /************************************************************************/ |
| 1294 | /* ** ROM capable initialization part - needed to reserve FB memory */ |
| 1295 | /************************************************************************/ |
| 1296 | |
| 1297 | /* |
| 1298 | * This is called early in the system initialization to grab memory |
| 1299 | * for the video controller. |
| 1300 | * Returns new address for monitor, after reserving video buffer memory |
| 1301 | * |
| 1302 | * Note that this is running from ROM, so no write access to global data. |
| 1303 | */ |
| 1304 | ulong video_setmem (ulong addr) |
| 1305 | { |
| 1306 | /* Allocate pages for the frame buffer. */ |
| 1307 | addr -= VIDEO_SIZE; |
| 1308 | |
| 1309 | debug ("Reserving %dk for Video Framebuffer at: %08lx\n", |
| 1310 | VIDEO_SIZE>>10, addr); |
| 1311 | |
| 1312 | return (addr); |
| 1313 | } |
| 1314 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1315 | #endif |