__s32 DDC_Read(char cmd,char pointer,char offset,int nbyte,char * pbuf) { #if 0 char i=0; char n=0; char off = offset; __u32 wait_ms; __inf("DDC_Read\n"); while(nbyte >0) { if(nbyte > 16) n = 16; else n = nbyte; nbyte = nbyte -n; HDMI_WUINT32(0x518,HDMI_RUINT32(0x518)| 0x00008000); //FIFO address clear HDMI_WUINT8(0x50f,pointer ); //segment pointer HDMI_WUINT8(0x50d,off ); //offset address HDMI_WUINT32(0x508,(n<<16) +cmd); //nbyte to access and cmd type HDMI_WUINT32(0x500,HDMI_RUINT32(0x500)| 0x08000000); //start the command off += n; wait_ms = 0; while(HDMI_RUINT32(0x500) & 0x08000000) { disp_delay_ms(1); wait_ms ++; if(wait_ms > 1000) { __wrn("ddc read timeout\n"); return -1; } } i=0; while(i<n) { * pbuf ++ = HDMI_RUINT8(0x580); i++; } } #endif return 0; }
__s32 video_config(__u32 vic) { __s32 vic_tab, clk_div,reg_val; __inf("video_config, vic:%d\n", vic); vic_tab = get_video_info(vic); if( vic_tab == -1) return 0; else video_mode = vic; HDMI_WUINT32(0x004,0x00000000); HDMI_WUINT32(0x040,0x00000000); //disable audio output HDMI_WUINT32(0x010,0x00000000); //disable video output HDMI_WUINT32(0x008,0xffffffff); //interrupt mask and clear all interrupt if( (vic == HDMI1440_480I) || (vic == HDMI1440_576I) ) //interlace and repeation { HDMI_WUINT32(0x010,0x00000011); } else if( (vic == HDMI1080I_50) || (vic == HDMI1080I_60) ) //interlace { HDMI_WUINT32(0x010,0x00000010); }else //progressive { HDMI_WUINT32(0x010,0x00000000); } if( (vic == HDMI1440_480I) || (vic == HDMI1440_576I) ) //need to use repeation { HDMI_WUINT16(0x014,(video_timing[vic_tab].INPUTX<<1) -1); //active H HDMI_WUINT16(0x018,(video_timing[vic_tab].HBP<<1) -1); //active HBP HDMI_WUINT16(0x01c,(video_timing[vic_tab].HFP<<1) -1); //active HFP HDMI_WUINT16(0x020,(video_timing[vic_tab].HPSW<<1) -1); //active HSPW } else { HDMI_WUINT16(0x014,(video_timing[vic_tab].INPUTX<<0) -1); //active H HDMI_WUINT16(0x018,(video_timing[vic_tab].HBP<<0) -1); //active HBP HDMI_WUINT16(0x01c,(video_timing[vic_tab].HFP<<0) -1); //active HFP HDMI_WUINT16(0x020,(video_timing[vic_tab].HPSW<<0) -1); //active HSPW } if( ( vic == HDMI1080P_24_3D_FP) || (vic == HDMI720P_50_3D_FP ) || (vic == HDMI720P_60_3D_FP ) ) { HDMI_WUINT16(0x016,video_timing[vic_tab].INPUTY + video_timing[vic_tab].VBP + video_timing[vic_tab].VFP -1); //active V }else { HDMI_WUINT16(0x016,video_timing[vic_tab].INPUTY -1); //active V } HDMI_WUINT16(0x01a,video_timing[vic_tab].VBP -1); //active VBP HDMI_WUINT16(0x01e,video_timing[vic_tab].VFP -1); //active VFP HDMI_WUINT16(0x022,video_timing[vic_tab].VPSW -1); //active VSPW if( video_timing[vic_tab].PCLK < 74250000) //SD format { HDMI_WUINT16(0x024,0x00 ); //Vsync/Hsync pol } else //HD format { HDMI_WUINT16(0x024,0x03 ); //Vsync/Hsync pol } HDMI_WUINT16(0x026,0x03e0 ); //TX clock sequence //avi packet HDMI_WUINT8 (0x080,0x82); HDMI_WUINT8 (0x081,0x02); HDMI_WUINT8 (0x082,0x0d); HDMI_WUINT8 (0x083,0x00); if(cts_enable &&(!YCbCr444_Support)) { HDMI_WUINT8 (0x084,0x10); //RGB444 __inf("HDMI RGB444 output mode\n"); } else { HDMI_WUINT8 (0x084,0x50); //YCbCr444 __inf("HDMI YCbCr444 output mode\n"); } if( video_timing[vic_tab].PCLK < 74250000) //SD format { HDMI_WUINT8 (0x085,0x58); //4:3 601 }else //HD format { HDMI_WUINT8 (0x085,0xa8); //16:9 709 } HDMI_WUINT8 (0x086,0x00); HDMI_WUINT8 (0x087,video_timing[vic_tab].VIC ); HDMI_WUINT8 (0x088,video_timing[vic_tab].AVI_PR); HDMI_WUINT8 (0x089,0x00); HDMI_WUINT8 (0x08a,0x00); HDMI_WUINT8 (0x08b,0x00); HDMI_WUINT8 (0x08c,0x00); HDMI_WUINT8 (0x08d,0x00); HDMI_WUINT8 (0x08e,0x00); HDMI_WUINT8 (0x08f,0x00); HDMI_WUINT8 (0x090,0x00); reg_val = HDMI_RUINT8(0x080) + HDMI_RUINT8(0x081) + HDMI_RUINT8(0x082) + HDMI_RUINT8(0x084) + HDMI_RUINT8(0x085) + HDMI_RUINT8(0x086) + HDMI_RUINT8(0x087) + HDMI_RUINT8(0x088) + HDMI_RUINT8(0x089) + HDMI_RUINT8(0x08a) + HDMI_RUINT8(0x08b) + HDMI_RUINT8(0x08c) + HDMI_RUINT8(0x08d) + HDMI_RUINT8(0x08e) + HDMI_RUINT8(0x08f) + HDMI_RUINT8(0x090); reg_val = reg_val & 0xff; if(reg_val != 0) reg_val = 0x100 - reg_val; HDMI_WUINT8 (0x083,reg_val); //checksum //gcp packet HDMI_WUINT32(0x0e0,0x00000003); HDMI_WUINT32(0x0e4,0x00000000); //vendor infoframe HDMI_WUINT8 (0x240,0x81); HDMI_WUINT8 (0x241,0x01); HDMI_WUINT8 (0x242,6 ); //length HDMI_WUINT8 (0x243,0x29); //pb0:checksum HDMI_WUINT8 (0x244,0x03); //pb1-3:24bit ieee id HDMI_WUINT8 (0x245,0x0c); // HDMI_WUINT8 (0x246,0x00); HDMI_WUINT8 (0x247,0x40); //pb4 HDMI_WUINT8 (0x248,0x00); //pb5:3d meta not present, frame packing HDMI_WUINT8 (0x249,0x00); //pb6:extra data for 3d HDMI_WUINT8 (0x24a,0x00); //pb7: matadata type=0,len=8 HDMI_WUINT8 (0x24b,0x00); HDMI_WUINT8 (0x24c,0x00); HDMI_WUINT8 (0x24d,0x00); HDMI_WUINT8 (0x24e,0x00); HDMI_WUINT8 (0x24f,0x00); HDMI_WUINT8 (0x250,0x00); HDMI_WUINT8 (0x251,0x00); HDMI_WUINT8 (0x252,0x00); //packet config if( ( vic != HDMI1080P_24_3D_FP) && (vic != HDMI720P_50_3D_FP) && ( vic != HDMI720P_60_3D_FP) ) { HDMI_WUINT32(0x2f0,0x0000f321); HDMI_WUINT32(0x2f4,0x0000000f); } else { HDMI_WUINT32(0x2f0,0x00005321); HDMI_WUINT32(0x2f4,0x0000000f); } HDMI_WUINT32(0x300,0x08000000); // set input sync enable if( (cts_enable == 0) || isHDMI) { __inf("hdmi mode: cts_enable=%d, isHDMI=%d\n", cts_enable,isHDMI); HDMI_WUINT8 (0x013,0xc0); //hdmi mode }else { __inf("dvi mode: cts_enable=%d, isHDMI=%d\n", cts_enable,isHDMI); HDMI_WUINT8 (0x013,0x80); //dvi mode } HDMI_WUINT32(0x004,0x80000000); //start hdmi controller ////////////////////// //hdmi pll setting if( (vic == HDMI1440_480I) || (vic == HDMI1440_576I)) { clk_div = hdmi_clk/video_timing[vic_tab].PCLK; clk_div /= 2; } else { clk_div = hdmi_clk/video_timing[vic_tab].PCLK; } clk_div &= 0x0f; HDMI_WUINT32(0x208,(1<<31)+ (1<<30)+ (1<<29)+ (3<<27)+ (0<<26)+ (1<<25)+ (0<<24)+ (0<<23)+ (4<<20)+ (7<<17)+ (15<<12)+ (7<<8)+ (clk_div<<4)+(8<<0) ); // tx driver setting HDMI_WUINT32(0x200,0xfe800000); //txen enable HDMI_WUINT32(0x204,0x00D8C850); //ckss = 1 HDMI_WUINT32(0x20c, hdmi_pll << 21); return 0; }