Skip to content

Sony Bravia: User Control "Power" (0x40) on source select suspends an already-on device #744

Open

Description

@DesertRec

Claude has helped me find a solution/workaround.

libCEC 8.1.6 (client version 4.0.0, firmware 5)
Adapter: Amlogic AOCEC
CoreELEC nightly 20260810 (clean install), Kodi 22
Ugoos AM9 Pro (S905X5) → miniDSP Tide16 (HDMI switch/processor) → Sony A90J
Device type: playback device. Physical address auto-detected correctly as 3.1.0.0

Description

Selecting the Kodi box's input on the TV causes the box to suspend instead of activate.

The Sony sends User Control Pressed: Power (0x40) — a toggle — followed ~275 ms later by User Control Pressed: Power On (0x6D). The toggle reaches Kodi as key 196, which the default keymap binds to ShutDown(), and the box begins suspending before the explicit power-on arrives.

Log — default keymap (box suspends)

16:32:33.104  >> 04:44:40
16:32:33.104  >> TV (0) -> Playback 1 (4): user control pressed (44)
16:32:33.105  SetCurrentButton power (40) D:0ms
16:32:33.105  key pressed: power (40) current(ff) duration(0)
16:32:33.105  PushCecKeypress - received key c4 duration 0
16:32:33.105  << Playback 1 (4) -> broadcast (F): inactive source
16:32:33.112  HandleKey: 196 (0xc4, obc59) pressed, window 10004, action is ShutDown()
16:32:33.138  LogindUPowerSyscall: Received PrepareForSleep with arg 1
16:32:33.138  OnSleep: Running sleep jobs
16:32:33.282  >> TV (0) -> Playback 1 (4): user control release (45)
16:32:33.379  >> 04:44:6d
16:32:33.379  >> TV (0) -> Playback 1 (4): user control pressed (44)
16:32:33.379  SetCurrentButton power on (6d) D:0ms
16:32:33.379  making Playback 1 (4) the active source
16:32:33.443  << Playback 1 (4) -> broadcast (F): active source (3100)
16:32:33.455  failed to make 'Playback 1' the active source. will retry later

Workaround — suppressing key 196 resolves it completely

/storage/.kodi/userdata/keymaps/cec-power.xml:

<keymap>
  <global>
    <universalremote>
      <obc59>Noop</obc59>
    </universalremote>
    <remote>
      <power>Noop</power>
    </remote>
  </global>
</keymap>

Log — with keymap (box activates correctly)

16:54:36.637  Changed key power (40) D:0ms cur:ff
16:54:36.637  PushCecKeypress - received key c4 duration 0
16:54:36.637  << Playback 1 (4) -> broadcast (F): inactive source
16:54:36.647  HandleKey: 196 (0xc4, obc59) pressed, window 10000, action is Noop
16:54:36.815  >> TV (0) -> Playback 1 (4): user control release (45)
16:54:36.912  >> 04:44:6d
16:54:36.912  >> TV (0) -> Playback 1 (4): user control pressed (44)
16:54:36.912  SetCurrentButton power on (6d) D:0ms
16:54:36.912  making Playback 1 (4) the active source
16:54:36.912  marking TV (0) as inactive source
16:54:36.912  >> source activated: Playback 1 (4)
16:54:36.976  << Playback 1 (4) -> broadcast (F): active source (3100)

Zero OnSleep events across repeated switching after the change.

Note

In both logs, libCEC broadcasts inactive source the moment 0x40 arrives — before Kodi has dispatched anything. So the toggle is being given power-off semantics internally regardless of current power state. The keymap only suppresses the consequence, not the interpretation. A power toggle arriving at a device that is already on arguably shouldn't be treated as off — the user has just asked to watch that device.

This behaviour started after 8.1.1 (the button-press timing change). Offered as correlation only — I haven't tested a pre-8.1.1 build to confirm.

Unrelated question, same version window: the peripheral settings filename changed from cec_CEC_Adapter.xml to cec__dev_aocec.xml. Is this the name going forward?

Activity

  1. spin-lock commented on Aug 12, 2026

    @spin-lock

    Can confirm the same issue with similar setup.
    After I switched out to a different input and switched back to CoreELEC device —which still on—it goes to sleep.

    CoreELEC 20260810 (Ugoos SK1) -> Denon X3800H AVR -> Sony Bravia K-85XR70

  2. opdenkamp commented on Sep 2, 2026

    @opdenkamp
    Contributor

    Thanks for the analysis and the two logs — they pin it down exactly.

    Fixed in efe7d98 on master.

    Your reading is right, with one addition: there were two separate problems in that sequence, and the keymap only masks the second one.

    libCEC resolved the 0x40 toggle against this device's own power status alone. A running box reads as on, so the toggle meant off, and libCEC both announced <inactive source> and forwarded the key to Kodi. The ShutDown() is what actually suspends the box, so Noop makes it work — but libCEC is still announcing itself inactive at that moment, which is why you saw the <inactive source> broadcast in the working log too.

    Two changes:

    • A power toggle only means off while the TV is showing this device. Your log confirms the box was not the active source when the 0x40 arrived — libCEC logs marking … as inactive source only when the device actually was one, and there is no such line; the TV was still the active source 275 ms later. So the toggle is now read as "wake up", which is what the Sony means by it.
    • A toggle that resolves to on is the TV's wake-up rather than a keypress, so it is no longer forwarded to the client. A power press while the TV is showing you still reaches Kodi unchanged, so the power button on the remote keeps working — you should be able to drop the cec-power.xml keymap entirely.

    On the 8.1.1 correlation: 8.1.2 is the more likely trigger, and for a related reason. It added a Sony handler that answers <give device power status> with standby for a device the set is not showing, which is what a Sony wants to hear. That is very likely why your set now sends the wake sequence on input select at all — before, it believed the box was already on. The handler is doing the right thing; libCEC was just contradicting itself by telling the set "I'm off" and then reading the resulting toggle against its own "I'm on".

    On the settings filename: that is Kodi's, not libCEC's. Kodi names the peripheral settings file after the device it found, and since libCEC 8.0 enumerates every /dev/cec* node rather than presenting one generic "CEC Adapter", Kodi sees /dev/aocec. So yes, cec__dev_aocec.xml is the name going forward for that adapter.

    Could you both give master a try without the keymap and confirm? @spin-lock, yours is through a Denon AVR, so it is worth checking separately — the AVR may pass the keys through with a different destination.

  3. spin-lock commented on Sep 2, 2026

    @spin-lock

    Understood, will do tests on straight TV->device with the new commit once it has been incorporated into a new Coreelec nightly—since I can't build it by myself.
    Thank you.

  4. spin-lock commented on Sep 4, 2026

    @spin-lock

    Ok tested with the latest CoreELEC nightly (20260904) with libcec 8.1.7, issue seems to be fixed.
    Both direct to TV and through AVR are working flawlessly now.
    Thanks again much appreciated!

  5. DesertRec commented on Sep 4, 2026

    @DesertRec
    Author

    Can also confirm the issue is solved👍

  6. DesertRec commented on Sep 14, 2026

    @DesertRec
    Author

    Please keep the issue open, I have a feeling there is more to do.
    I have seen a couple of times 3-4 maybe that when I wan't to watch CoreELEC, CEC is thinking its suddently connected to HDMI1 and not HDMI3 which it is, reboot the Kodi box puts it back to correct HDMI3, haven't seen it since I turn on debug, but some day.

  7. DesertRec commented on Sep 23, 2026

    @DesertRec
    Author

    I have found the reason for my post above. When I reboot CoreELEC remotely while the TV and my AVP is both Off and turn On those later or immediately CEC thinks the box is on HDMI1, when it's physically connected to HDMI3. Opened a new issue #752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions