title: Android - send HDMI CEC commands to TV - minix - libCEC
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>I found the serial device that get HDMI-CEC input commands</p>
  
  <pre><code>/dev/input/event7
  </code></pre>
  
  <p>The kernel references are placed at: "/sys/devices/virtual/input/input7/"</p>
  
  <pre><code># cat /sys/devices/virtual/input/input7/name
  cec_input
  </code></pre>
  
  <p>This is a part of dmesg log:</p>
  
  <blockquote>
    <p><a href="http://pastebin.com/raw.php?i=A5dE3qLu">http://pastebin.com/raw.php?i=A5dE3qLu</a></p>
  </blockquote>
  
  <pre><code>&lt;5&gt;[    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
  &lt;4&gt;[    0.000000@0] kernel get hdmimode form uboot is 4k2ksmpte
  &lt;4&gt;[    0.000000@0] hdmitx: cec: Function List: disable, , , 
  &lt;4&gt;[    0.000000@0] hdmitx: cec: HDMI aml_read_reg32(P_AO_DEBUG_REG0):0x0
  &lt;4&gt;[    0.000000@0] hdmitx: cec: HDMI hdmi_cec_func_config:0x0
  &lt;4&gt;[    1.392440@1] hdmitx: cec: CEC not ready
  &lt;4&gt;[    4.872752@0] hdmitx: cec: CEC init
  &lt;4&gt;[    4.876194@1] hdmitx: cec: CEC task process
  &lt;4&gt;[    4.876398@0] hdmitx: cec: hdmitx_device-&gt;cec_init_ready:0x1
  </code></pre>
  
  <p>that proves the effective presence of HDMI-CEC built-in support.</p>
  
  <p>I found <a href="https://github.com/Pulse-Eight/libcec">libCEC</a> 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.</p>
  
  <p>These are the build options:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>
  
  <p>If it can run on raspi it must be able to run on a Minix, i guess.</p>
  
  <p>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:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>
  
  <p>Problems:</p>
  
  <ul>
  <li>it is possible to send CEC command via Android using Java?</li>
  <li>if not, anyone know how to adapt the libCEC/cec-client to work on Minix?</li>
  </ul>
  
  <p>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"</p>
  
  <p>Anyone has tips? How can accomplish that?</p>