re-add sleeptime, needed by some devices (thx max!)

This commit is contained in:
TangoCash
2022-12-05 17:17:41 +01:00
committed by Thilo Graf
parent 5cc6f927a4
commit 44768b52fb
2 changed files with 20 additions and 15 deletions

View File

@@ -171,21 +171,26 @@ void hdmi_cec::ReportPhysicalAddress()
SendCECMessage(txmessage); SendCECMessage(txmessage);
} }
void hdmi_cec::SendCECMessage(struct cec_message &txmessage) void hdmi_cec::SendCECMessage(struct cec_message &txmessage, int sleeptime)
{ {
char str[txmessage.length * 6]; if (hdmiFd >= 0)
for (int i = 0; i < txmessage.length; i++)
{ {
sprintf(str + (i * 6), "[0x%02X]", txmessage.data[i]); char str[txmessage.length * 6];
}
struct cec_message_fb message; for (int i = 0; i < txmessage.length; i++)
message.address = txmessage.destination; {
message.length = txmessage.length; sprintf(str + (i * 6), "[0x%02X]", txmessage.data[i]);
memcpy(&message.data, txmessage.data, txmessage.length); }
if (::write(hdmiFd, &message, 2 + message.length) > 0)
struct cec_message_fb message;
message.address = txmessage.destination;
message.length = txmessage.length;
memcpy(&message.data, txmessage.data, txmessage.length);
if (::write(hdmiFd, &message, 2 + message.length) > 0)
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, "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);
usleep(sleeptime * 1000);
}
} }
void hdmi_cec::SetCECAutoStandby(bool state) void hdmi_cec::SetCECAutoStandby(bool state)
@@ -858,12 +863,12 @@ void hdmi_cec::send_key(unsigned char key, unsigned char destination)
txmessage.data[0] = CEC_OPCODE_USER_CONTROL_PRESSED; txmessage.data[0] = CEC_OPCODE_USER_CONTROL_PRESSED;
txmessage.data[1] = key; txmessage.data[1] = key;
txmessage.length = 2; txmessage.length = 2;
SendCECMessage(txmessage); SendCECMessage(txmessage, 1);
txmessage.destination = destination; txmessage.destination = destination;
txmessage.initiator = logicalAddress; txmessage.initiator = logicalAddress;
txmessage.data[0] = CEC_OPCODE_USER_CONTROL_RELEASE; txmessage.data[0] = CEC_OPCODE_USER_CONTROL_RELEASE;
txmessage.length = 1; txmessage.length = 1;
SendCECMessage(txmessage); SendCECMessage(txmessage, 0);
} }
void hdmi_cec::request_audio_status() void hdmi_cec::request_audio_status()
@@ -873,7 +878,7 @@ void hdmi_cec::request_audio_status()
txmessage.initiator = logicalAddress; txmessage.initiator = logicalAddress;
txmessage.data[0] = CEC_OPCODE_GIVE_AUDIO_STATUS; txmessage.data[0] = CEC_OPCODE_GIVE_AUDIO_STATUS;
txmessage.length = 1; txmessage.length = 1;
SendCECMessage(txmessage); SendCECMessage(txmessage, 0);
} }
void hdmi_cec::vol_up() void hdmi_cec::vol_up()

View File

@@ -102,7 +102,7 @@ class hdmi_cec : public OpenThreads::Thread
void SendActiveSource(bool force = false); void SendActiveSource(bool force = false);
void RequestTVPowerStatus(); void RequestTVPowerStatus();
void GetCECAddressInfo(); void GetCECAddressInfo();
void SendCECMessage(struct cec_message &message); void SendCECMessage(struct cec_message &message, int sleeptime = 250);
void SetCECState(bool state); void SetCECState(bool state);
void ReportPhysicalAddress(); void ReportPhysicalAddress();
void Ping(); void Ping();