X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cpu%2Fmpc8xx%2Fvideo.c;h=2e6a22a94bc00944f93c70e8538ff1276d5de4f4;hb=6d0f6bcf337c5261c08fabe12982178c2c489d76;hp=9db69e1e195c450b1c312382f18b4f818d989ad1;hpb=e95b61cfb0c7203964c1a3f163e16a65f04d87ec;p=oweals%2Fu-boot.git diff --git a/cpu/mpc8xx/video.c b/cpu/mpc8xx/video.c index 9db69e1e19..2e6a22a94b 100644 --- a/cpu/mpc8xx/video.c +++ b/cpu/mpc8xx/video.c @@ -23,7 +23,7 @@ * MA 02111-1307 USA */ -/* #define DEBUG */ +/* #define DEBUG */ /************************************************************************/ /* ** HEADER FILES */ @@ -39,6 +39,8 @@ #ifdef CONFIG_VIDEO +DECLARE_GLOBAL_DATA_PTR; + /************************************************************************/ /* ** DEBUG SETTINGS */ /************************************************************************/ @@ -86,6 +88,14 @@ #define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7177_ADDR #endif +#ifdef CONFIG_VIDEO_ENCODER_AD7179 + +#include /* 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 */ /************************************************************************/ @@ -105,9 +115,9 @@ #define VIDEO_BURST_LEN (VIDEO_COLS/8) #ifdef VIDEO_MODE_YUYV -#define VIDEO_BG_COL 0x80D880D8 /* Background color in YUYV format */ +#define VIDEO_BG_COL 0x80D880D8 /* Background color in YUYV format */ #else -#define VIDEO_BG_COL 0xF8F8F8F8 /* Background color in RGB format */ +#define VIDEO_BG_COL 0xF8F8F8F8 /* Background color in RGB format */ #endif /************************************************************************/ @@ -155,7 +165,7 @@ /* ** CONSOLE CONSTANTS */ /************************************************************************/ -#ifdef CONFIG_VIDEO_LOGO +#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 @@ -163,11 +173,11 @@ #endif #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH) -#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN) +#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_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_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) /* @@ -287,8 +297,8 @@ static int video_maprgb (int r, int g, int b) /* 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; + 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 @@ -439,9 +449,9 @@ static void video_drawchars (int xx, int yy, unsigned char *s, int count) } } -static inline void video_drawstring (int xx, int yy, unsigned char *s) +static inline void video_drawstring (int xx, int yy, char *s) { - video_drawchars (xx, yy, s, strlen (s)); + video_drawchars (xx, yy, (unsigned char *)s, strlen (s)); } /* Relative to console plotting functions */ @@ -466,13 +476,14 @@ static void video_putchar (int xx, int yy, unsigned char c) static inline void video_putstring (int xx, int yy, unsigned char *s) { - video_putchars (xx, yy, s, strlen (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; @@ -485,6 +496,7 @@ static void video_mode_dupefield (VRAM * source, VRAM * dest, int entries) 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, @@ -501,11 +513,11 @@ static void inline video_mode_addentry (VRAM * vr, 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) +#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; + immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; VRAM *vr = (VRAM *) (((void *) immap) + 0xb00); /* Pointer to the VRAM table */ int DX, X1, X2, DY, Y1, Y2, entry = 0, fifo; @@ -539,9 +551,12 @@ static int video_mode_generate (void) 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 + * Hx Vx Fx Bx VDS INT LCYC LP LST * * Retrace blanking */ @@ -641,6 +656,73 @@ static int video_mode_generate (void) #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 * @@ -692,7 +774,9 @@ static int video_mode_generate (void) * one more cycle loop and a last identifier) */ video_mode_dupefield (vr, &vr[entry], entry); -#endif +#endif /* CONFIG_RRVISION */ + +#endif /* VIDEO_MODE_PAL */ /* See what FIFO are we using */ fifo = GETBIT (immap->im_vid.vid_vsr, VIDEO_VSR_CAS); @@ -724,7 +808,7 @@ static void video_encoder_init (void) /* Initialize the I2C */ debug ("[VIDEO ENCODER] Initializing I2C bus...\n"); - i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); + i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); #ifdef CONFIG_FADS /* Reset ADV7176 chip */ @@ -749,10 +833,10 @@ static void video_encoder_init (void) puts ("[VIDEO ENCODER] Configuring the encoder...\n"); - printf ("Sending %d bytes (@ %08lX) to I2C 0x%X:\n ", + printf ("Sending %zu bytes (@ %08lX) to I2C 0x%lX:\n ", sizeof(video_encoder_data), (ulong)video_encoder_data, - VIDEO_I2C_ADDR); + (ulong)VIDEO_I2C_ADDR); for (i=0; iim_ioport.iop_pdpar, - immr->im_ioport.iop_pddir, - immr->im_ioport.iop_pddat); - - debug ("[RRvision] PC5 -> Output (1): "); - immr->im_ioport.iop_pcpar &= ~(0x0400); - immr->im_ioport.iop_pcdir |= 0x0400 ; - immr->im_ioport.iop_pcdat |= 0x0400 ; - debug ("PCPAR=%04X PCDIR=%04X PCDAT=%04X\n", - immr->im_ioport.iop_pcpar, - immr->im_ioport.iop_pcdir, - immr->im_ioport.iop_pcdat); - } + 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. + /* + * 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; @@ -1089,7 +1166,6 @@ static void *video_logo (void) u16 *screen = video_fb_address, width = VIDEO_COLS; #ifdef VIDEO_INFO # ifndef CONFIG_FADS - DECLARE_GLOBAL_DATA_PTR; char temp[32]; # endif char info[80]; @@ -1159,13 +1235,13 @@ static int video_init (void *videobase) video_setpalette (CONSOLE_COLOR_GREY2, 0xF8, 0xF8, 0xF8); video_setpalette (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); -#ifndef CFG_WHITE_ON_BLACK +#ifndef CONFIG_SYS_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 */ +#endif /* CONFIG_SYS_WHITE_ON_BLACK */ #ifdef CONFIG_VIDEO_LOGO /* Paint the logo and retrieve tv base address */ @@ -1207,8 +1283,6 @@ static int video_init (void *videobase) int drv_video_init (void) { - DECLARE_GLOBAL_DATA_PTR; - int error, devices = 1; device_t videodev; @@ -1252,6 +1326,4 @@ ulong video_setmem (ulong addr) return (addr); } - - #endif