SYS_STATUS RxHDCPGetBstatus(USHORT *pBstatus) { if(!pBstatus) { return ER_FAIL ; } HDMIRX_WriteI2C_Byte(REG_RX_BLOCK_SEL,1); *pBstatus=HDMIRX_ReadI2C_Byte(REG_RX_BSTATUSH); *pBstatus <<= 8 ; *pBstatus |= HDMIRX_ReadI2C_Byte(REG_RX_BSTATUSL); HDMIRX_WriteI2C_Byte(REG_RX_BLOCK_SEL,0); HDMIRX_DEBUG_PRINTF(("RxHDCPGetBstatus\n")); return ER_SUCCESS; }
SYS_STATUS HDMIRX_ReadI2C_ByteN(BYTE RegAddr, BYTE *pData, int N) { int i; for(i=0;i<N;i++){ *(pData+i) = HDMIRX_ReadI2C_Byte(RegAddr+i); } return 0; }
SYS_STATUS RxHDCPGetM0() { BYTE i=0; if(cDownStream > HDMIRX_MAX_KSV) { return ER_FAIL ; } HDMIRX_WriteI2C_Byte(REG_RX_BLOCK_SEL,1); for(;i<8;i++) { SHABuff[cDownStream*5+2+i]=HDMIRX_ReadI2C_Byte(REG_RX_M0_B0+i); HDMIRX_DEBUG_PRINTF3(("M[%d] = %02X\n",i,(int)SHABuff[cDownStream*5+2+i])); } HDMIRX_WriteI2C_Byte(REG_RX_BLOCK_SEL,0); HDMIRX_DEBUG_PRINTF(("RxHDCPGetM0\n")); return ER_SUCCESS; }
void RxHDCPRepeaterCapabilityClear(BYTE uc) { HDMIRX_WriteI2C_Byte(REG_RX_CDEPTH_CTRL,HDMIRX_ReadI2C_Byte(REG_RX_CDEPTH_CTRL)&(~uc)); HDMIRX_DEBUG_PRINTF(("RxHDCPRepeaterCapabilityClear=%2X\n",(int)uc)); }
static int hdmi_task_handle(void *data) { static BOOL bSignal ; BOOL bOldSignal, bChangeMode ; int dump_count = 0 ; int stable_count = 0; MCU_init() ; printk("\n%s\n" , VERSION_STRING); while(1){ HoldSystem(); hdmirx_clear_hpd(); #ifdef _COPY_EDID_ CopyDefaultEDID() ; #endif InitHDMIRX(TRUE); hdmirx_set_hpd(); xCntCnt = 0 ; xCntSum = 0 ; while(hdmirx_device.it660x_enable){ while(hdmirx_device.task_pause){ msleep(10); } if(ReadRXIntPin()) { Check_HDMInterrupt(); } //if(IsTimeOut(20)){ dump_count ++ ; bOldSignal = bSignal ; bSignal = CheckHDMIRX(); bChangeMode = (bSignal != bOldSignal); if(bChangeMode) { // if Changed Mode ... if(bSignal) { stable_count = 0; update_status(0); // if signal is TRUE , then ... dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } bChangeMode = FALSE ; // clear bChange Mode action } else { // if not change mode, ... if(bSignal) { if(stable_count<stable_threshold){ stable_count++; if(stable_count == stable_threshold){ start_vdin(getHDMIRXHorzActive(), getHDMIRXVertActive(), 10000, IsHDMIRXInterlace()); } } update_status(0); // if signal is TRUE , then ... if( (dump_count % 20) == 1 ) { xCntCnt ++ ; xCntSum += getHDMIRXxCnt() ; if( xCntCnt > 40 ) { xCntCnt /= 2 ; xCntSum /= 2 ; } } } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } } if( dump_count > (DUMP_TIME*1000/20) ) { dump_count = 0 ; if( bSignal ) { dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { printk("Reg10 = %02X\nReg12 = %02X\nReg64 = %02X\nReg65 = %02X\n" ,(int)HDMIRX_ReadI2C_Byte(0x10) ,(int)HDMIRX_ReadI2C_Byte(0x12) ,(int)HDMIRX_ReadI2C_Byte(0x64) ,(int)HDMIRX_ReadI2C_Byte(0x65) ) ; } printk("\n\n") ; DumpHDMIRXReg(); } //}// if(IsTimeOut(20)) msleep(10); } PowerDownHDMI(); } return 0; }
static ssize_t store_dbg(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) { char tmpbuf[128]; int i=0; unsigned int adr; unsigned int value=0; while((buf[i])&&(buf[i]!=',')&&(buf[i]!=' ')){ tmpbuf[i]=buf[i]; i++; } tmpbuf[i]=0; if(strncmp(tmpbuf, "config_dvin", 11)==0){ #ifdef DEBUG_DVIN config_dvin (hs_pol_inv, vs_pol_inv, de_pol_inv, field_pol_inv, ext_field_sel, de_mode, data_comp_map, mode_422to444, dvin_clk_inv, vs_hs_tim_ctrl, hs_lead_vs_odd_min, hs_lead_vs_odd_max, active_start_pix_fe, active_start_pix_fo, active_start_line_fe, active_start_line_fo, line_width, field_height); #endif } else if(strncmp(tmpbuf, "pause", 5)==0){ hdmirx_device.task_pause = 1; printk("Pause %s\n", __func__); } else if(strncmp(tmpbuf, "start", 5)==0){ hdmirx_device.task_pause = 0; printk("Start %s\n", __func__); } else if(strncmp(tmpbuf, "spdif", 5)==0){ setHDMIRX_SPDIFOutput(); } else if(strncmp(tmpbuf, "i2s", 3)==0){ setHDMIRX_I2SOutput(0x1); } else if(strncmp(tmpbuf, "hpd", 3)==0){ if(tmpbuf[3]=='0'){ CLEAR_HPD; } else if(tmpbuf[3]=='1'){ SET_HPD; } } else if(tmpbuf[0]=='w'){ adr=simple_strtoul(tmpbuf+2, NULL, 16); value=simple_strtoul(buf+i+1, NULL, 16); if(buf[1]=='h'){ HDMIRX_WriteI2C_Byte(adr, value); } else if(buf[1]=='c'){ WRITE_MPEG_REG(adr, value); pr_info("write %x to CBUS reg[%x]\n",value,adr); } else if(buf[1]=='p'){ WRITE_APB_REG(adr, value); pr_info("write %x to APB reg[%x]\n",value,adr); } } else if(tmpbuf[0]=='r'){ adr=simple_strtoul(tmpbuf+2, NULL, 16); if(buf[1]=='h'){ value = HDMIRX_ReadI2C_Byte(adr); pr_info("HDMI reg[%x]=%x\n", adr, value); } else if(buf[1]=='c'){ value = READ_MPEG_REG(adr); pr_info("CBUS reg[%x]=%x\n", adr, value); } else if(buf[1]=='p'){ value = READ_APB_REG(adr); pr_info("APB reg[%x]=%x\n", adr, value); } } return 16; }
static int hdmi_task_handle(void *data) { int repeater = 0; int stable_count = 0; static BOOL bSignal ; BOOL bOldSignal, bChangeMode ; int i; int dump_count = 0 ; MCU_init() ; printk("\n%s\n" , VERSION_STRING); while(1){ HoldSystem(); hdmirx_clear_hpd(); #ifdef _COPY_EDID_ CopyDefaultEDID() ; #endif repeater=repeater_enable ; #if 0 GetCurrentHDMIPort(); SelectHDMIPort(CAT_HDMI_PORTA); #endif // InitHDMIRX(FALSE); if( repeater ) { DownStreamCount = 3 ; RxHDCPSetRepeater(); } else { RxHDCPSetReceiver(); } hdmirx_set_hpd(); while(hdmirx_device.it660x_enable){ while(hdmirx_device.task_pause){ msleep(10); } //HoldSystem(); if(ReadRXIntPin()) { Check_HDMInterrupt(); } //if(IsTimeOut(20)) //{ dump_count ++ ; bOldSignal = bSignal ; bSignal = CheckHDMIRX(); bChangeMode = (bSignal != bOldSignal); if(bChangeMode) { // if Changed Mode ... if(bSignal) { stable_count = 0; update_status(0); // if signal is TRUE , then ... dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } bChangeMode = FALSE ; // clear bChange Mode action } else { // if not change mode, ... if(bSignal) { if(stable_count<stable_threshold){ stable_count++; if(stable_count == stable_threshold){ start_vdin(getHDMIRXHorzActive(), getHDMIRXVertActive(), 10000, IsHDMIRXInterlace()); } } update_status(0); // if signal is TRUE , then ... if( (dump_count % 20) == 1 ) { xCntCnt ++ ; xCntSum += getHDMIRXxCnt() ; if( xCntCnt > 40 ) { xCntCnt /= 2 ; xCntSum /= 2 ; } } } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } } if( dump_count > (DUMP_TIME*1000/20) ) { dump_count = 0 ; if( bSignal ) { dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { printk("Reg10 = %02X\nReg12 = %02X\nReg64 = %02X\nReg65 = %02X\n" ,(int)HDMIRX_ReadI2C_Byte(0x10) ,(int)HDMIRX_ReadI2C_Byte(0x12) ,(int)HDMIRX_ReadI2C_Byte(0x64) ,(int)HDMIRX_ReadI2C_Byte(0x65) ) ; } printk("\n\n"); DumpHDMIRXReg(); } if( (dump_count % (1000/20)) == 0) { if( repeater!=repeater_enable ) { repeater=repeater_enable ; hdmirx_clear_hpd(); if( repeater ) { if( DownStreamCount == 0 ) { DownStreamCount = 5 ; } else { DownStreamCount -- ; } printk("Set Repeater Mode, DownStream = %d\n",DownStreamCount) ; RxHDCPSetRepeater(); } else { RxHDCPSetReceiver(); } hdmirx_set_hpd(); } } if( repeater ) { if(IsRxAuthStart()) { DelayCounter = 0 ; } if(IsRxAuthDone()) { DelayCounter = DownStreamCount*2+1 ; } if(DelayCounter > 0) { DelayCounter -- ; if(DelayCounter == 0) { for(i = 0 ; i < 5*DownStreamCount ; i++) { KSVList[i] = SampleKSVList[i] ; } setRxHDCPKSVList(0,KSVList,DownStreamCount); if( DownStreamCount > 0 ) { bStatus=DownStreamCount|0x0100 ; } else { bStatus=0; } setRxHDCPBStatus(bStatus); setRxHDCPCalcSHA(); } } } //}// if(IsTimeOut(20)) msleep(10); } PowerDownHDMI(); } return 0; }
int main(void) { static BOOL bSignal ; BOOL bOldSignal, bChangeMode ; int dump_count = 0 ; hdmirx_clear_hpd(); EnableHDMIRXVideoOutput(VIDEO_AUTO) ; SelectHDMIPort(CAT_HDMI_PORTA); InitHDMIRX(TRUE); hdmirx_set_hpd(); xCntCnt = 0 ; xCntSum = 0 ; while(1){ HoldSystem(); if(ReadRXIntPin()) { Check_HDMInterrupt(); } #if 0 // for switching to port B hdmirx_clear_hpd(); EnableHDMIRXVideoOutput(VIDEO_AUTO) ; SelectHDMIPort(CAT_HDMI_PORTB); hdmirx_set_hpd(); #endif if(IsTimeOut(LOOP_MSEC)) { dump_count ++ ; bOldSignal = bSignal ; bSignal = CheckHDMIRX(); bChangeMode = (bSignal != bOldSignal); if(bChangeMode) { // if Changed Mode ... if(bSignal) { // if signal is TRUE , then ... dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } bChangeMode = FALSE ; // clear bChange Mode action } else { // if not change mode, ... if(bSignal) { // if signal is TRUE , then ... if( (dump_count % 20) == 1 ) { xCntCnt ++ ; xCntSum += getHDMIRXxCnt() ; if( xCntCnt > 40 ) { xCntCnt /= 2 ; xCntSum /= 2 ; } } } else { // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } } if( dump_count > (DUMP_TIME*1000/20) ) { dump_count = 0 ; if( bSignal ) { dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { printf("There is no signal: Reg10 = %02X Reg12 = %02X Reg64 = %02X Reg65 = %02X\n" ,(int)HDMIRX_ReadI2C_Byte(0x10) ,(int)HDMIRX_ReadI2C_Byte(0x12) ,(int)HDMIRX_ReadI2C_Byte(0x64) ,(int)HDMIRX_ReadI2C_Byte(0x65) ) ; } printf("\n\n") ; DumpHDMIRXReg(); } }// if(IsTimeOut(20)) } return 0; }