#include "drv_types.h" #include "hdmi_dbg.h" #include "hdmi_hw.h" #include "hdmi_notice.h" #include "hdmi_video.h" #include "hdmi_xvycc.h" #include "drv_hdmi_external.h" #include "../vip/6710/reg_vip_def.h" #include "../vip/6710/drv_reg_access.h" #include "hdmi.h" #include "hdmi_time.h" //#define HDMI_SHOW_AVI_INFO static HDMI_TIMING_PARAM_t* pHDMIVideoTimingTable = NULL; static UINT32 u32HDMIVideoTimingTblSize = 0; #ifdef CONFIG_SUPPORT_DEBUG_MESSAGE #ifdef HDMI_SHOW_AVI_INFO static void print_avi_info(void); #endif static void print_video_timing(void); #endif static void print_send_to_vip_info(VIP_InterfaceKIC *pstKic); extern INT32 GetCustomerData(INT8 *pcTableName, INT8 **tablestart, UINT32 *tablesize); UINT8 gbSupportMaxHz = 85; UINT8 HScalerDownFlag = FALSE; UINT16 SupportResolutionMode[][2] = { { 640, 350}, { 640, 400}, { 640, 480}, { 720, 240}, { 720, 288}, { 720, 400}, { 720, 480}, { 720, 576}, { 800, 600}, { 832, 624}, { 848, 480}, {1024, 768}, {1152, 864}, {1152, 870}, {1280, 720}, {1280, 768}, {1280, 800}, {1280, 960}, {1280,1024}, {1360, 768}, {1366, 768}, {1400,1050}, {1440, 240}, {1440, 288}, {1440, 480}, {1440, 576}, {1440, 900}, {1600, 900}, {1600,1200}, {1680,1050}, {1920, 540}, {1920,1080}, {1920,1200}, {2560,1080}, {2560,1440}, {2880, 240}, {2880, 288}, {2880, 480}, {2880, 576}, {3840,2160} }; #if 0 static void dump(const UINT8 *ptr, INT32 size) { INT32 i = 0, n = 0; INT8 str[3 * 0x10 + 8]; for (i = 0; i < size ; i++) { if (n >= 0) { n += sprintf(&str[n], "%02x ", ptr[i]); } if (n >= 3 * 0x10 || i + 1 == size) { n = 0; hdmidbg("%s\n", str); } } } #endif static UINT8 get_colorimetry(UINT32 vertical) { UINT8 outColorimetry; outColorimetry = HDMI_RegisterRead(HDMIRX_R_AVI_C); /* Patch? */ if (outColorimetry == AVI_C_NODATA) { outColorimetry = (vertical > 576) ? AVI_C_ITU709 : AVI_C_ITU601; } return outColorimetry; } static UINT8 get_pixel_fmt(void) { UINT8 outPixelFmt; HDMI_RegisterWrite(HDMIRX_R_DnSAMPLING_EN, 0); switch (HDMI_RegisterRead(HDMIRX_R_AVI_Y)) { case AVI_Y_YCC422: outPixelFmt = YUV_422; break; case AVI_Y_YCC444: outPixelFmt = YUV_444; break; case AVI_Y_RGB: outPixelFmt = RGB; break; default: outPixelFmt = YUV_444; break; } return outPixelFmt; } static UINT8 get_ratio(void) { UINT8 outRatio; outRatio = (HDMI_RegisterRead(HDMIRX_R_AVI_M)<<4) | HDMI_RegisterRead(HDMIRX_R_AVI_R) ; return outRatio; } static DRV_HDMI3DStructure_e get_3d_fmt(void) { DRV_HDMI3DStructure_e fmt; DRV_HDMIVSITYPE_e vsi_hdmi_video_fmt; fmt = NONE_3D; vsi_hdmi_video_fmt = HDMI_RegisterRead(HDMIRX_R_VSI_PB_7_0_) >> 5; if (vsi_hdmi_video_fmt == DRV_HDMI_VSI_TYEP_3D) { fmt = HDMI_RegisterRead(HDMIRX_R_VSI_PB_15_8_) >> 4; switch (fmt) { case DRV_HDMI_3D_STRUCT_FP: case DRV_HDMI_3D_STRUCT_FA: case DRV_HDMI_3D_STRUCT_LA: case DRV_HDMI_3D_STRUCT_SS_F: case DRV_HDMI_3D_STRUCT_L_D: case DRV_HDMI_3D_STRUCT_L_D_G: case DRV_HDMI_3D_STRUCT_TB: case DRV_HDMI_3D_STRUCT_SS_H: break; default: fmt = NONE_3D; break; } } hdmidbg("%s: %d\n", __FUNCTION__, fmt); return fmt; } #ifdef SUPPORT_XVYCC static UINT8 get_xvYCC(void) { UINT8 fmt; fmt = XV_YCC_NONE; if (HDMI_RegisterRead(HDMIRX_R_GBD_exist)) { fmt = (HDMI_RegisterRead(HDMIRX_AVI_EC) == 0) ? XV_YCC_601 : (HDMI_RegisterRead(HDMIRX_AVI_EC) == 1) ? XV_YCC_709 : XV_YCC_UNKNOWN_METRY; } return fmt; } #endif UINT32 get_pixel_clock(void) { UINT32 uiPixelClock = 0; if (HDMI_RegisterRead(HDMIRX_R_system_clk_cnt)) { //8506 CRYSTAL_USE_24MHZ uiPixelClock = (24000000 / HDMI_RegisterRead(HDMIRX_R_system_clk_cnt)) * HDMI_RegisterRead(HDMIRX_R_pixel_rate_cnt); //8506 VIP pixel clock limitation = 162MHz switch (HDMI_RegisterRead(HDMIRX_dcm)) //0xbe0e00dc[1:0] { case 0: // DCM Factor =1 break; case 1: // DCM Factor =1.25 uiPixelClock = (uiPixelClock << 2) / 5; // divide 1.25=*4/5 break; case 2: // DCM Factor =1.5 uiPixelClock = (uiPixelClock << 1) / 3; // devide 1.5=*2/3 break; case 3: // DCM Factor =2 uiPixelClock = uiPixelClock >> 1; break; default : // DCM Factor =1 break; } hdmidbg("pixel_clk>> %d, sys_clk_cnt: 0x%x R_pixel_rate_cnt: 0x%x, DCM Factor = %d\n", uiPixelClock, HDMI_RegisterRead(HDMIRX_R_system_clk_cnt), HDMI_RegisterRead(HDMIRX_R_pixel_rate_cnt),HDMI_RegisterRead(HDMIRX_dcm)); } return uiPixelClock; } static PLF_VideoID_t get_VideoID(VIP_InterfaceKIC *pstKic) { PLF_VideoID_t eVideoID = PLF_VIDEO_TIMING_ID_NON_VIDEO_TIMING; UINT8 i; for(i = 0;i < u32HDMIVideoTimingTblSize;i++) { if(pHDMIVideoTimingTable[i].fInterlace != pstKic->bInterlace) continue; else if(pHDMIVideoTimingTable[i].wVFreq != pstKic->uiVfreq) continue; else if(abs(pHDMIVideoTimingTable[i].wHActive - pstKic->uiHactive) > (pHDMIVideoTimingTable[i].wHActive * HDMI_HVAILD_TOLERANCE_PERMILE / 1000)) continue; else if(abs(pHDMIVideoTimingTable[i].wVActive - pstKic->uiVactive) > (pHDMIVideoTimingTable[i].wVActive * HDMI_VVAILD_TOLERANCE_PERMILE / 1000)) continue; else { eVideoID = pHDMIVideoTimingTable[i].eVideoID; hdmidbg("[%s]ID[0x%x]: HAct:%d VAct:%d VHz:%d Inter:%d\n", __FUNCTION__, pHDMIVideoTimingTable[i].eVideoID, pHDMIVideoTimingTable[i].wHActive, pHDMIVideoTimingTable[i].wVActive, pHDMIVideoTimingTable[i].wVFreq, pHDMIVideoTimingTable[i].fInterlace); break; } } return eVideoID; } UINT8 HDMI_CheckSupportResolutionMode(VIP_InterfaceKIC *pstKic) { UINT16 i; UINT32 size; UINT8 SupportFlag = false; size = sizeof(SupportResolutionMode) / (2 * sizeof(UINT16)); for(i=0;iuiHactive - SupportResolutionMode[i][0]) <= 2) && (pstKic->uiVactive == SupportResolutionMode[i][1])) { hdmidbg("Support Resolution mode!!\n"); SupportFlag = true; break; } } return SupportFlag; } #if 0 static BOOL HDMI_VideoNotSupport(VIP_InterfaceKIC *pstKic) { BOOL NotSupport = false; ULONG pixel_clk_freq = 0; pixel_clk_freq = get_pixel_clock(); // hdmidbg("pixel clk:0x%x HDMI=%d\n",HDMI_RegisterRead(HDMIRX_R_pixel_rate_cnt) , HDMI_RegisterRead(HDMIRX_R_HDMI_en)); // if((HDMI_RegisterRead(HDMIRX_R_pixel_rate_cnt) > 0x6e0) && (pstKic->uiHactive <= 2560)) //8506 VIP pixel clock limitation = 162MHz // { // NotSupport = true; // } if((pixel_clk_freq >= 165000000) && (pstKic->uiHactive <= 2560)) { NotSupport = true; } return NotSupport; } #endif void HDMI_GetVideoTimingTable(void) { GetCustomerData("gHDMI_VideoTimingTable", (void *)&pHDMIVideoTimingTable, &u32HDMIVideoTimingTblSize); //Calc Table Size u32HDMIVideoTimingTblSize = u32HDMIVideoTimingTblSize/sizeof(HDMI_TIMING_PARAM_t); } UINT8 HDMI_GetInputInformation(VIP_InterfaceKIC *pstKic) // return value: 0 - Not Support, 1 - Support, 2 - No signale { UINT8 ucModeSupport = 1; //Support UINT32 Vactive_o, Vactive_e; ULONG pixel_clk_freq = 0, vfreq = 0; INT32 iWait= 500; UINT8 hdmi_frmcnt = 0; UINT8 hdmi_frmcnt_debounce = 50; UINT8 hdmi_frmcnt_check=0; UINT32 Vtotal; UINT16 usHSyncCnt = 0; HScalerDownFlag = FALSE; pstKic->ucInputSource = HDMI; usHSyncCnt = VIP_RegisterRead(VIP_sta_hdmi_hs_lcnt); if(usHSyncCnt) pstKic->uiHfreq =(SYSTEM_CLK/10)/usHSyncCnt; else pstKic->uiHfreq =0; pstKic->ucFrameRate = -1; if(HDMI_RegisterRead(HDMIRX_R_HT)==0) { iWait= 500; printk("%s:HDMIRX_R_HT == 0!!!!!!\n", __FUNCTION__); while (iWait>0) { if((VIP_RegisterRead(VIP_sta_hdmi_hs_active)==TRUE)&& (VIP_RegisterRead(VIP_sta_hdmi_vs_active)==TRUE)) { break; } HDMI_DelayMs(1); iWait--; } if(iWait == 0) { printk("%s:Reach Wait Limit 500Ms!!\n", __FUNCTION__); } else { iWait= 1000; hdmi_frmcnt_check=0; printk("%s:HDMIRX_R_HT == 0!!!!!!\n", __FUNCTION__); while ((iWait>0) && (hdmi_frmcnt_check < hdmi_frmcnt_debounce)) { if(1 < abs(hdmi_frmcnt-VIP_RegisterRead(VIP_sta_hdmi_frmcnt))) { hdmi_frmcnt=VIP_RegisterRead(VIP_sta_hdmi_frmcnt); hdmi_frmcnt_check=0; } else { hdmi_frmcnt_check++; } HDMI_DelayMs(1); iWait--; } if(iWait == 0) { printk("%s:Reach Wait Limit 1000Ms!!\n", __FUNCTION__); } vfreq = 6000 /(hdmi_frmcnt+1); } } /* Interlace */ pstKic->bInterlace = HDMI_RegisterRead(HDMIRX_R_Interlace); /* Vertical */ Vactive_o = HDMI_RegisterRead(HDMIRX_top_de_v_width_lock); Vactive_e = HDMI_RegisterRead(HDMIRX_btn_de_v_width_lock); //HW issue:workaround for front porch = 0 case, hw VDEE report is wrong -- start -- if(((INT32)(HDMI_RegisterRead(HDMIRX_R_TOP_VDEE) - HDMI_RegisterRead(HDMIRX_R_TOP_VDES))) < 0) { Vactive_o = Vactive_o + 1; } if(((INT32)(HDMI_RegisterRead(HDMIRX_R_BTM_VDEE) - HDMI_RegisterRead(HDMIRX_R_BTM_VDES))) < 0) { Vactive_e = Vactive_e + 1; } //HW issue:workaround for front porch = 0 case, hw VDEE report is wrong -- end -- if (Vactive_o != 0) { pstKic->uiVactive = Vactive_o; pstKic->uiVtotal = HDMI_RegisterRead(HDMIRX_R_TOP_VT); pstKic->uiVstart = HDMI_RegisterRead(HDMIRX_R_TOP_VDES); } else { pstKic->uiVactive = Vactive_e; pstKic->uiVtotal = HDMI_RegisterRead(HDMIRX_R_BTM_VT); pstKic->uiVstart = HDMI_RegisterRead(HDMIRX_R_BTM_VDES); } //for 487i, top Vactive = 244, bottom Vactive = 243, if send 244 to VIP, the last line will be garbage if(pstKic->bInterlace == 1) { if(Vactive_o == (Vactive_e + 1)) pstKic->uiVactive = Vactive_e; else pstKic->uiVactive = Vactive_o; } pstKic->uiVend = pstKic->uiVstart + pstKic->uiVactive ; /* Horizontal */ pstKic->uiHactive = HDMI_RegisterRead(HDMIRX_de_h_width_lock) / (HDMI_RegisterRead(HDMIRX_R_AVI_PR) + 1); /* Patch: hactive should be a even number in DVI mode */ if (HDMI_RegisterRead(HDMIRX_R_HDMI_en) == 0) { pstKic->uiHactive &= 0xfffffffe; } pstKic->uiHtotal = HDMI_RegisterRead(HDMIRX_R_HT) + 1; pstKic->uiHstart = HDMI_RegisterRead(HDMIRX_R_HDES) + 1; pstKic->uiHend = pstKic->uiHstart + pstKic->uiHactive; /* Other */ pstKic->ucVpol = HDMI_RegisterRead(HDMIRX_R_Vsync_Polarity); pstKic->ucHpol = HDMI_RegisterRead(HDMIRX_R_Hsync_Polarity); pstKic->bDviEnable = HDMI_RegisterRead(HDMIRX_R_HDMI_en) ? 0 : 1; /* Color format */ pstKic->ucDataFormat = get_pixel_fmt(); /* Patch: In order to improve picture quality, transform YCC444 to YCC422 for SD resolution */ if (HDMI_RegisterRead(HDMIRX_R_AVI_Y) == AVI_Y_YCC444 && HDMI_RegisterRead(HDMIRX_R_HDMI_en) && ((pstKic->uiHactive == 720) && (pstKic->uiVactive == 480 || pstKic->uiVactive == 240 || pstKic->uiVactive == 576 || pstKic->uiVactive == 288))) { hdmidbg("YC444toYC422 for SD\n"); HDMI_RegisterWrite(HDMIRX_R_DnSAMPLING_EN, 1); pstKic->ucDataFormat = YUV_422; } pstKic->ucR_AVI_S = HDMI_RegisterRead(HDMIRX_R_AVI_S); pstKic->ucITC = HDMI_RegisterRead(HDMIRX_AVI_ITC); pstKic->ucColorimetry = get_colorimetry((pstKic->uiVactive * (pstKic->bInterlace + 1))); pstKic->ucAspectRatio = get_ratio(); //pstKic->ucxvYCC = get_xvYCC(); if(pstKic->bDviEnable == 1) //DVI mode, RGB range is full range pstKic->ucRGBRange = 2; else { pstKic->ucRGBRange = HDMI_RegisterRead(HDMIRX_AVI_Q); if(pstKic->ucRGBRange == 0) //in CEA-861-D spec.: if RGB Range = default, RGB pixel data values should be assumed to have the limited range when receiving a CE video format, and the full range when receiving an IT format. { if(HDMI_RegisterRead(HDMIRX_AVI_ITC) == 1) //IT format pstKic->ucRGBRange = 2; //full range else pstKic->ucRGBRange = 0; //Default } } pstKic->uc3DStructure = get_3d_fmt(); /* Patch: Sel field pol for 1080i */ if (HDMI_RegisterRead(HDMIRX_R_Interlace) == 1 && pstKic->uiVactive == 540 && (HDMI_RegisterRead(HDMIRX_R_TOP_VDES) + 1) != HDMI_RegisterRead(HDMIRX_R_BTM_VDES)) { HDMI_RegisterWrite(HDMIRX_R_FIELD_POL, 1); } else { HDMI_RegisterWrite(HDMIRX_R_FIELD_POL, 0); } pixel_clk_freq = get_pixel_clock(); if (HDMI_RegisterRead(HDMIRX_R_Interlace) == 1) { Vtotal = HDMI_RegisterRead(HDMIRX_R_BTM_VT); } else { Vtotal = pstKic->uiVtotal ; } /* get vfreq */ if ((pstKic->uiHtotal > 1) && Vtotal) //H total = HDMIRX_R_HT + 1 { vfreq = (pixel_clk_freq + ((pstKic->uiHtotal * Vtotal) >> 1)) / (pstKic->uiHtotal * Vtotal); } /* else { vfreq = 0; } */ /* switch (HDMI_RegisterRead(HDMIRX_dcm)) //0xbe0e00dc[1:0] { case 0: // DCM Factor =1 //hdmidbg("%s>> VFreq = %ld Hz = (((0x%lx+((0x%x*0x%x)>>1))/(0x%x*0x%x)))/1\n", __FUNCTION__, vfreq, pixel_clk_freq, pstKic->uiHtotal, pstKic->uiVtotal, pstKic->uiHtotal, pstKic->uiVtotal); break; case 1: // DCM Factor =1.25 vfreq = (vfreq << 2) / 5; // divide 1.25=*4/5 //hdmidbg("%s>> VFreq = %ld Hz = (((0x%lx+((0x%x*0x%x)>>1))/(0x%x*0x%x)))/1.25\n", __FUNCTION__, vfreq, pixel_clk_freq, pstKic->uiHtotal, pstKic->uiVtotal, pstKic->uiHtotal, pstKic->uiVtotal); break; case 2: // DCM Factor =1.5 vfreq = (vfreq << 1) / 3; // devide 1.5=*2/3 //hdmidbg("%s>> VFreq = %ld Hz = (((0x%lx+((0x%x*0x%x)>>1))/(0x%x*0x%x)))/1.5\n", __FUNCTION__, vfreq, pixel_clk_freq, pstKic->uiHtotal, pstKic->uiVtotal, pstKic->uiHtotal, pstKic->uiVtotal); break; case 3: // DCM Factor =2 vfreq = vfreq >> 1; //hdmidbg("%s>> VFreq = %ld Hz = (((0x%lx+((0x%x*0x%x)>>1))/(0x%x*0x%x)))/2\n", __FUNCTION__, vfreq, pixel_clk_freq, pstKic->uiHtotal, pstKic->uiVtotal, pstKic->uiHtotal, pstKic->uiVtotal); break; default : // DCM Factor =1 //hdmidbg("%s>> (Default) VFreq = %ld Hz = (((0x%lx+((0x%x*0x%x)>>1))/(0x%x*0x%x)))/1\n", __FUNCTION__, vfreq, pixel_clk_freq, pstKic->uiHtotal, pstKic->uiVtotal, pstKic->uiHtotal, pstKic->uiVtotal); break; } */ if((pixel_clk_freq >= 165000000) && (pstKic->uiHactive < 2560)) { ucModeSupport = 0; // Not Support } else if ((pstKic->uiHtotal != 0) && pstKic->uiVtotal != 0) { if (vfreq == 73) { vfreq = 72; // the experience from VIP } else if (vfreq == 59 || vfreq == 61) { vfreq = 60; // the experience from VIP } else if (vfreq == 74) { vfreq = 75; // the experience from VIP } else if (vfreq == 49) { vfreq = 50; // the experience from VIP } else if (vfreq == 57) { vfreq = 56; } else if (vfreq == 86) { vfreq = 85; } else if (vfreq == 76) { vfreq = 75; } else if (vfreq == 71) { vfreq = 70; } else if (vfreq == 23) { vfreq = 24; } } else { hdmidbg("else:Htotal %d Vtotal %d\n",pstKic->uiHtotal, pstKic->uiVtotal); } pstKic->uiVfreq = vfreq; printk("[H] VHz:%d \n",pstKic->uiVfreq); if(vfreq > gbSupportMaxHz) { hdmidbg("VHz not support, Max is %d \n", gbSupportMaxHz); ucModeSupport = 0; } if(ucModeSupport == 1) { ucModeSupport = HDMI_CheckSupportResolutionMode(pstKic); } #ifndef CONFIG_SUPPORT_4K_2K_30 if((pstKic->uiHactive > 2000)||(pstKic->uiVactive > 1500))// 4kx2K not support { hdmidbg("not support 4kx2K\n"); ucModeSupport = 0; } #endif pstKic->uiTimingIndex = get_VideoID(pstKic); #ifdef CONFIG_SUPPORT_DEBUG_MESSAGE print_video_timing(); #ifdef HDMI_SHOW_AVI_INFO print_avi_info(); #endif #endif print_send_to_vip_info(pstKic); if (pstKic->uiHactive == 0 && pstKic->uiVactive == 0) { hdmidbg("HAct=0 & VAct=0. \n"); ucModeSupport = 2; // Regard it as "No Signal". SW Workaround } #ifdef CONFIG_SUPPORT_4K_2K_30 pstKic->ucEnlargeWidthRate = 0; if (pstKic->uiHactive == 3840) { hdmidbg("......4K x 2K.....\n"); pstKic->uiHactive = (pstKic->uiHactive)/2; pstKic->uiHtotal = (pstKic->uiHtotal)/2; pstKic->uiHstart = (pstKic->uiHstart)/2 ; pstKic->uiHend = (pstKic->uiHend)/2; *((u8 *)0xbe000257) = 0x18 ; pstKic->ucEnlargeWidthRate = 1; HScalerDownFlag = TRUE; } else if (pstKic->uiHactive >= 2560) { hdmidbg("......H Scale Down.....\n"); pstKic->uiHactive = (pstKic->uiHactive)/2; pstKic->uiHtotal = (pstKic->uiHtotal)/2; pstKic->uiHstart = (pstKic->uiHstart)/2 ; pstKic->uiHend = (pstKic->uiHend)/2; *((u8 *)0xbe000257) = 0x18 ; pstKic->ucEnlargeWidthRate = 1; HScalerDownFlag = TRUE; } else { *((u8 *)0xbe000257) = 0x01 ;//Bit0: 1 => Bypass mode } #endif /* if((1 == ucModeSupport) && (pstKic->bDviEnable == FALSE)) { if((pstKic->bDviEnable == FALSE) && (0x00000000 == (HDMI_RegisterRead(HDMIRX_0134_DW_0134)))) { printk(KERN_EMERG"Hdmi have no avi info data!!\n"); ucModeSupport = 2; } } */ return ucModeSupport; } void HDMI_VSI_handler(void) { hdmidbg("Get VSI PB\n"); // HDMIRX_R_VSI_PB_7_0_ bit 7 ~ bit 5(HDMI_Video_Format): // 000 - No additional HDMI video format // 001 - 1 byte of parameter value follows // 010 - 3D format // HDMIRX_R_VSI_PB__15_8_ bit 7 ~ bit 4(3D_Structure): // 0000 - Frame packing // 0110 - Top-and Bottom // 1000 - Side-by-Side(Half) // HDMIRX_R_VSI_PB_23_16_ bit 7 ~ bit 4(3D_Ext_Data): // 00xx - Horizontal sub-sampling // 0100 - Odd/Left pic Odd/Right pic // 0101 - Odd/Left pic Even/Right pic // 0110 - Even/Left pic Odd/Right pic // 0111 - Even/Left pic Even/Right pic #if 0 #define VSI_VIDEO_FMT_3D_FMT 0x2 if ((HDMI_RegisterRead(HDMIRX_R_VSI_PB_7_0_) >> 5) == VSI_VIDEO_FMT_3D_FMT) { UINT8 uc3D_Struc = (HDMI_RegisterRead(HDMIRX_R_VSI_PB__15_8_) >> 4); if ((uc3D_Struc & 0xc) || (uc3D_Struc == 0x7)) { uc3D_Struc = NONE_3D; // unused. Set 2D } if (Active_flag) { VIP_SourceScreenMode(HDMI, BlackScreen, __LINE__); ModeSupport_flag = HDMI_SendVipInfo(); VIP_SourceScreenMode(HDMI, NormalScreen, __LINE__); } } #endif } BOOL HDMI_IsAviChanged(VIP_InterfaceKIC *pstKic) { BOOL ret = false; UINT32 bCurHactive = HDMI_RegisterRead(HDMIRX_de_h_width_lock) / (HDMI_RegisterRead(HDMIRX_R_AVI_PR) + 1); UINT8 bCurPixelFormat = get_pixel_fmt(); UINT8 bCurAspectRatio = get_ratio(); UINT8 bCurDviEnable = HDMI_RegisterRead(HDMIRX_R_HDMI_en) ? 0 : 1; if(bCurHactive == pstKic->uiHactive) { if(bCurPixelFormat != pstKic->ucDataFormat) { hdmidbg("Pixel Format change %d->%d\n",pstKic->ucDataFormat, bCurPixelFormat); pstKic->ucDataFormat = bCurPixelFormat; ret = true; } if(bCurAspectRatio != pstKic->ucAspectRatio) { hdmidbg("Aspect Ratio change %d->%d\n",pstKic->ucAspectRatio, bCurAspectRatio); pstKic->ucAspectRatio = bCurAspectRatio; ret = true; } if(bCurDviEnable != pstKic->bDviEnable) { hdmidbg("Hdmi/Dvi mode change %d->%d\n",pstKic->bDviEnable, bCurDviEnable); pstKic->bDviEnable = bCurDviEnable; ret = true; } } return ret; } void HDMI_SetSupportMaxHz(UINT8 bSupportMaxHz) { gbSupportMaxHz = bSupportMaxHz; hdmidbg("Support Max Hz:%d\n", gbSupportMaxHz); } #ifdef CONFIG_SUPPORT_DEBUG_MESSAGE #ifdef HDMI_SHOW_AVI_INFO /* Note: debug use only */ static void print_avi_info(void) { /* Auxiliary Video Information. Check CEA-861-D for more details */ hdmidbg("AVI Info\n"); hdmidbg("version: 0x%x (Must be 0x2)\n", HDMI_RegisterRead(HDMIRX_R_AVI_Ver)); hdmidbg("Pixel color format (Y=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_Y), HDMI_RegisterRead(HDMIRX_R_AVI_Y) == 0x0 ? "RGB" : HDMI_RegisterRead(HDMIRX_R_AVI_Y) == 0x1 ? "YCbCr422" : HDMI_RegisterRead(HDMIRX_R_AVI_Y) == 0x2 ? "YCbCr444" : "Future use" ); hdmidbg("Bar Info (B=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_B), HDMI_RegisterRead(HDMIRX_R_AVI_B) == 0x0 ? "Not valid" : HDMI_RegisterRead(HDMIRX_R_AVI_B) == 0x1 ? "Vertical Bar Info Valid" : HDMI_RegisterRead(HDMIRX_R_AVI_B) == 0x2 ? "Horizontal Bar Info Valid" : HDMI_RegisterRead(HDMIRX_R_AVI_B) == 0x3 ? "Horizontal/Vertical Bar Info Valid" : "" ); hdmidbg("Scan Info (S=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_S), HDMI_RegisterRead(HDMIRX_R_AVI_S) == 0x0 ? "No Data" : HDMI_RegisterRead(HDMIRX_R_AVI_S) == 0x1 ? "Overscanned" : HDMI_RegisterRead(HDMIRX_R_AVI_S) == 0x2 ? "Underscanned" : "Future use" ); hdmidbg("Colorimetry (C=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_C), HDMI_RegisterRead(HDMIRX_R_AVI_C) == 0x0 ? "No data" : HDMI_RegisterRead(HDMIRX_R_AVI_C) == 0x1 ? "ITU601" : HDMI_RegisterRead(HDMIRX_R_AVI_C) == 0x2 ? "ITU709" : HDMI_RegisterRead(HDMIRX_R_AVI_C) == 0x3 ? "Extended(Check EC)" : "" ); hdmidbg("Picture Aspect Ratio (M=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_M), HDMI_RegisterRead(HDMIRX_R_AVI_M) == 0x0 ? "No data" : HDMI_RegisterRead(HDMIRX_R_AVI_M) == 0x1 ? "4:3" : HDMI_RegisterRead(HDMIRX_R_AVI_M) == 0x2 ? "16:9" : "Future use" ); hdmidbg("Active Format Aspect Ratio (R=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_R), HDMI_RegisterRead(HDMIRX_R_AVI_R) == 0x8 ? "Same as picutre aspect ratio" : HDMI_RegisterRead(HDMIRX_R_AVI_R) == 0x9 ? "4:3(Center)" : HDMI_RegisterRead(HDMIRX_R_AVI_R) == 0xA ? "16:9(Center)" : HDMI_RegisterRead(HDMIRX_R_AVI_R) == 0xB ? "14:9(Center)" : "Per DVB AFD active_format field" ); hdmidbg("IT Content(ITC=%d): %s\n", HDMI_RegisterRead(HDMIRX_AVI_ITC), HDMI_RegisterRead(HDMIRX_AVI_ITC) == 0x0 ? "No data" : "IT Content" ); hdmidbg("Gamut Metadata packet %d\n", HDMI_RegisterRead(HDMIRX_R_GBD_exist)); // if( HDMI_RegisterRead(HDMIRX_R_GBD_exist) ) // { hdmidbg("Extended Colorimetry (EC=%d): %s\n", HDMI_RegisterRead(HDMIRX_AVI_EC), HDMI_RegisterRead(HDMIRX_AVI_EC) == 0x0 ? "xvYCC601" : HDMI_RegisterRead(HDMIRX_AVI_EC) == 0x1 ? "xvYCC709" : "Reserved" ); // } hdmidbg("RGB Quantizatio n Range (Q=%d): %s\n", HDMI_RegisterRead(HDMIRX_AVI_Q), HDMI_RegisterRead(HDMIRX_AVI_Q) == 0x0 ? "Default" : HDMI_RegisterRead(HDMIRX_AVI_Q) == 0x1 ? "Limited Range" : HDMI_RegisterRead(HDMIRX_AVI_Q) == 0x2 ? "Full Range" : "Reserved" ); hdmidbg("Non-Uniform Picture Scaling (SC=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_SC), HDMI_RegisterRead(HDMIRX_R_AVI_SC) == 0x0 ? "No known non-uniform scaling" : HDMI_RegisterRead(HDMIRX_R_AVI_SC) == 0x1 ? "Scaled horizontally" : HDMI_RegisterRead(HDMIRX_R_AVI_SC) == 0x2 ? "Scaled vertically" : HDMI_RegisterRead(HDMIRX_R_AVI_SC) == 0x3 ? "Scaled horizontally and vertically" : "" ); hdmidbg("Pixel Repetition Factor (PR): %d\n", HDMI_RegisterRead(HDMIRX_R_AVI_PR)); hdmidbg("Video Codes (VIC=%d): %s\n", HDMI_RegisterRead(HDMIRX_R_AVI_VIC), (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 1) ? "640x480p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 2 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 3) ? "720x480p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 4) ? "1280x720p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 5) ? "1920x1080i @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 6 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 7) ? "720(1440)x480i @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 8 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 9) ? "720(1440)x240p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 10 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 11) ? "2880x480i @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 12 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 13) ? "2880x240p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 14 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 15) ? "1440x480p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 16) ? "1920x1080p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 17 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 18) ? "720x576p @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 19) ? "1280x720p @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 20) ? "1920x1080i @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 21 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 22) ? "720(1440)x576i @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 23 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 24) ? "720(1440)x288p @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 25 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 26) ? "2880x576i @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 27 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 28) ? "2880x288p @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 29 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 30) ? "1440x576p @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 31) ? "1920x1080p @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 32) ? "1920x1080p @ 23.98/24Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 33) ? "1920x1080p @ 25Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 34) ? "1920x1080p @ 29.98/30Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 35 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 36) ? "2880x480p @ 59.94/60Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 37 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 38) ? "2880x576p @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 39) ? "1920x1080i(1250) @ 50Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 40) ? "1920x1080i @ 100Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 41) ? "1280x720p @ 100Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 42 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 43) ? "720x576p @ 100Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 44 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 45) ? "720(1440)x576i @ 100Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 46) ? "1920x1080i @ 119.88/120Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 47) ? "1920x720p @ 119.88/120Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 48 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 49) ? "720x480p @ 119.88/120Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 50 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 51) ? "720(1440)x480i @ 119.88/120Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 52 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 53) ? "720x576p @ 200Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 54 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 55) ? "720(1440)x576i @ 200Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 56 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 57) ? "720x480p @ 239.76/240Hz" : (HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 58 || HDMI_RegisterRead(HDMIRX_R_AVI_VIC) == 59) ? "720(1440)x480i @ 239.76/240Hz" : "Can't supported" ); hdmidbg("Start line number : %d\n", HDMI_RegisterRead(HDMIRX_R_AVI_SLN)); hdmidbg("End line number : %d\n", HDMI_RegisterRead(HDMIRX_R_AVI_ELN)); hdmidbg("Start pixel number: %d\n", HDMI_RegisterRead(HDMIRX_R_AVI_SPN)); hdmidbg("End pixel number : %d\n", HDMI_RegisterRead(HDMIRX_R_AVI_EPN)); } #endif static void print_video_timing(void) { hdmidbg("Print Video Timing info:\n"); hdmidbg("V Top:\n\tTotal:%d\n\tDE Start:%d, End: %d, sw_Valid:%d\n\thw_Valid:%d\n", HDMI_RegisterRead(HDMIRX_R_TOP_VT), HDMI_RegisterRead(HDMIRX_R_TOP_VDES), HDMI_RegisterRead(HDMIRX_R_TOP_VDEE), HDMI_RegisterRead(HDMIRX_R_TOP_VDEE) - HDMI_RegisterRead(HDMIRX_R_TOP_VDES), HDMI_RegisterRead(HDMIRX_top_de_v_width_lock)); hdmidbg("V Bottom:\n\tTotal:%d\n\tDE Start:%d, End: %d, sw_Valid:%d\n\thw_Valid:%d\n", HDMI_RegisterRead(HDMIRX_R_BTM_VT), HDMI_RegisterRead(HDMIRX_R_BTM_VDES), HDMI_RegisterRead(HDMIRX_R_BTM_VDEE), HDMI_RegisterRead(HDMIRX_R_BTM_VDEE) - HDMI_RegisterRead(HDMIRX_R_BTM_VDES), HDMI_RegisterRead(HDMIRX_btn_de_v_width_lock)); hdmidbg("H:\n\tTotal:%d\n\tDE Start:%d, End:%d, sw_valid:%d\n\thw_Valid:%d\n", HDMI_RegisterRead(HDMIRX_R_HT) + 1, HDMI_RegisterRead(HDMIRX_R_HDES) + 1, HDMI_RegisterRead(HDMIRX_R_HDEE) + 1, HDMI_RegisterRead(HDMIRX_R_HDEE) - HDMI_RegisterRead(HDMIRX_R_HDES), HDMI_RegisterRead(HDMIRX_de_h_width_lock)); hdmidbg("Other:\n"); hdmidbg("\tV Sync Polarity:%d\n", HDMI_RegisterRead(HDMIRX_R_Vsync_Polarity)); hdmidbg("\tH Sync Polarity:%d\n", HDMI_RegisterRead(HDMIRX_R_Hsync_Polarity)); hdmidbg("\tInterlace:%d\n", HDMI_RegisterRead(HDMIRX_R_Interlace)); hdmidbg("\tHDMI mode:%d\n", HDMI_RegisterRead(HDMIRX_R_HDMI_en)); hdmidbg("\tpixel repitition:%d\n", HDMI_RegisterRead(HDMIRX_R_PR_EN)); hdmidbg("\tdeep color:%d\n", HDMI_RegisterRead(HDMIRX_dcm)); } #endif static void print_send_to_vip_info(VIP_InterfaceKIC *pstKic) { printk("[H]Print Send to VIP info:\n"); printk("[H]\tID:0x%x HT:%d VT:%d HA:%d VA:%d\n\tHStart:%d HEnd:%d VStart:%d VEnd:%d VHz:%d Inter:%d\n", pstKic->uiTimingIndex, pstKic->uiHtotal, pstKic->uiVtotal, pstKic->uiHactive , pstKic->uiVactive, pstKic->uiHstart, pstKic->uiHend, pstKic->uiVstart, pstKic->uiVend, pstKic->uiVfreq, pstKic->bInterlace); printk("[H]\tdata format:%d range:%d AR:0x%x ITC:%d\n", pstKic->ucDataFormat, pstKic->ucRGBRange, pstKic->ucAspectRatio, pstKic->ucITC); }