void vcheckhdmiplugstate(void) { u32 bMask; MT8193_PLUG_FUNC(); bMask = bReadHdmiIntMask(); vWriteHdmiIntMask((bMask&0xfe)); if(bCheckPordHotPlug(PORD_MODE|HOTPLUG_MODE)==FALSE) { { if((i4SharedInfo(SI_HDMI_RECEIVER_STATUS)== HDMI_PLUG_IN_AND_SINK_POWER_ON)||(i4SharedInfo(SI_HDMI_RECEIVER_STATUS)== HDMI_PLUG_IN_ONLY)) { bMask = bReadHdmiIntMask(); vWriteHdmiIntMask((bMask|0xfE)); vHDCPReset(); vTxSignalOnOff(0); vSetSharedInfo(SI_HDMI_RECEIVER_STATUS, HDMI_PLUG_OUT); vSetHDMICtrlState(HDMI_STATE_HOT_PLUG_OUT); } else { MT8193_PLUG_LOG("plug out, no action\n"); } } } else { if((i4SharedInfo(SI_HDMI_RECEIVER_STATUS)== HDMI_PLUG_OUT)||(i4SharedInfo(SI_HDMI_RECEIVER_STATUS)== HDMI_PLUG_IN_ONLY)) { vSetSharedInfo(SI_HDMI_RECEIVER_STATUS, HDMI_PLUG_IN_AND_SINK_POWER_ON); vSetHDMICtrlState(HDMI_STATE_HOT_PLUGIN_AND_POWER_ON); } else { MT8193_PLUG_LOG("plug in ok, no action\n"); } } }
void vHwNCTSOnOff(u8 bHwNctsOn) { u8 bData; MT8193_AUDIO_FUNC(); if(i4SharedInfo(SI_EDID_VSDB_EXIST) == FALSE) return; bData=bReadByteHdmiGRL(GRL_CTS_CTRL); if(bHwNctsOn == TRUE) bData &= ~CTS_CTRL_SOFT; else bData |= CTS_CTRL_SOFT; vWriteByteHdmiGRL(GRL_CTS_CTRL, bData); }
void vHDMIResetGenReg(u8 ui1resindex, u8 ui1colorspace) { MT8193_DRV_FUNC(); vResetHDMI(1); vHDMIVideoOutput(ui1resindex, ui1colorspace); vResetHDMI(0); vEnableNotice(TRUE); vWriteHdmiIntMask(0xff); vSetHDMIDataEnable(ui1resindex); vSetHDMISyncDelay(ui1resindex); if (i4SharedInfo(SI_EDID_VSDB_EXIST) == TRUE) vEnableHdmiMode(TRUE); else vEnableHdmiMode(FALSE); vEnableNCTSAutoWrite(); vHDMISettingColorSpace(ui1colorspace); }
void HdcpService(HDCP_CTRL_STATE_T e_hdcp_state) { u8 bIndx, bTemp; u8 bMask; MT8193_HDCP_FUNC(); if (_bHdcpOff == 1) { vSetHDCPState(HDCP_RECEIVER_NOT_READY); vHDMIAVUnMute(); vWriteHdmiIntMask(0xff); } switch (e_hdcp_state) { case HDCP_RECEIVER_NOT_READY: MT8193_HDCP_LOG("HDCP_RECEIVER_NOT_READY\n"); break; case HDCP_READ_EDID: break; case HDCP_WAIT_RES_CHG_OK: MT8193_HDCP_LOG("HDCP_WAIT_RES_CHG_OK\n"); _bReAUTHCount = 0; if (fgIsHDCPCtrlTimeOut()) { if (_bHdcpOff == 1) /* disable HDCP */ { vSetHDCPState(HDCP_RECEIVER_NOT_READY); vHDMIAVUnMute(); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } else { vSetHDCPState(HDCP_RE_DO_AUTHENTICATION); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } } break; case HDCP_INIT_AUTHENTICATION: MT8193_HDCP_LOG("HDCP_INIT_AUTHENTICATION\n"); _bReAUTHCount++; vHDMIAVMute(); vSetSharedInfo(SI_HDMI_HDCP_RESULT, 0); if (!fgDDCDataRead(RX_ID, RX_REG_BCAPS, 1, &bTemp)) { vSetHDCPTimeOut(HDCP_WAIT_300MS_TIMEOUT); break; } vMiAnUpdateOrFix(TRUE); if (fgHostKey()) { for (bIndx = 0; bIndx < HDCP_AKSV_COUNT; bIndx++) { HDMI_AKSV[bIndx] = bHdcpKeyBuff[1 + bIndx]; } if ((_bReAUTHCount > 2) || ((HDMI_AKSV[0] == 0) && (HDMI_AKSV[1] == 0) && (HDMI_AKSV[2] == 0) && (HDMI_AKSV[3] == 0))) { vSetHDCPState(HDCP_RECEIVER_NOT_READY); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); _bReAUTHCount = 0; return; } } else { vReadAksvFromReg(&HDMI_AKSV[0]); } if ((bhdcpkey == INTERNAL_ENCRYPT_KEY) || (bhdcpkey == EXTERNAL_KEY)) vWriteAksvKeyMask(&HDMI_AKSV[0]); vEnableAuthHardware(); fgDDCDataRead(RX_ID, RX_REG_BCAPS, 1, &bTemp); vSetSharedInfo(SI_REPEATER_DEVICE_COUNT, 0); if (bTemp & RX_BIT_ADDR_RPTR) { _fgRepeater = TRUE; } else { _fgRepeater = FALSE; } if (fgIsRepeater()) { vRepeaterOnOff(TRUE); } else { vRepeaterOnOff(FALSE); } vSendAn(); vExchangeKSVs(); if (fgHostKey()) { vSendAKey(&bHdcpKeyBuff[6]); /* around 190msec */ vSetHDCPTimeOut(HDCP_WAIT_R0_TIMEOUT); } else { vSetHDCPTimeOut(HDCP_WAIT_R0_TIMEOUT); /* 100 ms */ } /* change state as waiting R0 */ vSetHDCPState(HDCP_WAIT_R0); break; case HDCP_WAIT_R0: MT8193_HDCP_LOG("HDCP_WAIT_R0\n"); bTemp = bCheckHDCPStatus(HDCP_STA_RI_RDY); if (bTemp == TRUE) { vSetHDCPState(HDCP_COMPARE_R0); } else { vSetHDCPState(HDCP_RE_DO_AUTHENTICATION); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); break; } case HDCP_COMPARE_R0: MT8193_HDCP_LOG("HDCP_COMPARE_R0\n"); if (fgCompareRi() == TRUE) { vMiAnUpdateOrFix(FALSE); vEnableEncrpt(); /* Enabe encrption */ vSetCTL0BeZero(TRUE); /* change state as check repeater */ vSetHDCPState(HDCP_CHECK_REPEATER); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); vSetSharedInfo(SI_HDMI_HDCP_RESULT, 0x01); /* step 1 OK. */ } else { vSetHDCPState(HDCP_RE_COMPARE_R0); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); _bReCompRiCount = 0; } break; case HDCP_RE_COMPARE_R0: MT8193_HDCP_LOG("HDCP_RE_COMPARE_R0\n"); _bReCompRiCount++; if (fgIsHDCPCtrlTimeOut() && _bReCompRiCount > 3) { vSetHDCPState(HDCP_RE_DO_AUTHENTICATION); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); _bReCompRiCount = 0; } else { if (fgCompareRi() == TRUE) { vMiAnUpdateOrFix(FALSE); vEnableEncrpt(); /* Enabe encrption */ vSetCTL0BeZero(TRUE); /* change state as check repeater */ vSetHDCPState(HDCP_CHECK_REPEATER); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); vSetSharedInfo(SI_HDMI_HDCP_RESULT, 0x01); /* step 1 OK. */ } else { vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } } break; case HDCP_CHECK_REPEATER: MT8193_HDCP_LOG("HDCP_CHECK_REPEATER\n"); /* if the device is a Repeater, */ if (fgIsRepeater()) { _bReCheckReadyBit = 0; vSetHDCPState(HDCP_WAIT_KSV_LIST); vSetHDCPTimeOut(HDCP_WAIT_KSV_LIST_TIMEOUT); } else { vSetHDCPState(HDCP_WAIT_RI); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } break; case HDCP_WAIT_KSV_LIST: MT8193_HDCP_LOG("HDCP_WAIT_KSV_LIST\n"); fgDDCDataRead(RX_ID, RX_REG_BCAPS, 1, &bTemp); if ((bTemp & RX_BIT_ADDR_READY)) { _bReCheckReadyBit = 0; vSetHDCPState(HDCP_READ_KSV_LIST); } else if (_bReCheckReadyBit > HDCP_CHECK_KSV_LIST_RDY_RETRY_COUNT) { vSetHDCPState(HDCP_RE_DO_AUTHENTICATION); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); _bReCheckReadyBit = 0; break; } else { _bReCheckReadyBit++; vSetHDCPState(HDCP_WAIT_KSV_LIST); vSetHDCPTimeOut(HDCP_WAIT_KSV_LIST_RETRY_TIMEOUT); break; } case HDCP_READ_KSV_LIST: MT8193_HDCP_LOG("HDCP_READ_KSV_LIST\n"); vReadKSVFIFO(); break; case HDCP_COMPARE_V: MT8193_HDCP_LOG("HDCP_COMPARE_V\n"); bTemp = bReadHDCPStatus(); if ((bTemp & HDCP_STA_V_MATCH) || (bTemp & HDCP_STA_V_RDY)) { if ((bTemp & HDCP_STA_V_MATCH)) /* for Simplay #7-20-5 */ { vSetHDCPState(HDCP_WAIT_RI); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); vSetSharedInfo(SI_HDMI_HDCP_RESULT, (i4SharedInfo(SI_HDMI_HDCP_RESULT) | 0x02)); /* step 2 OK. */ } else { vSetHDCPState(HDCP_RE_DO_AUTHENTICATION); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } } break; case HDCP_WAIT_RI: MT8193_HDCP_LOG("HDCP_WAIT_RI\n"); vHDMIAVUnMute(); bMask = bReadHdmiIntMask(); vWriteHdmiIntMask(0xfd); break; case HDCP_CHECK_LINK_INTEGRITY: MT8193_HDCP_LOG("HDCP_CHECK_LINK_INTEGRITY\n"); if (fgCompareRi() == TRUE) { vSetSharedInfo(SI_HDMI_HDCP_RESULT, (i4SharedInfo(SI_HDMI_HDCP_RESULT) | 0x04)); /* step 3 OK. */ if (fgIsRepeater()) { if (i4SharedInfo(SI_HDMI_HDCP_RESULT) == 0x07) /* step 1, 2, 3. */ { vSetSharedInfo(SI_HDMI_HDCP_RESULT, (i4SharedInfo(SI_HDMI_HDCP_RESULT) | 0x08)); /* all ok. */ } } else /* not repeater, don't need step 2. */ { if (i4SharedInfo(SI_HDMI_HDCP_RESULT) == 0x05) /* step 1, 3. */ { vSetSharedInfo(SI_HDMI_HDCP_RESULT, (i4SharedInfo(SI_HDMI_HDCP_RESULT) | 0x08)); /* all ok. */ } } } else { bMask = bReadHdmiIntMask(); vWriteHdmiIntMask(0xff); /* disable INT HDCP */ _bReCompRiCount = 0; vSetHDCPState(HDCP_RE_COMPARE_RI); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } break; case HDCP_RE_COMPARE_RI: MT8193_HDCP_LOG("HDCP_RE_COMPARE_RI\n"); _bReCompRiCount++; if (_bReCompRiCount > 5) { vSetHDCPState(HDCP_RE_DO_AUTHENTICATION); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); _bReCompRiCount = 0; } else { if (fgCompareRi() == TRUE) { _bReCompRiCount = 0; vSetHDCPState(HDCP_CHECK_LINK_INTEGRITY); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); vSetSharedInfo(SI_HDMI_HDCP_RESULT, (i4SharedInfo(SI_HDMI_HDCP_RESULT) | 0x04)); /* step 3 OK. */ if (fgIsRepeater()) { if (i4SharedInfo(SI_HDMI_HDCP_RESULT) == 0x07) /* step 1, 2, 3. */ { vSetSharedInfo(SI_HDMI_HDCP_RESULT, (i4SharedInfo(SI_HDMI_HDCP_RESULT) | 0x08)); /* all ok. */ } } else { if (i4SharedInfo(SI_HDMI_HDCP_RESULT) == 0x05) /* step 1, 3. */ { vSetSharedInfo(SI_HDMI_HDCP_RESULT, (i4SharedInfo(SI_HDMI_HDCP_RESULT) | 0x08)); /* all ok. */ } } bMask = bReadHdmiIntMask(); vWriteHdmiIntMask(0xfd); } else { vSetHDCPState(HDCP_RE_COMPARE_RI); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } } break; case HDCP_RE_DO_AUTHENTICATION: MT8193_HDCP_LOG("HDCP_RE_DO_AUTHENTICATION\n"); vHDMIAVMute(); vHDCPReset(); if (i4SharedInfo(SI_HDMI_RECEIVER_STATUS) != HDMI_PLUG_IN_AND_SINK_POWER_ON) { vSetHDCPState(HDCP_RECEIVER_NOT_READY); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } else { vSetHDCPState(HDCP_WAIT_RESET_OK); vSetHDCPTimeOut(HDCP_WAIT_RE_DO_AUTHENTICATION); } break; case HDCP_WAIT_RESET_OK: MT8193_HDCP_LOG("HDCP_WAIT_RESET_OK\n"); if (fgIsHDCPCtrlTimeOut()) { vSetHDCPState(HDCP_INIT_AUTHENTICATION); vSendHdmiCmd(HDMI_HDCP_PROTOCAL_CMD); } break; default: break; } }