i'm working on a Minix NEO X8-H (Android media center, 4.4.2) and i need to send HDMI-CEC command to TV: when my App receives a call i want to change automatically the TV Source to the Minix hdmi source.
Actually the Minix offer some options to enable HDMI-CEC and the media center software XBMC is reported to support CEC. But only in "receive mode" i guess: the user can command the Android device using TV remote. I want to work the opposite way. I browse XBMC's source code and i found very interesting code but do not know if it can be useful to me.
I found the serial device that get HDMI-CEC input commands
/dev/input/event7
The kernel references are placed at: "/sys/devices/virtual/input/input7/"
# cat /sys/devices/virtual/input/input7/name
cec_input
This is a part of dmesg log:
http://pastebin.com/raw.php?i=A5dE3qLu
<5>[ 0.000000@0] Kernel command line: init=/init console=ttyS0,115200n8 no_console_suspend storage=5 cvbsdrv=0 vdaccfg=0xa007 logo=osd1,loaded,0x15100000,4k2ksmpte,full hdmimode=4k2ksmpte cvbsmode=576cvbs androidboot.firstboot=0 hdmitx=cec0
<4>[ 0.000000@0] kernel get hdmimode form uboot is 4k2ksmpte
<4>[ 0.000000@0] hdmitx: cec: Function List: disable, , ,
<4>[ 0.000000@0] hdmitx: cec: HDMI aml_read_reg32(P_AO_DEBUG_REG0):0x0
<4>[ 0.000000@0] hdmitx: cec: HDMI hdmi_cec_func_config:0x0
<4>[ 1.392440@1] hdmitx: cec: CEC not ready
<4>[ 4.872752@0] hdmitx: cec: CEC init
<4>[ 4.876194@1] hdmitx: cec: CEC task process
<4>[ 4.876398@0] hdmitx: cec: hdmitx_device->cec_init_ready:0x1
that proves the effective presence of HDMI-CEC built-in support.
I found libCEC and i managed to cross-compile it using Android NDK toolchain and i was able to install "libcec.so" and a demo client binary "cec-client" onto the Minix.
These are the build options:
asd@vm-ubuntu:~/Desktop/libcec/libcec-master/build$ cmake ..
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
-- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
-- Configured features:
-- Pulse-Eight CEC Adapter: no
-- Pulse-Eight CEC Adapter detection: no
-- lockdev support: no
-- xrandr support: no
-- Raspberry Pi support: no
-- TDA995x support: no
-- Exynos support: no
-- Python support: no
-- lib info: compiled on Linux-3.13.0-35-generic, features: P8_USB
-- Configuring done
-- Generating done
-- Build files have been written to: /home/asd/Desktop/libcec/libcec-master/build
I know that libcec works with an external hdmi-cec controller or, if build with Raspberry support feature it can runs smoothly on a raspi, using its integrated video controller.
If it can run on raspi it must be able to run on a Minix, i guess.
The cec-client was a demo client, developed to communicate with a serial interface and actually it can not communicate with /dev/input/evet7 because of some errors:
root@NEO-X8:/data # cec-client -t p -p 4 /dev/input/event7
== using device type 'playback device'
using HDMI port '4'
CEC Parser created - libCEC version 3.0.0
opening a connection to the CEC adapter...
DEBUG: [ 7] Broadcast (F): osd name set to 'Broadcast'
ERROR: [ 3520] error opening serial port '/dev/input/event7': Invalid argument
ERROR: [ 3521] could not open a connection (try 1)
ERROR: [ 6355] error opening serial port '/dev/input/event7': Too many open files
ERROR: [ 6355] could not open a connection (try 2)
ERROR: [ 8243] error opening serial port '/dev/input/event7': Too many open files
ERROR: [ 8243] could not open a connection (try 3)
ERROR: [ 9501] error opening serial port '/dev/input/event7': Too many open files
ERROR: [ 9501] could not open a connection (try 4)
unable to open the device on port /dev/input/event7
NOTICE: [ 10506] connection opened
But AFAIK Hdmi-CEC use a serial communication protocol using pin 13 of the HDMI connector so even if "cec-client" is a demo client it must be able to work properly! As you see there is a problem on locking the device or something similar.
Problems:
If Java way is not possible there are no problems: my own app is built using Qt and actually i'm already using a couple of native shared librare ".so"
Anyone has tips? How can accomplish that?
My two cents on the issue:
I went through all the trouble you went, too, especially with libCEC, so I'd like to describe the only way I got any interaction going between an Android TV box and the TV connected to it with HDMI cable.
Send a request for connected device's power status
echo 0x40 0x8F > /sys/class/cec/cmd
To get the response, you can:
read the "registry"
cat /sys/class/cec/dump_reg
wait and look for the response in logcat
// Example:
02-06 16:33:10.568 4012 4105 D CEC : [cec_rx_loop]msg:04 90 00
02-06 16:33:10.570 4012 4105 D HdmiCecExtend: onCecMessageRx
02-06 16:33:10.657 4012 4012 W HDMI : [1]:Unhandled cec command:<Report Power Status> src: 0, dst: 4, params: 00
02-06 16:33:10.762 4012 4104 D CEC : [cec_send_message][4 -> 0]len:3, body:00 90 00 , result:success
Magic numbers (codes) explanation:
40 - Playback device #1
04 - TV device #1
On - 90 00
Off - 00 00 // in registry or no response at all in logcat
Other available codes can be constructed or read on Cec-O-Matic or amlogic.
I still have to try and get to Android's HdmiControlService but I still don't know how, probably through Java reflection. You can see HdmiCecExtend: onCecMessageRx
so the API is available on the device, but you cannot use it in Android Studio, as far as I know, it's only available to Android TV vendors.
Will update if anything comes along.
First of all, very impressive reverse engineering work!
Secondly, I'm facing a similar issue (but with a non Minix product). Have you tried upgrading to a newer firmware, such as this one:
http://minixforum.com/threads/x8-x8-plus-x8-h-official-firmware-004a-not-for-x8-h-plus.5567/
I am suggesting this as a possible solution, because one of the issues it fixes is this:
Fixed HDMI-CEC multi devices issues
This means the device is not only a "slave", but also a "master" (i.e. can send commands to other hdmi devices).
Please note that as stated in the link, it is not intended for the plus version.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With