fix hdmi cec from deep standby and logical address is not ready yet

Origin commit data
------------------
Branch: ni/coolstream
Commit: 005392335e
Author: TangoCash <eric@loxat.de>
Date: 2022-11-25 (Fri, 25 Nov 2022)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2022-11-25 21:19:02 +01:00
committed by vanhofen
parent 6459035fcd
commit d00aa6d47f
2 changed files with 21 additions and 3 deletions

View File

@@ -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<cec_message_fb>::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<struct epoll_event, EPOLL_MAX_EVENTS> events;
cecprintf(GREEN, "thread started...");
Ping();
while (running)
{
n = epoll_wait(epollfd, events.data(), EPOLL_MAX_EVENTS, EPOLL_WAIT_TIMEOUT);

View File

@@ -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();