Hacker News new | ask | show | jobs
by derefr 30 days ago
> have it boot to HDMI1, hook up an external HDMI-CEC switch

That's not actually how HDMI-CEC works. HDMI-CEC switches aren't KVM switches that only do HDMI.

An HDMI-CEC switcher box (or devices with that functionality built into them, like many soundbars) doesn't act as its own isolated sub-HDMI-CEC bus, where the switch presents to its downstreams as the root HDMI-CEC device, catching (without bubbling) <Active Source> messages from said downstreams, selecting one downstream to be active in an internal sense, and then presenting itself to its upstream connected TV or what-have-you as if it's one leaf-node source whose video+audio signals just-so-happen to be those of the currently-selected downstream.

Rather, at an HDMI-CEC level, an HDMI switch is a lot more like a USB switch: it passes through all the CEC message broadcasts from all of its downstream source devices through to its upstream receiver device (and vice-versa), sometimes also interpreting them in turn for effect; and the root host device can actually see the whole tree topology, including any switches.

(Fun fact: HDMI-CEC devices have four-step hierarchical addresses, that look like IP addresses, describing at each step the physical socket-number offset on the upstream device that connects said upstream to the given downstream. The TV is always 0.0.0.0. Whatever's plugged into the TV's first HDMI socket is 1.0.0.0. If that thing is an HDMI switcher box, then whatever's plugged into its first downstream HDMI socket is 1.1.0.0. And so on. All of these devices can see and talk to one another using these addresses, at all times. It's a network!)

Importantly, this means that if a TV is plugged into an HDMI switcher box, which in turn has several source devices plugged into it, then the TV will still be aware of, and can still hear and speak to, all the inactive sources downstream of the switcher box, not just the active one.

Which in turn means that if your TV is really stupid in the way it handles HDMI-CEC (e.g. trying to "argue" with sources about who's supposed to be active on wake, with the TV trying to force the last-active source and the source that woke the TV trying to force itself as the active source), then putting an HDMI-CEC switcher box in between will by no means improve things. They'll still be arguing, now "through" the switcher box; and the switcher box will itself be doing additional things in response to seeing these messages. Where previously you had O(N) HDMI-CEC problems, now you'll have O(N log N) HDMI-CEC problems.

But hey, at least your leaf-node sources in this tree all show up in the TV's input switcher menu! That was definitely worth making all this mess, HDMI Forum! :P

1 comments

I've never really dug into it but this does explain a lot of the strange and flakey behavior that I've seen with switches purporting to offer HDMI-CEC support. All I really want is auto-input switching and being able to control the volume through the device.

It doesn't seem like it should be so hard, but it has broken and fixed itself so many times that I really don't know what I should be looking for.

I think HDMI-CEC is just fundamentally broken (at least in all versions of the spec up to now.) I've played around with hypothetical workarounds, and I suspect so have many device manufacturers, and it seems like there's just no way to "stabilize" an HDMI-CEC network into behaving correctly while there's at least one bad actor on it, if you can't directly modify the firmware of that bad-actor device. You can't do it from a peer device; you can't do it from a "man in the middle" like a switch; and you can't even do it from the TV.

Why? Because the HDMI-CEC bus protocol, as it stands today, has no separation of responsibilities/phases between "request" and "response" messages, or between "command" and "event" messages.

Imagine how you or any other reasonable person would design HDMI-CEC. There'd be one "leader" device (probably the TV) whose opinion on the current active source / signal-path is canonical for the whole bus. Other devices would send command messages to this leader device to get it to change the active source. The leader could ACK or NACK these command messages. If the leader accepts the change, the leader would broadcast an event message declaring to the bus what the new canonical active source is. And if a device misses that message, it could also query the leader device to find out the active source.

But that's not how any of this works. Instead, at any time, any device on the bus can just outright say "I'm the active source now." And every other device on the bus that receives this packet, must then update their own internal HDMI-CEC state-machines to consider that device to be active. If something (the TV, say) disagrees with this assertion, it can't just ignore the packet, because everything else on the bus won't have ignored it. So even if the TV had logic telling it to stay on source 1.0.0.0 rather than switching to 3.1.0.0, the soundbar (3.0.0.0) connected to said TV might have switched from playing the eARC audio stream from the TV to playing audio directly from its downstream 3.1.0.0. And 1.0.0.0 might have gone to sleep in response to seeing the message that 3.1.0.0 is now active. Etc.

The only legal thing a device that wants to "prevent another device from making itself the active source" can do, under HDMI-CEC, is to steal focus right back to itself (or, if it's a TV, assign focus right back to the source it remembers.) Which means everything on a bus sees the active source flapping back and forth.

Which is where all the stupid "your TV takes 30 seconds to turn on because it's flapping between three inputs" stuff comes from.