123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- /**
- * @file hv_edid_UpdateEdid.c
- * @brief EDID configure of HDMI.
- *
- * @verbatim
- * ==============================================================================
- * ##### How to use #####
- * ==============================================================================
- * (+) .
- *
- @ endverbatim
- *
- * @author HiView SoC Software Team
- * @version 1.0.0
- * @date 2023-12-04
- */
- #include "hv_edid_UpdateEdid.h"
- static Status UpdateEdidHdmi(LinkPortIndex enMwPortIndex , BOOL bVrrEn, BOOL bHdrEn)
- {
- const InputPortManager* pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
- UCHAR8 ucHdmiFormat = 0;
- if(LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
- {
- ucHdmiFormat = HV_COMMON_DATABASE_GET(UserData, ucHdmi0Format);
- }
- else
- {
- ucHdmiFormat = HV_COMMON_DATABASE_GET(UserData, ucHdmi1Format);
- }
- if(bVrrEn)
- {
- if(UD_HDMI_FORMAT_V_STANDARD == ucHdmiFormat)
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_TMDS_VRR : (EDID_TYPE_TMDS_VRR | EDID_TYPE_CLOSE_HDR)));
- }
- else if(UD_HDMI_FORMAT_V_ENHANCE == ucHdmiFormat)
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL_VRR : (EDID_TYPE_FRL_VRR | EDID_TYPE_CLOSE_HDR)));
- }
- else
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL_ENHANCED_VRR : (EDID_TYPE_FRL_ENHANCED_VRR | EDID_TYPE_CLOSE_HDR)));
- }
- }
- else
- {
- if(UD_HDMI_FORMAT_V_STANDARD == ucHdmiFormat)
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_TMDS : (EDID_TYPE_TMDS | EDID_TYPE_CLOSE_HDR)));
- }
- else if(UD_HDMI_FORMAT_V_ENHANCE == ucHdmiFormat)
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL : (EDID_TYPE_FRL | EDID_TYPE_CLOSE_HDR)));
- }
- else
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL_ENHANCED : (EDID_TYPE_FRL_ENHANCED | EDID_TYPE_CLOSE_HDR)));
- }
- }
- return HV_SUCCESS;
- }
- static Status UpdateEdidAll(BOOL bVrrEn, BOOL bHdrEn, LinkPortIndex enMwPortIndex)
- {
- const InputPortManager* pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
- EDIDType enEdidType = (bVrrEn > 0) ? EDID_TYPE_ADAPTIVESYNC : EDID_TYPE_DEFAULT;
- enEdidType = (bHdrEn == HV_TRUE) ? enEdidType : (enEdidType | EDID_TYPE_CLOSE_HDR);
- BOOL bProEsPort = HV_COMMON_DATABASE_GET(UserData, ucProEsportSwitch);
- Status eRet = HV_SUCCESS;
- Status eStat = HV_SUCCESS;
- if (HV_TRUE == bProEsPort)
- {
- enEdidType = (bHdrEn == HV_TRUE) ? EDID_TYPE_PRO_ESPORT : (EDID_TYPE_PRO_ESPORT | EDID_TYPE_CLOSE_HDR);
- #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX0, enEdidType);
- if (LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX1, enEdidType);
- if (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enEdidType);
- if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enEdidType);
- if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- return eRet;
- }
- #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
- eStat = UpdateEdidHdmi(LINK_PORT_INDEX_HDMI_RX0, bVrrEn, bHdrEn);
- if (LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
- eStat = UpdateEdidHdmi(LINK_PORT_INDEX_HDMI_RX1, bVrrEn, bHdrEn);
- if (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enEdidType);
- if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enEdidType);
- if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- return eRet;
- }
- Status Hw_Mw_Channel_Update_EDID(const ChannelData* pstChannelData, LinkPortIndex enMwPortIndex)
- {
- const InputPortManager* pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
- BOOL bVrrEn = HV_COMMON_DATABASE_GET(UserData, ucFreeSync);
- #if (HV_PROJECT_CONFIG_PQ_HDR_CHANGEEDID == HV_CONFIG_ON)
- BOOL bHdrEn = HV_COMMON_DATABASE_GET(UserData, enHdrSwitch);
- #else
- BOOL bHdrEn = HV_TRUE;
- #endif
- Status eRet = HV_SUCCESS;
- Status eStat = HV_SUCCESS;
- #if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY))
- PxpMode enPxpMode = Hv_Mw_Channel_GetPxpMode();
- if (PXP_MODE_CLOSE == enPxpMode)
- #endif
- {
- HV_LOG_DEBUG(CHANNEL, "Update EDID,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
- return (UpdateEdidAll(bVrrEn, bHdrEn, enMwPortIndex));
- }
- #if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY))
- else if (PXP_MODE_PIP_ENABLE == enPxpMode)
- {
- HV_LOG_DEBUG(CHANNEL, "Update EDID,PIP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
- if (CHANNEL_TYPE_SUB == pstChannelData->enChannelType)
- {
- /*除了主通道其他通道全部切为PIP子窗口的EDID*/
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, EDID_TYPE_PIP));
- }
- else
- {
- EDIDType enDpEdidType = (bVrrEn > 0) ? (EDID_TYPE_ADAPTIVESYNC | EDID_TYPE_CLOSE_HDR) : (EDID_TYPE_DEFAULT | EDID_TYPE_CLOSE_HDR);
- if((LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex) || (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex))
- {
- return (UpdateEdidHdmi(enMwPortIndex, bVrrEn, HV_FALSE));
- }
- if((LINK_PORT_INDEX_DP_RX0 == enMwPortIndex) || (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex))
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, enDpEdidType));
- }
- }
- }
- else if (PXP_MODE_PBP_ENABLE == enPxpMode)
- {
- HV_LOG_DEBUG(CHANNEL, "Update EDID,PBP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
- /*PBP场景暂不支持 PBP VRR EDID;PBP下更新所有通道EDID为PBP*/
- #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, EDID_TYPE_PBP);
- if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_PBP);
- if (LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, EDID_TYPE_PBP);
- if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_PBP);
- if (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- return eRet;
- }
- else if (PXP_MODE_MAGNIFY_GLASS_ENABLE == enPxpMode)
- {
- HV_LOG_DEBUG(CHANNEL, "Update EDID,Magnifyglass,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
- return (UpdateEdidAll(bVrrEn, bHdrEn, enMwPortIndex));
- }
- #endif
- return HV_SUCCESS;
- }
- Status Hw_Mw_Channel_ChangeFreesync(ChannelData *pstChannelData)
- {
- const InputPortManager *pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
- BOOL bVrrEn = HV_COMMON_DATABASE_GET(UserData, ucFreeSync);
- #if (HV_PROJECT_CONFIG_PQ_HDR_CHANGEEDID == HV_CONFIG_ON)
- BOOL bHdrEn = HV_COMMON_DATABASE_GET(UserData, enHdrSwitch);
- #else
- BOOL bHdrEn = HV_TRUE;
- #endif
- LinkPortIndex enMwPortIndex = pstChannelData->enChannelSrcLinkPortIndex;
- PxpMode enPxpMode = Hv_Mw_Channel_GetPxpMode();
- EDIDType enDpEdidType = (bVrrEn == HV_TRUE) ? EDID_TYPE_ADAPTIVESYNC : EDID_TYPE_DEFAULT;
- enDpEdidType = (bHdrEn == HV_TRUE) ? enDpEdidType : (enDpEdidType | EDID_TYPE_CLOSE_HDR);
- Status eRet = HV_SUCCESS;
- Status eStat = HV_SUCCESS;
- // hdmi直接拉hpd,通知source询问sink
- #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
- Hv_Mw_InputPort_ToggleHpd(LINK_PORT_INDEX_HDMI_RX0);
- #endif
- #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
- Hv_Mw_InputPort_ToggleHpd(LINK_PORT_INDEX_HDMI_RX1);
- #endif
- #if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY))
- if (PXP_MODE_CLOSE == enPxpMode)
- {
- #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enDpEdidType);
- if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enDpEdidType);
- if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- return eRet;
- }
- else if (PXP_MODE_PIP_ENABLE == enPxpMode)
- {
- HV_LOG_DEBUG(CHANNEL, "Update EDID,PIP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
- if (enMwPortIndex == LINK_PORT_INDEX_HDMI_RX0 || enMwPortIndex == LINK_PORT_INDEX_HDMI_RX1)
- {
- // hdmi已经拉了hpd,此处不处理
- return HV_SUCCESS;
- }
- if (CHANNEL_TYPE_SUB == pstChannelData->enChannelType)
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, EDID_TYPE_PIP));
- }
- else
- {
- EDIDType enDpEdidType = (bVrrEn > 0) ? (EDID_TYPE_ADAPTIVESYNC | EDID_TYPE_CLOSE_HDR) : (EDID_TYPE_DEFAULT | EDID_TYPE_CLOSE_HDR);
- if ((LINK_PORT_INDEX_DP_RX0 == enMwPortIndex) || (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex))
- {
- return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, enDpEdidType));
- }
- }
- }
- else if (PXP_MODE_PBP_ENABLE == enPxpMode)
- {
- HV_LOG_DEBUG(CHANNEL, "Update EDID,PBP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
- #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, EDID_TYPE_PBP);
- if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, EDID_TYPE_PBP);
- if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- return eRet;
- }
- else
- {
- HV_LOG_DEBUG(CHANNEL, "Update EDID,Magnifyglass,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
- #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enDpEdidType);
- if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enDpEdidType);
- if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- return eRet;
- }
- #else
- #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enDpEdidType);
- if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
- eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enDpEdidType);
- if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
- {
- eRet = eStat;
- }
- #endif
- return eRet;
- #endif
- return HV_SUCCESS;
- }
|