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