Skip to content

Commit 0a1bddb

Browse files
authored
hdmi_cec: wake a standby TV with no EDID via fallback init (One Touch Play) (MiSTer-devel#1218)
1 parent f8a198e commit 0a1bddb

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

hdmi_cec.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ static int cec_fd = -1;
200200
static uint8_t cec_logical_addr = CEC_LOG_ADDR_FREEUSE;
201201
static uint16_t cec_physical_addr = CEC_INVALID_PHYS_ADDR;
202202
static uint16_t cec_active_physical_addr = CEC_INVALID_PHYS_ADDR;
203+
static bool cec_addr_is_fallback = false; // inited without EDID to wake a standby TV
203204
static uint16_t cec_pressed_key = 0;
204205
static uint8_t cec_advertise_step = 0;
205206
static uint8_t cec_advertise_attempts = 0;
@@ -1008,6 +1009,7 @@ void cec_deinit(void)
10081009
cec_enabled = false;
10091010
cec_retry_deadline = 0;
10101011
cec_can_try = false;
1012+
cec_addr_is_fallback = false;
10111013
}
10121014

10131015
bool cec_init()
@@ -1057,10 +1059,24 @@ bool cec_init()
10571059
cec_physical_addr = cec_read_physical_address();
10581060
if (cec_physical_addr == CEC_INVALID_PHYS_ADDR)
10591061
{
1060-
return false;
1062+
// no EDID (TV in standby): wake it anyway if power-on is wanted
1063+
if (!cfg.hdmi_cec_power_on)
1064+
{
1065+
printf("CEC: no EDID and power-on disabled; skipping init.\n");
1066+
return false;
1067+
}
1068+
cec_addr_is_fallback = true;
1069+
printf("CEC: no EDID yet; fallback init to wake the TV, will re-init when EDID arrives.\n");
10611070
}
10621071

1063-
cec_program_logical_address(cec_pick_logical_address_from_physical(cec_physical_addr));
1072+
if (cec_addr_is_fallback)
1073+
{
1074+
cec_program_logical_address(CEC_LOG_ADDR_MISTER1);
1075+
}
1076+
else
1077+
{
1078+
cec_program_logical_address(cec_pick_logical_address_from_physical(cec_physical_addr));
1079+
}
10641080

10651081
cec_enabled = true;
10661082

@@ -1072,7 +1088,8 @@ bool cec_init()
10721088
cec_physical_addr & 0x0F);
10731089

10741090
cec_advertise_step = 0;
1075-
cec_advertise_attempts = CEC_ADVERTISE_STARTUP_ATTEMPTS;
1091+
// fallback has no real address: don't advertise one until the post-EDID re-init
1092+
cec_advertise_attempts = cec_addr_is_fallback ? 0 : CEC_ADVERTISE_STARTUP_ATTEMPTS;
10761093
cec_advertise_deadline = 0;
10771094

10781095
cec_power_on_state = CEC_POWER_ON_DONE;
@@ -1123,7 +1140,11 @@ static void cec_poll_power_on_switch(void)
11231140
break;
11241141

11251142
case CEC_POWER_ON_ACTIVE:
1126-
cec_send_active_source(false);
1143+
// fallback has no real address yet: wake only, skip the input switch (re-init handles it)
1144+
if (!cec_addr_is_fallback)
1145+
{
1146+
cec_send_active_source(false);
1147+
}
11271148
cec_power_on_state = CEC_POWER_ON_DONE;
11281149
cec_power_on_deadline = 0;
11291150
break;

0 commit comments

Comments
 (0)