hv_edid_UpdateEdid.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /**
  2. * @file hv_edid_UpdateEdid.c
  3. * @brief EDID configure of HDMI.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. * (+) .
  10. *
  11. @ endverbatim
  12. *
  13. * @author HiView SoC Software Team
  14. * @version 1.0.0
  15. * @date 2023-12-04
  16. */
  17. #include "hv_edid_UpdateEdid.h"
  18. static Status UpdateEdidHdmi(LinkPortIndex enMwPortIndex , BOOL bVrrEn, BOOL bHdrEn)
  19. {
  20. const InputPortManager* pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
  21. UCHAR8 ucHdmiFormat = 0;
  22. if(LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
  23. {
  24. ucHdmiFormat = HV_COMMON_DATABASE_GET(UserData, ucHdmi0Format);
  25. }
  26. else
  27. {
  28. ucHdmiFormat = HV_COMMON_DATABASE_GET(UserData, ucHdmi1Format);
  29. }
  30. if(bVrrEn)
  31. {
  32. if(UD_HDMI_FORMAT_V_STANDARD == ucHdmiFormat)
  33. {
  34. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_TMDS_VRR : (EDID_TYPE_TMDS_VRR | EDID_TYPE_CLOSE_HDR)));
  35. }
  36. else if(UD_HDMI_FORMAT_V_ENHANCE == ucHdmiFormat)
  37. {
  38. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL_VRR : (EDID_TYPE_FRL_VRR | EDID_TYPE_CLOSE_HDR)));
  39. }
  40. else
  41. {
  42. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL_ENHANCED_VRR : (EDID_TYPE_FRL_ENHANCED_VRR | EDID_TYPE_CLOSE_HDR)));
  43. }
  44. }
  45. else
  46. {
  47. if(UD_HDMI_FORMAT_V_STANDARD == ucHdmiFormat)
  48. {
  49. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_TMDS : (EDID_TYPE_TMDS | EDID_TYPE_CLOSE_HDR)));
  50. }
  51. else if(UD_HDMI_FORMAT_V_ENHANCE == ucHdmiFormat)
  52. {
  53. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL : (EDID_TYPE_FRL | EDID_TYPE_CLOSE_HDR)));
  54. }
  55. else
  56. {
  57. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, bHdrEn ? EDID_TYPE_FRL_ENHANCED : (EDID_TYPE_FRL_ENHANCED | EDID_TYPE_CLOSE_HDR)));
  58. }
  59. }
  60. return HV_SUCCESS;
  61. }
  62. static Status UpdateEdidAll(BOOL bVrrEn, BOOL bHdrEn, LinkPortIndex enMwPortIndex)
  63. {
  64. const InputPortManager* pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
  65. EDIDType enEdidType = (bVrrEn > 0) ? EDID_TYPE_ADAPTIVESYNC : EDID_TYPE_DEFAULT;
  66. enEdidType = (bHdrEn == HV_TRUE) ? enEdidType : (enEdidType | EDID_TYPE_CLOSE_HDR);
  67. BOOL bProEsPort = HV_COMMON_DATABASE_GET(UserData, ucProEsportSwitch);
  68. Status eRet = HV_SUCCESS;
  69. Status eStat = HV_SUCCESS;
  70. if (HV_TRUE == bProEsPort)
  71. {
  72. enEdidType = (bHdrEn == HV_TRUE) ? EDID_TYPE_PRO_ESPORT : (EDID_TYPE_PRO_ESPORT | EDID_TYPE_CLOSE_HDR);
  73. #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
  74. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX0, enEdidType);
  75. if (LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
  76. {
  77. eRet = eStat;
  78. }
  79. #endif
  80. #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
  81. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX1, enEdidType);
  82. if (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex)
  83. {
  84. eRet = eStat;
  85. }
  86. #endif
  87. #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
  88. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enEdidType);
  89. if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
  90. {
  91. eRet = eStat;
  92. }
  93. #endif
  94. #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
  95. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enEdidType);
  96. if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
  97. {
  98. eRet = eStat;
  99. }
  100. #endif
  101. return eRet;
  102. }
  103. #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
  104. eStat = UpdateEdidHdmi(LINK_PORT_INDEX_HDMI_RX0, bVrrEn, bHdrEn);
  105. if (LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
  106. {
  107. eRet = eStat;
  108. }
  109. #endif
  110. #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
  111. eStat = UpdateEdidHdmi(LINK_PORT_INDEX_HDMI_RX1, bVrrEn, bHdrEn);
  112. if (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex)
  113. {
  114. eRet = eStat;
  115. }
  116. #endif
  117. #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
  118. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enEdidType);
  119. if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
  120. {
  121. eRet = eStat;
  122. }
  123. #endif
  124. #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
  125. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enEdidType);
  126. if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
  127. {
  128. eRet = eStat;
  129. }
  130. #endif
  131. return eRet;
  132. }
  133. Status Hw_Mw_Channel_Update_EDID(const ChannelData* pstChannelData, LinkPortIndex enMwPortIndex)
  134. {
  135. const InputPortManager* pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
  136. BOOL bVrrEn = HV_COMMON_DATABASE_GET(UserData, ucFreeSync);
  137. #if (HV_PROJECT_CONFIG_PQ_HDR_CHANGEEDID == HV_CONFIG_ON)
  138. BOOL bHdrEn = HV_COMMON_DATABASE_GET(UserData, enHdrSwitch);
  139. #else
  140. BOOL bHdrEn = HV_TRUE;
  141. #endif
  142. Status eRet = HV_SUCCESS;
  143. Status eStat = HV_SUCCESS;
  144. #if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY))
  145. PxpMode enPxpMode = Hv_Mw_Channel_GetPxpMode();
  146. if (PXP_MODE_CLOSE == enPxpMode)
  147. #endif
  148. {
  149. HV_LOG_DEBUG(CHANNEL, "Update EDID,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
  150. return (UpdateEdidAll(bVrrEn, bHdrEn, enMwPortIndex));
  151. }
  152. #if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY))
  153. else if (PXP_MODE_PIP_ENABLE == enPxpMode)
  154. {
  155. HV_LOG_DEBUG(CHANNEL, "Update EDID,PIP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
  156. if (CHANNEL_TYPE_SUB == pstChannelData->enChannelType)
  157. {
  158. /*除了主通道其他通道全部切为PIP子窗口的EDID*/
  159. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, EDID_TYPE_PIP));
  160. }
  161. else
  162. {
  163. EDIDType enDpEdidType = (bVrrEn > 0) ? (EDID_TYPE_ADAPTIVESYNC | EDID_TYPE_CLOSE_HDR) : (EDID_TYPE_DEFAULT | EDID_TYPE_CLOSE_HDR);
  164. if((LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex) || (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex))
  165. {
  166. return (UpdateEdidHdmi(enMwPortIndex, bVrrEn, HV_FALSE));
  167. }
  168. if((LINK_PORT_INDEX_DP_RX0 == enMwPortIndex) || (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex))
  169. {
  170. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, enDpEdidType));
  171. }
  172. }
  173. }
  174. else if (PXP_MODE_PBP_ENABLE == enPxpMode)
  175. {
  176. HV_LOG_DEBUG(CHANNEL, "Update EDID,PBP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
  177. /*PBP场景暂不支持 PBP VRR EDID;PBP下更新所有通道EDID为PBP*/
  178. #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
  179. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, EDID_TYPE_PBP);
  180. if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
  181. {
  182. eRet = eStat;
  183. }
  184. #endif
  185. #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
  186. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_PBP);
  187. if (LINK_PORT_INDEX_HDMI_RX0 == enMwPortIndex)
  188. {
  189. eRet = eStat;
  190. }
  191. #endif
  192. #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
  193. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, EDID_TYPE_PBP);
  194. if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
  195. {
  196. eRet = eStat;
  197. }
  198. #endif
  199. #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
  200. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_PBP);
  201. if (LINK_PORT_INDEX_HDMI_RX1 == enMwPortIndex)
  202. {
  203. eRet = eStat;
  204. }
  205. #endif
  206. return eRet;
  207. }
  208. else if (PXP_MODE_MAGNIFY_GLASS_ENABLE == enPxpMode)
  209. {
  210. HV_LOG_DEBUG(CHANNEL, "Update EDID,Magnifyglass,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
  211. return (UpdateEdidAll(bVrrEn, bHdrEn, enMwPortIndex));
  212. }
  213. #endif
  214. return HV_SUCCESS;
  215. }
  216. Status Hw_Mw_Channel_ChangeFreesync(ChannelData *pstChannelData)
  217. {
  218. const InputPortManager *pstInputPortManager = Hv_Mw_InputPort_GetManagerPtr();
  219. BOOL bVrrEn = HV_COMMON_DATABASE_GET(UserData, ucFreeSync);
  220. #if (HV_PROJECT_CONFIG_PQ_HDR_CHANGEEDID == HV_CONFIG_ON)
  221. BOOL bHdrEn = HV_COMMON_DATABASE_GET(UserData, enHdrSwitch);
  222. #else
  223. BOOL bHdrEn = HV_TRUE;
  224. #endif
  225. LinkPortIndex enMwPortIndex = pstChannelData->enChannelSrcLinkPortIndex;
  226. PxpMode enPxpMode = Hv_Mw_Channel_GetPxpMode();
  227. EDIDType enDpEdidType = (bVrrEn == HV_TRUE) ? EDID_TYPE_ADAPTIVESYNC : EDID_TYPE_DEFAULT;
  228. enDpEdidType = (bHdrEn == HV_TRUE) ? enDpEdidType : (enDpEdidType | EDID_TYPE_CLOSE_HDR);
  229. Status eRet = HV_SUCCESS;
  230. Status eStat = HV_SUCCESS;
  231. // hdmi直接拉hpd,通知source询问sink
  232. #if (HV_BOARD_CONFIG_HDMI_0 == PORT_VALID)
  233. Hv_Mw_InputPort_ToggleHpd(LINK_PORT_INDEX_HDMI_RX0);
  234. #endif
  235. #if (HV_BOARD_CONFIG_HDMI_1 == PORT_VALID)
  236. Hv_Mw_InputPort_ToggleHpd(LINK_PORT_INDEX_HDMI_RX1);
  237. #endif
  238. #if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY))
  239. if (PXP_MODE_CLOSE == enPxpMode)
  240. {
  241. #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
  242. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enDpEdidType);
  243. if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
  244. {
  245. eRet = eStat;
  246. }
  247. #endif
  248. #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
  249. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enDpEdidType);
  250. if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
  251. {
  252. eRet = eStat;
  253. }
  254. #endif
  255. return eRet;
  256. }
  257. else if (PXP_MODE_PIP_ENABLE == enPxpMode)
  258. {
  259. HV_LOG_DEBUG(CHANNEL, "Update EDID,PIP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
  260. if (enMwPortIndex == LINK_PORT_INDEX_HDMI_RX0 || enMwPortIndex == LINK_PORT_INDEX_HDMI_RX1)
  261. {
  262. // hdmi已经拉了hpd,此处不处理
  263. return HV_SUCCESS;
  264. }
  265. if (CHANNEL_TYPE_SUB == pstChannelData->enChannelType)
  266. {
  267. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, EDID_TYPE_PIP));
  268. }
  269. else
  270. {
  271. EDIDType enDpEdidType = (bVrrEn > 0) ? (EDID_TYPE_ADAPTIVESYNC | EDID_TYPE_CLOSE_HDR) : (EDID_TYPE_DEFAULT | EDID_TYPE_CLOSE_HDR);
  272. if ((LINK_PORT_INDEX_DP_RX0 == enMwPortIndex) || (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex))
  273. {
  274. return (pstInputPortManager->pfUpdateEdid(enMwPortIndex, enDpEdidType));
  275. }
  276. }
  277. }
  278. else if (PXP_MODE_PBP_ENABLE == enPxpMode)
  279. {
  280. HV_LOG_DEBUG(CHANNEL, "Update EDID,PBP,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
  281. #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
  282. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, EDID_TYPE_PBP);
  283. if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
  284. {
  285. eRet = eStat;
  286. }
  287. #endif
  288. #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
  289. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, EDID_TYPE_PBP);
  290. if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
  291. {
  292. eRet = eStat;
  293. }
  294. #endif
  295. return eRet;
  296. }
  297. else
  298. {
  299. HV_LOG_DEBUG(CHANNEL, "Update EDID,Magnifyglass,Vrr %u,Channel %u", bVrrEn, pstChannelData->enChannelType);
  300. #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
  301. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enDpEdidType);
  302. if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
  303. {
  304. eRet = eStat;
  305. }
  306. #endif
  307. #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
  308. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enDpEdidType);
  309. if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
  310. {
  311. eRet = eStat;
  312. }
  313. #endif
  314. return eRet;
  315. }
  316. #else
  317. #if (HV_BOARD_CONFIG_DISPLAYPORT_0 == PORT_VALID)
  318. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX0, enDpEdidType);
  319. if (LINK_PORT_INDEX_DP_RX0 == enMwPortIndex)
  320. {
  321. eRet = eStat;
  322. }
  323. #endif
  324. #if (HV_BOARD_CONFIG_DISPLAYPORT_1 == PORT_VALID)
  325. eStat = pstInputPortManager->pfUpdateEdid(LINK_PORT_INDEX_DP_RX1, enDpEdidType);
  326. if (LINK_PORT_INDEX_DP_RX1 == enMwPortIndex)
  327. {
  328. eRet = eStat;
  329. }
  330. #endif
  331. return eRet;
  332. #endif
  333. return HV_SUCCESS;
  334. }