HDMI(一):adb 查看HDMI信息
LeeAaron https://www.cnblogs.com/lialong1st/p/8522240.html
rk3288_7.1HDMI开发总结 https://www.codeleading.com/article/24242032782/
只是一下暗恋而已 https://blog.csdn.net/qq_30624591/article/details/106840966
截图、录屏
adb shell screencap -p /sdcard/01.png adb shell screenrecord /sdcard/demo.mp4
一、adb 查看HDMI信息
Android 5.1
1.1、查看支持的分辨率
cat /sys/class/display/HDMI/modes
1.2、查看当前分辨率
cat /sys/class/display/HDMI/mode
1.3、切换分辨率
echo 1920x1080p-60 > /sys/class/display/HDMI/mode
1.4、查看HDMI是否连接
cat /sys/class/display/HDMI/connect
1.5、查看HDMI使能状态
cat /sys/class/display/HDMI/enable
1.6、设置HDMI使能,<value> 可取0或1,0表示关闭,1表示开启。
echo <value> > /sys/class/display/HDMI/enable
1.7.查看屏幕密度 120,160,240,320,480,640
adb shell wm size 屏幕分辨率
Physical size: 1920x1080
adb shell wm density 屏幕密度
Physical density: 480
Override density: 323
adb shell wm density 240 设置屏幕密度
Android7.1 查看HDMI信息
1.8.查看当前分辨率
cat /sys/class/drm/card0-HDMI-A-1/mode
1.9.查看支持分辨率
cat sys/devices/platform/display-subsystem/drm/card0/card0-HDMI-A-1/modes
二、Android7.1 HDMI设备节点
DRM 的设备节点为 “/dev/dri/cardX”, X为0-15的数值.
默认使用的是/dev/dri/card0
节点控制hdmi和lvds的显示开关
HDMI:
echo on > /sys/class/drm/card0-HDMI-A-1/status //打开hdmiout显示
echo off > /sys/class/drm/card0-HDMI-A-1/status //关闭hdmiout显示
cat /sys/class/drm/card0-HDMI-A-1/status //打开是connected,关闭是disconnected
LVDS:
ls -dl /sys/class/drm/*/st* && cat /sys/class/drm/card0-LVDS-1/st*
echo on > /sys/class/drm/card0-LVDS-1/st* //开
echo off > /sys/class/drm/card0-LVDS-1/st* //关
cat /proc/device-tree/display-subsystem/route/route-lvds/status
判断一下节点存不存在
private boolean getScreenType() { File f = new File("/sys/class/drm/card0-DSI-1"); if (f.exists()) { return true; } return false; }
三、主副显示器设置:
可以在产品配置目录下的system.prop里(如 device/rockchip/rk3288/rk3288_mid/system.prop)添加如下两个属性:
sys.hwc.device.primary = HDMI-A //设置显示接口做为主显,这里设置HDMI接口为主显
sys.hwc.device.extend = LVDS //设置显示接口做为副显,这里设置LVDS接口为副显
默认情况下(即以上属性未配置时),不支持热拔插设备(如 CVBS/MIPI/LVDS 等)会作为主显,支持热插拔设备(如HDMI/DP等)会作为次显。通常主、副显只配置一个显示接口,
例如RK3399MID SDK默认采用的配置, HDMI作为主显示,EDP作为副显示。
关于接口名称可以参见hardware/rockchip/hwcomposer/drmresources.cpp里的定义:
struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_Unknown, “unknown” },//未知接口 { DRM_MODE_CONNECTOR_VGA, “VGA” }, //VGA { DRM_MODE_CONNECTOR_DVII, “DVI-I” },//DVI,暂不支持 { DRM_MODE_CONNECTOR_DVID, “DVI-D” },//DVI,暂不支持 { DRM_MODE_CONNECTOR_DVIA, “DVI-A” },//DVI,暂不支持 { DRM_MODE_CONNECTOR_Composite, “composite” },//不支持 { DRM_MODE_CONNECTOR_SVIDEO, “s-video” },//S端子 { DRM_MODE_CONNECTOR_LVDS, “LVDS” },//LVDS { DRM_MODE_CONNECTOR_Component, “component” },//分量信号YPbPr { DRM_MODE_CONNECTOR_9PinDIN, “9-pin DIN” },//不支持 { DRM_MODE_CONNECTOR_DisplayPort, “DP” },//DP { DRM_MODE_CONNECTOR_HDMIA, “HDMI-A” },//HDMI A型口 { DRM_MODE_CONNECTOR_HDMIB, “HDMI-B” },//HDMI B型口,不支持 { DRM_MODE_CONNECTOR_TV, “TV” },// CVBS { DRM_MODE_CONNECTOR_eDP, “eDP” },//EDP { DRM_MODE_CONNECTOR_VIRTUAL, “Virtual” },//不支持 { DRM_MODE_CONNECTOR_DSI, “DSI” },//MIPI };
RK3288
struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_Unknown, "unknown" }, { DRM_MODE_CONNECTOR_VGA, "VGA" }, { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, { DRM_MODE_CONNECTOR_DVID, "DVI-D" }, { DRM_MODE_CONNECTOR_DVIA, "DVI-A" }, { DRM_MODE_CONNECTOR_Composite, "composite" }, { DRM_MODE_CONNECTOR_SVIDEO, "s-video" }, { DRM_MODE_CONNECTOR_LVDS, "LVDS" }, { DRM_MODE_CONNECTOR_Component, "component" }, { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" }, { DRM_MODE_CONNECTOR_DisplayPort, "DP" }, { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" }, { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" }, { DRM_MODE_CONNECTOR_TV, "TV" }, { DRM_MODE_CONNECTOR_eDP, "eDP" }, { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, };
判断Android7.1 HDMI 插拔状态
import java.io.File;
import java.util.Scanner;
private static boolean isHdmiSwitchSet() { File switchFile = new File("/sys/devices/virtual/switch/hdmi/state"); if (!switchFile.exists()) { switchFile = new File("/sys/class/switch/hdmi/state"); } try { Scanner switchFileScanner = new Scanner(switchFile); int switchValue = switchFileScanner.nextInt(); switchFileScanner.close(); return switchValue > 0; } catch (Exception e) { return false; } }