Rockchip RK3399 - DRM eDP调试
----------------------------------------------------------------------------------------------------------------------------
开发板 :NanoPC-T4
开发板
eMMC
:16GB
LPDDR3
:4GB
显示屏 :15.6
英寸HDMI
接口显示屏
u-boot
:2023.04
linux
:6.3
----------------------------------------------------------------------------------------------------------------------------
在《Rockchip RK3399 - DRM eDP
驱动程序》中我们介绍了eDP
相关设备树的配置,并对eDP
相关驱动程序源码进行了分析,本节我们将进行内核烧录和调试。
一、烧录内核
1.1 内核配置
在linux
内核根目录下执行make menuconfig
配置以下内容。
1.1.1 eDP
驱动配置
eDP
驱动实现主要位于:
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
;drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
;drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
;drivers/phy/rockchip/phy-rockchip-dp.c
;
如果需要使以上文件生效,首先需要配置CONFIG_ROCKCHIP_ANALOGIX_DP
,具体参考drivers/gpu/drm/rockchip/Makefile
;
rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
......
obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o
接着需要配置CONFIG_PHY_ROCKCHIP_DP
,具体参考drivers/gpu/drm/rockchip/Makefile
;
obj-$(CONFIG_PHY_ROCKCHIP_DP) += phy-rockchip-dp.o
因此,我们需要在linux
内核根目录下执行make menuconfig
配置以下选项:
Device Drivers --->
Graphics support --->
<*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
<*> DRM Support for Rockchip (DRM_ROCKCHIP [=y])
[*] Rockchip VOP driver # CONFIG_ROCKCHIP_VOP2
[ ] Rockchip VOP2 driver # CONFIG_ROCKCHIP_VOP
[*] Rockchip specific extensions for Analogix DP driver # CONFIG_ROCKCHIP_ANALOGIX_DP
[*] Rockchip cdn DP # CONFIG_ROCKCHIP_CDN_DP
[*] Rockchip specific extensions for Synopsys DW HDMI # CONFIG_ROCKCHIP_DW_HDMI
[*] Rockchip specific extensions for Synopsys DW MIPI DSI # CONFIG_ROCKCHIP_DW_MIPI_DSI
[*] Rockchip specific extensions for Innosilicon HDMI # CONFIG_ROCKCHIP_INNO_HDMI 实际上RK3399并没有使用Innosilicon IP,可以不选
[*] Rockchip LVDS support # CONFIG_ROCKCHIP_LVDS
[ ] Rockchip RGB support # CONFIG_ROCKCHIP_RGB
Display Interface Bridges ---> # CONFIG_DRM_DW_HDMI取决于CONFIG_DRM_BRIDGE、DRM_DRM(默认开启)
<M> Synopsys Designware AHB Audio interface # CONFIG_DRM_DW_HDMI_AHB_AUDIO
<*> Synopsys Designware I2S Audio interface # CONFIG_DRM_DW_HDMI_I2S_AUDIO HDMI音频
<M> Synopsys Designware GP Audio interface # CONFIG_DRM_DW_HDMI_I2S_AUDIO
<*> Synopsis Designware CEC interface # CONFIG_DRM_DW_HDMI_CEC
Device Drivers --->
PHY Subsystem --->
<*> Rockchip Display Port PHY Driver
1.1.2 配置backlight
驱动
backlight
驱动实现位于drivers/video/backlight/pwm_bl.c
,如果需要使该文件生效,需要配置CONFIG_BACKLIGHT_PWM
,具体参考drivers/video/backlight/Makefile
;
obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
因此,我们需要配置内核:
Device Drivers --->
Graphics support --->
Backlight & LCD device support --->
-*- Lowlevel Backlight controls
<*> Generic PWM based Backlight Driver
1.1.3 配置pwm
驱动
PWM
驱动位于drivers/pwm/pwm-rockchip.c
,如果需要使该文件生效,需要配置CONFIG_PWM_ROCKCHIP
,具体参考drivers/pwm/Makefile
;
obj-$(CONFIG_PWM_ROCKCHIP) += pwm-rockchip.o
因此,我们需要配置内核:
Device Drivers --->
[*] Pulse-Width Modulation (PWM) Support --->
<*> Rockchip PWM support // CONFIG_PWM_ROCKCHIP
1.1.4 配置panel
驱动
panel
驱动位于drivers/gpu/drm/panel/panel-simple.c
,如果需要使该文件生效,需要配置CONFIG_PWM_ROCKCHIP
,具体参考drivers/gpu/drm/panel/Makefile
;
obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
因此,我们需要配置内核:
Device Drivers --->
Graphics support --->
Display Panels --->
<*> support for simple panels (other than eDP ones)
< > support for simple Embedded DisplayPort panels
1.1.5 配置gt9xx
驱动
在内核中,配置gt9xx
有多种方式,比如I2C HID
驱动程序、Generic input layer
,我们采用其中一种即可。
(1) ``Generic input layer`
在linux
内核中中有一个通用输入层子系统,用于处理和管理各种输入设备,例如键盘、鼠标、触摸屏和游戏手柄等。通用输入层提供了一个统一的接口,使应用程序可以以一致的方式与不同类型的输入设备进行交互。
gt9xx
驱动位于:
drivers/input/touchscreen/goodix.c
;drivers/input/touchscreen/goodix_fwupload.c
;
如果需要使该文件生效,需要配置CONFIG_TOUCHSCREEN_GOODIX
,具体参考drivers/input/touchscreen/Makefile
;
goodix_ts-y := goodix.o goodix_fwupload.o
obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix_ts.o
因此,我们需要配置内核:
Device Drivers --->
Input device support --->
-*- Generic input layer (needed for keyboard, mouse, ...)
[*] Touchscreens --->
<*> Goodix I2C touchscreen
注意:这里我才用这种方式;
(2) I2C HID
驱动程序
如果要使用I2C
接口的HID
设备,那么就需要配置 I2C HID support
;
Device Drivers --->
[*] HID bus support --->
<*> I2C HID support --->
<*> Driver for Goodix hid-i2c based devices on OF systems
注意:该方式未测试。
1.2 保存配置
配置完内核之后记得保存配置:
存档:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# mv rk3399_defconfig ./arch/arm64/configs/
重新配置内核(如果不想重新编译内核,可以存档一份到.config
):
root@zhengyang:/work/sambashare/rk3399/linux-6.3# make rk3399_defconfig
1.3 编译内核
在linux
内核根目录下执行如下命令进行编译内核:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# make -j8
u-boot-2023.04
路径下的mkimage
工具拷贝过来,然后在命令行使用mkimage
工具编译即可:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# cp ../u-boot-2023.04/tools/mkimage ./
root@zhengyang:/work/sambashare/rk3399/linux-6.3# ./mkimage -f kernel.its kernel.itb
1.4 通过tftp
烧录内核
给开发板上电,同时连接上网线,进入uboot
命令行。我们将内核拷贝到tftp
文件目录:
root@zhengyang:/work/sambashare/rk3399/linux-6.3# cp kernel.itb /work/tftpboot/
接着给开发板上电。通过uboot
命令行将kernel.itb
下到内存地址0x10000000
处:
=> tftp 0x10000000 kernel.itb
通过mmc write
命令将内核镜像烧录到eMMC
第0x8000
个扇区处:
=> mmc erase 0x8000 0xA000
=> mmc write 0x10000000 0x8000 0xA000
=> bootm
1.5 启动内核
将开发板和HD702E
显示屏通过eDP 30PIN
接口引脚连接起来,同时将开发板和hdmi
显示器通过hdmi
线缆连接起来,然后给开发板上电启动。内核输入有关edp
日志:
root@rk3399:~# dmesg | grep -E "hdmi|edp|drm|Goodix"
[ 0.551098] platform ff940000.hdmi: Fixed dependency cycle(s) with /vop@ff900000/port/endpoint@2
[ 0.561496] platform ff970000.edp: Fixed dependency cycle(s) with /vop@ff8f0000/port/endpoint@1
[ 0.669022] platform edp-panel: Fixed dependency cycle(s) with /edp@ff970000/ports/port@1/endpoint@0
[ 3.413841] Goodix-TS 4-005d: ID 9271, version: 1020
[ 3.419508] Goodix-TS 4-005d: Direct firmware load for goodix_9271_cfg.bin failed with error -2
[ 3.438411] input: Goodix Capacitive TouchScreen as /devices/platform/ff3d0000.i2c/i2c-4/4-005d/input/input0
[ 5.060616] [drm] Initialized panfrost 1.2.0 20180908 for ff9a0000.gpu on minor 0
[ 5.417080] rockchip-dp ff970000.edp: no DP phy configured
[ 5.425681] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops)
[ 5.434692] [drm] unsupported AFBC format[3231564e]
[ 5.441264] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops)
[ 5.451078] rockchip-drm display-subsystem: bound ff970000.edp (ops rockchip_dp_component_ops)
[ 5.460949] dwhdmi-rockchip ff940000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 5.470491] dwhdmi-rockchip ff940000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 5.480056] dwhdmi-rockchip ff940000.hdmi: Detected HDMI TX controller v2.11a with HDCP (DWC HDMI 2.0 TX PHY)
[ 5.495963] rockchip-drm display-subsystem: bound ff940000.hdmi (ops dw_hdmi_rockchip_ops)
[ 5.507029] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 1
[ 5.573242] rockchip-dp ff970000.edp: AUX CH error happened: 0x2 (1)
[ 5.574257] rockchip-dp ff970000.edp: AUX CH error happened: 0x0 (1)
[ 5.759654] rockchip-drm display-subsystem: [drm] fb0: rockchipdrmfb frame buffer device
[ 5.771274] asoc-simple-card hdmi-sound: ASoC: binding ff8a0000.i2s-i2s-hifi
[ 5.783063] asoc-simple-card hdmi-sound: ASoC: CPU DAI (null)registered
[ 5.790541] asoc-simple-card hdmi-sound: ASoC: CODEC DAI i2s-hifi registered
[ 5.800032] asoc-simple-card hdmi-sound: connected DAI link ff8a0000.i2s:Playback -> hdmi-audio-codec.6.auto:I2S Playback
[ 5.818546] asoc-simple-card hdmi-sound: connected DAI link hdmi-audio-codec.6.auto:Capture -> ff8a0000.i2s:Capture
[ 5.833667] dev hdmi-audio-codec.6.auto
[ 5.859644] #1: hdmi-sound
[ 10.198950] systemd[1]: Starting Load Kernel Module drm...
二、eDP
调试
此处测试开发板烧录的根文件系统为ubuntu 22.04
版本,同时编译安装了mesa 24.0.0
,根文件系统的制作可以参考文章:
2.1 sysfs
在/dev/dri/
目录下可以看到驱动注册的各个显卡,DRM
设备节点为 /dev/dri/cardX
,X
为0-15
的数值。
root@rk3399:~# ll /dev/dri/
drwxr-xr-x 2 root root 100 Jan 18 2013 by-path/
crw-rw---- 1 root video 226, 0 Jan 18 2013 card0
crw-rw---- 1 root video 226, 1 Jan 18 2013 card1
crw-rw---- 1 root render 226, 128 Jan 18 2013 renderD128
root@rk3399:~# ll /sys/class/drm
lrwxrwxrwx 1 root root 0 Sep 20 2023 card0 -> ../../devices/platform/ff9a0000.gpu/drm/card0/
lrwxrwxrwx 1 root root 0 Sep 20 2023 card1 -> ../../devices/platform/display-subsystem/drm/card1/
lrwxrwxrwx 1 root root 0 Sep 20 2023 card1-eDP-1 -> ../../devices/platform/display-subsystem/drm/card1/card1-eDP-1/
lrwxrwxrwx 1 root root 0 Sep 20 2023 card1-HDMI-A-1 -> ../../devices/platform/display-subsystem/drm/card1/card1-HDMI-A-1/
lrwxrwxrwx 1 root root 0 Sep 20 2023 renderD128 -> ../../devices/platform/ff9a0000.gpu/drm/renderD128/
-r--r--r-- 1 root root 4096 Sep 20 2023 version
sysfs
文件系统中的card1-HDMI-A-1
代表的是hdmi
显示设备,sysfs
文件系统中的card1-eDP-1
代表的是edp
显示设备,是由drm_sysfs_connector_add
函数(位于drivers/gpu/drm/drm_sysfs.c
文件)创建的。其中card1
代表的是display-subsystem
显示子系统,而HDMI-A-1
、eDP-1
是connector
(即显示设备)的名称;
int drm_sysfs_connector_add(struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;
struct device *kdev;
int r;
if (connector->kdev)
return 0;
kdev = kzalloc(sizeof(*kdev), GFP_KERNEL);
if (!kdev)
return -ENOMEM;
device_initialize(kdev);
kdev->class = drm_class;
kdev->type = &drm_sysfs_device_connector;
kdev->parent = dev->primary->kdev;
kdev->groups = connector_dev_groups;
kdev->release = drm_sysfs_release;
dev_set_drvdata(kdev, connector);
r = dev_set_name(kdev, "card%d-%s", dev->primary->index, connector->name);
if (r)
goto err_free;
DRM_DEBUG("adding \"%s\" to sysfs\n",
connector->name);
r = device_add(kdev);
if (r) {
drm_err(dev, "failed to register connector device: %d\n", r);
goto err_free;
}
connector->kdev = kdev;
if (connector->ddc)
return sysfs_create_link(&connector->kdev->kobj,
&connector->ddc->dev.kobj, "ddc");
return 0;
err_free:
put_device(kdev);
return r;
}
查看card1-eDP-1
目录结构;
lrwxrwxrwx 1 root root 0 Sep 20 2023 /sys/class/drm/card1 -> ../../devices/platform/display-subsystem/drm/card1/
root@rk3399:~# ll /sys/class/drm/card1/card1-eDP-1/
lrwxrwxrwx 1 root root 0 Apr 30 02:32 device -> ../../card1/
-r--r--r-- 1 root root 4096 Apr 30 11:34 dpms
-r--r--r-- 1 root root 0 Jan 18 2013 edid
-r--r--r-- 1 root root 4096 Jan 18 2013 enabled
-r--r--r-- 1 root root 4096 Apr 30 11:34 modes
drwxr-xr-x 2 root root 0 Apr 30 11:34 power/
-rw-r--r-- 1 root root 4096 Apr 30 11:34 status
lrwxrwxrwx 1 root root 0 Sep 20 2023 subsystem -> ../../../../../../class/drm/
-rw-r--r-- 1 root root 4096 Sep 20 2023 uevent
其中:
device
:指向card1
;edid
:存储edp
显示器的扩展显示标识数据;enabled
:edp
接口是否被启用或禁用;modes
:连接的edp
显示器以及当前edp
控制器同时支持的分辨率列表;status
:edp
接口连接状态的信息;
2.1.1 查看edp
使能状态
查看edp
输出使能状态:
root@rk3399:~# cat /sys/class/drm/card1-eDP-1/enabled
enabled
如果将edp
显示屏拔掉:
root@rk3399:~# cat /sys/class/drm/card1-eDP-1/enabled
disabled
在使用cat
命令读取enabled
文件时调用enabled_show
方法;
static ssize_t enabled_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct drm_connector *connector = to_drm_connector(device);
bool enabled;
enabled = READ_ONCE(connector->encoder);
return sysfs_emit(buf, enabled ? "enabled\n" : "disabled\n");
}
2.1.2 查看edp
连接状态
查看edp
的插拔连接状态;
root@rk3399:~# cat /sys/class/drm/card1-eDP-1/status
connected
如果将edp
显示屏拔掉:
root@rk3399:~# cat /sys/class/drm/card1-eDP-1/status
disconnected
在使用cat
命令读取status
文件时调用status_show
方法;
static ssize_t status_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct drm_connector *connector = to_drm_connector(device);
enum drm_connector_status status;
status = READ_ONCE(connector->status);
return sysfs_emit(buf, "%s\n",
drm_get_connector_status_name(status));
}
2.1.3 查看edid
通过如下命令可以查看edid
信息,一共0个字节;
root@rk3399:/# cat /sys/class/drm/card1-eDP-1/edid > /data/edid.bin
root@rk3399:/# hexdump -C /data/edid.bin
2.1.4 分辨率
查看连接的edp
显示器支持的分辨率列表;;
root@rk3399:~# cat /sys/class/drm/card1-eDP-1/modes
800x1280
在使用cat
命令读取modes
文件时调用modes_show
方法;
static ssize_t modes_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct drm_connector *connector = to_drm_connector(device);
struct drm_display_mode *mode;
int written = 0;
mutex_lock(&connector->dev->mode_config.mutex);
// 遍历connector支持的modes
list_for_each_entry(mode, &connector->modes, head) {
// 写入到buf 在之前博客我们说过显示模式的命名规则为:%dx%d%s 第一个参数为:mode->hdisplay 第二个参数为:mode->vdisplay 第三个参数为:i/''(取决于mode->flags是否设置了DRM_MODE_FLAG_INTERLACE隔行扫描)
written += scnprintf(buf + written, PAGE_SIZE - written, "%s\n",
mode->name);
}
mutex_unlock(&connector->dev->mode_config.mutex);
return written;
}
2.2 查看当前分辨率
在Linux
系统中,DISPLAY
环境变量指定了X
服务器的显示地址,它告诉系统在哪里可以找到用户图形界面的显示。
通常,DISPLAY
的值采用以下格式:
hostname:displaynumber.screennumber
其中:
hostname
:指定了X
服务器所在的主机名或IP
地址。如果不指定,则默认为本地主机;displaynumber
:指定了X
服务器的显示号,通常以0
开始。例如,:0
表示默认的显示器;screennumber
:指定了屏幕号,通常默认为0,表示主屏幕;
例如,如果 DISPLAY
的值为 :0.0
,则表示X
服务器运行在本地主机上的默认显示器上的第一个屏幕。
2.2..1 xrandr
运行如下命令查看当前分辨率:
root@rk3399:~# export DISPLAY=:0.0;xrandr
Screen 0: minimum 16 x 16, current 2720 x 1280, maximum 32767 x 32767
XWAYLAND0 connected primary 800x1280+0+0 (normal left inverted right x axis y axis) 150mm x 94mm
800x1280 56.85*+
800x600 56.93
640x480 56.36
320x240 54.78
720x480 56.47
640x400 56.21
320x200 56.01
720x400 56.21
640x350 56.35
XWAYLAND2 connected 1920x1080+800+0 (normal left inverted right x axis y axis) 480mm x 270mm
1920x1080 59.96*+
1440x1080 59.99
1400x1050 59.98
1280x1024 59.89
1280x960 59.94
1152x864 59.96
1024x768 59.92
800x600 59.86
640x480 59.38
320x240 59.52
1680x1050 59.95
1440x900 59.89
1280x800 59.81
720x480 59.71
640x400 59.95
320x200 58.96
1600x900 59.95
1368x768 59.88
1280x720 59.86
1024x576 59.90
864x486 59.92
720x400 59.55
640x350 59.77
在ubuntu 22.4
系统上,可以看到当前分辨率为2720x1280
,XWAYLAND0
和 XWAYLAND2
是两个连接的显示器,分辨率分别为 800x1280
和1920x1080
,对应我们的edp
显示器和hdmi
显示器,而分辨率实际上就是(800+1920)x1290
。
因此不难猜出,当前两个显示器默认采用的是扩展链接方式,即edp
显示器作为主屏,hdmi
显示器作为扩展屏。
测试时发现无法通过xrandr
调整屏幕参数,需要修改/etc/gdm3/custom.conf
,移除#WaylandEnable=false
,然后就要进行屏幕参数调整了,比如旋转屏幕:
root@rk3399:~# export DISPLAY=:0.0; xrandr -o right
重启之后修改就会被还原,如果想永久生效,编辑vim /etc/profile
,添加;
xrandr --output XWAYLAND0 --rotate right
2.2.2 更改Display Mode
在桌面环境,右键Display Settings
可以更改显示配置;
![](https://gitee.com/zyly2033/blog-pic/raw/master/202404301625217.png)
这里默认配置为Join Displays
,我们可以更改为Mirror
、Single Display
测试.
此外由于edp
屏幕分辨率为800x1280
,因此我们可以调整方向为Orientation
为Portrait Left
(纵向向左),等价于分辨率调整为1280x800
。
2.3 modetest
安装modetest
root@rk3399:/# cd /opt/
root@rk3399:/opt# wget https://gitlab.freedesktop.org/mesa/drm/-/archive/libdrm-2.4.105/drm-libdrm-2.4.105.tar.gz
root@rk3399:/opt# tar -zvxf drm-libdrm-2.4.105.tar.gz
root@rk3399:/opt# apt-get install meson
root@rk3399:/opt# cd drm-libdrm-2.4.105
root@rk3399:/opt/drm-libdrm-2.4.105# meson builddir/
root@rk3399:/opt/drm-libdrm-2.4.105# ninja -C builddir install
root@rk3399:/opt/drm-libdrm-2.4.105# cp builddir/tests/modetest/modetest /usr/bin/
查看帮助信息:
root@rk3399:/opt/drm-libdrm-2.4.105# modetest -h
usage: modetest [-acDdefMPpsCvrw]
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 index>]<mode>[-<vrefresh>][@<format>] set a mode
-C test hw cursor
-v test vsynced page flipping
-r set the preferred mode for all connectors
-w <obj_id>:<prop_name>:<value> set property
-a use atomic API
-F pattern1,pattern2 specify fill patterns
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.
2.3.1 modetest -c
查看connector
的信息:
root@rk3399:~# modetest -c
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
Connectors:
id encoder status name size (mm) modes encoders
52 51 connected eDP-1 94x150 1 51
modes:
index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot
#0 800x1280 57.00 800 849 882 899 1280 1281 1288 1303 66770 flags: nhsync, nvsync; type: preferred, driver
props:
1 EDID:
flags: immutable blob
blobs:
value:
2 DPMS:
flags: enum
enums: On=0 Standby=1 Suspend=2 Off=3
value: 0
5 link-status:
flags: enum
enums: Good=0 Bad=1
value: 0
6 non-desktop:
flags: immutable range
values: 0 1
value: 0
4 TILE:
flags: immutable blob
blobs:
value:
54 53 connected HDMI-A-1 480x270 9 53
modes:
index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot
#0 1920x1080 60.00 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: preferred, driver
#1 1920x1080 50.00 1920 2448 2492 2640 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: driver
#2 1280x1024 60.02 1280 1328 1440 1688 1024 1025 1028 1066 108000 flags: phsync, pvsync; type: driver
#3 1280x720 60.00 1280 1390 1430 1650 720 725 730 750 74250 flags: phsync, pvsync; type: driver
#4 1024x768 60.00 1024 1048 1184 1344 768 771 777 806 65000 flags: nhsync, nvsync; type: driver
#5 800x600 60.32 800 840 968 1056 600 601 605 628 40000 flags: phsync, pvsync; type: driver
#6 800x600 56.25 800 824 896 1024 600 601 603 625 36000 flags: phsync, pvsync; type: driver
#7 720x576 50.00 720 732 796 864 576 581 586 625 27000 flags: nhsync, nvsync; type: driver
#8 720x480 59.94 720 736 798 858 480 489 495 525 27000 flags: nhsync, nvsync; type: driver
props:
1 EDID:
flags: immutable blob
blobs:
value:
00ffffffffffff00158f942226260000
2e20010380301b782a7ca5a3544ea027
125054a308008100450081809500b300
010101010101023a801871382d40582c
4500db0b1100001e662156aa51001e30
468f3300db0b1100001e000000fc0045
4c4f204554323239344c0a20000000fd
00324b1e5211000a2020202020200151
020312b14701020304901f1165030c00
1000023a801871382d40582c4500db0b
1100001e000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
000000000000000000000000000000db
2 DPMS:
flags: enum
enums: On=0 Standby=1 Suspend=2 Off=3
value: 0
5 link-status:
flags: enum
enums: Good=0 Bad=1
value: 0
6 non-desktop:
flags: immutable range
values: 0 1
value: 0
4 TILE:
flags: immutable blob
blobs:
value:
55 max bpc:
flags: range
values: 8 16
value: 0
7 HDR_OUTPUT_METADATA:
flags: blob
blobs:
value:
可以看到connector
有2个,id
为52
的connector
信息如下;
modes
是和当前connector
关联的modes
个数,当前为1个;encoders
是和当前connector
关联的encoders
列表,如果有多个会按逗号分隔。当前只有id
为51
的encoder
;name
是当前connector
的名称,这里为eDP-1
,连接状态为connected
,对应的edp
显示屏尺寸为94x150
(即7寸屏);
id
为54
的connector
信息如下;
modes
是和当前connector
关联的modes
个数,当前为9个;encoders
是和当前connector
关联的encoders
列表,如果有多个会按逗号分隔。当前只有id
为53
的encoder
;name
是当前connector
的名称,这里为HDMI-A-1
,连接状态为connected
,对应的hdmi
显示屏尺寸为480x270
;
2.3.2 modetest -e
输出当前内核的encoders
,可以看到encoder
有2个,id
为51
的encoder
其连接的crtc
为37
,id
为53
的encoder
其连接的crtc
为44
;
root@rk3399:~# modetest -M rockchip -e
Encoders:
id crtc type possible crtcs possible clones
51 37 TMDS 0x00000003 0x00000001 # 连接edp显示屏
53 44 TMDS 0x00000003 0x00000002 # 连接hdmi显示屏
2.3.3 modetest -p
输出当前内核的crtc
和plane
,从输出信息可以看到有两个crtc
,分别对应vopb
(id
为44
)和vopl
(id
为37
);
root@rk3399:~# modetest -M rockchip -p
CRTCs:
id fb pos size
37 61 (0,0) (800x1280)
#0 800x1280 57.00 800 849 882 899 1280 1281 1288 1303 66770 flags: nhsync, nvsync; type: preferred, driver
props:
24 VRR_ENABLED:
flags: range
values: 0 1
value: 0
28 GAMMA_LUT:
flags: blob
blobs:
value:
00000000000000000101010101010000
0202020202020000030303030303598a
04040404040400000505050505050000
.......
fefefefefefe0000ffffffffffff0000
29 GAMMA_LUT_SIZE:
flags: immutable range
values: 0 4294967295
value: 256
44 63 (0,0) (1920x1080)
#0 1920x1080 60.00 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: preferred, driver
props:
24 VRR_ENABLED:
flags: range
values: 0 1
value: 0
28 GAMMA_LUT:
flags: blob
blobs:
value:
00000000000000004000400040000000
8000800080000000c000c000c0000000
......
3efe3efe3efe00007efe7efe7efe0000
befebefebefe0000fefefefefefe0000
3eff3eff3eff00007eff7eff7eff0000
beffbeffbeff0000ffffffffffff0000
29 GAMMA_LUT_SIZE:
flags: immutable range
values: 0 4294967295
value: 1024
Planes:
id crtc fb CRTC x,y x,y gamma size possible crtcs
31 37 61 0,0 0,0 0 0x00000001
formats: XR24 AR24 XB24 AB24 RG24 BG24 RG16 BG16 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 1
30 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000000e00000018000000
01000000500000005852323441523234
58423234414232345247323442473234
52473136424731364e5631324e563231
4e5631364e5636314e5632344e563432
ff3f0000000000000000000000000000
0000000000000000
in_formats blob decoded:
XR24: LINEAR
AR24: LINEAR
XB24: LINEAR
AB24: LINEAR
RG24: LINEAR
BG24: LINEAR
RG16: LINEAR
BG16: LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR
33 rotation:
flags: bitmask
values: rotate-0=0x1 reflect-x=0x10 reflect-y=0x20
value: 1
34 37 59 0,0 0,0 0 0x00000001
formats: XR24 AR24 XB24 AB24 RG24 BG24 RG16 BG16
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 2
30 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000000800000018000000
01000000380000005852323441523234
58423234414232345247323442473234
5247313642473136ff00000000000000
00000000000000000000000000000000
in_formats blob decoded:
XR24: LINEAR
AR24: LINEAR
XB24: LINEAR
AB24: LINEAR
RG24: LINEAR
BG24: LINEAR
RG16: LINEAR
BG16: LINEAR
36 rotation:
flags: bitmask
values: rotate-0=0x1 reflect-y=0x20
value: 1
38 44 63 0,0 0,0 0 0x00000002
formats: XR24 AR24 XB24 AB24 RG24 BG24 RG16 BG16 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 1
30 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000000e00000018000000
02000000500000005852323441523234
58423234414232345247323442473234
52473136424731364e5631324e563231
4e5631364e5636314e5632344e563432
ff000000000000000000000000000000
5100000000000008ff3f000000000000
00000000000000000000000000000000
in_formats blob decoded:
XR24: (UNKNOWN MODIFIER) LINEAR
AR24: (UNKNOWN MODIFIER) LINEAR
XB24: (UNKNOWN MODIFIER) LINEAR
AB24: (UNKNOWN MODIFIER) LINEAR
RG24: (UNKNOWN MODIFIER) LINEAR
BG24: (UNKNOWN MODIFIER) LINEAR
RG16: (UNKNOWN MODIFIER) LINEAR
BG16: (UNKNOWN MODIFIER) LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR
40 rotation:
flags: bitmask
values: rotate-0=0x1 reflect-x=0x10 reflect-y=0x20
value: 1
41 0 0 0,0 0,0 0 0x00000002
formats: XR24 AR24 XB24 AB24 RG24 BG24 RG16 BG16
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 2
30 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000000800000018000000
01000000380000005852323441523234
58423234414232345247323442473234
5247313642473136ff00000000000000
00000000000000000000000000000000
in_formats blob decoded:
XR24: LINEAR
AR24: LINEAR
XB24: LINEAR
AB24: LINEAR
RG24: LINEAR
BG24: LINEAR
RG16: LINEAR
BG16: LINEAR
43 rotation:
flags: bitmask
values: rotate-0=0x1 reflect-y=0x20
value: 1
45 0 0 0,0 0,0 0 0x00000002
formats: XR24 AR24 XB24 AB24 RG24 BG24 RG16 BG16 NV12 NV21 NV16 NV61 NV24 NV42
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
30 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000000e00000018000000
01000000500000005852323441523234
58423234414232345247323442473234
52473136424731364e5631324e563231
4e5631364e5636314e5632344e563432
ff3f0000000000000000000000000000
0000000000000000
in_formats blob decoded:
XR24: LINEAR
AR24: LINEAR
XB24: LINEAR
AB24: LINEAR
RG24: LINEAR
BG24: LINEAR
RG16: LINEAR
BG16: LINEAR
NV12: LINEAR
NV21: LINEAR
NV16: LINEAR
NV61: LINEAR
NV24: LINEAR
NV42: LINEAR
47 rotation:
flags: bitmask
values: rotate-0=0x1 reflect-x=0x10 reflect-y=0x20
value: 1
48 0 0 0,0 0,0 0 0x00000002
formats: XR24 AR24 XB24 AB24 RG24 BG24 RG16 BG16
props:
8 type:
flags: immutable enum
enums: Overlay=0 Primary=1 Cursor=2
value: 0
30 IN_FORMATS:
flags: immutable blob
blobs:
value:
01000000000000000800000018000000
01000000380000005852323441523234
58423234414232345247323442473234
5247313642473136ff00000000000000
00000000000000000000000000000000
in_formats blob decoded:
XR24: LINEAR
AR24: LINEAR
XB24: LINEAR
AB24: LINEAR
RG24: LINEAR
BG24: LINEAR
RG16: LINEAR
BG16: LINEAR
50 rotation:
flags: bitmask
values: rotate-0=0x1 reflect-y=0x20
value: 1
2.3.4 设置分辨率
在modetest
中通过id
来引用encoder
/ connector
/ CRTC
/ plane
,查看个组件的id
;
root@rk3399:~# modetest -M rockchip | cut -f1 | grep -E ^[0-9A-Z]\|id
Encoders:
id
51
53
Connectors:
id
52
54
CRTCs:
id
37
44
Planes:
id
31
34
38
41
45
48
Frame buffers:
id
更改hdmi
显示屏分辨率为1280x720@60Hz
;
root@rk3399:~# modetest -M rockchip -s 54@44:1280x720-60 # 正常情况下 在对应屏幕会有彩色条纹显示
其中:
54
:hdmi connector id
;44
: 某个vop
的crtc id
;1280x720
:显示 模式;60
:刷新率;
如果出现如下错误:
failed to set mode: Permission denied
大概率是有进程占用了drm
设备;
root@rk3399:~# ps -ef | grep wayland
root 6129 4921 0 16:41 ? 00:00:01 /usr/bin/Xwayland :0 -rootless -noreset -accessx -core -auth /run/user/0/.mutter-Xwaylandauth.GEV8M2 -listen 4 -listen 5 -displayfd 6 -initfd 7
root 4821 4802 0 16:36 tty2 00:00:00 /usr/libexec/gdm-wayland-session env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --session=ubuntu
root@rk3399:~# kill 4821 6129
root@rk3399:~# modetest -M rockchip -s 54@44:1280x720-60 # 可以正常显示
setting mode 1280x720-60.00Hz on connectors 54, crtc 44
root@rk3399:~# modetest -M rockchip -s 52@37:1280x800-57 # 可以正常显示
setting mode 800x1280-57.00Hz on connectors 52, crtc 37
正常情况下在对应屏幕会有彩色条纹显示;
2.4 查看调试信息
DRM
子系统内核debug
日志位于/sys/kernel/debug/dri/
:
root@rk3399:~# ll /sys/kernel/debug/dri/
drwxr-xr-x 5 root root 0 Jan 1 1970 0/
drwxr-xr-x 2 root root 0 Jan 1 1970 1/
drwxr-xr-x 2 root root 0 Jan 1 1970 128/
root@rk3399:~# ll /sys/kernel/debug/dri/0/
drwxr-xr-x 2 root root 0 Jan 1 1970 HDMI-A-1/
-r--r--r-- 1 root root 0 Jan 1 1970 clients
drwxr-xr-x 3 root root 0 Jan 1 1970 crtc-0/
drwxr-xr-x 3 root root 0 Jan 1 1970 crtc-1/
-r--r--r-- 1 root root 0 Jan 1 1970 framebuffer
-r--r--r-- 1 root root 0 Jan 1 1970 gem_names
-r--r--r-- 1 root root 0 Jan 1 1970 internal_clients
-r--r--r-- 1 root root 0 Jan 1 1970 name
-r--r--r-- 1 root root 0 Jan 1 1970 state
2.4.1 查看设备名称
root@rk3399:~# cat /sys/kernel/debug/dri/1/name
rockchip dev=display-subsystem unique=display-subsystem
2.4.2 查看framebuffer
查看framebuffer
信息:
root@rk3399:~# cat /sys/kernel/debug/dri/1/framebuffer
framebuffer[57]:
allocated by = gnome-shell
refcount=2
format=XR24 little-endian (0x34325258)
modifier=0x0
size=800x1280
layers:
size[0]=800x1280
pitch[0]=3200
offset[0]=0
obj[0]:
name=0
refcount=3
start=00000000
size=4132864
imported=no
framebuffer[65]:
allocated by = gnome-shell
refcount=2
format=XR24 little-endian (0x34325258)
modifier=0x800000000000051
size=1920x1080
layers:
size[0]=1920x1080
pitch[0]=7680
offset[0]=0
obj[0]:
name=0
refcount=4
start=00000000
size=8556544
imported=no
framebuffer[56]:
allocated by = [fbcon]
refcount=1
format=XR24 little-endian (0x34325258)
modifier=0x0
size=1920x1280
layers:
size[0]=1920x1280
pitch[0]=7680
offset[0]=0
obj[0]:
name=0
refcount=2
start=00000000
size=9830400
imported=no
2.5 其它配置
2.5.1 虚拟键盘
既然我们已经点亮了eDP
屏幕,并且触摸屏可以使用了,那么我们是否可以放弃键盘,然后安装一个虚拟键盘呢?
执行如下命令:
root@rk3399:~# apt install onboard
下载完后去Settings
-Accessibility
- Typing
,然后把Screen Keyboard
设置为on
便可以使用。
2.5.2 设置中文语言
输入以下命令:
root@rk3399:~# dpkg-reconfigure locales
执行之后可以使用空格选择,Tab
键跳转光标,这里用空格选中 zh_CN.UTF-8
,并取消其它选择;
选择OK
之后,会要求为系统设置一个默认的locale
,设置为 zh_CN.UTF-8
;
重启系统,查看系统所有可用的locale
:
root@rk3399:~# locale -a
C
C.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX
zh_CN.utf8
使用locale
命令可以查询当前环境中所有的本地化信息,包括语言、字符集、货币格式等,具体操作如下:
root@rk3399:~# locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
2.5.3 安装中文输入法
打开设置面板Settings
,点击 Region & Language
, 确认存在语言”汉语(中国)“,如果不存在,点击Manage Instaled Languages
;
点击Install/Remove Language
,勾选Chinese(Simplified)
,点击 Apply
按钮。再点击Apply System-Wide
。
重启系统,重启后再次打开设置面板,点击Keyboard
,点击+号按钮,添加 Chinese(Intelligent Pinyin)
。
2.5.4 安装Chromium
运行以下命令以安装Chromium
浏览器:
root@rk3399:~# apt install dialog
root@rk3399:~# apt install chromium-browser
这样,您就成功在ubuntu 22.04
上安装了Chromium
浏览器。可以在应用程序菜单中搜索并启动Chromium
浏览器,或者在终端中运行chromium-browser
命令来启动它。
root@rk3399:~# export DISPLAY=:0.0; chromium-browser --no-sandbox --user-data-dir
2.5.4 清理磁盘
清理日志文件,这会删除较旧的系统日志文件,保留指定大小内的日志文件;
root@rk3399:~# journalctl --vacuum-size=30M
卸载所有自动安装且不再使用的软件包:
root@rk3399:~# apt autoremove --purge
动态调整 tmpfs
大小,修改/etc/fstab
;
tmpfs /dev/shm tmpfs defaults,size=300m 0 0
tmpfs /run tmpfs defaults,size=200m 0 0
完成修改后,可以重新加载 tmpfs
:
root@rk3399:~# sudo mount -o remount /dev/shm
root@rk3399:~# sudo mount -o remount /run
2.6 异常处理
对于ubuntu 22.04
系统很容易出现如下错误:
Oh no! Something has gone wrong. A problem has occurred and the system can't recover. please log out and try again.
可以尝试安装一下组件:
root@rk3399:~# apt-install upgrade
root@rk3399:~# dpkg --configure -a
root@rk3399:~# apt remove gnome-session gnome gnome-shell
root@rk3399:~# apt autoremove
root@rk3399:~# apt install --reinstall ubuntu-desktop
接着尝试安装一下lightdm
:
root@rk3399:~# apt install lightdm
root@rk3399:~# dpkg-reconfigure lightdm
选择lightdm
:
![](https://gitee.com/zyly2033/blog-pic/raw/master/202405020039958.png)
lightdm
是一个轻量级的显示管理器,它设计简洁、可定制性强。lightdm
不依赖于特定的桌面环境,可以与多种桌面环境配合使用,如GNOME
、Unity
、XFCE
、LXDE
等。lightdm
提供了一个标准的登录界面,用户可以通过该界面登录系统。- 由于其灵活性,
LightDM
也被许多其他Linux
发行版采用为默认的显示管理器。
这样重启系统后,登陆时我们就可以将服务器协议从默认的Wayland
切换成Xorg
;
参考文章