----------------------------------------------------------------------------------------------------------------------------
开发板 :NanoPC-T4
开发板
eMMC
:16GB
LPDDR3
:4GB
显示屏 :15.6
英寸HDMI
接口显示屏
u-boot
:2023.04
linux
:6.3
----------------------------------------------------------------------------------------------------------------------------
一、烧录内核
1.1 配置内核
在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(默认开启)
<*> Synopsys Designware AHB Audio interface # CONFIG_DRM_DW_HDMI_AHB_AUDIO
<*> Synopsys Designware I2S Audio interface # CONFIG_DRM_DW_HDMI_I2S_AUDIO
<*> Synopsys Designware GP Audio interface # CONFIG_DRM_DW_HDMI_I2S_AUDIO
<*> Synopsis Designware CEC interface # CONFIG_DRM_DW_HDMI_CEC
Device Drivers --->
PHY Subsystem --->
<M> Rockchip INNO HDMI PHY Driver
HDMI PHY
使用的是DesignWare HDMI IP
,并没有使用Innosilicon IP
。因此可以不用选择Rockchip INNO HDMI PHY Driver
。
CONFIG_DRM_DW_HDMI
对应的驱动位于drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
。
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
1.5 启动内核
将开发板和HDMI
显示器(显示器支持分辨率是12560x1440@144Hz
)通过HDMI
线缆连接起来,然后给开发板上电启动。内核输入有关hdmi
日志:
[ 0.539951] platform ff940000.hdmi: Fixed dependency cycle(s) with /vop@ff8f0000/port/endpoint@2
[ 0.549676] platform ff940000.hdmi: Fixed dependency cycle(s) with /vop@ff900000/port/endpoint@2
[ 1.430309] rockchip-vop ff8f0000.vop: Adding to iommu group 2
[ 1.437640] rockchip-vop ff900000.vop: Adding to iommu group 3
[ 1.450511] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops)
[ 1.459516] [drm] unsupported AFBC format[3231564e]
[ 1.466072] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops)
[ 1.475048] dwhdmi-rockchip ff940000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 1.484573] dwhdmi-rockchip ff940000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 4.136104] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops)
[ 4.146266] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops)
[ 4.155351] dwhdmi-rockchip ff940000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 4.164983] dwhdmi-rockchip ff940000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 4.174627] dwhdmi-rockchip ff940000.hdmi: Detected HDMI TX controller v2.11a with HDCP (DWC HDMI 2.0 TX PHY)
[ 4.188847] rockchip-drm display-subsystem: bound ff940000.hdmi (ops dw_hdmi_rockchip_ops)
[ 4.199257] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0
[ 4.331400] Console: switching to colour frame buffer device 240x67
[ 4.382497] rockchip-drm display-subsystem: [drm] fb0: rockchipdrmfb frame buffer device
[ 5.035286] [drm] Initialized panfrost 1.2.0 20180908 for ff9a0000.gpu on minor 1
二、hdmi
调试
2.1 查看hdmi
信息
在/sys/class/drm
目录下可以看到驱动注册的各个显卡,DRM
设备节点为 /dev/dri/cardX
,,X为0-15
的数值;
root@rk3399:~# ll /dev/dri/
drwxr-xr-x 2 root root 100 Mar 15 23:04 by-path/
crw-rw----+ 1 root video 226, 0 Mar 15 23:07 card0
crw-rw----+ 1 root video 226, 1 Mar 15 23:04 card1
crw-rw----+ 1 root render 226, 128 Mar 15 23:04 renderD128
root@rk3399:~# ll /sys/class/drm
lrwxrwxrwx 1 root root 0 Mar 15 23:04 card0 -> ../../devices/platform/display-subsystem/drm/card0/
lrwxrwxrwx 1 root root 0 Mar 15 23:04 card0-HDMI-A-1 -> ../../devices/platform/display-subsystem/drm/card0/card0-HDMI-A-1/
lrwxrwxrwx 1 root root 0 Mar 15 23:04 card1 -> ../../devices/platform/ff9a0000.gpu/drm/card1/
lrwxrwxrwx 1 root root 0 Mar 15 23:04 renderD128 -> ../../devices/platform/ff9a0000.gpu/drm/renderD128/
-r--r--r-- 1 root root 4096 Mar 15 23:04 version
其中card0-HDMI-A-1
代表的是HDMI
显示设备,是由drm_sysfs_connector_add
函数创建的,位于drivers/gpu/drm/drm_sysfs.c
;
static DEVICE_ATTR_RW(status);
static DEVICE_ATTR_RO(enabled);
static DEVICE_ATTR_RO(dpms);
static DEVICE_ATTR_RO(modes);
static struct attribute *connector_dev_attrs[] = {
&dev_attr_status.attr,
&dev_attr_enabled.attr,
&dev_attr_dpms.attr,
&dev_attr_modes.attr,
NULL
};
// edid文件属性
static struct bin_attribute edid_attr = {
.attr.name = "edid",
.attr.mode = 0444,
.size = 0,
.read = edid_show,
};
static struct bin_attribute *connector_bin_attrs[] = {
&edid_attr,
NULL
};
static const struct attribute_group connector_dev_group = {
.attrs = connector_dev_attrs,
.bin_attrs = connector_bin_attrs,
};
static const struct attribute_group *connector_dev_groups[] = {
&connector_dev_group,
NULL
};
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;
// 动态分配内存,指向struct device
kdev = kzalloc(sizeof(*kdev), GFP_KERNEL);
if (!kdev)
return -ENOMEM;
// 初始化设备,这个函数是device_register函数的前半部分的实现,主要用于设备的初始化
device_initialize(kdev);
// 设置设备class
kdev->class = drm_class;
kdev->type = &drm_sysfs_device_connector;
// 设置父设备,一般为显卡设备card0,位于/sys/devices/platform/display-subsystem/drm/card0/
kdev->parent = dev->primary->kdev;
kdev->groups = connector_dev_groups;
kdev->release = drm_sysfs_release;
// 设置驱动私有数据
dev_set_drvdata(kdev, connector);
// 设置设备名称 比如:card0-HDMI-A-1
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);
// 在/sys/class/drm/创建card%d-%s文件,同时创建设备节点/dev/drm/card%d-%s
r = device_add(kdev);
if (r) {
drm_err(dev, "failed to register connector device: %d\n", r);
goto err_free;
}
connector->kdev = kdev;
// 连接器如果指定了ddc通道
if (connector->ddc)
// 创建ddc链接文件
return sysfs_create_link(&connector->kdev->kobj,
&connector->ddc->dev.kobj, "ddc");
return 0;
err_free:
put_device(kdev);
return r;
}
查看card0-HDMI-A-1
目录结构;
root@rk3399:~# ll /sys/class/drm/card0-HDMI-A-1/
lrwxrwxrwx 1 root root 0 Mar 15 23:14 ddc -> ../../../../ff160000.i2c/i2c-7/
lrwxrwxrwx 1 root root 0 Mar 15 23:14 device -> ../../card0/
-r--r--r-- 1 root root 4096 Mar 15 23:14 dpms
-r--r--r-- 1 root root 0 Mar 15 23:14 edid
-r--r--r-- 1 root root 4096 Mar 15 23:04 enabled
-r--r--r-- 1 root root 4096 Mar 15 23:14 modes
drwxr-xr-x 2 root root 0 Mar 15 23:14 power/
-rw-r--r-- 1 root root 4096 Mar 15 23:04 status
lrwxrwxrwx 1 root root 0 Mar 15 23:04 subsystem -> ../../../../../../class/drm/
-rw-r--r-- 1 root root 4096 Mar 15 23:04 uevent
其中:
ddc
:HDMI
显示数据通道,指向i2c7
,用来获取EDID
、HDCP
密钥等内容;device
:指向card0
;edid
:存储HDMI
显示器的扩展显示标识数据;enabled
:HDMI
接口是否被启用或禁用;modes
:连接的HDMI
显示器支持的分辨率列表;status
:HDMI
接口连接状态的信息;
2.1.1 查看hdmi
使能状态
查看HDMI
输出使能状态:
root@rk3399:~# cat /sys/class/drm/card0-HDMI-A-1/enabled
enabled
如果将HDMI
线拔掉:
root@rk3399:~# cat /sys/class/drm/card0-HDMI-A-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 查看hdmi
连接状态
查看HDMI
的插拔连接状态;
root@rk3399:~# cat /sys/class/drm/card0-HDMI-A-1/status
connected
如果将HDMI
线拔掉:
root@rk3399:~# cat /sys/class/drm/card0-HDMI-A-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
信息,一共256个字节;
root@rk3399:/# cat /sys/class/drm/card0-HDMI-A-1/edid > /data/edid.bin
root@rk3399:/# hexdump -C /data/edid.bin
00000000 00 ff ff ff ff ff ff 00 35 34 00 00 01 01 01 01 |........54......|
00000010 00 20 01 03 81 00 00 78 ee 8c 75 a9 54 45 98 22 |. .....x..u.TE."|
00000020 1e 50 54 2f cf 00 71 40 81 c0 81 80 95 00 a9 c0 |.PT/..q@........|
00000030 b3 00 d1 c0 d1 00 d3 bc 00 a0 a0 a0 29 50 30 20 |............)P0 |
00000040 35 00 b9 88 21 00 00 1a 56 5e 00 a0 a0 a0 29 50 |5...!...V^....)P|
00000050 30 20 35 00 b9 88 21 00 00 1a 67 e2 00 a0 a0 a0 |0 5...!...g.....|
00000060 29 50 30 20 35 00 b9 88 21 00 00 1a 00 00 00 fc |)P0 5...!.......|
00000070 00 4d 45 49 54 49 41 4e 48 41 4f 0a 20 20 01 0b |.MEITIANHAO. ..|
00000080 02 03 3a f2 4f 04 05 10 13 14 1f 6c 6c 6c 27 6c |..:.O......lll'l|
00000090 6c 6c 4b 4c e2 00 d5 e3 05 c0 00 23 09 7f 07 83 |llKL.......#....|
000000a0 01 00 00 67 03 0c 00 10 00 38 78 e6 06 05 01 69 |...g.....8x....i|
000000b0 69 4f 67 d8 5d c4 01 76 c0 00 02 3a 80 18 71 38 |iOg.]..v...:..q8|
000000c0 2d 40 58 2c 25 00 58 c3 10 00 00 1e d4 bc 00 a0 |-@X,%.X.........|
000000d0 a0 a0 29 50 30 20 35 00 b9 88 21 00 00 1e 98 e2 |..)P0 5...!.....|
000000e0 00 a0 a0 a0 29 50 30 20 35 00 b9 88 21 00 00 1e |....)P0 5...!...|
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c4 |................|
这里我们尝试通过EDID Manager
工具去解析,首先需要去下载EDID Manager
工具,然后将edid.bin
下载到windows系统上,并加载文件解析内容如下:
Time: 21:03:42
Date: 2023年11月9日
EDID Manager Version: 1.0.0.14
___________________________________________________________________
Block 0 (EDID Base Block), Bytes 0 - 127, 128 BYTES OF EDID CODE:
0 1 2 3 4 5 6 7 8 9
000 | 00 FF FF FF FF FF FF 00 35 34
010 | 00 00 01 01 01 01 00 20 01 03
020 | 81 00 00 78 EE 8C 75 A9 54 45
030 | 98 22 1E 50 54 2F CF 00 71 40
040 | 81 C0 81 80 95 00 A9 C0 B3 00
050 | D1 C0 D1 00 D3 BC 00 A0 A0 A0
060 | 29 50 30 20 35 00 B9 88 21 00
070 | 00 1A 56 5E 00 A0 A0 A0 29 50
080 | 30 20 35 00 B9 88 21 00 00 1A
090 | 67 E2 00 A0 A0 A0 29 50 30 20
100 | 35 00 B9 88 21 00 00 1A 00 00
110 | 00 FC 00 4D 45 49 54 49 41 4E
120 | 48 41 4F 0A 20 20 01 0B
(8-9) ID Manufacture Name : MIT
(10-11) ID Product Code : 0000
(12-15) ID Serial Number : N/A
(16) Week of Manufacture : 0
(17) Year of Manufacture : 2022
(18) EDID Version Number : 1
(19) EDID Revision Number: 3
(20) Video Input Definition : Digital
DFP 1.x Compatible
(21) Maximum Horizontal Image Size: 0 cm
(22) Maximum Vertical Image Size : 0 cm
(23) Display Gamma : 2.20
(24) Power Management and Supported Feature(s):
Standby, Suspend, Active Off/Very Low Power, RGB Color, sRGB, Preferred Timing Mode
(25-34) Color Characteristics
Red Chromaticity : Rx = 0.658 Ry = 0.328
Green Chromaticity : Gx = 0.269 Gy = 0.594
Blue Chromaticity : Bx = 0.134 By = 0.120
Default White Point: Wx = 0.313 Wy = 0.329
(35) Established Timings I
640 x 480 @ 60Hz (IBM, VGA)
640 x 480 @ 72Hz (VESA)
640 x 480 @ 75Hz (VESA)
800 x 600 @ 56Hz (VESA)
800 x 600 @ 60Hz (VESA)
(36) Established Timings II
800 x 600 @ 72Hz (VESA)
800 x 600 @ 75Hz (VESA)
1024 x 768 @ 60Hz (VESA)
1024 x 768 @ 70Hz(VESA)
1024 x 768 @ 75Hz (VESA)
1280 x 1024 @ 75Hz (VESA)
(37) Manufacturer's Timings (Not Used)
(38-53) Standard Timings
1152x864 @ 60 Hz (4:3 Aspect Ratio)
1280x720 @ 60 Hz (16:9 Aspect Ratio)
1280x1024 @ 60 Hz (5:4 Aspect Ratio)
1440x900 @ 60 Hz (16:10 Aspect Ratio)
1600x900 @ 60 Hz (16:9 Aspect Ratio)
1680x1050 @ 60 Hz (16:10 Aspect Ratio)
1920x1080 @ 60 Hz (16:9 Aspect Ratio)
1920x1200 @ 60 Hz (16:10 Aspect Ratio)
(54-71) Detailed Descriptor #1: Preferred Detailed Timing (2560x1440 @ 120Hz)
Pixel Clock : 483.39 MHz
Horizontal Image Size : 697 mm
Vertical Image Size : 392 mm
Refresh Mode : Non-interlaced
Normal Display, No Stereo
Horizontal:
Active Time : 2560 Pixels
Blanking Time : 160 Pixels
Sync Offset : 48 Pixels
Sync Pulse Width: 32 Pixels
Border : 0 Pixels
Frequency : 177 kHz
Vertical:
Active Time : 1440 Lines
Blanking Time : 41 Lines
Sync Offset : 3 Lines
Sync Pulse Width: 5 Lines
Border : 0 Lines
Digital Separate, Horizontal Polarity (+), Vertical Polarity (-)
Modeline: "2560x1440" 483.390 2560 2608 2640 2720 1440 1443 1448 1481 +hsync -vsync
(72-89) Detailed Descriptor #2: Detailed Timing (2560x1440 @ 60Hz)
Pixel Clock : 241.5 MHz
Horizontal Image Size : 697 mm
Vertical Image Size : 392 mm
Refresh Mode : Non-interlaced
Normal Display, No Stereo
Horizontal:
Active Time : 2560 Pixels
Blanking Time : 160 Pixels
Sync Offset : 48 Pixels
Sync Pulse Width: 32 Pixels
Border : 0 Pixels
Frequency : 88 kHz
Vertical:
Active Time : 1440 Lines
Blanking Time : 41 Lines
Sync Offset : 3 Lines
Sync Pulse Width: 5 Lines
Border : 0 Lines
Digital Separate, Horizontal Polarity (+), Vertical Polarity (-)
Modeline: "2560x1440" 241.500 2560 2608 2640 2720 1440 1443 1448 1481 +hsync -vsync
(90-107) Detailed Descriptor #3: Detailed Timing (2560x1440 @ 144Hz)
Pixel Clock : 579.59 MHz
Horizontal Image Size : 697 mm
Vertical Image Size : 392 mm
Refresh Mode : Non-interlaced
Normal Display, No Stereo
Horizontal:
Active Time : 2560 Pixels
Blanking Time : 160 Pixels
Sync Offset : 48 Pixels
Sync Pulse Width: 32 Pixels
Border : 0 Pixels
Frequency : 213 kHz
Vertical:
Active Time : 1440 Lines
Blanking Time : 41 Lines
Sync Offset : 3 Lines
Sync Pulse Width: 5 Lines
Border : 0 Lines
Digital Separate, Horizontal Polarity (+), Vertical Polarity (-)
Modeline: "2560x1440" 579.590 2560 2608 2640 2720 1440 1443 1448 1481 +hsync -vsync
(108-125) Detailed Descriptor #4: Monitor Name
Monitor Name: MEITIANHAO
(126-127) Extension Flag and Checksum
Extension Block(s) : 1
Checksum Value : 11
___________________________________________________________________
Block 1 ( CEA-861 Extension Block), Bytes 128 - 255, 128 BYTES OF EDID CODE:
0 1 2 3 4 5 6 7 8 9
128 | 02 03 3A F2 4F 04 05 10 13 14
138 | 1F 6C 6C 6C 27 6C 6C 6C 4B 4C
148 | E2 00 D5 E3 05 C0 00 23 09 7F
158 | 07 83 01 00 00 67 03 0C 00 10
168 | 00 38 78 E6 06 05 01 69 69 4F
178 | 67 D8 5D C4 01 76 C0 00 02 3A
188 | 80 18 71 38 2D 40 58 2C 25 00
198 | 58 C3 10 00 00 1E D4 BC 00 A0
208 | A0 A0 29 50 30 20 35 00 B9 88
218 | 21 00 00 1E 98 E2 00 A0 A0 A0
228 | 29 50 30 20 35 00 B9 88 21 00
238 | 00 1E 00 00 00 00 00 00 00 00
248 | 00 00 00 00 00 00 00 C4
(128-130) Extension Header
Revision Number : 3
DTD Starting Offset: 58
(131) Display Support
DTV Underscan, Basic Audio, YCbCr 4:4:4, YCbCr 4:2:2
Number of Native Formats: 2
(132-147) Video Data Block
1280x720p @ 59.94/60Hz - HDTV (16:9, 1:1)
1920x1080i @ 59.94/60Hz - HDTV (16:9, 1:1)
1920x1080p @ 59.94/60Hz - HDTV (16:9, 1:1)
1280x720p @ 50Hz - HDTV (16:9, 1:1)
1920x1080i @ 50Hz - HDTV (16:9, 1:1)
1920x1080p @ 50Hz - HDTV (16:9, 1:1)
Reserved for the Future
Reserved for the Future
Reserved for the Future
1920x1080i (1250 total) - HDTV 50Hz (16:9, 1:1)
Reserved for the Future
Reserved for the Future
Reserved for the Future
Reserved for the Future
Reserved for the Future
(148-150) Video Capability Data Block (VCDB)
(151-154) Colorimetry Data Block
我们重点留意Established Timings
、Standard Timings
、Detailed Timings
,通过分析EDID
我们知道我是用的这款HDMI
显示器支持的时序有:
640 x 480 @ 60Hz (IBM, VGA)
;640 x 480 @ 72Hz (VESA)
;640 x 480 @ 75Hz (VESA)
;800 x 600 @ 56Hz (VESA)
;800 x 600 @ 60Hz (VESA)
;800 x 600 @ 72Hz (VESA)
;800 x 600 @ 75Hz (VESA)
;1024 x 768 @ 60Hz (VESA)
;1024 x 768 @ 70Hz(VESA)
;1024 x 768 @ 75Hz (VESA)
;1280 x 1024 @ 75Hz (VESA)
;1152x864 @ 60 Hz (4:3 Aspect Ratio)
;1280x720 @ 60 Hz (16:9 Aspect Ratio)
;1280x1024 @ 60 Hz (5:4 Aspect Ratio);
1440x900 @ 60 Hz (16:10 Aspect Ratio);
1600x900 @ 60 Hz (16:9 Aspect Ratio)
;1680x1050 @ 60 Hz (16:10 Aspect Ratio);
1920x1080 @ 60 Hz (16:9 Aspect Ratio);
1920x1200 @ 60 Hz (16:10 Aspect Ratio)
;2560x1440 @ 120Hz
最佳时序;2560x1440 @ 60Hz
;2560x1440 @ 144Hz
;
2.1.4 分辨率
查看HDMI
显示器支持的分辨率列表;
root@rk3399:~# cat /sys/class/drm/card0-HDMI-A-1/modes
1920x1080
1920x1080
1920x1080
1920x1080i
1920x1080
1920x1080
1920x1080i
1600x900
1280x1024
1280x720
1280x720
1280x720
1024x768
800x600
800x600
再使用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支持的dispaly mode
list_for_each_entry(mode, &connector->modes, head) {
// 写入到buf
written += scnprintf(buf + written, PAGE_SIZE - written, "%s\n",
mode->name);
}
mutex_unlock(&connector->dev->mode_config.mutex);
return written;
}
在桌面系统打开终端,运行如下命令查看当前分辨率:
root@rk3399:/data# xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 4096 x 4096
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 697mm x 392mm
1920x1080 60.00 60.00* 50.00
1920x1080i 60.00 50.00
1600x900 60.00
1280x1024 60.02
1280x720 60.00 50.00
1024x768 60.00
800x600 60.32 56.25
可以看到当前分辨率为1920 x 1080
,实际上我们从EDID
信息中了解到我们使用的HDMI
显示器的最佳时序是2560x1440 @ 120Hz
。
然而这里默认确是1920 x 1080
,这主要是因为我们的驱动中并没有支持2560x1440
的分辨率。因此我们需要新增2560x1440
分辨率时序。
2.1.5 新增特殊分辨率时序
DRM
框架目前代码已经支持了绝大部分分辨率时序,但是还有一些特殊分辨率不支持,那么就需要在 drivers/gpu/drm/drm_edid.c
中的drm_dmt_modes
的末尾新增项目。以drm_dmt_modes
最后一项为例介绍:
/*
* Autogenerated from the DMT spec.
* This table is copied from xfree86/modes/xf86EdidModes.c.
*/
static const struct drm_display_mode drm_dmt_modes[] = {
......
/* 0x4d - 2560x1600@60Hz */
{ DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752,
3032, 3504, 0, 1600, 1603, 1609, 1658, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
.....
/* 0x58 - [email protected] RB */
{ DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 556188, 4096, 4104,
4136, 4176, 0, 2160, 2208, 2216, 2222, 0,
DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
}
其中:
4096x2160
:display mode name
,为分辨率的hdisplay x vdisplay
;DRM_MODE_TYPE_DRIVER
:display mode type
,配置为DRM_MODE_TYPE_DRIVER
;556188
:clock
,像素时钟;4096
:hdisplay
,行有效像素;4104
:hsync_start
,行同步起始像素;4136
:hsync_end
,行同步结束像素;4176
:htotal
,一行总像素;- 0:
hskew
,行偏差,通常为 0; 2160
:vdisplay
,帧有效行;2208
:vsync_start
,帧同步开始行;2216
:vsync_end
,帧同步结束行;2222
:vtotal
,一帧总行数;- 0:
vscan
, 帧扫描信号,通常为 0; DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC
:flags
,hsync
和vsync
极性;
具体时序说明见下图:
更多细节参考文章:《Rockchip RK3399 - DRM crtc
基础知识》。
2.2 查看调试信息
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.2.1 查看设备名称
root@rk3399:~# cat /sys/kernel/debug/dri/0/name
rockchip dev=display-subsystem unique=display-subsystem
2.2.2 查看framebuffer
查看framebuffer
信息:
root@rk3399:~# cat /sys/kernel/debug/dri/0/framebuffer
framebuffer[56]:
allocated by = Xorg
refcount=2
format=XR24 little-endian (0x34325258)
modifier=0x0
size=1920x1080
layers:
size[0]=1920x1080
pitch[0]=7680
offset[0]=0
obj[0]:
name=0
refcount=5
start=00000000
size=8294400
imported=no
framebuffer[61]:
allocated by = Xorg
refcount=1
format=AR24 little-endian (0x34325241)
modifier=0x0
size=64x64
layers:
size[0]=64x64
pitch[0]=256
offset[0]=0
obj[0]:
name=0
refcount=3
start=00100000
size=16384
imported=no
framebuffer[54]:
allocated by = [fbcon]
refcount=1
format=XR24 little-endian (0x34325258)
modifier=0x0
size=1920x1080
layers:
size[0]=1920x1080
pitch[0]=7680
offset[0]=0
obj[0]:
name=0
refcount=2
start=00000000
size=8294400
imported=no
参考文章
[1] [Rockchip_Developer_Guide_HDMI_CN
]
[3] LVDS+HDMI
输出特殊分辨率800*1280
竖屏
[5] EDID
的简介和解析