i2cm_status = mmio_read_1(HDMI_IH_I2CM_STAT0); mmio_write_1(HDMI_IH_I2CM_STAT0,i2cm_status); unk = mmio_read_1(HDMI_CEC_UNK_7d33); mmio_write_1(HDMI_CEC_UNK_7d33,unk & 0xfe); for (;;) { // check for incoming CEC if (((local_standby_para.event & CPUS_WAKEUP_HDMI_CEC) != 0) && (unk = mmio_read_1(HDMI_CEC_UNK_7d33), unk != 0)) { rx_data2 = (uint)mmio_read_1(HDMI_CEC_RX_DATA[2]); i2cm_status = mmio_read_1(HDMI_IH_I2CM_STAT0); mmio_write_1(HDMI_IH_I2CM_STAT0,i2cm_status); unk = mmio_read_1(HDMI_CEC_UNK_7d33); mmio_write_1(HDMI_CEC_UNK_7d33,unk & 0xfe); if (rx_data2 != CEC_MSG_ACTIVE_SOURCE) { if ((rx_data2 != CEC_IMAGE_TEXT_VIEW_ON) && (rx_data2 != CEC_MSG_TEXT_VIEW_ON)) { if (rx_data2 != CEC_MSG_GIVE_DEVICE_POWER_STATUS) goto try_next_wakeup_source; // Either the register definitions in Linux are backward, or the code here is wrong... dest_index = 0; dest_addr = CEC_LOG_ADDR_PLAYBACK_1; mmio_write_1(HDMI_CEC_ADDR_L,0); mmio_write_1(HDMI_CEC_ADDR_H,BIT(CEC_LOG_ADDR_PLAYBACK_1)); goto report_power_status; } } iVar10 = 0x800; goto do_wake; } try_next_wakeup_source: // others } report_power_status: cec_int = mmio_read_1(HDMI_CEC_INT); attempts = 20; mmio_write_1(HDMI_CEC_INT,cec_int & 0xe0 | 1); mmio_write_1(HDMI_CEC_TX_DATA[3],dest_addr | (dest_addr << 4)); polarity = mmio_read_1(HDMI_CEC_POLARITY); mmio_write_1(HDMI_CEC_POLARITY,polarity & 0xf9 | 2); mmio_write_1(HDMI_CEC_STAT,0); polarity = mmio_read_1(HDMI_CEC_POLARITY); mmio_write_1(HDMI_CEC_POLARITY,polarity | 1); do { mdelay(20); polarity = mmio_read_1(HDMI_CEC_POLARITY); if (((polarity & 1) == 0) && (i2cm_status = mmio_read_1(HDMI_IH_I2CM_STAT0), (i2cm_status & 4) != 0)) { mmio_write_1(HDMI_IH_I2CM_STAT0,4); goto got_an_ack; } attempts = attempts - 1; } while (attempts != 0); dest_index = dest_index + 1; if (dest_index == 1) dest_addr = CEC_LOG_ADDR_PLAYBACK_2; else if (dest_index == 2) dest_addr = CEC_LOG_ADDR_PLAYBACK_3; else if (dest_index == 3) goto got_no_ack; // Either the register definitions in Linux are backward, or the code here is wrong... mmio_write_1(HDMI_CEC_ADDR_H,0); mmio_write_1(HDMI_CEC_ADDR_L,BIT(dest_addr - 8)); goto report_power_status; got_no_ack: dest_addr = CEC_LOG_ADDR_PLAYBACK_1; got_an_ack: attempts = 20; cec_int = mmio_read_1(HDMI_CEC_INT); mmio_write_1(HDMI_CEC_INT,cec_int & 0xe0 | 3); mmio_write_1(HDMI_CEC_TX_DATA[3],dest_addr << 4); mmio_write_1(HDMI_CEC_TX_DATA[2],CEC_MSG_REPORT_POWER_STATUS); mmio_write_1(HDMI_CEC_TX_DATA[1],1); polarity = mmio_read_1(HDMI_CEC_POLARITY); mmio_write_1(HDMI_CEC_POLARITY,polarity & 0xf9 | 2); mmio_write_1(HDMI_CEC_STAT,0); polarity = mmio_read_1(HDMI_CEC_POLARITY); mmio_write_1(HDMI_CEC_POLARITY,polarity & 0xf8 | 1); while( true ) { mdelay(20); polarity = mmio_read_1(HDMI_CEC_POLARITY); if (((polarity & 1) == 0) && (i2cm_status = mmio_read_1(HDMI_IH_I2CM_STAT0), (i2cm_status & 1) != 0)) break; attempts = attempts - 1; if (attempts == 0) { do_wake: /* wakeup process */ } } mmio_write_1(HDMI_IH_I2CM_STAT0,1); goto do_wake;