欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

RK3399 HDMI接口了解

程序员文章站 2022-06-24 10:02:40
涉及文件kernel/drivers/gpu/drm/drm_edid.ckernel/drivers/gpu/drm/rockchip/inno_hdmi.ckernel/drivers/gpu/drm/rockchip/inno_hdmi.hkernel/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c部分代码kernel/drivers/gpu/drm/drm_edid.c/* * Autogenerated from the DMT spec...

文章的主要目的是为了记录,其次希望自己做的东西越来越多以后,可以把这些东西整合、重塑,让自己的知识体系更加的立体、完整

参考文档

https://blog.csdn.net/dahailinan/article/details/111309692
https://blog.csdn.net/qq_30624591/article/details/106840966
https://blog.csdn.net/m0_38022615/article/details/109378391

涉及文件

kernel/drivers/gpu/drm/drm_edid.c
kernel/drivers/gpu/drm/rockchip/inno_hdmi.c
kernel/drivers/gpu/drm/rockchip/inno_hdmi.h
kernel/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
kernel/drivers/video/rockchip/hdmi/rockchip-hdmi.h
kernel/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c

部分代码

kernel/drivers/gpu/drm/drm_edid.c
/*
 * Probably taken from CEA-861 spec.
 * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c.
 *
 * Index using the VIC.
 */
static const struct drm_display_mode edid_cea_modes[] = {
...
        /* 5 - 1920x1080i@60Hz */
        { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008,
                   2052, 2200, 0, 1080, 1084, 1094, 1125, 0,
                   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
                        DRM_MODE_FLAG_INTERLACE),
          .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
...

------------------
drm_add_edid_modes
	add_detailed_modes
		do_detailed_mode
			drm_mode_detailed
include/drm/drm_edid.h
struct edid {
        u8 header[8];
        /* Vendor & product info */
        u8 mfg_id[2];
        u8 prod_code[2];
        u32 serial; /* FIXME: byte order */
        u8 mfg_week;
        u8 mfg_year;
        /* EDID version */
        u8 version;
        u8 revision;
        /* Display info: */
        u8 input;
        u8 width_cm;
        u8 height_cm;
        u8 gamma;
        u8 features;
        /* Color characteristics */
        u8 red_green_lo;
        u8 black_white_lo;
        u8 red_x;
        u8 red_y;
        u8 green_x;
        u8 green_y;
        u8 blue_x;
        u8 blue_y;
        u8 white_x;
        u8 white_y;
        /* Est. timings and mfg rsvd timings*/
        struct est_timings established_timings;
        /* Standard timings 1-8*/
        struct std_timing standard_timings[8];
        /* Detailing timings 1-4 */
        struct detailed_timing detailed_timings[4];
        /* Number of 128 byte ext. blocks */
        u8 extensions;
        /* Checksum */
        u8 checksum;
} __attribute__((packed));
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
{
        struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
                                             connector);
        struct edid *edid;
        struct drm_display_mode *mode;
        const u8 def_modes[6] = {97, 16, 31, 19, 17, 2};
        struct drm_display_info *info = &connector->display_info;
        struct hdr_static_metadata *metedata =
                        &connector->display_info.hdmi.hdr_panel_metadata;
        int i, ret = 0;

        if (!hdmi->ddc)
                return 0;

        edid = drm_get_edid(connector, hdmi->ddc);
        edid = NULL;
        if (edid) {
                dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
                        edid->width_cm, edid->height_cm);

                hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid);
                hdmi->sink_has_audio = drm_detect_monitor_audio(edid);
                drm_mode_connector_update_edid_property(connector, edid);
                cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, edid);
                ret = drm_add_edid_modes(connector, edid);
                /* Store the ELD */
                drm_edid_to_eld(connector, edid);
                drm_mode_connector_update_hdr_property(connector, metedata);
                kfree(edid);
        } else {
                hdmi->sink_is_hdmi = true;
                hdmi->sink_has_audio = true;
                for (i = 0; i < sizeof(def_modes); i++) {
                        mode = drm_display_mode_from_vic_index(connector,
                                                               def_modes,
                                                               31, i);
                        if (mode) {
                                if (!i)
                                        mode->type = DRM_MODE_TYPE_PREFERRED;
                                drm_mode_probed_add(connector, mode);
                                ret++;
                        }
                }
                info->edid_hdmi_dc_modes = 0;
                info->hdmi.y420_dc_modes = 0;
                info->color_formats = 0;

                dev_info(hdmi->dev, "failed to get edid\n");
        }

        return ret;
}

========================================

查看当前HDMI屏分辨率支持列表

# cat /sys/class/drm/card0-HDMI-A-1/modes
3840x2160p60
3840x2160p60
3840x2160p60
3840x2160p50
3840x2160p30
3840x2160p30
3840x2160p30
3840x2160p25
3840x2160p24
3840x2160p24
1920x2160p60
2560x1440p60
1920x1080p60
1920x1080p60
1920x1080p50
1680x1050p60
1280x1024p75
1280x1024p60
1440x900p60
1280x960p60
1280x720p60
1280x720p60
1280x720p50
1024x768p75
1024x768p70
1024x768p60
832x624p75
800x600p75
800x600p72
800x600p60
800x600p56
720x576p50
720x480p60
720x480p60
640x480p75
640x480p73
640x480p67
640x480p60
640x480p60
720x400p70

当前的显示分辨率

# cat /sys/class/drm/card0-HDMI-A-1/mode
3840x2160p60

查看EDID信息

# cat sys/class/drm/card0-HDMI-A-1/edid | busybox hexdump
0000000 ff00 ffff ffff 00ff e305 2790 8b64 0000
0000010 1d11 0301 3c80 7822 672a a5a1 4d55 27a2
0000020 500e bf54 00ef c0d1 00b3 0095 8081 4081
0000030 c081 0101 0101 d04d a000 70f0 803e 2030
0000040 0035 5055 0021 1a00 66a3 a000 70f0 801f
0000050 2030 0035 5055 0021 1a00 0000 fc00 5500
0000060 3732 3039 0a42 2020 2020 2020 0000 fd00
0000070 1700 1e50 3ca0 0a00 2020 2020 2020 c901
0000080 0302 f133 904c 0304 131f 1201 5e5d 605f
0000090 2361 0709 8307 0001 6d00 0c03 1000 3800
00000a0 2078 6000 0201 6703 5dd8 01c4 8078 e303
00000b0 000f 560c 005e a0a0 29a0 3050 3520 5500
00000c0 2150 0000 021e 803a 7118 2d38 5840 452c
00000d0 5500 2150 0000 011e 001d 5172 1ed0 6e20
00000e0 5528 5500 2150 0000 4d1e 806c 70a0 3e70
00000f0 3080 3a20 5500 2150 0000 001a 0000 4e00
0000100

VOP的状态

# cat /sys/kernel/debug/dri/0/summary 
VOP [ff900000.vop]: ACTIVE
    Connector: HDMI-A
        overlay_mode[1] bus_format[2025] output_mode[f] color_space[3]
    Display mode: 3840x2160p60
        clk[533250] real_clk[533250] type[48] flag[9]
        H: 3840 3888 3920 4000
        V: 2160 2163 2168 2222
    win0-0: ACTIVE
        format: AR24 little-endian (0x34325241) SDR[0] color_space[0]
        csc: y2r[0] r2r[0] r2y[1] csc mode[1]
        zpos: 0
        src: pos[0x0] rect[3840x2160]
        dst: pos[0x0] rect[3840x2160]
        buf[0]: addr: 0x0000000004000000 pitch: 15360 offset: 0
    win1-0: DISABLED
    win2-0: DISABLED
    win2-1: DISABLED
    win2-2: DISABLED
    win2-3: DISABLED
    win3-0: DISABLED
    win3-1: DISABLED
    win3-2: DISABLED
    win3-3: DISABLED
    post: sdr2hdr[0] hdr2sdr[0]
    pre : sdr2hdr[0]
    post CSC: r2y[0] y2r[0] CSC mode[1]
VOP [ff8f0000.vop]: DISABLED

HDMI当前输出状态

# cat /sys/kernel/debug/dw-hdmi/status 
PHY: enabled                    Mode: HDMI
Pixel Clk: 533250000Hz          TMDS Clk: 133312500Hz
Color Format: YUV444            Color Depth: 8 bit
Colorimetry: ITU.BT709          EOTF: Off

本文地址:https://blog.csdn.net/scottmvp/article/details/110087006

相关标签: linux kernel hdmi