首页 > 其他分享 >Rockchip RK3399 - DRM HDMI调试

Rockchip RK3399 - DRM HDMI调试

时间:2023-11-14 23:33:53浏览次数:41  
标签:00 HDMI -- Rockchip connector RK3399 DRM drm root

----------------------------------------------------------------------------------------------------------------------------

开发板 :NanoPC-T4开发板
eMMC16GB
LPDDR34GB
显示屏 :15.6英寸HDMI接口显示屏
u-boot2023.04
linux6.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 保存配置

配置完内核之后记得保存配置:

img

存档:

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命令将内核镜像烧录到eMMC0x8000个扇区处:

=> 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

其中:

  • ddcHDMI显示数据通道,指向i2c7,用来获取EDIDHDCP密钥等内容;
  • device:指向card0
  • edid:存储HDMI显示器的扩展显示标识数据;
  • enabledHDMI接口是否被启用或禁用;
  • modes:连接的HDMI显示器支持的分辨率列表;
  • statusHDMI接口连接状态的信息;
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 TimingsStandard TimingsDetailed 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) },
}

其中:

  • 4096x2160display mode name,为分辨率的hdisplay x vdisplay
  • DRM_MODE_TYPE_DRIVERdisplay mode type,配置为DRM_MODE_TYPE_DRIVER
  • 556188clock,像素时钟;
  • 4096hdisplay,行有效像素;
  • 4104hsync_start,行同步起始像素;
  • 4136hsync_end,行同步结束像素;
  • 4176htotal,一行总像素;
  • 0:hskew,行偏差,通常为 0;
  • 2160vdisplay,帧有效行;
  • 2208vsync_start,帧同步开始行;
  • 2216vsync_end,帧同步结束行;
  • 2222vtotal,一帧总行数;
  • 0:vscan, 帧扫描信号,通常为 0;
  • DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNCflagshsyncvsync极性;

具体时序说明见下图:

img

更多细节参考文章:《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]

[2] DesignWare HDMI IP 解决方案

[3] LVDS+HDMI输出特殊分辨率800*1280竖屏

[4] Linux DRM那些事-HDMI接口EDID获取

[5] EDID的简介和解析

[6] 什么是EDIDEDID能做什么,EDID基本介绍

标签:00,HDMI,--,Rockchip,connector,RK3399,DRM,drm,root
From: https://www.cnblogs.com/zyly/p/17832856.html

相关文章

  • Rockchip RK3399 - DRM encoder、connector基础知识
    3.1.3structdrm_connectorlinux内核使用structdrm_connector来表示一个连接器,用于连接编码器和显示设备。3.1.3structdrm_encoderlinux内核使用structdrm_encoder来表示一个编码器,用于连接CRT控制器和显示设备。3.2structdrm_devicelinux内核使用structdrm_device来......
  • Rockchip RK3399 - DRM HDMI驱动程序
    ----------------------------------------------------------------------------------------------------------------------------开发板:NanoPC-T4开发板eMMC:16GBLPDDR3:4GB显示屏:15.6英寸HDMI接口显示屏u-boot:2023.04linux:6.3----------------------------------......
  • Rockchip RK3399 - DRM encoder、connector基础知识
    3.1.3structdrm_connectorlinux内核使用structdrm_connector来表示一个连接器,用于连接编码器和显示设备。3.1.3structdrm_encoderlinux内核使用structdrm_encoder来表示一个编码器,用于连接CRT控制器和显示设备。3.2structdrm_devicelinux内核使用structdrm_device来......
  • Rockchip RK3399 - DRM eDP驱动程序
    在《RockchipRK3399-DRM驱动程序》》我们已经介绍过了,RK3399有两个VOP,均可以支持HDMI、eDP、DP、MIPIDSI0、MIPIDSI1显示接口,本节我们选择eDP作为分析的对象。一、设备树配置1.1edp设备节点设备节点vopb下的子节点vopb_out_edp通过edp_in_vopb(由remote-endpoint属性指定)......
  • Rockchip RK3399 - DRM crtc基础知识
    一、LCD硬件原理1.1CRT介绍CRT是阴极射线管(CathodeRayTube)的缩写,它是一种使用电子束在荧光屏上创建图像的显示设备。CRT显示器在过去很长一段时间内是主流的显示技术,现已被液晶显示屏或其他新兴技术所替代。在CRT显示器中,扫描电子束从左到右、从上到下移动,照亮屏幕上的荧光......
  • Rockchip RK3399 - DRM eDP驱动程序
    在《RockchipRK3399-DRM驱动程序》》我们已经介绍过了,RK3399有两个VOP,均可以支持HDMI、eDP、DP、MIPIDSI0、MIPIDSI1显示接口,本节我们选择eDP作为分析的对象。一、设备树配置1.1edp设备节点设备节点vopb下的子节点vopb_out_edp通过edp_in_vopb(由remote-endpoint属性指定)......
  • Rockchip RK3399 - linux下抓取usb数据包
    ----------------------------------------------------------------------------------------------------------------------------开发板:NanoPC-T4开发板eMMC:16GBLPDDR3:4GB显示屏:15.6英寸HDMI接口显示屏u-boot:2017.09linux:4.19----------------------------------......
  • Rockchip RK3399 - linux-headers制作(linux 4.19)
    linux-headers(内核头文件)包含各种头文件,可以让设备具有本地编译驱动的能力。一、制作linux-headers这一节我们借助friendly提供的工具来编译linux-headers,编译的内核的内核也是friendly提供的linux4.19版本。1.1下载工具和固件root@zhengyang:/work/sambashare/rk3399/frien......
  • Rockchip RK3399 - USB触摸屏接口驱动
    ----------------------------------------------------------------------------------------------------------------------------开发板:NanoPC-T4开发板eMMC:16GBLPDDR3:4GB显示屏:15.6英寸HDMI接口显示屏u-boot:2023.04linux:6.3----------------------------------......
  • Rockchip RK3399 - USB OTG和extcon驱动
    一、USBOTGUSB是主从模式的总线,主机称为Host,丛机称为Device(设备)。从机与从机之间、主机与主机之间(不包括USB4.0),不能互联。每次通信都是由主机发起,从机不能主动发起通信,只能被动的应答主机的请求。USBOTG(On-The-Go)是一个扩展的USB标准,允许USB设备之间直接进行通信,而无需通......