modetest

modetest

modetest 是一个用于显示和测试 Linux 内核模式设置的工具。它通过使用 DRM(Direct Rendering Manager)接口与显示驱动程序进行通信,可以列出可用的显示模式并测试它们的功能。

作者:炭烤毛蛋 ,点击博主了解更多。


提示:modetest 工具可以外部编译或者安装再使用。

文章目录

  • modetest
  • 前期准备
    • .Android
    • .Linux
  • 1. modetest测试显示
  • 1.1 解析组件
    • 1.2 显示模式设置
    • 1.3 设置显示图层
  • Tips
  • 结语


前期准备

.Android

Android 编译 modetest

mmm external/libdrm/tests/modetest/ -j8
......
[100% 464/464] Copy xml: out/target/product/rk3568_s/testcases/modetest/modetest.config

Android 32bit

adb push [PATH]testcases/modetest/arm/modetest /system/bin/

Android 64bit

adb push [PATH] testcases/modetest/arm64/modetest /system/bin/
  • Android 停止 framebuffer
stop

.Linux

在 Linux 上使用 modetest 命令可以方便地测试和显示显示器的模式设置。

sudo apt-get install drm-utils
  • linux 停止 framebuffer
systemctl stop lightdm

注意:先关闭显示 framebuffer,再开启modetest,不然显示只有一帧然后被刷掉。

1. modetest测试显示

  • modetest 详细参数
modetest --help
usage: modetest [-cDdefMPpsCvw]Query options:-c      list connectors-e      list encoders-f      list framebuffers-p      list CRTCs and planes (pipes)Test options:-P <plane_id>@<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 propertyGeneric options:-d      drop master after mode set-M module       use the given driver-D device       use the given deviceDefault is to dump all info.

1.1 解析组件

将数据从帧缓冲区(framebuffer)传输到 DRM(Direct Rendering Manager)是在图形系统中进行显示的常见流程。
drm
CRTC(Cathode Ray Tube Controller)是驱动显示设备的硬件单元。你需要分配一个 CRTC 来控制显示输出。你可以使用 drmModeSetCrtc() 函数来分配 CRTC,并将帧缓冲缓冲区与 CRTC 关联起来。一旦 CRTC 分配完成,将触发显示控制器将帧缓冲缓冲区的内容发送到显示设备。
找到显示连接的 connector和与encoder匹配CTRC panle,通过直接送显示画面可以判定硬件链路好坏。

  • 查看组件的信息

modetest -M rockchip

-M:用于指定访问 rockchip DRM driver
如果不指定DRM芯片则会逐个遍历

trying to open device 'i915'...failed
trying to open device 'amdgpu'...failed
trying to open device 'radeon'...failed
trying to open device 'nouveau'...failed
trying to open device 'vmwgfx'...failed
trying to open device 'omapdrm'...failed
trying to open device 'exynos'...failed
trying to open device 'tilcdc'...failed
trying to open device 'msm'...failed
trying to open device 'sti'...failed
trying to open device 'tegra'...failed
trying to open device 'imx-drm'...failed
trying to open device 'rockchip'...done
modetest -M rockchip
Encoders:
id      crtc    type    possible crtcs  possible clones
345     0       Virtual 0x00000003      0x00000000
347     71      TMDS    0x00000001      0x00000000Connectors:
id      encoder status          name            size (mm)       modes   encoders
348     347     connected       HDMI-A-1        530x300         40      347modes:name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)1920x1080 60 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: preferred, driver1920x1080 75 1920 1968 2000 2080 1080 1083 1088 1119 174500 flags: phsync, nvsync; type: driver1920x1080 60 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: driver1920x1080 60 1920 2008 2052 2200 1080 1084 1089 1125 148352 flags: phsync, pvsync; type: driver
......props:1 EDID:flags: immutable blobblobs:
......
CRTCs:
id	fb	pos	size
71	0	(0,0)	(1920x1080)1920x1080 60 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: preferred, driverprops:21 ACTIVE:flags: rangevalues: 0 1value: 1
......
formats: XR24 AR24 XB24 AB24 RG24 BG24 RG16 BG16props:8 type:flags: immutable enumenums: Overlay=0 Primary=1 Cursor=2value: 1

Encoders / Connectors / CRTCs / Planes 的 id是 modetest 用户索引这些组件标识。
Connectors 的 modes/props:
prop: 任何你想设置的参数,都可以做成 property,是 DRM 驱动中最灵活、最方便的 Mode setting 机制;
modes: 显示模式中包含多组 mode,mode 则是分辨率/刷新率等显示相关的信息;
CRTCs 包含 props;
Planes 包含 formats/props;

1.2 显示模式设置

从modetest 中解析到 HDMI 显示CRTCs链路
connector --> 348

Encoders:
id      crtc    type    possible crtcs  possible clones
345     0       Virtual 0x00000003      0x00000000
347     71      TMDS    0x00000001      0x00000000

encoder -> 347

Connectors:
id      encoder status          name            size (mm)       modes   encoders
348     347     connected       HDMI-A-1        530x300         40      347

crtc -> 71

CRTCs:
id	fb	pos	size
71	0	(0,0)	(1920x1080)1920x1080 60 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: preferred, driverprops:
  • 设置显示分辨率
    设置成功后对应屏幕会有彩色条纹显示
modetest -M rockchip -s 348@71:1920x1080# buildroot中在weston.ini里面写入 mode=current,重启weston显示在这边指定的connector
modetest -M rockchip -s 348@71:1920x1080 -d

部分设备分辨率设定支持 mode 编号

modetest -M rockchip -s 348@71:#1

1.3 设置显示图层

#理论上背景图+720x480,实际只能看到720x480放大2倍的图 偏移100像素 y偏移100像素
# -P <plane_id>@<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
modetest -M rockchip -s 348:1920x1080 -P  57@71:720x480+100+100*2@XR24# 理论上背景+720x480的图,偏移100像素 y偏移100像素,实际之恶能看到720x480的图
modetest -M rockchip -s 348:1920x1080 -P 57@71:720x480+100+100*2@BG16 -P 57@71:320x240 modetest -M rockchip -s 348@71:1920x1080@RG24 -P 57@71:1920x540+0+0 -P 61@71:1080x1080+1080+0 -P 63@71:1280x720+10+10@RG24 -P 36@139:96x96+260+900@RG24

Tips

  1. 测试vsync是否正常
modetest -M rockchip -s 348@71:1920x1080 -v
setting mode 1920x1080-60Hz@XR24 on connectors 348, crtc 71
freq: 60.64Hz
  1. 开启drm日志
# 开启DRM所有日志
echo 0xff > /sys/module/drm/parameters/debug
# 开启DRM driver部分日志
echo 0x02 > /sys/module/drm/parameters/debug
# 关闭DRM日志
echo 0 > /sys/module/drm/parameters/debug
  1. 获取 connector 名字
for drm in /sys/class/drm/*/status; do con=${drm%/status}; echo -n "${con#*/card?-}: "; cat $drm;
HDMI-A-1: connected
Writeback-1: connected
  1. HDMI 状态转换
cat /d/dw-hdmi/status
PHY: enabled                    Mode: HDMI
Pixel Clk: 148500000Hz          TMDS Clk: 148500000Hz
Color Format: RGB               Color Depth: 8 bit
Colorimetry: ITU.BT709          EOTF: Off# 关闭 HDMI
echo off > /sys/class/drm/card0-HDMI-1/status
# 开启 HDMI
echo on > /sys/class/drm/card0-HDMI-1/status
  1. DSI 状态转换
# 开启 DSI-1
echo on > /sys/class/drm/card0-DSI-1/status
# 关闭 DSI-1
echo off > /sys/class/drm/card0-DSI-1/status
  1. 确认DRM 显示状态属性
cat /sys/kernel/debug/dri/0/state
# 开启时显示状态
plane[313]: Cluster1-win0crtc=video_port0fb=401allocated by = composer@2.1-serefcount=2format=XB24 little-endian (0x34324258)modifier=0x800000000000001size=1280x1280layers:size[0]=1280x1280pitch[0]=5120offset[0]=0obj[0]:(null)crtc-pos=1920x1080+0+0src-pos=1164.000000x654.000000+58.000000+313.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[327]: Cluster1-win1crtc=video_port0fb=416allocated by = composer@2.1-serefcount=2format=AB24 little-endian (0x34324241)modifier=0x800000000000001size=1920x1080layers:size[0]=1920x1080pitch[0]=7680offset[0]=0obj[0]:(null)crtc-pos=1920x1080+0+0src-pos=1920.000000x1080.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
crtc[71]: video_port0enable=1active=1planes_changed=1mode_changed=0active_changed=0connectors_changed=0color_mgmt_changed=0plane_mask=c0300connector_mask=2encoder_mask=2mode: 0:"1920x1080" 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x48 0x5
connector[346]: Writeback-1crtc=(null)
connector[348]: HDMI-A-1crtc=video_port0# 关闭后显示状态
plane[57]: Smart1-win0crtc=(null)fb=0crtc-pos=1920x1080+0+0src-pos=1920.000000x1080.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[73]: Smart0-win0crtc=(null)fb=0crtc-pos=654x270+633+405src-pos=654.000000x270.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[89]: Smart0-win1crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[103]: Smart0-win2crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[117]: Smart0-win3crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[131]: Smart1-win1crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[145]: Smart1-win2crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[159]: Smart1-win3crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[173]: Esmart1-win0crtc=(null)fb=0crtc-pos=1920x48+0+0src-pos=1920.000000x48.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[187]: Esmart1-win1crtc=(null)fb=0crtc-pos=1920x96+0+984src-pos=1920.000000x96.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[201]: Esmart1-win2crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[215]: Esmart1-win3crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[229]: Esmart0-win0crtc=(null)fb=0crtc-pos=1920x48+0+0src-pos=1920.000000x48.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[243]: Esmart0-win1crtc=(null)fb=0crtc-pos=1920x96+0+984src-pos=1920.000000x96.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[257]: Esmart0-win2crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[271]: Esmart0-win3crtc=(null)fb=0crtc-pos=0x0+0+0src-pos=0.000000x0.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[285]: Cluster0-win0crtc=(null)fb=0crtc-pos=1920x1080+0+0src-pos=1164.000000x654.000000+58.000000+313.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[299]: Cluster0-win1crtc=(null)fb=0crtc-pos=1920x1080+0+0src-pos=1920.000000x1080.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[313]: Cluster1-win0crtc=(null)fb=0crtc-pos=1920x1080+0+0src-pos=1164.000000x654.000000+58.000000+313.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
plane[327]: Cluster1-win1crtc=(null)fb=0crtc-pos=1920x1080+0+0src-pos=1920.000000x1080.000000+0.000000+0.000000rotation=1normalized-zpos=0color-encoding=ITU-R BT.601 YCbCrcolor-range=YCbCr limited range
crtc[71]: video_port0enable=1active=1planes_changed=0mode_changed=1active_changed=1connectors_changed=1color_mgmt_changed=0plane_mask=0connector_mask=2encoder_mask=2mode: 0:"1920x1080" 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x48 0x5
connector[346]: Writeback-1crtc=(null)
connector[348]: HDMI-A-1crtc=video_port0

结语

不枉博主详细讲解,欢迎订阅博主–炭烤毛蛋 。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/298201.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux应用程序管理(rpm yum 源码安装)

一.Linux应用程序基础 当我们主机安装Linux操作系统时候&#xff0c;也会同时安装一些软件或网络服务等等&#xff0c;但是随着系统一起安装的软件包毕竟他是少数的&#xff0c;能够实现的功能也是有限的&#xff0c;如果需要实现更丰富的功能&#xff0c;那就需要安装应用程序…

Codeforces Round 917 (Div. 2)(A~D)(又是数学题)

A - Least Product 题意&#xff1a; 思路&#xff1a;若有奇数个负数&#xff0c;则不需要任何操作。若存在0&#xff0c;也不需要任何操作。其余情况将任意一个数改为0即可。 #include <bits/stdc.h> using namespace std; void solve() {int n;cin >> n;int …

Nginx快速入门:实现企业安全防护|nginx部署https,ssl证书(七)

0. 引言 之前我们讲到nginx的一大核心作用就是实现企业安全防护&#xff0c;而实现安全防护的原理就是通过部署https证书&#xff0c;以此实现参数加密访问&#xff0c;从而加强企业网站的安全能力。 nginx作为各类服务的统一入口&#xff0c;只需要在入口处部署一个证书&…

详解Vue3中的插槽(slot)

本文主要介绍Vue3中的插槽&#xff08;slot&#xff09;。 目录 一、在普通写法中使用插槽&#xff08;slot&#xff09;作用域插槽默认插槽 二、在setup写法中使用插槽&#xff1a;注意事项 在Vue3中&#xff0c;插槽&#xff08;slot&#xff09;是一种用于在父组件中向子组件…

Leetcode162. 寻找峰值

Every day a Leetcode 题目来源&#xff1a;162. 寻找峰值 解法1&#xff1a;STL 代码&#xff1a; class Solution { public:int findPeakElement(vector<int>& nums) {return max_element(nums.begin(), nums.end()) - nums.begin();} };复杂度分析&#xff1…

【SD】差异值 生成 同一人物 制作 表情包 【1】

说明&#xff1a;只对AI生成的人物&#xff0c;效果稳定。 Reference差异值 生成表情 首先生成一张图片。 测试命令&#xff1a;1 man,chibi,full body, 模型&#xff1a;envyclarityxl02_v10.safetensors [f6c13197db] 种子&#xff1a;2704867166 》》测试命令&#xff1a…

基于包围盒算法的三维点云数据压缩和曲面重建matlab仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 4.1 包围盒构建 4.2 点云压缩 4.3 曲面重建 5.算法完整程序工程 1.算法运行效果图预览 2.算法运行软件版本 matlab2022a 3.部分核心程序 ...........................................…

【附三菱 MX OPC Server 6.04的安装包】MX-OPC下载以及用GX Works2和组态王进行仿真连接

使用MX-OPC来完成三菱和组态王的仿真连接。 文章目录 目录 文章目录 软件下载 1.OPC设置 2.GX Works 2 设置 3.GX Works 2 和OPC 连接测试 4.和组态王进行仿真连接 5.安装OPC后&#xff0c;GX Works2 无法打开 提示堆栈不足 6.收尾&#xff08;组态王变量的删除&#xff0…

Python - 深夜数据结构与算法之 Graph

目录 一.引言 二.图的简介 1.Graph 图 2.Undirected graph 无向图 3.Directed Graph 有向图 4.DFS / BFS 遍历 三.经典算法实战 1.Num-Islands [200] 2.Land-Perimeter [463] 3.Largest-Island [827] 四.总结 一.引言 Graph 无论是应用还是算法题目在日常生活中比较…

YOLOv7(目标检测)入门教程详解---检测,推理,训练

目录 一.前言 二.yolov7源码下载 三.detect&#xff08;检测&#xff09; 四.Train&#xff08;训练&#xff09; 数据准备&#xff1a; labellmg: 配置训练的相关文件 配置数据集文件 正式训练&#xff1a; 推理&#xff1a; 推理效果&#xff1a; 五.总结 一.前言 …

【C++练级之路】【Lv.5】动态内存管理(都2023年了,不会有人还不知道new吧?)

目录 一、C/C内存分布二、new和delete的使用方式2.1 C语言内存管理2.2 C内存管理2.2.1 new和delete操作内置类型2.2.2 new和delete操作自定义类型 三、new和delete的底层原理3.1 operator new与operator delete函数3.2 原理总结3.2.1 内置类型3.2.2 自定义类型 四、定位new表达…

docker笔记3-dockerfile定制镜像

dockerfile的组成 1.基础镜像信息&#xff0c;指定发行版本 FROM centos 2.制作镜像操作指令 RUN yum install openssh-server -y 3.容器启动指令执行 CMD [/bin/bash] dockerfile常用指令 指令 含义FROM指定基础镜像MAINTAINER指定维护人信息&#xff0c;可省略RUN基于基础…