int api_Configure(videoParams_t * video, audioParams_t * audio, productParams_t * product, hdcpParams_t * hdcp) { hdmivsdb_t vsdb; // int audioOn = 0; //lltang audio on int audioOn = 1; int success = TRUE; int hdcpOn = (hdcp != 0 && (control_SupportsHdcp(api_mBaseAddress) == TRUE)) ? TRUE : FALSE; LOG_TRACE(); if (video == NULL) { error_Set(ERR_HPD_LOST); LOG_ERROR("video params invalid"); return FALSE; } audioOn = (audio != 0 && videoParams_GetHdmi(video)); if (api_mCurrentState < API_HPD) { error_Set(ERR_HPD_LOST); LOG_ERROR("cable not connected"); return FALSE; } else if (api_mCurrentState == API_HPD) { printk("E-EDID not read. Media may not be supported by sink\n"); } else if (api_mCurrentState == API_EDID_READ) { api_CheckParamsVideo(video); if (api_EdidHdmivsdb(&vsdb)) { if (!hdmivsdb_GetDeepColor30(&vsdb) && !hdmivsdb_GetDeepColor36(&vsdb) && !hdmivsdb_GetDeepColor48(&vsdb)) { videoParams_SetColorResolution(video, 0); } } } control_InterruptMute(api_mBaseAddress, ~0); /* disable interrupts */ #ifdef CONFIG_HMDI_JZ4780_DEBUG printk("=====>disable TX_INT in %s:%d\n", __func__, __LINE__); #endif system_InterruptDisable(TX_INT); do { if (video_Configure(api_mBaseAddress, video, api_mDataEnablePolarity, hdcpOn) != TRUE) { success = FALSE; break; } if (audioOn) { if (api_mCurrentState == API_EDID_READ) { api_CheckParamsAudio(audio); } #if 0 //del by lltang if (board_AudioClock(api_mBaseAddress, audioParams_AudioClock(audio)) != TRUE) { success = FALSE; break; } #endif if (audio_Configure(api_mBaseAddress, audio, videoParams_GetPixelClock( video), videoParams_GetRatioClock(video)) != TRUE) { success = FALSE; break; } packets_AudioInfoFrame(api_mBaseAddress, audio); } else if (audio != 0 && videoParams_GetHdmi(video) != TRUE) { printk("DVI mode selected: audio not configured\n"); } else { printk("No audio parameters provided: not configured\n"); } if (videoParams_GetHdmi(video) == TRUE) { if (packets_Configure(api_mBaseAddress, video, product) != TRUE) { success = FALSE; break; } api_mSendGamutOk = (videoParams_GetEncodingOut(video) == YCC444) || (videoParams_GetEncodingOut(video) == YCC422); api_mSendGamutOk = api_mSendGamutOk && (videoParams_GetColorimetry( video) == EXTENDED_COLORIMETRY); } else { printk("DVI mode selected: packets not configured\n"); } if (hdcpOn == TRUE) { /* HDCP is PHY independent */ if (hdcp_Configure(api_mBaseAddress, hdcp, videoParams_GetHdmi(video), dtd_GetHSyncPolarity(videoParams_GetDtd(video)), dtd_GetVSyncPolarity(videoParams_GetDtd(video))) == FALSE) { printk("HDCP not configured\n"); hdcpOn = FALSE; success = FALSE; break; } } else if (hdcp != 0 && control_SupportsHdcp(api_mBaseAddress) != TRUE) { printk("HDCP is not supported by hardware\n"); } else { printk("No HDCP parameters provided: not configured\n"); } if (board_PixelClock(api_mBaseAddress, videoParams_GetPixelClock(video), videoParams_GetColorResolution(video)) != TRUE) { success = FALSE; break; } if (control_Configure(api_mBaseAddress, videoParams_GetPixelClock(video), videoParams_GetPixelRepetitionFactor(video), videoParams_GetColorResolution(video), videoParams_IsColorSpaceConversion(video), audioOn, FALSE, hdcpOn) != TRUE) { success = FALSE; break; } if (phy_Configure(api_mBaseAddress, videoParams_GetPixelClock(video), videoParams_GetColorResolution(video), videoParams_GetPixelRepetitionFactor(video)) != TRUE) { success = FALSE; break; } /* disable blue screen transmission after turning on all necessary blocks (e.g. HDCP) */ if (video_ForceOutput(api_mBaseAddress, FALSE) != TRUE) { success = FALSE; break; } /* reports HPD state to HDCP */ if (hdcpOn) { hdcp_RxDetected(api_mBaseAddress, phy_HotPlugDetected( api_mBaseAddress)); } /* send AVMUTE CLEAR (optional) */ api_mCurrentState = API_CONFIGURED; } while(0); control_InterruptMute(api_mBaseAddress, 0); /* enable interrupts */ #ifdef CONFIG_HMDI_JZ4780_DEBUG printk("hdmi enable TX_INT in %s:%d\n", __func__, __LINE__); #endif system_InterruptEnable(TX_INT); return success; }
int api_Initialize(u16 address, u8 dataEnablePolarity, u16 sfrClock, u8 force) //cmd:auto argument: 0, 1, 2500, 0 { dtd_t dtd; videoParams_t params; dataEnablePolarity = 1; api_mDataEnablePolarity = dataEnablePolarity; api_mHpd = FALSE; api_mSendGamutOk = FALSE; //????????????????? api_mSfrClock = sfrClock; // sfrClock,that are required for setting the low time of the SCL clock in each speed mode LOG_NOTICE("dwc_hdmi_tx_software_api_2.12"); LOG_NOTICE(__DATE__); LOG_TRACE1(dataEnablePolarity); /* reset error */ error_Set(NO_ERROR); api_mBaseAddress = address; if (!api_mutex_inited) { mutex_Initialize(&api_mMutex); api_mutex_inited = 1; } control_InterruptMute(api_mBaseAddress, ~0); /* disable all interrupts */ if ((api_mCurrentState < API_HPD) || (api_mCurrentState > API_EDID_READ)) { /* if EDID read do not re-read, if HPDetected, keep in same state * otherwise, NOT INIT */ api_mCurrentState = API_NOT_INIT; } /* VGA must be supported by all sinks * so use it as default configuration */ dtd_Fill(&dtd, 4, 60000); videoParams_Reset(¶ms); videoParams_SetHdmi(¶ms, TRUE); videoParams_SetDtd(¶ms, &dtd); /* params->mDtd = dtd; */ pixelClock = videoParams_GetPixelClock(¶ms); /* dtd_GetPixelClock(&(params->mDtd)); */ /* reset HAPS51 DEMO BOARD, by default mask all interrupts */ if (board_Initialize(api_mBaseAddress, pixelClock, 8) != TRUE) { return FALSE; } /* get Product Identification Register 0 */ LOG_NOTICE2("Product Line", control_ProductLine(api_mBaseAddress)); /* get Product Identification Register 1*/ LOG_NOTICE2("Product Type", control_ProductType(api_mBaseAddress)); /* if ((ProductLine == 0xA0) && ((ProductType == 0x01 || ProductType == 0xC1))) */ if (control_SupportsCore(api_mBaseAddress) != TRUE) { error_Set(ERR_HW_NOT_SUPPORTED); LOG_ERROR("Unknown device: aborting..."); return FALSE; } /* get Design Identification Register */ LOG_NOTICE2("HDMI TX Controller Design", control_Design(api_mBaseAddress)); /* get Revision Identification Register */ LOG_NOTICE2("HDMI TX Controller Revision", control_Revision(api_mBaseAddress)); /* if(ProductLine == 0xA0 && ProductType == 0xC1)*/ if (control_SupportsHdcp(api_mBaseAddress) == TRUE) { LOG_NOTICE("HDMI TX controller supports HDCP"); } /* print api_mDataEnablePolarity value ,always return TRUE */ if (video_Initialize(api_mBaseAddress, ¶ms, api_mDataEnablePolarity) != TRUE) { return FALSE; } if (audio_Initialize(api_mBaseAddress) != TRUE) { return FALSE; } if (packets_Initialize(api_mBaseAddress) != TRUE) { return FALSE; } if (hdcp_Initialize(api_mBaseAddress, api_mDataEnablePolarity) != TRUE) { return FALSE; } /* clock gate == 1 => turn off all modules */ if (control_Initialize(api_mBaseAddress, api_mDataEnablePolarity, pixelClock) != TRUE) { return FALSE; } #ifdef CONFIG_HMDI_JZ4780_DEBUG printk("jz4780 hdmi %s %d phy init\n",__func__,__LINE__); #endif control_InterruptClearAll(api_mBaseAddress); if (board_PixelClock(api_mBaseAddress, pixelClock, videoParams_GetColorResolution(¶ms))!= TRUE) { return FALSE; } #ifdef CONFIG_HMDI_JZ4780_DEBUG printk("jz4780 hdmi %s %d video configured\n",__func__,__LINE_); #endif if (video_Configure(api_mBaseAddress, ¶ms, api_mDataEnablePolarity, FALSE) != TRUE) { return FALSE; } if ((api_mCurrentState < API_HPD) || (api_mCurrentState > API_EDID_READ)) { /* if EDID read do not re-read, if HPDetected, keep in same state * otherwise, set to INIT */ api_mCurrentState = API_INIT; } /* * By default no pixel repetition and color resolution is 8 */ #ifdef CONFIG_HMDI_JZ4780_DEBUG printk("jz4780 hdmi %s %d control configured\n",__func__,__LINE_); #endif if (control_Configure(api_mBaseAddress, pixelClock, 0, 8, 0, 0, 0, 0) != TRUE) { return FALSE; } /* send AVMUTE SET (optional) */ #ifdef CONFIG_HMDI_JZ4780_DEBUG printk("jz4780 hdmi %s %d phy configured\n",__func__,__LINE_); #endif #if 0 /* enable interrupts */ access_CoreWriteByte(0x0, 0x10D2); access_CoreWriteByte(0x0, 0x10D6); access_CoreWriteByte(0x0, 0x10DA); access_CoreWriteByte(0x0, 0x0180); #endif #if 0 access_CoreWriteByte(~0x4, 0x10D2); //audio packets access_CoreWriteByte(0x0, 0x0180); //intc mute #endif api_phy_enable(PHY_ENABLE_HPD); control_InterruptMute(api_mBaseAddress, 0); if (system_InterruptHandlerRegister(TX_INT, api_EventHandler, NULL) == TRUE) { printk("=====>enable TX_INT in %s:%d\n", __func__, __LINE__); //return system_InterruptEnable(TX_INT); return TRUE; } return FALSE; }
static int hdmi_config(struct jzhdmi *jzhdmi) { u8 currentMode = 0; hdmivsdb_t vsdb; shortVideoDesc_t tmp_svd; dtd_t tmp_dtd; u8 ceaCode = 0; u8 errorCode = NO_ERROR; u8 svdNo=0; /* needed to make sure it doesn't change while in this function*/ struct device *dev = jzhdmi->dev; videoParams_t *pVideo = jzhdmi->hdmi_params.pVideo; audioParams_t *pAudio = jzhdmi->hdmi_params.pAudio; hdcpParams_t *pHdcp = jzhdmi->hdmi_params.pHdcp; productParams_t *pProduct = jzhdmi->hdmi_params.pProduct; svdNo = api_EdidSvdCount(); if ((api_EdidHdmivsdb(&vsdb) == TRUE) && (jzhdmi->edid_faild == 0)) { dev_info(dev, "==========>HDMI mode\n"); videoParams_SetHdmi(pVideo, TRUE); /* TODO: if (hdmivsdb_GetDeepColor48(&vsdb)) { videoParams_SetColorResolution(pVideo, 16); } else if (hdmivsdb_GetDeepColor36(&vsdb)) { videoParams_SetColorResolution(pVideo, 12); } else if (hdmivsdb_GetDeepColor30(&vsdb)) { videoParams_SetColorResolution(pVideo, 10); } else { videoParams_SetColorResolution(pVideo, 0); } */ videoParams_SetColorResolution(pVideo, 0); if (currentMode >= svdNo) { currentMode = 0; } #ifdef HDMI_JZ4780_DEBUG dev_info(jzhdmi->dev, "=====> cur==%d svno=%d\n",currentMode,svdNo); #endif for (; currentMode < svdNo; currentMode++) { if (api_EdidSvd(currentMode, &tmp_svd)) { ceaCode = shortVideoDesc_GetCode(&tmp_svd); if (ceaCode != jzhdmi->hdmi_info.out_type) continue; if (board_SupportedRefreshRate(ceaCode) != -1) { dtd_Fill(&tmp_dtd, ceaCode, board_SupportedRefreshRate(ceaCode)); videoParams_SetDtd(pVideo, &tmp_dtd); } else { dev_err(dev, "CEA mode not supported\n"); continue; } } if (api_Configure(pVideo, pAudio, pProduct, pHdcp)) { dev_info(dev, "----api_Configure ok\n"); break; } dev_err(dev, "error: VM = %d\n", ceaCode); errorCode = error_Get(); if (errorCode == ERR_HDCP_FAIL) { system_SleepMs(1000); currentMode--; } } if (currentMode >= svdNo) { /* spanned all SVDs and non works, sending VGA */ dev_err(dev, "error spanned all SVDs and non works\n"); dtd_Fill(&tmp_dtd, 1, board_SupportedRefreshRate(1)); videoParams_SetDtd(pVideo, &tmp_dtd); api_Configure(pVideo, pAudio, pProduct, pHdcp); } /* lltang add test overflow */ if(0){ /* ====>tmds reset */ access_CoreWrite(1, 0x4002, 1, 1); /* ====>video_Configure again */ if (video_Configure(0, pVideo, 1, FALSE) != TRUE) { return FALSE; } access_CoreWriteByte(0x0, 0x10DA); } } else { dev_info(dev, "Force into hdmi mode!\n"); #ifndef DVIMODE videoParams_SetHdmi(pVideo, TRUE); videoParams_SetColorResolution(pVideo, 0); if (currentMode >= svdNo) { currentMode = 0; } #ifdef HDMI_JZ4780_DEBUG dev_info(jzhdmi->dev, "=====>out_type=%d\n",jzhdmi->hdmi_info.out_type); #endif ceaCode = jzhdmi->hdmi_info.out_type; if (board_SupportedRefreshRate(ceaCode) != -1) { dtd_Fill(&tmp_dtd, ceaCode, board_SupportedRefreshRate(ceaCode)); videoParams_SetDtd(pVideo, &tmp_dtd); } else { dev_err(dev, "CEA mode not supported\n"); } if (api_Configure(pVideo, pAudio, pProduct, pHdcp)) { dev_info(dev, "api_Configure ok\n"); } } #else dev_info(dev, "====DVI mode!\n"); videoParams_SetHdmi(pVideo, FALSE); videoParams_SetColorResolution(pVideo, 0); if (currentMode >= api_EdidDtdCount()) { currentMode = 0; } for (; currentMode < api_EdidDtdCount(); currentMode++) { continue; if (api_EdidDtd(currentMode, &tmp_dtd)) { ceaCode = cliEdid_GetDtdCode(&tmp_dtd); dev_info(dev, "check ceaCode = %d\n", ceaCode); if (ceaCode != 3) continue; dev_info(dev, "find ceaCode = %d\n", ceaCode); dtd_Fill(&tmp_dtd, ceaCode, board_SupportedRefreshRate(ceaCode)); videoParams_SetDtd(pVideo, &tmp_dtd); } if (api_Configure(pVideo, pAudio, pProduct, pHdcp)) { break; } errorCode = error_Get(); dev_err(dev, "API configure fail\n"); if (errorCode == ERR_HDCP_FAIL) { system_SleepMs(1000); currentMode--; } } if (currentMode >= api_EdidDtdCount()) { dev_err(dev, "spanned all dtds and non works, sending VGA\n"); dtd_Fill(&tmp_dtd, 1, board_SupportedRefreshRate(1)); videoParams_SetDtd(pVideo, &tmp_dtd); api_Configure(pVideo, pAudio, pProduct, pHdcp); } }