工具:modetest
工具路径:libdrm/tests/modetest/
环境:Qcom
使用方法:
usage: ./modetest [-cDdefMPpsCvwa]
Query options:
-c list connectors
-e list encoders
-f list framebuffers
-p list CRTCs and planes (pipes)
Test options:
-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>] set a plane
-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>] set a mode
-C test hw cursor
-v test vsynced page flipping
-w <obj_id>:<prop_name>:<value> set property
-a use atomic IOCTL for all the settings and pageflip
Generic options:
-d drop master after mode set
-M module use the given driver
-D device use the given device
Default is to dump all info.
使用实列:
注:不同厂商对应-M参数不一样,已下示例均在高通平台
1.显示设备所有信息
# ./modetest -M msm_drm
Encoders:
id crtc type possible crtcs possible clones
27 0 DSI 0x0000003f 0x00000000
43 0 DSI 0x0000003f 0x00000000
48 0 Virtual 0x0000003f 0x00000000
58 0 TMDS 0x0000003f 0x00000000
64 0 DPMST 0x0000003f 0x00000000
65 0 DPMST 0x0000003f 0x00000000
Connectors:
id encoder status name size (mm) modes encoders
28 0 connected DSI-1 0x0 1 27
modes:
name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
1920x1080x60x148500 60 1920 2008 2052 2200 1080 1084 1089 1125 flags: ; type: preferred
props:
1 EDID:
flags: immutable blob
blobs:
value:
00ffffffffffff00446d010001000000
1b10010380502d780a0dc9a057479827
12484c00000001010101010101010101
010101010101023a801871382d40582c
45000000000000000000000000000000
00000000000000000000000000000000
000000000000000000000000000000fe
0065787420766964656f206d6f640083
2 DPMS:
flags: enum
enums: On=0 Standby=1 Suspend=2 Off=3
value: 0
...
44 0 connected DSI-2 0x0 1 43
modes:
...
59 0 disconnected DP-1 0x0 0 58
props:
1 EDID:
flags: immutable blob
blobs:
value:
2 DPMS:
flags: enum
enums: On=0 Standby=1 Suspend=2 Off=3
value: 0
...
CRTCs:
id fb pos size
139 0 (0,0) (0x0)
0 0 0 0 0 0 0 0 0 flags: ; type:
props:
19 ACTIVE:
flags: range
values: 0 1
value: 0
...
Planes:
id crtc fb CRTC x,y x,y gamma size possible crtcs
66 0 0 0,0 0,0 0 0x0000003f
formats: AR24 AB24 RA24 BX24 AB24 BA24 XR24 XB24 RX24 XB24 RG24 BG24 RG16 BG16 AR15 AB15 RA15 BA15 XR15 XB15 RX15 BX15 AR12 AB12 RA12 BA12 XR12 XB12 RX12 BX12 NV12 NV21 NV16 NV61 VYUY UYVY YUYV YVYU YU1
2 YV12 BA30 BX30 RA30 RX30 AB30 XB30 AR30 XR30 NV12
props:
6 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 1
...
111 0 0 0,0 0,0 0 0x0000003f
formats: AR24 AB24 RA24 AB24 BA24 XR24 RX24 BX24 XB24 RG24 BG24 RG16 BG16 AR15 AB15 RA15 BA15 XR15 XB15 RX15 BX15 AR12 AB12 RA12 BA12 XR12 XB12 RX12 BX12 BA30 BX30 RA30 RX30 AB30 XB30 AR30 XR30
props:
6 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
15 FB_ID:
...
Frame buffers:
id size pitch
上述内容我们可以看到诸多信息:encoder数量,类型;connector数量,电源状态,对应encoder是谁;crtc,planes等。
2.验证设备状态
验证id为28的connector整个通路是否ok
connector->28
encoder ->27
crtc ->139
# ./modetest -M msm_drm -s 28:1920x1080x60x148500
正常情况下 在对应屏幕会有彩色条纹显示
最后一个参数为connector name下面的那个分辨率全称
如果
# ./modetest -M msm_drm -s 28:1920x1080x60x148500 -d
那么在我关闭此测试,并且又在weston.ini里面写入 mode=current 字段,则我重启weston以后会显示在这边指定的connector上面
3.多layer显示
# ./modetest -M msm_drm -a -s 28:1920x1080x60x148500 -P 139:200x200+100+100*2@YV12
理论上应该是 背景+200x200的图,实际只能看到200x200的图
# ./modetest -M msm_drm -a -s 28:1920x1080x60x148500 -P 139:200x200+100+100*2@YV12 -P 139:320x240
理论上应该是 背景+ 200x200的图+ 320x240的图,实际之恶能看到200x200的图
./modetest -M msm_drm -a -s 235@139:3840x2160@RG24 -a -P 66@139:1920x2160+0+0 -P 90@139:1920x2160+1920+0 -P 93@139:1280x720+10+10@RG24 -P 96@139:96x96+1500+900@RG24
4.测试vsync是否正常
# ./modetest -M msm_drm -s 28:1920x1080x60x148500 -v
setting mode 1920x1080x60x148500-60Hz@XR24 on connectors 28, crtc 139
[ 4681.823795] dsi-ctrl:[_dsi_ctrl_setup_isr] [DSI_0] IRQ 518 registered
[ 4681.838720] DSI_Configuration Input Index = 09
[ 4681.859968] anx7625 enabled
freq: 60.85Hz
freq: 59.99Hz
freq: 60.00Hz
均为60帧
另:如想通过DRM atomic mode ,则需要在参数后追加 -a参数
====额外调试手段
1.获取connector名字及状态
# for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n "${con#*/card?-}: "; cat $p; done
DP-1: disconnected
DSI-1: connected
DSI-2: connected
Virtual-1: connected
2.DRM-KMS框架下的debugfs节点
# ls /sys/kernel/debug/dri/0/
DP-1 Virtual-1 crtc-1 crtc-4 crtc193 crtc217 encoder27 encoder58 fb gpu perf plane111 plane121 plane130 plane66 plane96 state
DSI-1 clients crtc-2 crtc-5 crtc201 crtc225 encoder43 encoder64 gem mm plane105 plane114 plane124 plane133 plane90 plane99
DSI-2 crtc-0 crtc-3 crtc139 crtc209 debug encoder48 encoder65 gem_names name plane108 plane118 plane127 plane136 plane93 rd
在没有开启任何应用
# cat /sys/kernel/debug/dri/0/state
plane[66]: plane-0
crtc=(null)
fb=0
crtc-pos=1920x1080+0+0
src-pos=1920.000000x1080.000000+0.000000+0.000000
rotation=0
plane[90]: plane-1
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=0
...
crtc[139]: crtc-0
enable=0
active=0
planes_changed=0
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=0
connector_mask=0
encoder_mask=0
mode: 0:"" 0 0 0 0 0 0 0 0 0 0 0x0 0x0
...
connector[28]: DSI-1
crtc=(null)
connector[44]: DSI-2
crtc=(null)
connector[49]: Virtual-1
crtc=(null)
connector[59]: DP-1
crtc=(null)
开启后差异部分/weston desktop模式;接显示器dsi0
# cat /sys/kernel/debug/dri/0/state
...
plane[108]: plane-6
crtc=crtc-1
fb=45
format=AB24 little-endian (0x34324241)
modifier=0x500000000000001
size=1920x1080
layers:
pitch[0]=7680
offset[0]=0
crtc-pos=1920x1080+0+0
src-pos=1920.000000x1080.000000+0.000000+0.000000
rotation=1
plane[111]: plane-7
crtc=crtc-0
fb=284
format=AB24 little-endian (0x34324241)
modifier=0x500000000000001
size=1920x1080
layers:
pitch[0]=7680
offset[0]=0
crtc-pos=1920x1080+0+0
src-pos=1920.000000x1080.000000+0.000000+0.000000
rotation=1
...
crtc[139]: crtc-0
enable=1
active=1
planes_changed=1
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=80
connector_mask=1
encoder_mask=1
mode: 0:"1920x1080x60x148500" 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x8 0x0
crtc[193]: crtc-1
enable=1
active=1
planes_changed=1
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=40
connector_mask=2
encoder_mask=2
mode: 0:"1920x1080x60x148500" 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x8 0x0
...
connector[28]: DSI-1
crtc=crtc-0
connector[44]: DSI-2
crtc=crtc-1
connector[49]: Virtual-1
crtc=(null)
connector[59]: DP-1
crtc=(null)
# ls /sys/class/drm
card0 card0-DP-1 card0-DSI-1 card0-DSI-2 card0-Virtual-1 renderD128 sde-crtc-0 sde-crtc-1 sde-crtc-2 sde-crtc-3 sde-crtc-4 sde-crtc-5 version
# cat /sys/class/drm/card0-DSI-1/status
connected
# cat /sys/class/drm/card0-DSI-1/modes
1920x1080x60x148500
# cat /sys/class/drm/card0-DP-1/status
disconnected
3.查看试试fps
# (while true; do export fps=`cat /sys/kernel/debug/dri/0/state | grep fps -m1 | grep -o '[0-9]\+'`; echo display ${fps}fps; sleep 4; done)
查看实时fps的命令,然而高通平台实验失败
4.开启drm-kms log实时输出
对应值的含义在include/drm/drmP.h
/*
* The following categories are defined:
*
* CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
* This is the category used by the DRM_DEBUG() macro.
*
* DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
* This is the category used by the DRM_DEBUG_DRIVER() macro.
*
* KMS: used in the modesetting code.
* This is the category used by the DRM_DEBUG_KMS() macro.
*
* PRIME: used in the prime code.
* This is the category used by the DRM_DEBUG_PRIME() macro.
*
* ATOMIC: used in the atomic code.
* This is the category used by the DRM_DEBUG_ATOMIC() macro.
*
* VBL: used for verbose debug message in the vblank code
* This is the category used by the DRM_DEBUG_VBL() macro.
*
* Enabling verbose debug messages is done through the drm.debug parameter,
* each category being enabled by a bit.
*
* drm.debug=0x1 will enable CORE messages
* drm.debug=0x2 will enable DRIVER messages
* drm.debug=0x3 will enable CORE and DRIVER messages
* ...
* drm.debug=0x3f will enable all messages
*
* An interesting feature is that it's possible to enable verbose logging at
* run-time by echoing the debug value in its sysfs node:
* # echo 0xf > /sys/module/drm/parameters/debug
*/
开启所有DRM-KMS logs:
# echo 0xff > /sys/module/drm/parameters/debug
开启driver部分DRM-KMS logs:
# echo 0x02 > /sys/module/drm/parameters/debug
关闭所有DRM-KMS logs:
# echo 0 > /sys/module/drm/parameters/debug
参考:https://wiki.st.com/stm32mpu/wiki/Main_Page
https://wiki.st.com/stm32mpu/wiki/DRM_KMS_overview
https://wiki.st.com/stm32mpu/wiki/DRM_KMS_overview#8