123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329 |
- /*
- * (C) Copyright 2000
- * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
- * (C) Copyright 2002
- * Wolfgang Denk, wd@denx.de
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
- /* #define DEBUG */
- /************************************************************************/
- /* ** HEADER FILES */
- /************************************************************************/
- #include <stdarg.h>
- #include <common.h>
- #include <config.h>
- #include <version.h>
- #include <i2c.h>
- #include <linux/types.h>
- #include <devices.h>
- #ifdef CONFIG_VIDEO
- DECLARE_GLOBAL_DATA_PTR;
- /************************************************************************/
- /* ** DEBUG SETTINGS */
- /************************************************************************/
- #if 0
- #define VIDEO_DEBUG_COLORBARS /* Force colorbars output */
- #endif
- /************************************************************************/
- /* ** VIDEO MODE SETTINGS */
- /************************************************************************/
- #if 0
- #define VIDEO_MODE_EXTENDED /* Allow screen size bigger than visible area */
- #define VIDEO_MODE_NTSC
- #endif
- #define VIDEO_MODE_PAL
- #if 0
- #define VIDEO_BLINK /* This enables cursor blinking (under construction) */
- #endif
- #define VIDEO_INFO /* Show U-Boot information */
- #define VIDEO_INFO_X VIDEO_LOGO_WIDTH+8
- #define VIDEO_INFO_Y 16
- /************************************************************************/
- /* ** VIDEO ENCODER CONSTANTS */
- /************************************************************************/
- #ifdef CONFIG_VIDEO_ENCODER_AD7176
- #include <video_ad7176.h> /* Sets encoder data, mode, and visible and active area */
- #define VIDEO_I2C 1
- #define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7176_ADDR
- #endif
- #ifdef CONFIG_VIDEO_ENCODER_AD7177
- #include <video_ad7177.h> /* Sets encoder data, mode, and visible and active area */
- #define VIDEO_I2C 1
- #define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7177_ADDR
- #endif
- #ifdef CONFIG_VIDEO_ENCODER_AD7179
- #include <video_ad7179.h> /* Sets encoder data, mode, and visible and active area */
- #define VIDEO_I2C 1
- #define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7179_ADDR
- #endif
- /************************************************************************/
- /* ** VIDEO MODE CONSTANTS */
- /************************************************************************/
- #ifdef VIDEO_MODE_EXTENDED
- #define VIDEO_COLS VIDEO_ACTIVE_COLS
- #define VIDEO_ROWS VIDEO_ACTIVE_ROWS
- #else
- #define VIDEO_COLS VIDEO_VISIBLE_COLS
- #define VIDEO_ROWS VIDEO_VISIBLE_ROWS
- #endif
- #define VIDEO_PIXEL_SIZE (VIDEO_MODE_BPP/8)
- #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE) /* Total size of buffer */
- #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2) /* Number of ints */
- #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE) /* Number of bytes per line */
- #define VIDEO_BURST_LEN (VIDEO_COLS/8)
- #ifdef VIDEO_MODE_YUYV
- #define VIDEO_BG_COL 0x80D880D8 /* Background color in YUYV format */
- #else
- #define VIDEO_BG_COL 0xF8F8F8F8 /* Background color in RGB format */
- #endif
- /************************************************************************/
- /* ** FONT AND LOGO DATA */
- /************************************************************************/
- #include <video_font.h> /* Get font data, width and height */
- #ifdef CONFIG_VIDEO_LOGO
- #include <video_logo.h> /* Get logo data, width and height */
- #define VIDEO_LOGO_WIDTH DEF_U_BOOT_LOGO_WIDTH
- #define VIDEO_LOGO_HEIGHT DEF_U_BOOT_LOGO_HEIGHT
- #define VIDEO_LOGO_ADDR &u_boot_logo
- #endif
- /************************************************************************/
- /* ** VIDEO CONTROLLER CONSTANTS */
- /************************************************************************/
- /* VCCR - VIDEO CONTROLLER CONFIGURATION REGISTER */
- #define VIDEO_VCCR_VON 0 /* Video controller ON */
- #define VIDEO_VCCR_CSRC 1 /* Clock source */
- #define VIDEO_VCCR_PDF 13 /* Pixel display format */
- #define VIDEO_VCCR_IEN 11 /* Interrupt enable */
- /* VSR - VIDEO STATUS REGISTER */
- #define VIDEO_VSR_CAS 6 /* Active set */
- #define VIDEO_VSR_EOF 0 /* End of frame */
- /* VCMR - VIDEO COMMAND REGISTER */
- #define VIDEO_VCMR_BD 0 /* Blank display */
- #define VIDEO_VCMR_ASEL 1 /* Active set selection */
- /* VBCB - VIDEO BACKGROUND COLOR BUFFER REGISTER */
- #define VIDEO_BCSR4_RESET_BIT 21 /* BCSR4 - Extern video encoder reset */
- #define VIDEO_BCSR4_EXTCLK_BIT 22 /* BCSR4 - Extern clock enable */
- #define VIDEO_BCSR4_VIDLED_BIT 23 /* BCSR4 - Video led disable */
- /************************************************************************/
- /* ** CONSOLE CONSTANTS */
- /************************************************************************/
- #ifdef CONFIG_VIDEO_LOGO
- #define CONSOLE_ROWS ((VIDEO_ROWS - VIDEO_LOGO_HEIGHT) / VIDEO_FONT_HEIGHT)
- #define VIDEO_LOGO_SKIP (VIDEO_COLS - VIDEO_LOGO_WIDTH)
- #else
- #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT)
- #endif
- #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH)
- #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN)
- #define CONSOLE_ROW_FIRST (video_console_address)
- #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE)
- #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
- #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
- #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
- /*
- * Simple color definitions
- */
- #define CONSOLE_COLOR_BLACK 0
- #define CONSOLE_COLOR_RED 1
- #define CONSOLE_COLOR_GREEN 2
- #define CONSOLE_COLOR_YELLOW 3
- #define CONSOLE_COLOR_BLUE 4
- #define CONSOLE_COLOR_MAGENTA 5
- #define CONSOLE_COLOR_CYAN 6
- #define CONSOLE_COLOR_GREY 13
- #define CONSOLE_COLOR_GREY2 14
- #define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
- /************************************************************************/
- /* ** BITOPS MACROS */
- /************************************************************************/
- #define HISHORT(i) ((i >> 16)&0xffff)
- #define LOSHORT(i) (i & 0xffff)
- #define HICHAR(s) ((i >> 8)&0xff)
- #define LOCHAR(s) (i & 0xff)
- #define HI(c) ((c >> 4)&0xf)
- #define LO(c) (c & 0xf)
- #define SWAPINT(i) (HISHORT(i) | (LOSHORT(i) << 16))
- #define SWAPSHORT(s) (HICHAR(s) | (LOCHAR(s) << 8))
- #define SWAPCHAR(c) (HI(c) | (LO(c) << 4))
- #define BITMASK(b) (1 << (b))
- #define GETBIT(v,b) (((v) & BITMASK(b)) > 0)
- #define SETBIT(v,b,d) (v = (((d)>0) ? (v) | BITMASK(b): (v) & ~BITMASK(b)))
- /************************************************************************/
- /* ** STRUCTURES */
- /************************************************************************/
- typedef struct {
- unsigned char V, Y1, U, Y2;
- } tYUYV;
- /* This structure is based on the Video Ram in the MPC823. */
- typedef struct VRAM {
- unsigned hx:2, /* Horizontal sync */
- vx:2, /* Vertical sync */
- fx:2, /* Frame */
- bx:2, /* Blank */
- res1:6, /* Reserved */
- vds:2, /* Video Data Select */
- inter:1, /* Interrupt */
- res2:2, /* Reserved */
- lcyc:11, /* Loop/video cycles */
- lp:1, /* Loop start/end */
- lst:1; /* Last entry */
- } VRAM;
- /************************************************************************/
- /* ** VARIABLES */
- /************************************************************************/
- static int
- video_panning_range_x = 0, /* Video mode invisible pixels x range */
- video_panning_range_y = 0, /* Video mode invisible pixels y range */
- video_panning_value_x = 0, /* Video mode x panning value (absolute) */
- video_panning_value_y = 0, /* Video mode y panning value (absolute) */
- video_panning_factor_x = 0, /* Video mode x panning value (-127 +127) */
- video_panning_factor_y = 0, /* Video mode y panning value (-127 +127) */
- console_col = 0, /* Cursor col */
- console_row = 0, /* Cursor row */
- video_palette[16]; /* Our palette */
- static const int video_font_draw_table[] =
- { 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff };
- static char
- video_color_fg = 0, /* Current fg color index (0-15) */
- video_color_bg = 0, /* Current bg color index (0-15) */
- video_enable = 0; /* Video has been initialized? */
- static void
- *video_fb_address, /* Frame buffer address */
- *video_console_address; /* Console frame buffer start address */
- /************************************************************************/
- /* ** MEMORY FUNCTIONS (32bit) */
- /************************************************************************/
- static void memsetl (int *p, int c, int v)
- {
- while (c--)
- *(p++) = v;
- }
- static void memcpyl (int *d, int *s, int c)
- {
- while (c--)
- *(d++) = *(s++);
- }
- /************************************************************************/
- /* ** VIDEO DRAWING AND COLOR FUNCTIONS */
- /************************************************************************/
- static int video_maprgb (int r, int g, int b)
- {
- #ifdef VIDEO_MODE_YUYV
- unsigned int pR, pG, pB;
- tYUYV YUYV;
- unsigned int *ret = (unsigned int *) &YUYV;
- /* Transform (0-255) components to (0-100) */
- pR = r * 100 / 255;
- pG = g * 100 / 255;
- pB = b * 100 / 255;
- /* Calculate YUV values (0-255) from RGB beetween 0-100 */
- YUYV.Y1 = YUYV.Y2 = 209 * (pR + pG + pB) / 300 + 16;
- YUYV.U = pR - (pG * 3 / 4) - (pB / 4) + 128;
- YUYV.V = pB - (pR / 4) - (pG * 3 / 4) + 128;
- return *ret;
- #endif
- #ifdef VIDEO_MODE_RGB
- return ((r >> 3) << 11) | ((g > 2) << 6) | (b >> 3);
- #endif
- }
- static void video_setpalette (int color, int r, int g, int b)
- {
- color &= 0xf;
- video_palette[color] = video_maprgb (r, g, b);
- /* Swap values if our panning offset is odd */
- if (video_panning_value_x & 1)
- video_palette[color] = SWAPINT (video_palette[color]);
- }
- static void video_fill (int color)
- {
- memsetl (video_fb_address, VIDEO_PIX_BLOCKS, color);
- }
- static void video_setfgcolor (int i)
- {
- video_color_fg = i & 0xf;
- }
- static void video_setbgcolor (int i)
- {
- video_color_bg = i & 0xf;
- }
- static int video_pickcolor (int i)
- {
- return video_palette[i & 0xf];
- }
- /* Absolute console plotting functions */
- #ifdef VIDEO_BLINK
- static void video_revchar (int xx, int yy)
- {
- int rows;
- u8 *dest;
- dest = video_fb_address + yy * VIDEO_LINE_LEN + xx * 2;
- for (rows = VIDEO_FONT_HEIGHT; rows--; dest += VIDEO_LINE_LEN) {
- switch (VIDEO_FONT_WIDTH) {
- case 16:
- ((u32 *) dest)[6] ^= 0xffffffff;
- ((u32 *) dest)[7] ^= 0xffffffff;
- /* FALL THROUGH */
- case 12:
- ((u32 *) dest)[4] ^= 0xffffffff;
- ((u32 *) dest)[5] ^= 0xffffffff;
- /* FALL THROUGH */
- case 8:
- ((u32 *) dest)[2] ^= 0xffffffff;
- ((u32 *) dest)[3] ^= 0xffffffff;
- /* FALL THROUGH */
- case 4:
- ((u32 *) dest)[0] ^= 0xffffffff;
- ((u32 *) dest)[1] ^= 0xffffffff;
- }
- }
- }
- #endif
- static void video_drawchars (int xx, int yy, unsigned char *s, int count)
- {
- u8 *cdat, *dest, *dest0;
- int rows, offset, c;
- u32 eorx, fgx, bgx;
- offset = yy * VIDEO_LINE_LEN + xx * 2;
- dest0 = video_fb_address + offset;
- fgx = video_pickcolor (video_color_fg);
- bgx = video_pickcolor (video_color_bg);
- if (xx & 1) {
- fgx = SWAPINT (fgx);
- bgx = SWAPINT (bgx);
- }
- eorx = fgx ^ bgx;
- switch (VIDEO_FONT_WIDTH) {
- case 4:
- case 8:
- while (count--) {
- c = *s;
- cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
- for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
- rows--;
- dest += VIDEO_LINE_LEN) {
- u8 bits = *cdat++;
- ((u32 *) dest)[0] =
- (video_font_draw_table[bits >> 6] & eorx) ^ bgx;
- ((u32 *) dest)[1] =
- (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx;
- if (VIDEO_FONT_WIDTH == 8) {
- ((u32 *) dest)[2] =
- (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx;
- ((u32 *) dest)[3] =
- (video_font_draw_table[bits & 3] & eorx) ^ bgx;
- }
- }
- dest0 += VIDEO_FONT_WIDTH * 2;
- s++;
- }
- break;
- case 12:
- case 16:
- while (count--) {
- cdat = video_fontdata + (*s) * (VIDEO_FONT_HEIGHT << 1);
- for (rows = VIDEO_FONT_HEIGHT, dest = dest0; rows--;
- dest += VIDEO_LINE_LEN) {
- u8 bits = *cdat++;
- ((u32 *) dest)[0] =
- (video_font_draw_table[bits >> 6] & eorx) ^ bgx;
- ((u32 *) dest)[1] =
- (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx;
- ((u32 *) dest)[2] =
- (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx;
- ((u32 *) dest)[3] =
- (video_font_draw_table[bits & 3] & eorx) ^ bgx;
- bits = *cdat++;
- ((u32 *) dest)[4] =
- (video_font_draw_table[bits >> 6] & eorx) ^ bgx;
- ((u32 *) dest)[5] =
- (video_font_draw_table[bits >> 4 & 3] & eorx) ^ bgx;
- if (VIDEO_FONT_WIDTH == 16) {
- ((u32 *) dest)[6] =
- (video_font_draw_table[bits >> 2 & 3] & eorx) ^ bgx;
- ((u32 *) dest)[7] =
- (video_font_draw_table[bits & 3] & eorx) ^ bgx;
- }
- }
- s++;
- dest0 += VIDEO_FONT_WIDTH * 2;
- }
- break;
- }
- }
- static inline void video_drawstring (int xx, int yy, char *s)
- {
- video_drawchars (xx, yy, (unsigned char *)s, strlen (s));
- }
- /* Relative to console plotting functions */
- static void video_putchars (int xx, int yy, unsigned char *s, int count)
- {
- #ifdef CONFIG_VIDEO_LOGO
- video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, s, count);
- #else
- video_drawchars (xx, yy, s, count);
- #endif
- }
- static void video_putchar (int xx, int yy, unsigned char c)
- {
- #ifdef CONFIG_VIDEO_LOGO
- video_drawchars (xx, yy + VIDEO_LOGO_HEIGHT, &c, 1);
- #else
- video_drawchars (xx, yy, &c, 1);
- #endif
- }
- static inline void video_putstring (int xx, int yy, unsigned char *s)
- {
- video_putchars (xx, yy, (unsigned char *)s, strlen ((char *)s));
- }
- /************************************************************************/
- /* ** VIDEO CONTROLLER LOW-LEVEL FUNCTIONS */
- /************************************************************************/
- #if !defined(CONFIG_RRVISION)
- static void video_mode_dupefield (VRAM * source, VRAM * dest, int entries)
- {
- int i;
- for (i = 0; i < entries; i++) {
- dest[i] = source[i]; /* Copy the entire record */
- dest[i].fx = (!dest[i].fx) * 3; /* Negate field bit */
- }
- dest[0].lcyc++; /* Add a cycle to the first entry */
- dest[entries - 1].lst = 1; /* Set end of ram entries */
- }
- #endif
- static void inline video_mode_addentry (VRAM * vr,
- int Hx, int Vx, int Fx, int Bx,
- int VDS, int INT, int LCYC, int LP, int LST)
- {
- vr->hx = Hx;
- vr->vx = Vx;
- vr->fx = Fx;
- vr->bx = Bx;
- vr->vds = VDS;
- vr->inter = INT;
- vr->lcyc = LCYC;
- vr->lp = LP;
- vr->lst = LST;
- }
- #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)
- static int video_mode_generate (void)
- {
- immap_t *immap = (immap_t *) CFG_IMMR;
- VRAM *vr = (VRAM *) (((void *) immap) + 0xb00); /* Pointer to the VRAM table */
- int DX, X1, X2, DY, Y1, Y2, entry = 0, fifo;
- /* CHECKING PARAMETERS */
- if (video_panning_factor_y < -128)
- video_panning_factor_y = -128;
- if (video_panning_factor_y > 128)
- video_panning_factor_y = 128;
- if (video_panning_factor_x < -128)
- video_panning_factor_x = -128;
- if (video_panning_factor_x > 128)
- video_panning_factor_x = 128;
- /* Setting panning */
- DX = video_panning_range_x = (VIDEO_ACTIVE_COLS - VIDEO_COLS) * 2;
- DY = video_panning_range_y = (VIDEO_ACTIVE_ROWS - VIDEO_ROWS) / 2;
- video_panning_value_x = (video_panning_factor_x + 128) * DX / 256;
- video_panning_value_y = (video_panning_factor_y + 128) * DY / 256;
- /* We assume these are burst units (multiplied by 2, we need it pari) */
- X1 = video_panning_value_x & 0xfffe;
- X2 = DX - X1;
- /* We assume these are field line units (divided by 2, we need it pari) */
- Y1 = video_panning_value_y & 0xfffe;
- Y2 = DY - Y1;
- debug("X1=%d, X2=%d, Y1=%d, Y2=%d, DX=%d, DY=%d VIDEO_COLS=%d \n",
- X1, X2, Y1, Y2, DX, DY, VIDEO_COLS);
- #ifdef VIDEO_MODE_NTSC
- /*
- * Hx Vx Fx Bx VDS INT LCYC LP LST
- *
- * Retrace blanking
- */
- ADDENTRY (0, 0, 3, 0, 1, 0, 3, 1, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 243, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 1440, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0);
- /*
- * Vertical blanking
- */
- ADDENTRY (0, 0, 0, 0, 1, 0, 18, 1, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 243, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0);
- /*
- * Odd field active area (TOP)
- */
- if (Y1 > 0) {
- ADDENTRY (0, 0, 0, 0, 1, 0, Y1, 1, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 235, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0);
- }
- /*
- * Odd field active area
- */
- ADDENTRY (0, 0, 0, 0, 1, 0, 240 - DY, 1, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 235, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, 8 + X1, 0, 0);
- ADDENTRY (3, 0, 0, 3, 0, 0, VIDEO_COLS * 2, 0, 0);
- if (X2 > 0)
- ADDENTRY (3, 0, 0, 3, 1, 0, X2, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0);
- /*
- * Odd field active area (BOTTOM)
- */
- if (Y1 > 0) {
- ADDENTRY (0, 0, 0, 0, 1, 0, Y2, 1, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 235, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0);
- }
- /*
- * Vertical blanking
- */
- ADDENTRY (0, 0, 0, 0, 1, 0, 4, 1, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 243, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 32, 1, 0);
- /*
- * Vertical blanking
- */
- ADDENTRY (0, 0, 3, 0, 1, 0, 19, 1, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 243, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 1440, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0);
- /*
- * Even field active area (TOP)
- */
- if (Y1 > 0) {
- ADDENTRY (0, 0, 3, 0, 1, 0, Y1, 1, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 235, 0, 0);
- ADDENTRY (3, 0, 3, 3, 1, 0, 1448, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0);
- }
- /*
- * Even field active area (CENTER)
- */
- ADDENTRY (0, 0, 3, 0, 1, 0, 240 - DY, 1, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 235, 0, 0);
- ADDENTRY (3, 0, 3, 3, 1, 0, 8 + X1, 0, 0);
- ADDENTRY (3, 0, 3, 3, 0, 0, VIDEO_COLS * 2, 0, 0);
- if (X2 > 0)
- ADDENTRY (3, 0, 3, 3, 1, 0, X2, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0);
- /*
- * Even field active area (BOTTOM)
- */
- if (Y1 > 0) {
- ADDENTRY (0, 0, 3, 0, 1, 0, Y2, 1, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 235, 0, 0);
- ADDENTRY (3, 0, 3, 3, 1, 0, 1448, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 32, 1, 0);
- }
- /*
- * Vertical blanking
- */
- ADDENTRY (0, 0, 3, 0, 1, 0, 1, 1, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 243, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 0, 1440, 0, 0);
- ADDENTRY (3, 0, 3, 0, 1, 1, 32, 1, 1);
- #endif
- #ifdef VIDEO_MODE_PAL
- #if defined(CONFIG_RRVISION)
- #define HPW 160 /* horizontal pulse width (was 139) */
- #define VPW 2 /* vertical pulse width */
- #define HBP 104 /* horizontal back porch (was 112) */
- #define VBP 19 /* vertical back porch (was 19) */
- #define VID_R 240 /* number of rows */
- debug ("[VIDEO CTRL] Starting to add controller entries...");
- /*
- * Even field
- */
- ADDENTRY (0, 3, 0, 3, 1, 0, 2, 0, 0);
- ADDENTRY (0, 0, 0, 3, 1, 0, HPW, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 0, 0);
- ADDENTRY (0, 0, 0, 3, 1, 0, VPW, 1, 0);
- ADDENTRY (0, 0, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, VBP, 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);
- /*
- * Active area
- */
- ADDENTRY (0, 3, 0, 3, 1, 0, VID_R , 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, HBP, 0, 0);
- ADDENTRY (3, 3, 0, 3, 0, 0, VIDEO_COLS*2, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, 72, 1, 1);
- ADDENTRY (0, 3, 0, 3, 1, 0, 51, 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, HBP +(VIDEO_COLS * 2) + 72 , 1, 0);
- /*
- * Odd field
- */
- ADDENTRY (0, 3, 0, 3, 1, 0, 2, 0, 0);
- ADDENTRY (0, 0, 0, 3, 1, 0, HPW, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 0, 0);
- ADDENTRY (0, 0, 0, 3, 1, 0, VPW+1, 1, 0);
- ADDENTRY (0, 0, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, VBP, 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, HBP + (VIDEO_COLS * 2) + 72, 1, 0);
- /*
- * Active area
- */
- ADDENTRY (0, 3, 0, 3, 1, 0, VID_R , 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, HBP, 0, 0);
- ADDENTRY (3, 3, 0, 3, 0, 0, VIDEO_COLS*2, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, 72, 1, 1);
- ADDENTRY (0, 3, 0, 3, 1, 0, 51, 1, 0);
- ADDENTRY (0, 3, 0, 3, 1, 0, HPW-1, 0, 0);
- ADDENTRY (3, 3, 0, 3, 1, 0, HBP +(VIDEO_COLS * 2) + 72 , 1, 0);
- debug ("done\n");
- #else /* !CONFIG_RRVISION */
- /*
- * Hx Vx Fx Bx VDS INT LCYC LP LST
- *
- * vertical; blanking
- */
- ADDENTRY (0, 0, 0, 0, 1, 0, 22, 1, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 263, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0);
- /*
- * active area (TOP)
- */
- if (Y1 > 0) {
- ADDENTRY (0, 0, 0, 0, 1, 0, Y1, 1, 0); /* 11? */
- ADDENTRY (3, 0, 0, 0, 1, 0, 255, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0);
- }
- /*
- * field active area (CENTER)
- */
- ADDENTRY (0, 0, 0, 0, 1, 0, 288 - DY, 1, 0); /* 265? */
- ADDENTRY (3, 0, 0, 0, 1, 0, 255, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, 8 + X1, 0, 0);
- ADDENTRY (3, 0, 0, 3, 0, 0, VIDEO_COLS * 2, 0, 0);
- if (X2 > 0)
- ADDENTRY (3, 0, 0, 1, 1, 0, X2, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0);
- /*
- * field active area (BOTTOM)
- */
- if (Y2 > 0) {
- ADDENTRY (0, 0, 0, 0, 1, 0, Y2, 1, 0); /* 12? */
- ADDENTRY (3, 0, 0, 0, 1, 0, 255, 0, 0);
- ADDENTRY (3, 0, 0, 3, 1, 0, 1448, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0);
- }
- /*
- * field vertical; blanking
- */
- ADDENTRY (0, 0, 0, 0, 1, 0, 2, 1, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 263, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 1440, 0, 0);
- ADDENTRY (3, 0, 0, 0, 1, 0, 24, 1, 0);
- /*
- * Create the other field (like this, but whit other field selected,
- * one more cycle loop and a last identifier)
- */
- video_mode_dupefield (vr, &vr[entry], entry);
- #endif /* CONFIG_RRVISION */
- #endif /* VIDEO_MODE_PAL */
- /* See what FIFO are we using */
- fifo = GETBIT (immap->im_vid.vid_vsr, VIDEO_VSR_CAS);
- /* Set number of lines and burst (only one frame for now) */
- if (fifo) {
- immap->im_vid.vid_vfcr0 = VIDEO_BURST_LEN |
- (VIDEO_BURST_LEN << 8) | ((VIDEO_ROWS / 2) << 19);
- } else {
- immap->im_vid.vid_vfcr1 = VIDEO_BURST_LEN |
- (VIDEO_BURST_LEN << 8) | ((VIDEO_ROWS / 2) << 19);
- }
- SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_ASEL, !fifo);
- /*
- * Wait until changes are applied (not done)
- * while (GETBIT(immap->im_vid.vid_vsr, VIDEO_VSR_CAS) == fifo) ;
- */
- /* Return number of VRAM entries */
- return entry * 2;
- }
- static void video_encoder_init (void)
- {
- #ifdef VIDEO_I2C
- int rc;
- /* Initialize the I2C */
- debug ("[VIDEO ENCODER] Initializing I2C bus...\n");
- i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
- #ifdef CONFIG_FADS
- /* Reset ADV7176 chip */
- debug ("[VIDEO ENCODER] Resetting encoder...\n");
- (*(int *) BCSR4) &= ~(1 << 21);
- /* Wait for 5 ms inside the reset */
- debug ("[VIDEO ENCODER] Waiting for encoder reset...\n");
- udelay (5000);
- /* Take ADV7176 out of reset */
- (*(int *) BCSR4) |= 1 << 21;
- /* Wait for 5 ms after the reset */
- udelay (5000);
- #endif /* CONFIG_FADS */
- /* Send configuration */
- #ifdef DEBUG
- {
- int i;
- puts ("[VIDEO ENCODER] Configuring the encoder...\n");
- printf ("Sending %zu bytes (@ %08lX) to I2C 0x%lX:\n ",
- sizeof(video_encoder_data),
- (ulong)video_encoder_data,
- (ulong)VIDEO_I2C_ADDR);
- for (i=0; i<sizeof(video_encoder_data); ++i) {
- printf(" %02X", video_encoder_data[i]);
- }
- putc ('\n');
- }
- #endif /* DEBUG */
- if ((rc = i2c_write (VIDEO_I2C_ADDR, 0, 1,
- video_encoder_data,
- sizeof(video_encoder_data))) != 0) {
- printf ("i2c_send error: rc=%d\n", rc);
- return;
- }
- #endif /* VIDEO_I2C */
- return;
- }
- static void video_ctrl_init (void *memptr)
- {
- immap_t *immap = (immap_t *) CFG_IMMR;
- video_fb_address = memptr;
- /* Set background */
- debug ("[VIDEO CTRL] Setting background color...\n");
- immap->im_vid.vid_vbcb = VIDEO_BG_COL;
- /* Show the background */
- debug ("[VIDEO CTRL] Forcing background...\n");
- SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 1);
- /* Turn off video controller */
- debug ("[VIDEO CTRL] Turning off video controller...\n");
- SETBIT (immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 0);
- #ifdef CONFIG_FADS
- /* Turn on Video Port LED */
- debug ("[VIDEO CTRL] Turning off video port led...\n");
- SETBIT (*(int *) BCSR4, VIDEO_BCSR4_VIDLED_BIT, 1);
- /* Disable internal clock */
- debug ("[VIDEO CTRL] Disabling internal clock...\n");
- SETBIT (*(int *) BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 0);
- #endif
- /* Generate and make active a new video mode */
- debug ("[VIDEO CTRL] Generating video mode...\n");
- video_mode_generate ();
- /* Start of frame buffer (even and odd frame, to make it working with */
- /* any selected active set) */
- debug ("[VIDEO CTRL] Setting frame buffer address...\n");
- immap->im_vid.vid_vfaa1 =
- immap->im_vid.vid_vfaa0 = (u32) video_fb_address;
- immap->im_vid.vid_vfba1 =
- immap->im_vid.vid_vfba0 =
- (u32) video_fb_address + VIDEO_LINE_LEN;
- /* YUV, Big endian, SHIFT/CLK/CLK input (BEFORE ENABLING 27MHZ EXT CLOCK) */
- debug ("[VIDEO CTRL] Setting pixel mode and clocks...\n");
- immap->im_vid.vid_vccr = 0x2042;
- /* Configure port pins */
- debug ("[VIDEO CTRL] Configuring input/output pins...\n");
- immap->im_ioport.iop_pdpar = 0x1fff;
- immap->im_ioport.iop_pddir = 0x0000;
- #ifdef CONFIG_FADS
- /* Turn on Video Port Clock - ONLY AFTER SET VCCR TO ENABLE EXTERNAL CLOCK */
- debug ("[VIDEO CTRL] Turning on video clock...\n");
- SETBIT (*(int *) BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 1);
- /* Turn on Video Port LED */
- debug ("[VIDEO CTRL] Turning on video port led...\n");
- SETBIT (*(int *) BCSR4, VIDEO_BCSR4_VIDLED_BIT, 0);
- #endif
- #ifdef CONFIG_RRVISION
- debug ("PC5->Output(1): enable PAL clock");
- immap->im_ioport.iop_pcpar &= ~(0x0400);
- immap->im_ioport.iop_pcdir |= 0x0400 ;
- immap->im_ioport.iop_pcdat |= 0x0400 ;
- debug ("PDPAR=0x%04X PDDIR=0x%04X PDDAT=0x%04X\n",
- immap->im_ioport.iop_pdpar,
- immap->im_ioport.iop_pddir,
- immap->im_ioport.iop_pddat);
- debug ("PCPAR=0x%04X PCDIR=0x%04X PCDAT=0x%04X\n",
- immap->im_ioport.iop_pcpar,
- immap->im_ioport.iop_pcdir,
- immap->im_ioport.iop_pcdat);
- #endif /* CONFIG_RRVISION */
- /* Blanking the screen. */
- debug ("[VIDEO CTRL] Blanking the screen...\n");
- video_fill (VIDEO_BG_COL);
- /*
- * Turns on Aggressive Mode. Normally, turning on the caches
- * will cause the screen to flicker when the caches try to
- * fill. This gives the FIFO's for the Video Controller
- * higher priority and prevents flickering because of
- * underrun. This may still be an issue when using FLASH,
- * since accessing data from Flash is so slow.
- */
- debug ("[VIDEO CTRL] Turning on aggressive mode...\n");
- immap->im_siu_conf.sc_sdcr = 0x40;
- /* Turn on video controller */
- debug ("[VIDEO CTRL] Turning on video controller...\n");
- SETBIT (immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 1);
- /* Show the display */
- debug ("[VIDEO CTRL] Enabling the video...\n");
- SETBIT (immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 0);
- }
- /************************************************************************/
- /* ** CONSOLE FUNCTIONS */
- /************************************************************************/
- static void console_scrollup (void)
- {
- /* Copy up rows ignoring the first one */
- memcpyl (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE >> 2);
- /* Clear the last one */
- memsetl (CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, VIDEO_BG_COL);
- }
- static inline void console_back (void)
- {
- console_col--;
- if (console_col < 0) {
- console_col = CONSOLE_COLS - 1;
- console_row--;
- if (console_row < 0)
- console_row = 0;
- }
- video_putchar ( console_col * VIDEO_FONT_WIDTH,
- console_row * VIDEO_FONT_HEIGHT, ' ');
- }
- static inline void console_newline (void)
- {
- console_row++;
- console_col = 0;
- /* Check if we need to scroll the terminal */
- if (console_row >= CONSOLE_ROWS) {
- /* Scroll everything up */
- console_scrollup ();
- /* Decrement row number */
- console_row--;
- }
- }
- void video_putc (const char c)
- {
- if (!video_enable) {
- serial_putc (c);
- return;
- }
- switch (c) {
- case 13: /* Simply ignore this */
- break;
- case '\n': /* Next line, please */
- console_newline ();
- break;
- case 9: /* Tab (8 chars alignment) */
- console_col |= 0x0008; /* Next 8 chars boundary */
- console_col &= ~0x0007; /* Set this bit to zero */
- if (console_col >= CONSOLE_COLS)
- console_newline ();
- break;
- case 8: /* Eat last character */
- console_back ();
- break;
- default: /* Add to the console */
- video_putchar ( console_col * VIDEO_FONT_WIDTH,
- console_row * VIDEO_FONT_HEIGHT, c);
- console_col++;
- /* Check if we need to go to next row */
- if (console_col >= CONSOLE_COLS)
- console_newline ();
- }
- }
- void video_puts (const char *s)
- {
- int count = strlen (s);
- if (!video_enable)
- while (count--)
- serial_putc (*s++);
- else
- while (count--)
- video_putc (*s++);
- }
- /************************************************************************/
- /* ** CURSOR BLINKING FUNCTIONS */
- /************************************************************************/
- #ifdef VIDEO_BLINK
- #define BLINK_TIMER_ID 0
- #define BLINK_TIMER_HZ 2
- static unsigned char blink_enabled = 0;
- static timer_t blink_timer;
- static void blink_update (void)
- {
- static int blink_row = -1, blink_col = -1, blink_old = 0;
- /* Check if we have a new position to invert */
- if ((console_row != blink_row) || (console_col != blink_col)) {
- /* Check if we need to reverse last character */
- if (blink_old)
- video_revchar ( blink_col * VIDEO_FONT_WIDTH,
- (blink_row
- #ifdef CONFIG_VIDEO_LOGO
- + VIDEO_LOGO_HEIGHT
- #endif
- ) * VIDEO_FONT_HEIGHT);
- /* Update values */
- blink_row = console_row;
- blink_col = console_col;
- blink_old = 0;
- }
- /* Reverse this character */
- blink_old = !blink_old;
- video_revchar ( console_col * VIDEO_FONT_WIDTH,
- (console_row
- #ifdef CONFIG_VIDEO_LOGO
- + VIDEO_LOGO_HEIGHT
- #endif
- ) * VIDEO_FONT_HEIGHT);
- }
- /*
- * Handler for blinking cursor
- */
- static void blink_handler (void *arg)
- {
- /* Blink */
- blink_update ();
- /* Ack the timer */
- timer_ack (&blink_timer);
- }
- int blink_set (int blink)
- {
- int ret = blink_enabled;
- if (blink)
- timer_enable (&blink_timer);
- else
- timer_disable (&blink_timer);
- blink_enabled = blink;
- return ret;
- }
- static inline void blink_close (void)
- {
- timer_close (&blink_timer);
- }
- static inline void blink_init (void)
- {
- timer_init (&blink_timer,
- BLINK_TIMER_ID, BLINK_TIMER_HZ,
- blink_handler);
- }
- #endif
- /************************************************************************/
- /* ** LOGO PLOTTING FUNCTIONS */
- /************************************************************************/
- #ifdef CONFIG_VIDEO_LOGO
- void easylogo_plot (fastimage_t * image, void *screen, int width, int x,
- int y)
- {
- int skip = width - image->width, xcount, ycount = image->height;
- #ifdef VIDEO_MODE_YUYV
- ushort *source = (ushort *) image->data;
- ushort *dest = (ushort *) screen + y * width + x;
- while (ycount--) {
- xcount = image->width;
- while (xcount--)
- *dest++ = *source++;
- dest += skip;
- }
- #endif
- #ifdef VIDEO_MODE_RGB
- unsigned char
- *source = (unsigned short *) image->data,
- *dest = (unsigned short *) screen + ((y * width) + x) * 3;
- while (ycount--) {
- xcount = image->width * 3;
- memcpy (dest, source, xcount);
- source += xcount;
- dest += ycount;
- }
- #endif
- }
- static void *video_logo (void)
- {
- u16 *screen = video_fb_address, width = VIDEO_COLS;
- #ifdef VIDEO_INFO
- # ifndef CONFIG_FADS
- char temp[32];
- # endif
- char info[80];
- #endif /* VIDEO_INFO */
- easylogo_plot (VIDEO_LOGO_ADDR, screen, width, 0, 0);
- #ifdef VIDEO_INFO
- sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
- video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info);
- sprintf (info, "(C) 2002 DENX Software Engineering");
- video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,
- info);
- sprintf (info, " Wolfgang DENK, wd@denx.de");
- video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 2,
- info);
- #ifndef CONFIG_FADS /* all normal boards */
- /* leave one blank line */
- sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",
- strmhz(temp, gd->cpu_clk),
- gd->ram_size >> 20,
- gd->bd->bi_flashsize >> 20 );
- video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 4,
- info);
- #else /* FADS :-( */
- sprintf (info, "MPC823 CPU at 50 MHz on FADS823 board");
- video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,
- info);
- sprintf (info, "2MB FLASH - 8MB DRAM - 4MB SRAM");
- video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT * 2,
- info);
- #endif
- #endif
- return video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN;
- }
- #endif
- /************************************************************************/
- /* ** VIDEO HIGH-LEVEL FUNCTIONS */
- /************************************************************************/
- static int video_init (void *videobase)
- {
- /* Initialize the encoder */
- debug ("[VIDEO] Initializing video encoder...\n");
- video_encoder_init ();
- /* Initialize the video controller */
- debug ("[VIDEO] Initializing video controller at %08x...\n",
- (int) videobase);
- video_ctrl_init (videobase);
- /* Setting the palette */
- video_setpalette (CONSOLE_COLOR_BLACK, 0, 0, 0);
- video_setpalette (CONSOLE_COLOR_RED, 0xFF, 0, 0);
- video_setpalette (CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
- video_setpalette (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
- video_setpalette (CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
- video_setpalette (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
- video_setpalette (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
- video_setpalette (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
- video_setpalette (CONSOLE_COLOR_GREY2, 0xF8, 0xF8, 0xF8);
- video_setpalette (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
- #ifndef CFG_WHITE_ON_BLACK
- video_setfgcolor (CONSOLE_COLOR_BLACK);
- video_setbgcolor (CONSOLE_COLOR_GREY2);
- #else
- video_setfgcolor (CONSOLE_COLOR_GREY2);
- video_setbgcolor (CONSOLE_COLOR_BLACK);
- #endif /* CFG_WHITE_ON_BLACK */
- #ifdef CONFIG_VIDEO_LOGO
- /* Paint the logo and retrieve tv base address */
- debug ("[VIDEO] Drawing the logo...\n");
- video_console_address = video_logo ();
- #else
- video_console_address = video_fb_address;
- #endif
- #ifdef VIDEO_BLINK
- /* Enable the blinking (under construction) */
- blink_init ();
- blink_set (0); /* To Fix! */
- #endif
- /* Initialize the console */
- console_col = 0;
- console_row = 0;
- video_enable = 1;
- #ifdef VIDEO_MODE_PAL
- # define VIDEO_MODE_TMP1 "PAL"
- #endif
- #ifdef VIDEO_MODE_NTSC
- # define VIDEO_MODE_TMP1 "NTSC"
- #endif
- #ifdef VIDEO_MODE_YUYV
- # define VIDEO_MODE_TMP2 "YCbYCr"
- #endif
- #ifdef VIDEO_MODE_RGB
- # define VIDEO_MODE_TMP2 "RGB"
- #endif
- debug ( VIDEO_MODE_TMP1
- " %dx%dx%d (" VIDEO_MODE_TMP2 ") on %s - console %dx%d\n",
- VIDEO_COLS, VIDEO_ROWS, VIDEO_MODE_BPP,
- VIDEO_ENCODER_NAME, CONSOLE_COLS, CONSOLE_ROWS);
- return 0;
- }
- int drv_video_init (void)
- {
- int error, devices = 1;
- device_t videodev;
- video_init ((void *)(gd->fb_base)); /* Video initialization */
- /* Device initialization */
- memset (&videodev, 0, sizeof (videodev));
- strcpy (videodev.name, "video");
- videodev.ext = DEV_EXT_VIDEO; /* Video extensions */
- videodev.flags = DEV_FLAGS_OUTPUT; /* Output only */
- videodev.putc = video_putc; /* 'putc' function */
- videodev.puts = video_puts; /* 'puts' function */
- error = device_register (&videodev);
- return (error == 0) ? devices : error;
- }
- /************************************************************************/
- /* ** ROM capable initialization part - needed to reserve FB memory */
- /************************************************************************/
- /*
- * This is called early in the system initialization to grab memory
- * for the video controller.
- * Returns new address for monitor, after reserving video buffer memory
- *
- * Note that this is running from ROM, so no write access to global data.
- */
- ulong video_setmem (ulong addr)
- {
- /* Allocate pages for the frame buffer. */
- addr -= VIDEO_SIZE;
- debug ("Reserving %dk for Video Framebuffer at: %08lx\n",
- VIDEO_SIZE>>10, addr);
- return (addr);
- }
- #endif
|