HDMI-CEC Control

Hello everyone!
As i am digging deeper in to Xibo I find myself wanting to do more things with it.

As the tile says it … HDMI-CEC control. Has anyone used/succeeded with it?
I tried a lot of commands but nothing works so far.
Interestingly enough my test Minix Neo-X6 box and Sharp Aquos TV seem to talk to each other both ways, But i am looking to control the TV from Xibo via the Minix box.

Thank you!

From what I understand you need to have at least Android version 5 and a kernel on the device that supports it with that device.

Is this what you have also found?

Interesting about the Android 5, but I don’t think that is the case.
As I wrote earlier My Minix Box seem to support it -> if I put the TV in standby the Minix goes to standby as well and vice versa.
What I am trying to achieve is the same as the shell commands but to control only the screen - I want the display to sleep not the Android box.
BTW the Minix box is with Android 4.4.2 and form what I see it works as it has it as switch in its control panel.

what I found is this:
http://www.cec-o-matic.com/

Tried several codes but it doesn’t seem to respond as it does not seem to be a valid shell command.
Also found some code about Raspbery Pi but still a no go .

Sounds like the hardware layer is communicating between the two. I think that to get to the software layer, you could use something like cec-o-matic. (I don’t know much about it, weather it is a hardware/software solution, or if they have a software only soution) But, I think you would need some application to be the go between for the Xibo/Android to cec-o-matic.

I think that utilizing Android hardware and a kernel that already supports CEC, like the unit you have, and then installing libCEC would be the way to go. The problem with this, is that libCEC is not directly available for Android.

I did find that recently someone posted online how to compile libCEC for Android, here. I have not tried to compile it yet for Android. I belive that if libCEC was installed on an Android client that had hardware and kernel support for CEC, one could then pass CEC commands via Xibo to the Screen/Monitor using the Shell Command on a region in a layout.

I mentioned Android 5 because Google/Alphabet introduced TIF into the OS and gives hardware using Android 5 a uniformed method of handle CEC communications. More here.

Sorry for the late replay but I had some troubles at work so yeah …
So after a lot of compilation and tests I did not manage to control the screen via xibo and so I went for hardware control of the screens. Lame but it works. Electronic timers that can be set by days and hours. And the screen was set to power on upon mains restore :slight_smile:
I will be purchasing some more gear and will continue testing but for now I am on a dead end. Thanks all for the input !

aster,

Also, just for some more info, Alex pointed out to me in another discussion that the TIF is more than likely only included with the Android TV version of android.

But please do post any progress, as I am sure a number of users would love to hear of some way to do this.

Will notify for any advancement I make I promise.
I am currently deploying my system and man there is a lot of trouble …

Finance module is not reading data. Forecast is not working …

As soon as I iron these things out will continue wireless CEC control.

Not sure if anyone has figured anything out regarding this?

My client is asking for this as well. According to the Android docs, it’s built into the API and most TV boxes seem to support it (Minix and Amlogic)

https://source.android.com/devices/tv/HDMI-CEC.html

It’s hard to ‘fix’ closed source software like Xibo for Android. I am really looking forward to something that’s hackable.

Nevermind, I figured it out.

Can you please share?

You just have to compile LibCEC against the Android SDK. Then you can use the Xibo 1.8 commands to turn the TV on/off.

I’ve returned the Android I tested because it kept overheating and crashing but as soon as I get my replacement (Minix U1, cross fingers), I’ll be posting fresh instructions.

Here’s how I did it:

Install Android Studio and install the SDK, CMAKE support and NDK for whatever flavor of Android you’re compiling for. I used API version 22.

Make a working directory (eg mkdir ~/libcec; cd ~/libcec). Get libcec and p8-platform from the Github (or a release) and unpack it into that directory. In each directory I also created the directory build (so I could clean up easily (mkdir build)).

I am using this on an Amlogic device so I also have to compile Exynos support into it. If you have a Pulse-Eight adapter or another CEC device, you could avoid this. You basically add -DHAVE_EXYNOS_API=1 or -DHAVE_TDA995X_API=1 if you have either of those.

Then simply do this:

In platform/build do:
cmake -DCMAKE_TOOLCHAIN_FILE=~/Library/Android/sdk/cmake/3.6.3155560/android.toolchain.cmake -DCMAKE_INSTALL_PREFIX:PATH=~/libcec/p8-platform/ -DANDROID_ABI=“armeabi-v7a” -DANDROID_STL=gnustl_static -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 …

Then:
make install

In libcec-libcec-3.1.0/build do:
cmake -DCMAKE_TOOLCHAIN_FILE=~/Library/Android/sdk/cmake/3.6.3155560/android.toolchain.cmake -DCMAKE_INSTALL_PREFIX:PATH=~/libcec/libcec/ -DANDROID_ABI=“armeabi-v7a” -DANDROID_STL=gnustl_static -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DCMAKE_FIND_ROOT_PATH=~/libcec/p8-platform/ …

Then:
make install

You now have ~/libcec/libcec folder with a bin/cec-client-3.1.0, bin/cecc-client-3.1.0 (as well as some symlinks) and lib/libcec.so.

Use adb push to copy the things onto your device into /system/bin/cec-client-3.1.0, /system/bin/cecc-client-3.1.0 and /system/lib/libcec.so.3.1.0 respectively. Then symlink ln -s /system/lib/libcec.so.3.1.0 /system/lib/libsec.so.3; ln -s /system/lib/libcec.so.3 /system/lib/libsec.so and (if you wish) symlink cec-client to cec-client-3.1.0.

Now find your CEC serial port device. It doesn’t exist by default on my Android so I have to do mknod /dev/CEC u 253 0. There is a /dev/amhdmitx0 but it’s not a typewriter device so it’s not usable by cec-client.

I currently don’t have a CEC-capable display (HDMI->DVI) but at least I get the response from the CEC processor that the TV is not present.

2 Likes

Guru_Evi,

You are awesome.

I can post the binaries although I’m unsure how useful they will be for your specific platform. The above instructions are fairly useful and easy (at least on a Mac).

I am working on a ‘finished’ Android player so I can just flash the player and it will have Xibo and cec-client. Now to find a CEC-compatible TV…

So, thanks to @Guru_Evi I was able to compile cec-client to android. Thanks a lot for your instructions. As a note to the future, I had to add a flag -DANDROID_PLATFORM=android-16 in order to be able to execute the command on android >= 5.0, otherwise I was receiving the error " error: only position independent executables (PIE) are supported.".

I’ve added the flag -DHAVE_EXYNOS_API=1 and -DHAVE_AOCEC_API=1

Now I’m facing a problem of “command ‘PING’ was not acked by the controller”.

I’m running it on this android dongle.

The device /dev/cec is settled:

q8723bs:/ # ls -l /dev/cec                                                                                                                                              
crw-rw-rw- 1 root root 218,   0 2017-12-19 16:33 /dev/cec

I also can find it on /sys/class/cec:

q8723bs:/ # ls -laht /sys/class/cec/                                                                                                                                    
total 0
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 arc_port
lrwxrwxrwx   1 root root    0 2017-12-19 16:45 cec -> ../../devices/aocec/cec
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 cec_version
--w-------   1 root root 4.0K 2017-12-19 16:45 cmd
-rw-rw-r--   1 root root 4.0K 2017-12-19 16:45 dbg_en
-rw-rw-r--   1 root root 4.0K 2017-12-19 16:45 device_type
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 dump_reg
-rw-rw-r--   1 root root 4.0K 2017-12-19 16:45 fun_cfg
-rw-rw-r--   1 root root 4.0K 2017-12-19 16:45 menu_language
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 osd_name
-rw-rw-r--   1 root root 4.0K 2017-12-19 16:45 physical_addr
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 pin_status
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 port_num
-rw-rw-r--   1 root root 4.0K 2017-12-19 16:45 port_seq
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 port_status
-rw-rw-r--   1 root root 4.0K 2017-12-19 16:45 vendor_id
-r--r--r--   1 root root 4.0K 2017-12-19 16:45 wake_up
drwxr-xr-x   2 root root    0 2017-12-19 16:33 .
drwxr-xr-x 110 root root    0 2017-12-19 16:33 ..

But when I ran cec-client I receive this answer:

q8723bs:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:toolbox:s0
q8723bs:/ # cec-client -s /dev/cec                                                                                                                                      
opening a connection to the CEC adapter...
DEBUG:   [               1]	Broadcast (F): osd name set to 'Broadcast'
DEBUG:   [               2]	connection opened, clearing any previous input and waiting for active transmissions to end before starting
DEBUG:   [             396]	communication thread started
DEBUG:   [            1396]	command 'PING' was not acked by the controller

As a note, I also have the device /dev/input/event2 that is a read only cec_input:

q8723bs:/ # ls -l /dev/input/event2                                                                                                                                     
crw-rw---- 1 root input 13,  66 2017-12-19 16:33 /dev/input/event2
q8723bs:/ # ls /sys/devices/virtual/input/input2/                                                                                                                      
capabilities/  event2/        id/            modalias       name           phys           power/         properties     subsystem/     uevent         uniq
q8723bs:/ # cat /sys/devices/virtual/input/input2/name                                                                                                                  
cec_input

I tried to run it on /dev/input/event2 but obviously it didn’t work because it could not open a connection:

q8723bs:/ # cec-client /dev/input/event2                                                                                                                                
No device type given. Using 'recording device'
CEC Parser created - libCEC version 4.0.2
opening a connection to the CEC adapter...
DEBUG:   [               1]	Broadcast (F): osd name set to 'Broadcast'
ERROR:   [            3335]	error opening serial port '/dev/input/event2': Couldn't lock the serial port
ERROR:   [            3335]	could not open a connection (try 1)

Any thoughts to help me on this? Thanks in advance.

A) Does your TV actually have CEC controls and is it enabled - this is often buried within TV set’s settings
Anynet+ (Samsung)
Aquos Link (Sharp)
BRAVIA Link, BRAVIA Sync, Control for HDMI (Sony)
CE-Link, Regza Link (Toshiba)
E-link (AOC)
EasyLink (Philips)
Fun-Link (Funai, Sylvania, Emerson, Magnavox, Philips)
HDMI-CEC (Hitachi)

B) Keep running in Debug mode and see if you do anything on the TV set that should passthrough (eg. if you have a Vizio, use one of the DVD controls) whether it shows up on the system. Make sure the system is on the first or master HDMI input, some Tv’s only support CEC on the first or first couple of HDMI inputs.

C) Use a high quality HDMI cable or another TV set, make sure there are no other devices (like a receiver) in the chain that could interfere.

You may eventually want to get an actual CEC USB dongle for your computer to see if the commands actually end up on the HDMI bus or not.

A) I’ve tried with RPI (libecec) in the same tv and CEC commands works.

B) I have an LG. I will try the developer mode to check if I find any interesting log. Thanks.

C) I’m connecting the android dongle directly to the tv. No cables. I tried in both hdmi ports. No success.

I also posted my both approaches at this stackoverflow. If you have any more idea it would be very helpful since there are a lack of documentation about this subject. Thanks in advance.