RK3568 LCD 屏幕驱动

MIPI LVDS

Posted by LXG on April 3, 2025

DRM 显示框架

Rockchip_Developer_Guide_DRM_Display_Driver_CN.pdf

vop 2.0 显示子系统架构

rockchip_vop_arch

VOP 2.0 采用了统一显示架构,即整个 SOC 上只存在一个 VOP,但是在 VOP 的后端设计了多路独立的 Video Port(简称 VP) 输出接口, 这些 VP 能够同时独立工作,并且输出相互独立的显示时序。比如在上面的 VOP 2.0 框图中,有三个 VP,就能同时实现三屏异显。

RK3568 VP 和各显示接口的连接关系

rk3568_vop

DTS

kernel/arch/arm64/boot/dts/rockchip/rk3568.dtsi


	vop: vop@fe040000 {
		compatible = "rockchip,rk3568-vop";
		reg = <0x0 0xfe040000 0x0 0x3000>, <0x0 0xfe044000 0x0 0x1000>;
		reg-names = "regs", "gamma_lut";
		rockchip,grf = <&grf>;
		interrupts = <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>;
		clocks = <&cru ACLK_VOP>, <&cru HCLK_VOP>, <&cru DCLK_VOP0>, <&cru DCLK_VOP1>, <&cru DCLK_VOP2>;
		clock-names = "aclk_vop", "hclk_vop", "dclk_vp0", "dclk_vp1", "dclk_vp2";
		iommus = <&vop_mmu>;
		power-domains = <&power RK3568_PD_VO>;
		status = "disabled";

		vop_out: ports {
			#address-cells = <1>;
			#size-cells = <0>;

			vp0: port@0 {
				#address-cells = <1>;
				#size-cells = <0>;
				reg = <0>;

				vp0_out_dsi0: endpoint@0 {
					reg = <0>;
					remote-endpoint = <&dsi0_in_vp0>;
				};

				vp0_out_dsi1: endpoint@1 {
					reg = <1>;
					remote-endpoint = <&dsi1_in_vp0>;
				};

				vp0_out_edp: endpoint@2 {
					reg = <2>;
					remote-endpoint = <&edp_in_vp0>;
				};

				vp0_out_hdmi: endpoint@3 {
					reg = <3>;
					remote-endpoint = <&hdmi_in_vp0>;
				};
			};

			vp1: port@1 {
				#address-cells = <1>;
				#size-cells = <0>;
				reg = <1>;

				vp1_out_dsi0: endpoint@0 {
					reg = <0>;
					remote-endpoint = <&dsi0_in_vp1>;
				};

				vp1_out_dsi1: endpoint@1 {
					reg = <1>;
					remote-endpoint = <&dsi1_in_vp1>;
				};

				vp1_out_edp: endpoint@2 {
					reg = <2>;
					remote-endpoint = <&edp_in_vp1>;
				};

				vp1_out_hdmi: endpoint@3 {
					reg = <3>;
					remote-endpoint = <&hdmi_in_vp1>;
				};

				vp1_out_lvds: endpoint@4 {
					reg = <4>;
					remote-endpoint = <&lvds_in_vp1>;
				};

				vp1_out_lvds1: endpoint@5 {
					reg = <5>;
					remote-endpoint = <&lvds1_in_vp1>;
				};
			};

			vp2: port@2 {
				#address-cells = <1>;
				#size-cells = <0>;

				reg = <2>;

				vp2_out_lvds: endpoint@0 {
					reg = <0>;
					remote-endpoint = <&lvds_in_vp2>;
				};

				vp2_out_rgb: endpoint@1 {
					reg = <1>;
					remote-endpoint = <&rgb_in_vp2>;
				};

				vp2_out_lvds1: endpoint@2 {
					reg = <2>;
					remote-endpoint = <&lvds1_in_vp2>;
				};
			};
		};
	};

DRM

全称是 Direct Rendering Manager,进行显示输出管理、buffer 分配、帧缓冲。对应的 userspace 库为 libdrm,libdrm 库提供了一系列友好的控制封装,使用户可以方便的进行显示的控制和 buffer 申请。 DRM 的设备节点为 “/dev/dri/cardX”, X 为 0-15 的数值,默认使用的是 /dev/dri/card0

rockchip_drm

显示通路

rockchip_drm_2

DRM 驱动 和 libdrm 的交互过程

rockchip_drm_3

扫描时序

lcd_display_time


            dsi0_timing0: timing0 {
                                clock-frequency = <68000000>;
                                hactive = <800>;
                                vactive = <1280>;
                                hback-porch = <18>;
                                hfront-porch = <18>;
                                vback-porch = <8>;
                                vfront-porch = <24>;
                                hsync-len = <18>;
                                vsync-len = <4>;
                                hsync-active = <0>;
                                vsync-active = <0>;
                                de-active = <0>;
                                pixelclk-active = <0>;
            };


MIPI 驱动适配

原理图

rk3568_mipi

DTS


	dsi1: dsi@fe070000 {
		compatible = "rockchip,rk3568-mipi-dsi";
		reg = <0x0 0xfe070000 0x0 0x10000>;
		interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
		clocks = <&cru PCLK_DSITX_1>, <&cru HCLK_VO>;
		clock-names = "pclk", "hclk";
		resets = <&cru SRST_P_DSITX_1>;
		reset-names = "apb";
		phys = <&video_phy1>;
		phy-names = "dphy";
		power-domains = <&power RK3568_PD_VO>;
		rockchip,grf = <&grf>;
		#address-cells = <1>;
		#size-cells = <0>;
		status = "okay";  // okay

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			dsi1_in: port@0 {
				reg = <0>;
				#address-cells = <1>;
				#size-cells = <0>;

				dsi1_in_vp0: endpoint@0 {
					reg = <0>;
					remote-endpoint = <&vp0_out_dsi1>;
					status = "disabled";
				};

				dsi1_in_vp1: endpoint@1 {
					reg = <1>;
					remote-endpoint = <&vp1_out_dsi1>;
					status = "disabled";
				};
			};
		};
	};


Xrandr

xrandr(X Resize and Rotate)是 Linux 下用于 管理显示屏(屏幕)配置 的命令行工具。它适用于 Xorg(X11)系统,可以用于调整 分辨率、刷新率、旋转方向、多屏显示 以及 启用/禁用显示输出 等操作。


root@ubuntu2004:~# xrandr
Screen 0: minimum 320 x 200, current 1824 x 1280, maximum 16384 x 16384
HDMI-1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00*+
   1280x720      60.00    60.00    59.94
   800x600       60.32    56.25
   720x576       50.00
   720x480       60.00    60.00    59.94    59.94    59.94
   640x480       60.00    59.94    59.94
DSI-1 connected primary 800x1280+1024+0 (normal left inverted right x axis y axis) 0mm x 0mm
   800x1280      50.01*+


Related Issues not found

Please contact @lixiaogang03 to initialize the comment