Announcement

Collapse
No announcement yet.

Getting HDMI CEC to work on pCP 7.0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting HDMI CEC to work on pCP 7.0

    I thought I would start a new thread on this to document progress.

    The pCP kernel has HDMI CEC enabled.
    So next step is to get it to work so that a TV remote control can be used to control JiveLite (and potentially other things) through the TV itself rather then adding an infrared receiver to the RPi.

    I think that for this to work it need ps the /dev/cec0 to exist (a RPi4 with dual HDMI would also have /dev/cec1 for the 2nd HDMI port but that is for later study).

    Tests done on an old RPi with HDMI cable attached and TV switched on at time of boot and JiveLite running with display over the HDMI connection to the TV.

    sudo modprobe cec
    Does not give an error.
    However, it does not result in a /dev/cec0 being created.
    So this might be fatal but not sure if it is this that is supposed to create the device.

    In any case, tried to install v4l2-utils to get the cec command line tools.
    This is not in the pCP repo but is in TinyCore ... so switched to that repo to try to install.
    However, it fails on v4l-dvb-5.4.83-pcpCore.tcz - Presumably because the version in the repo is older.

    Code:
    Downloading: libxshmfence.tcz
    libxshmfence.tcz: OK
    Downloading: expat2.tcz
    expat2.tcz: OK
    Downloading: libXdmcp.tcz
    libXdmcp.tcz: OK
    Downloading: libXau.tcz
    libXau.tcz: OK
    Downloading: libxcb.tcz
    libxcb.tcz: OK
    Downloading: libX11.tcz
    libX11.tcz: OK
    Downloading: libXext.tcz
    libXext.tcz: OK
    Downloading: libXxf86vm.tcz
    libXxf86vm.tcz: OK
    Downloading: libXfixes.tcz
    libXfixes.tcz: OK
    Downloading: libXdamage.tcz
    libXdamage.tcz: OK
    Downloading: bzip2-lib.tcz
    bzip2-lib.tcz: OK
    Downloading: pcre.tcz
    pcre.tcz: OK
    Downloading: libelf.tcz
    libelf.tcz: OK
    Downloading: gamin.tcz
    gamin.tcz: OK
    Downloading: glib2.tcz
    glib2.tcz: OK
    Downloading: libudev.tcz
    libudev.tcz: OK
    Downloading: libpciaccess.tcz
    libpciaccess.tcz: OK
    Downloading: libdrm.tcz
    libdrm.tcz: OK
    Downloading: mesa.tcz
    mesa.tcz: OK
    Downloading: SDL2.tcz
    SDL2.tcz: OK
    Downloading: SDL2_image.tcz
    SDL2_image.tcz: OK
    Downloading: libjpeg-turbo.tcz
    libjpeg-turbo.tcz: OK
    Downloading: v4l-dvb-5.4.83-pcpCore.tcz
    Error on v4l-dvb-5.4.83-pcpCore.tcz
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

    #2
    Update:
    Getting /dev/cec0 to appear requires using recent RPi kms

    dtoverlay=vc4-kms-v3d-pi4 on a pi4, or dtoverlay=vc4-kms-v3d on Pi2/3 (not recommended on Pi0/1) ... of course, I am trying to get this to work on an old Pi1 ...
    anyway ... adding into config.txt
    dtoverlay=vc4-kms-v3d
    and rebooting results in /dev/cec0 being created.

    As expected - this messes up the display of JiveLite but can research that later. Edit: just needed the Jivelite skin to be changed to one of the HD skins via Settings/Screen (and a keyboard to do the navigation because CEC not working yet)

    It also prevents Squeezelite starting up on HDMI because "b1" does not appear ... but changing it to use the new device allows it to start
    hw:CARD=vc4hdmi,DEV=0
    but no sound comes out .. however, sound does come out with
    iec958:CARD=vc4hdmi,DEV=0
    (perhaps it is related to the sample format)
    It would not start with
    sysdefault:CARD=vc4hdmi

    Now need the v4l2-utils to get the command line tools to try things out.

    Trying loading
    v4l-dvb-5.4.83-pcpCore.tcz
    from pCP repo ...
    Last edited by Paul Webster; 2021-01-27, 17:55.
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

    Comment


      #3
      Watching with interest.....

      I have a multi-device 'learning' IR remote controller, and I have an IR receiver attached to my RPi. So when I press the corresponding device key on the remote (to put it into Squeezebox mode), the commands that it sends are the same as those sent by an original Squeezebox remote. In theory, would this CEC setup allow the TV to send those same commands back to the RPi via HDMI (i.e. remote in Squeezebox mode), or is it translating commands coming from the TV device remote keys (i.e. remote in TV mode)?

      Comment


        #4
        after installing the pcp-dvb modules ... I was then able to install v4l2-utils.tcz

        Code:
        Downloading: libv4l2.tcz
        libv4l2.tcz: OK
        Downloading: v4l2-utils.tcz
        v4l2-utils.tcz: OK
        and I now have cec-ctl command line tool ... next to work out what it does.
        Code:
        [email protected]:~$cec-ctl
        Failed to open /dev/cec0: Permission denied
        [email protected]:~$ sudo cec-ctl
        Driver Info:
                Driver Name                : vc4_hdmi
                Adapter Name               : vc4
                Capabilities               : 0x0000000e
                        Logical Addresses
                        Transmit
                        Passthrough
                Driver version             : 5.4.83
                Available Logical Addresses: 1
                Connector Info             : None
                Physical Address           : 2.0.0.0
                Logical Address Mask       : 0x0000
                CEC Version                : 2.0
                OSD Name                   : ''
                Logical Addresses          : 0
        Paul Webster
        Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
        and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

        Comment


          #5
          Some progress ... at least able to send a command ...
          #First need to configure the device
          sudo cec-ctl --audio --osd-name pCP

          #then can turn on TV (from standby)
          sudo cec-ctl --image-view-on -t0

          Not yet been able to receive something from Tv remote ... but looks promising.

          Edited: see later about using "playback" rather than "audio" (probably would need to be configurable since perhaps not all TVs react in the same way)
          Last edited by Paul Webster; 2021-01-27, 16:07.
          Paul Webster
          Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
          and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

          Comment


            #6
            I have not been able to get cec-ctl to see messages ... but I suspect this is me rather than it.
            So I decided to try a different route and use cec-client (from Pulse8) on top of the kernel CEC support.

            I probably need to build it on pCP but have not done that yet (not even sure if it is possible).
            I built in on a different RPi running Raspbian with the idea of copying it over to the pCP box ... and in doing so I went through a couple of iterations turning things off.
            But not successful yet.

            I followed the instructions at

            with one line changed
            from
            cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib ..
            to
            cmake -DHAVE_CURSES_API=0 -DHAVE_CURSES_TINFO=0 -DHAVE_LINUX_API=1 -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib ..

            I turned off the ncurses parts because pCP has ncursesw but cec-client looks for ncurses (the "w" is "wide" for Unicode) and I could not work out how to patch it.
            The HAVE_LINUX_API=1 is what turns on the ability in cec-client to use the Linux kernel API.

            Having copied over the cec-client and libcec modules I was still getting errors when trying to run on pCP - it wants libudev.so.1 rather than libudev.so.1 that is on pCP.
            I do not know if that is a result of me building under Raspbian.

            Maybe someone with more knowledge in the area of building things for pCP could give me some ideas.
            Paul Webster
            Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
            and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

            Comment


              #7
              Originally posted by chill View Post
              Watching with interest.....

              I have a multi-device 'learning' IR remote controller, and I have an IR receiver attached to my RPi. So when I press the corresponding device key on the remote (to put it into Squeezebox mode), the commands that it sends are the same as those sent by an original Squeezebox remote. In theory, would this CEC setup allow the TV to send those same commands back to the RPi via HDMI (i.e. remote in Squeezebox mode), or is it translating commands coming from the TV device remote keys (i.e. remote in TV mode)?
              If this works you would use the regular TV/Video remote which usually has a marked up pause/play/skip buttons.
              The TV receives those commands and translates them to CEC equivalent to relay to the correct device (in this case the RPi).
              That is the theory ... not even getting the commands in yet.
              The TV does not know how to interpret remote signals from a regular Squeezebox remote.
              Paul Webster
              Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
              and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

              Comment


                #8
                Aha ...
                Code:
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_PRESSED (0x44):
                        ui-cmd: pause (0x46)
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_PRESSED (0x44):
                        ui-cmd: pause (0x46)
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_RELEASED (0x45)
                Received from TV to Playback Device 2 (0 to 8): POLL
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_PRESSED (0x44):
                        ui-cmd: electronic-program-guide (0x53)
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_PRESSED (0x44):
                        ui-cmd: electronic-program-guide (0x53)
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_RELEASED (0x45)
                Received from TV to Playback Device 2 (0 to 8): POLL
                Received from TV to Playback Device 2 (0 to 8): POLL
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_PRESSED (0x44):
                        ui-cmd: device-root-menu (0x09)
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_PRESSED (0x44):
                        ui-cmd: device-root-menu (0x09)
                Received from TV to Playback Device 2 (0 to 8): USER_CONTROL_RELEASED (0x45)
                Received from TV to Playback Device 2 (0 to 8): POLL
                Received from TV to Playback Device 2 (0 to 8): POLL
                The "ui-cmd:" lines above correspond to pressing keys on the TV remote while the TV source is set to the RPi.

                I went back to cec-ctl and tried with a different profile ... instead of --audio I went for --playback
                Now I see remote control key presses ... this is very promising.

                Volume Up/Down did not come through but were actioned by the TV directly.
                I suspect that this is configurable ... not sure if in the TV or through a CEC configuration command.
                In the case where the volume being controlled is the local TV (or HDMI connected AMP) this is not a problem - but if JiveLite is being used to control a different LMS player then would need to see the vol up/down requests so that they can be passed to LMS.
                Paul Webster
                Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                Comment


                  #9
                  A bit more stream of consciousness stuff ...

                  If someone can get libCEC from Pulse8 (see earlier stuff in this thread) to build and install on pCP ... then there is another tool that can sit on top of it that maps CEC commands to uinput (like keyboard input ... so I think it might work like ir-keytable with Jivelite)
                  Paul Webster
                  Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                  and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                  Comment


                    #10
                    I'll take a look. And I'll pull in the v4l2-utils as well.
                    piCorePlayer a small player for the Raspberry Pi in RAM.
                    Homepage: https://www.picoreplayer.org

                    Please donate if you like the piCorePlayer

                    Comment


                      #11
                      Getting HDMI CEC to work on pCP 7.0

                      One quick update .... I said earlier that the screen wa messed up in Jivelite when I use
                      dtoverlay=vc4-kms-v3d
                      ...
                      of course ...
                      Jivelite is set to the Joggler screen on startup ... so I had a mini Jivelite in the top left corner of the screen.

                      To resolve that all that I had to do was use a keyboard to navigate into Settings/Screen and change to one of the HD skins.
                      So that part of things is working fine now.
                      I'll update the earlier post.
                      Last edited by Paul Webster; 2021-01-27, 22:37.
                      Paul Webster
                      Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                      and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                      Comment


                        #12
                        Okay, I added all of the needed dependencies. It build cleanly for me. I'm not sure what options are needed and which aren't. But these instructions work fine, with these changes.

                        pCP (piCore) packages names that are needed

                        cmake libudev-dev libXrandr-dev python3.8-dev swig git rpi-vc-dev

                        The rpi-vc stuff is in a different spot......

                        cmake -DHAVE_CURSES_API=0 -DHAVE_CURSES_TINFO=0 -DHAVE_LINUX_API=1 -DRPI_INCLUDE_DIR=/usr/local/include -DRPI_LIB_DIR=/usr/local/lib ..

                        I did not have time to package things up.....which I probably could this weekend...... but the build is pretty easy for you to continue to test.

                        Code:
                        [email protected]:~$ sudo cec-client
                        No device type given. Using 'recording device'
                        CEC Parser created - libCEC version 6.0.2
                        no serial port given. trying autodetect:
                         path:     Raspberry Pi
                         com port: RPI
                        
                        opening a connection to the CEC adapter...
                        DEBUG:   [              10]     Broadcast (F): osd name set to 'Broadcast'
                        DEBUG:   [              10]     logical address changed to Free use (e)
                        DEBUG:   [              10]     Open - vc_cec initialised
                        NOTICE:  [              10]     connection opened
                        DEBUG:   [              10]     processor thread started
                        DEBUG:   [              10]     << Broadcast (F) -> TV (0): POLL
                        DEBUG:   [              10]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
                        TRAFFIC: [              10]     << e0
                        DEBUG:   [            1011]     command 'feature abort' timeout
                        DEBUG:   [            1511]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
                        TRAFFIC: [            1511]     << e0
                        DEBUG:   [            1545]     >> POLL not sent
                        DEBUG:   [            1545]     TV (0): device status changed into 'not present'
                        DEBUG:   [            1545]     registering new CEC client - v6.0.2
                        DEBUG:   [            1546]     SetClientVersion - using client version '6.0.2'
                        NOTICE:  [            1546]     setting HDMI port to 1 on device TV (0)
                        DEBUG:   [            1546]     << Broadcast (F) -> TV (0): POLL
                        DEBUG:   [            1546]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
                        TRAFFIC: [            1546]     << e0
                        DEBUG:   [            2546]     command 'feature abort' timeout
                        ^Csignal caught: 2 - exiting
                        DEBUG:   [            3047]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
                        Last edited by paul-; 2021-01-28, 04:07.
                        piCorePlayer a small player for the Raspberry Pi in RAM.
                        Homepage: https://www.picoreplayer.org

                        Please donate if you like the piCorePlayer

                        Comment


                          #13
                          Thanks.

                          Just tried to build on the device ... very old RPI1
                          Code:
                          [    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
                          [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
                          [    0.000000] OF: fdt: Machine model: Raspberry Pi Model B Rev 2
                          cmake fails immediately with a "Segmentation Fault"
                          wrong Arm?

                          Also - swig not in the list of extensions (and not on PiCore either).

                          I'll see if I can free up a more modern RPi and see if it works there.
                          Last edited by Paul Webster; 2021-01-28, 10:18.
                          Paul Webster
                          Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                          and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                          Comment


                            #14
                            Borrowed a newer RPi ... progress
                            cmake does not segfault.


                            For the list of extensions required to build ... also need 'C' compiler and related applications
                            compiletc

                            .. currently building ...
                            Paul Webster
                            Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                            and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                            Comment


                              #15
                              Annoyingly I can't get the RPi to load the /dev/cec0 with the new SD card that I have rebuilt things on.

                              I suspect there is something that I did yesterday that I have missed out today.
                              The overlay is specified in config.txt
                              dtoverlay=vc4-kms-v3d

                              If I put the SD card from yesterday into the 2nd RPi then I do get /dev/cec0 created ... so the hardware difference does not appear to be the issue.
                              The 2nd Pi is a B+ ... so not very different anyway.

                              I have also put the cmdline.txt from RPi1 into RPi2 and it does not change things.

                              Next step is to compare all of the .tcz extensions I loaded.
                              Obviously RPi2 has a lot more because of the build environment (I had to add a max_loop=150 to cmdline.txt avoid a mount error when installing one).
                              Paul Webster
                              Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                              and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                              Comment

                              Working...
                              X