Req [CEC] Use connected device with volume commands
#1
Description

Kodi allows for volume changes through CEC commands. The target of these commands is hard-coded to CECDEVICE_AUDIOSYSTEM, e.g. here in PeripheralCecAdapter.cpp In case the HTPC is connected to a TV and there is no audio system available, the volume cannot be changed using this approach.

There is even a setting connected_device in the peripherals section, where the user can define the device the HTPC is connected to. However, this setting is not used for volume commands.
Code:
<setting id="connected_device" value="36037"/>

Context

I am using ARC to route audio from my HTPC (RPi 5 with LibreELEC 12) through the TV to an AV receiver. In order to save energy I sometimes turn off the receiver, so audio is output by the TV.

When the receiver is on, I can change volume with my HTPC's remote using Kodi's CEC capabilities. However, if the receiver is off, this does not work anymore. I instead have to write custom CEC commands with cec-ctl and map them to buttons of my remote (or use the TV's remote).

Possible Implementation

The setting connected_device is already available in the variable m_configuration.baseDevice of PeripheralCecAdapter.cpp, so it can be used directly.
 
cpp:
switch (pendingVolumeChange)
  {
    case VOLUME_CHANGE_UP:
      m_cecAdapter->SendKeypress(m_configuration.baseDevice, CEC_USER_CONTROL_CODE_VOLUME_UP, false);
      break;
    case VOLUME_CHANGE_DOWN:
      m_cecAdapter->SendKeypress(m_configuration.baseDevice, CEC_USER_CONTROL_CODE_VOLUME_DOWN, false);
      break;
    case VOLUME_CHANGE_MUTE:
      m_cecAdapter->SendKeypress(m_configuration.baseDevice, CEC_USER_CONTROL_CODE_MUTE, false);
      {
        std::unique_lock<CCriticalSection> lock(m_critSection);
        m_bIsMuted = !m_bIsMuted;
      }
      break;
    case VOLUME_CHANGE_NONE:
      if (bSendRelease)
        m_cecAdapter->SendKeyRelease(m_configuration.baseDevice, false);
      break;
  }
Reply
#2
(2024-12-12, 01:24)MaxMustermann Wrote: However, if the receiver is off, this does not work anymore. I instead have to write custom CEC commands with cec-ctl and map them to buttons of my remote (or use the TV's remote).

this just sounds like something is broken

if kodi is sending CEC commands to the TV which the AV responds to then the TV is forwarding them (and/or ignoring them)

is kodi capable "AT ALL" of controlling the TV over CEC, say if you were to reboot libre elec with the AV unplugged?
if not, there's the answer
if so, then it must be a negotiation issue, something in the chain is broken when the AV gets turned off
and if that part is true then the fix is renegotiation or re-detection of connected devices

have you brought this up as a possible bug on the LibreELEC forum?
Reply
#3
These are the custom CEC commands I use to control the volume on the TV when the AV receiver is off:
Code:

cec-ctl --to 0 --user-control-pressed ui-cmd=0x41 (volume up)
cec-ctl --to 0 --user-control-pressed ui-cmd=0x42 (volume down)

... which correspond to these commands in PeripheralCecAdapter.cpp:
Code:

m_cecAdapter->SendKeypress(CECDEVICE_AUDIOSYSTEM, CEC_USER_CONTROL_CODE_VOLUME_UP, false);
m_cecAdapter->SendKeypress(CECDEVICE_AUDIOSYSTEM, CEC_USER_CONTROL_CODE_VOLUME_DOWN, false);

This is my topology:
Code:

htpc:~ # cec-ctl -S
Driver Info:
    Driver Name                : vc4_hdmi
    Adapter Name               : vc4-hdmi-0
    Capabilities               : 0x0000010e
        Logical Addresses
        Transmit
        Passthrough
        Connector Info
    Driver version             : 6.6.28
    Available Logical Addresses: 1
    DRM Connector Info         : card 1, connector 32
    Physical Address           : 4.0.0.0
    Logical Address Mask       : 0x0002
    CEC Version                : 1.4
    Vendor ID                  : 0x001582 (Pulse-Eight)
    OSD Name                   : ''
    Logical Addresses          : 1 (Allow Fallback to Unregistered)
      Logical Address          : 1 (Recording Device 1)
        Primary Device Type    : Record
        Logical Address Type   : Record
        All Device Types       : Record
        RC TV Profile          : None
        Device Features        :
        None
    System Information for device 0 (TV) from device 1 (Recording Device 1):
        CEC Version                : 1.4
        Physical Address           : 0.0.0.0
        Primary Device Type        : TV
        Vendor ID                  : 0x00e091 (LG)
        OSD Name                   : Tx, OK, Rx, OK, Feature Abort
        Menu Language              : ger
        Power Status               : On
    System Information for device 5 (Audio System) from device 1 (Recording Device 1):
        CEC Version                : 1.4
        Physical Address           : 2.0.0.0
        Primary Device Type        : Audio System
        Vendor ID                  : 0x00a0de (Yamaha)
        OSD Name                   : 'RX-V381'
        Power Status               : Standby
    Topology:
        0.0.0.0: TV
            2.0.0.0: Audio System
            4.0.0.0: Recording Device 1
Quote:if kodi is sending CEC commands to the TV which the AV responds to then the TV is forwarding them (and/or ignoring them)
AFAIK with ARC the CEC commands are processed by the TV, not just forwarded. Audio sources do not communicate with the AV directly, only the TV does. The TV is in control of the AV. Sending a volume up CEC command to the TV (set TV as target explicitly) makes it
  • AV off: adjust its own volume and show OSD
  • AV on: adjust AV's volume with separate CEC command and show OSD

Do you really think that something is broken?
When I reboot LE having the AV turned off nothing changes with regard to CEC.

I reported this behavior already in June on the LibreELEC forum. Here is the thread.
Reply
#4
(2024-12-12, 09:51)MaxMustermann Wrote: Do you really think that something is broken?
When I reboot LE having the AV turned off nothing changes with regard to CEC.

well, yea, that's not normal CEC behavior
if libreelec cannot control your TV's volume "at all" then that is at minimum broken

the way this should work is that the TV is in control of the volume at all times
when the TV sees that there is an AV device it should control the AV device instead of internal speakers
when the AV device is not longer present then the internal TV speakers should kick in/turn on
but no point during that does the audio control change, it's always the TV

with that, when your Media device sends audio control to your CEC device it sends it to the TV, the TV then decides from there what is supposed to happen

what it sounds like is that when it does work it only ever sends it to the AV device which is incorrect, it should be controlling the TV
Reply
#5
Thanks for helping me get this straight. So my concern is rather a bug than a feature request?
Actually I had this FR already in xbmc GH repo as an issue yesterday and was asked to move it here.

Could someone from Team Kodi please tell me where to put my concern and how to label it correctly Huh
Reply

Logout Mark Read Team Forum Stats Members Help
[CEC] Use connected device with volume commands0
This forum uses Lukasz Tkacz MyBB addons.