Android - 将HDMI CEC命令发送到电视 - minix - libCEC

Mat*_*att 15 java qt android android-ndk hdmi

我正在使用Minix NEO X8-H(Android媒体中心,4.4.2),我需要向电视发送HDMI-CEC命令:当我的应用程序接到电话时,我想自动将电视源更改为Minix hdmi资源.

实际上,Minix提供了一些启用HDMI-CEC的选项,据报道媒体中心软件XBMC支持CEC.但我只想在"接收模式"中:用户可以使用电视遥控器命令Android设备.我想以相反的方式工作.我浏览了XBMC的源代码,我发现了非常有趣的代码,但不知道它是否对我有用.

我找到了获得HDMI-CEC输入命令的串行设备

/dev/input/event7
Run Code Online (Sandbox Code Playgroud)

内核引用放在:"/ sys/devices/virtual/input/input7 /"

# cat /sys/devices/virtual/input/input7/name
cec_input
Run Code Online (Sandbox Code Playgroud)

这是dmesg日志的一部分:

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
Run Code Online (Sandbox Code Playgroud)

这证明了HDMI-CEC内置支持的有效存在.

我找到了libCEC并且我设法使用Android NDK工具链交叉编译它,我能够在Minix上安装"libcec.so"和一个演示客户端二进制文件"cec-client".

这些是构建选项:

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
Run Code Online (Sandbox Code Playgroud)

我知道libcec可以与外部hdmi-cec控制器配合使用,或者如果使用Raspberry支持功能构建,它可以使用其集成的视频控制器在raspi上顺利运行.

如果它可以在raspi上运行,它必须能够在Minix上运行,我猜.

cec-client是一个演示客户端,开发用于与串行接口通信,实际上由于某些错误它无法与/ dev/input/evet7通信:

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
Run Code Online (Sandbox Code Playgroud)

但AFAIK Hdmi-CEC使用HDMI连接器的引脚13进行串行通信协议,因此即使"cec-client"是演示客户端,它也必须能够正常工作!如您所见,锁定设备或类似设备存在问题.

问题:

  • 可以使用Java通过Android发送CEC命令吗?
  • 如果没有,任何人都知道如何使libCEC/cec-client适应Minix?

如果Java方式不可能没有问题:我自己的应用程序是使用Qt构建的,实际上我已经使用了几个本机共享库".so"

有人有提示吗?怎么能做到这一点?

rex*_*xar 3

我对这个问题的两分钱:

第一章:慈悲

我也经历了你遇到的所有麻烦,尤其是 libCEC,所以我想描述一下在 Android 电视盒和通过 HDMI 电缆连接到它的电视之间进行交互的唯一方法。

第二章:低火慢煮

发送连接设备电源状态请求 echo 0x40 0x8F > /sys/class/cec/cmd

要获得响应,您可以:

  1. 阅读“注册表” cat /sys/class/cec/dump_reg

  2. 等待并在 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
Run Code Online (Sandbox Code Playgroud)

幻数(代码)解释:

40 - Playback device #1
04 - TV device #1
On - 90 00
Off - 00 00 // in registry or no response at all in logcat
Run Code Online (Sandbox Code Playgroud)

其他可用代码可以在Cec-O-Maticamlogic上构建或读取。

第三章 新的希望

我仍然需要尝试访问 Android 的HdmiControlService,但我仍然不知道如何实现,可能是通过 Java 反射。可以看到HdmiCecExtend: onCecMessageRx,该API在设备上可用,但不能在Android Studio中使用,据我所知,它仅适用于Android TV供应商。

如果有什么情况就会更新。