diff --git a/src/driver/hdmi_cec.cpp b/src/driver/hdmi_cec.cpp index 0b8d12041..8ec787135 100644 --- a/src/driver/hdmi_cec.cpp +++ b/src/driver/hdmi_cec.cpp @@ -104,7 +104,7 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE cecOnOff) { physicalAddress[0] = 0x10; physicalAddress[1] = 0x00; - logicalAddress = 1; + logicalAddress = 0xFF; if (cecOnOff == VIDEO_HDMI_CEC_MODE_OFF) { @@ -156,6 +156,8 @@ void hdmi_cec::GetCECAddressInfo() memcpy(physicalAddress, addressinfo.physical, sizeof(physicalAddress)); ReportPhysicalAddress(); } + if (logicalAddress != 0xFF) + Ping(); } } } @@ -184,7 +186,7 @@ void hdmi_cec::SendCECMessage(struct cec_message &txmessage, int sleeptime) sprintf(str + (i * 6), "[0x%02X]", txmessage.data[i]); } - cecprintf(YELLOW, "send message %s to %s (0x%02X>>0x%02X) '%s' (%s)", ToString((cec_logical_address)txmessage.initiator), txmessage.destination == 0xf ? "all" : ToString((cec_logical_address)txmessage.destination), txmessage.initiator, txmessage.destination, ToString((cec_opcode)txmessage.data[0]), str); + cecprintf(YELLOW, "queue message to %s (0x%02X) '%s' (%s)", txmessage.destination == 0xf ? "all" : ToString((cec_logical_address)txmessage.destination), txmessage.destination, ToString((cec_opcode)txmessage.data[0]), str); struct cec_message_fb message; message.address = txmessage.destination; message.length = txmessage.length; @@ -193,12 +195,15 @@ void hdmi_cec::SendCECMessage(struct cec_message &txmessage, int sleeptime) msg_que.push_back(message); mutex.unlock(); - if (hdmiFd >= 0) + if (hdmiFd >= 0 && running && logicalAddress != 0xFF) { mutex.lock(); for (std::vector::iterator it = msg_que.begin(); it != msg_que.end(); ++it) + { + cecprintf(YELLOW, "send message %s to %s (0x%02X>>0x%02X) '%s' (%s)", ToString((cec_logical_address)logicalAddress), (*it).address == 0xf ? "all" : ToString((cec_logical_address)(*it).address), logicalAddress, (*it).address, ToString((cec_opcode)(*it).data[0]), str); ::write(hdmiFd, &(*it), 2 + (*it).length); + } msg_que.clear(); mutex.unlock(); @@ -305,6 +310,16 @@ void hdmi_cec::RequestTVPowerStatus() SendCECMessage(message); } +void hdmi_cec::Ping() +{ + struct cec_message pingmessage; + pingmessage.initiator = logicalAddress; + pingmessage.destination = CECDEVICE_TV; + pingmessage.data[0] = CEC_OPCODE_NONE; + pingmessage.length = 1; + SendCECMessage(pingmessage); +} + long hdmi_cec::translateKey(unsigned char code) { long key = 0; @@ -523,6 +538,8 @@ void hdmi_cec::run() std::array events; cecprintf(GREEN, "thread started..."); + Ping(); + while (running) { n = epoll_wait(epollfd, events.data(), EPOLL_MAX_EVENTS, EPOLL_WAIT_TIMEOUT); diff --git a/src/driver/hdmi_cec.h b/src/driver/hdmi_cec.h index 0e35b4981..5642c4fa9 100644 --- a/src/driver/hdmi_cec.h +++ b/src/driver/hdmi_cec.h @@ -110,6 +110,7 @@ class hdmi_cec : public OpenThreads::Thread void SendCECMessage(struct cec_message &message, int sleeptime = 250); void SetCECState(bool state); void ReportPhysicalAddress(); + void Ping(); bool standby_cec_activ; void vol_up(); void vol_down();