byte ReadIndexedRegister (byte PageNum, byte Offset) { EXIT_ON_CABLE_DISCONNECTION; WriteByteTPI(TPI_INDEXED_PAGE_REG, PageNum); // Indexed page WriteByteTPI(TPI_INDEXED_OFFSET_REG, Offset); // Indexed register return ReadByteTPI(TPI_INDEXED_VALUE_REG); // Return read value }
int MHD_Read_deviceID(void) { byte devID = 0x00; word wID = 0x0000; devID = ReadIndexedRegister(0x00, 0x03); wID = devID; wID <<= 8; devID = ReadIndexedRegister(0x00, 0x02); wID |= devID; devID = ReadByteTPI(TPI_DEVICE_ID); printk ("SiI %04X\n", (int) wID); if (devID == SiI_DEVICE_ID) { return TRUE; } printk ("Unsupported TX\n"); return FALSE; }
void MHD_INT_clear(void) { byte Int_state; Int_state= ReadByteTPI(TPI_INTERRUPT_STATUS_REG); WriteByteTPI (TPI_INTERRUPT_STATUS_REG, Int_state); // Clear this interrupt. }
void ReadModifyWriteTPI(u8 Offset, u8 Mask, u8 Data) { u8 Temp; Temp = ReadByteTPI(Offset); // Read the current value of the register. Temp &= ~Mask; // Clear the bits that are set in Mask. Temp |= (Data & Mask); // OR in new value. Apply Mask to Value for safety. WriteByteTPI(Offset, Temp); // Write new value back to register. }
void ReadModifyWriteTPI(byte Offset, byte Mask, byte Data) { byte Temp; EXIT_ON_CABLE_DISCONNECTION_V; Temp = ReadByteTPI(Offset); // Read the current value of the register. Temp &= ~Mask; // Clear the bits that are set in Mask. Temp |= (Data & Mask); // OR in new value. Apply Mask to Value for safety. WriteByteTPI(Offset, Temp); // Write new value back to register. }
void ReadModifyWriteTPI(byte Offset, byte Mask, byte Data) { byte Temp; Temp = ReadByteTPI(Offset); /* Read the current value of the register.*/ Temp &= ~Mask; /*Clear the bits that are set in Mask.*/ Temp |= (Data & Mask); /*OR in new value. Apply Mask to Value for safety.*/ WriteByteTPI(Offset, Temp); /*Write new value back to register.*/ }
void tpi_clear_pending_event(void) { int retry = 100; while (retry--) { WriteByteTPI(0x3c, 1); WriteByteTPI(0x3d, 1); if (ReadByteTPI(0x3d) & 0x01) DelayMS(1); else break; } if (retry < 19) TPI_DEBUG_PRINT(("%s: retry=%d\n", __func__, 19 - retry)); }
void MHD_INT_clear(void) { byte Int_state; #if 0 Int_state= ReadByteTPI(TPI_INTERRUPT_STATUS_REG); WriteByteTPI (TPI_INTERRUPT_STATUS_REG, Int_state); // Clear this interrupt. WriteByteTPI(TPI_INTERRUPT_ENABLE_REG, 0x00); WriteIndexedRegister(INDEXED_PAGE_0, 0x78, 0x01); // Enable #endif Int_state = ReadIndexedRegister(INDEXED_PAGE_0,0x74); WriteIndexedRegister(INDEXED_PAGE_0,0x74,Int_state); }
static byte ReadIndexedRegister(byte PageNum, byte Offset) { WriteByteTPI(TPI_INDEXED_PAGE_REG, PageNum); /* Indexed page */ WriteByteTPI(TPI_INDEXED_OFFSET_REG, Offset); /* Indexed register */ return ReadByteTPI(TPI_INDEXED_VALUE_REG); /* Return read value */ }
int sil902x_CP_check_status(char InterruptStatusImage) { char reg; unsigned int NewLinkProtectionLevel; #ifdef READKSV char RiCnt; #endif int ret = 0; // 1:auto ok,-1:cp fail // DPRINT("[SIL902X] CP check status 0x%x\n",InterruptStatusImage); // Check if Link Status has changed: if (InterruptStatusImage & 0x20){ DBGMSG("HDCP -> "); reg = ReadByte(0x29); reg &= 0x30; #ifdef SIL902X_CP_POLL_LINK_STATUS WriteByte(0x3D,0x20); // clear SECURITY_CHANGE_EVENT bit #endif switch (reg){ case 0x00: // LINK_STATUS_NORMAL DBGMSG("Link = Normal\n"); break; case 0x10: // LINK_STATUS_LINK_LOST DBGMSG("Link = Lost\n"); sil902x_CP_restart(); ret = -1; break; case 0x20: // LINK_STATUS_RENEGOTIATION_REQ DBGMSG("Link = Renegotiation Required\n"); sil902x_CP_enable(0); sil902x_CP_enable(1); ret = -1; break; case 0x30: // LINK_STATUS_LINK_SUSPENDED DBGMSG("Link = Suspended\n"); sil902x_CP_enable(1); break; } } // Check if CP state has changed: if (InterruptStatusImage & 0x80){ reg = ReadByte(0x29); NewLinkProtectionLevel = reg & (EXTENDED_LINK_PROTECTION_MASK | LOCAL_LINK_PROTECTION_MASK); if (NewLinkProtectionLevel != sil902x_cp_linkProtectionLevel){ DBGMSG("HDCP -> "); sil902x_cp_linkProtectionLevel = NewLinkProtectionLevel; switch (sil902x_cp_linkProtectionLevel){ case (EXTENDED_LINK_PROTECTION_NONE | LOCAL_LINK_PROTECTION_NONE): DBGMSG("Protection = None\n"); sil902x_CP_restart(); ret = -1; break; case LOCAL_LINK_PROTECTION_SECURE: ReadModifyWrite(0x1A,0x8,0x0); DBGMSG("Protection = Local, Video Unmuted\n"); ret = 1; break; case (EXTENDED_LINK_PROTECTION_SECURE | LOCAL_LINK_PROTECTION_SECURE): DBGMSG("Protection = Extended\n"); #ifdef READKSV if (sil902x_CP_IsRepeater()){ RiCnt = ReadIndexedRegister(INDEXED_PAGE_0, 0x25); while (RiCnt > 0x70){ // Frame 112 RiCnt = ReadIndexedRegister(INDEXED_PAGE_0, 0x25); } ReadModifyWriteTPI(TPI_SYSTEM_CONTROL_DATA_REG, 0x06, 0x06); sil902x_CP_get_KSV(); RiCnt = ReadByteTPI(TPI_SYSTEM_CONTROL_DATA_REG); ReadModifyWriteTPI(TPI_SYSTEM_CONTROL_DATA_REG, 0x08, 0x00); } #endif break; default: DBGMSG("Protection = Extended but not Local?\n"); sil902x_CP_restart(); ret = -1; break; } } #ifdef SIL902X_CP_POLL_CP_STATE WriteByte(0x3D,0x80); // clear HDCP_CHANGE_EVENT bit #endif } return ret; }
u8 ReadIndexedRegister (u8 PageNum, u8 Offset) { WriteByteTPI(TPI_INDEXED_PAGE_REG, PageNum); // Indexed page WriteByteTPI(TPI_INDEXED_OFFSET_REG, Offset); // Indexed register return ReadByteTPI(TPI_INDEXED_VALUE_REG); // Return read value }