OK3568-C Linux 5.10 Display Interface Adaptation Guide: Modifying and Debugging RGB/LVDS/MIPI/HDMI Display Parameters
by yir65681 in Circuits > Linux
25 Views, 0 Favorites, 0 Comments
OK3568-C Linux 5.10 Display Interface Adaptation Guide: Modifying and Debugging RGB/LVDS/MIPI/HDMI Display Parameters
Display adaptation is often one of the key challenges in embedded Linux development, to help developers streamline the process, Forlinx has released the OK3568-C Linux 5.10 Display Interface Adaptation Guide, covering the complete workflow for configuring and debugging
Screen Selection
Take OK3568-C as example: The OK3568-C supports five mainstream display interfaces by default: MIPI, EDP, RGB, LVDS and HDMI,which are all pre-configured by default, and users can switch between them during the U-Boot phase.
At start-up, press Ctrl+C to enter the U-Boot command line:
Press 2 to enter the display type selection screen:
- 1 corresponds to the HDMI screen display
- 2 corresponds to MIPI and EDP displays; the default display is MIPI
- 3 corresponds to LVDS and RGB displays; the default display is LVDS
- At this point, we can enter a number to switch the screen display; for example, we can enter 2
At this point, the display changes from ''mipi_edp display mipi'' to ''mipi_edp display edp'', indicating that the switch from MIPI to EDP has been completed. If you enter 2 again, you can turn off the display:
The same applies to the HDMI and LVDS_RGB options.
If you wish to retain the current settings, enter 0 to exit the screen selection menu, then enter 1 to restart.
The configuration will take effect after a restart.
Adjust the Screen Settings
Reference Document:
User documentation source code /docs/cn/Common/DISPLAY/Rockchip_DRM_Panel_Porting_Guide
Display Parameters
Display parameter acquisition and modification
Common Description
Device Tree Property
Meaning/Source
Synchronization Signals
hsync / vsync
Display parameters / Panel manual
Vback
hback / vback
Display parameters / Panel manual
Resolution
hactive / vactive
Display parameters / Panel manual
Vfront
hfront / vfront
Display parameters / Panel manual
Signal
bus-format
Display parameters / Panel manual
Initialisation Sequence
panel-init-sequence
Required only for MIPI screens / to be provided by the screen manufacturer
Clock
clock-frequency
Pixel Clock (PCLK) / Display Panel Manual
These display parameters have corresponding entries in the device tree framework. After obtaining the parameters according to their sources, filling them into the appropriate locations completes the display setup.
Below describes the locations for entering parameters for different interfaces and important considerations when dealing with various interfaces.
2.1 RGB Interface
2.1.1 Modifying the device tree
The device tree file path corresponding to OK3568-C:
OK3568_Linux_fs/kernel/arch/arm64/boot/dts/rockchip/OK3568-C-common.dtsi
Open the device tree file, locate the ''rgb-panel'' node, and modify the display parameters in accordance with the relevant screen manual. The following are the default display parameters in the source code:
Once you have modified the device tree, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilation and 6.System Flashing. (Click on the blue text to follow the link)
2.1.2 RGB Signal Format Switching:
The RGB signal formats are defined in the kernel source file ''kernel/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c''; the available formats are RGB565, RGB666 and RGB888.
The above content shows an excerpt from the code.
Once you have modified the source code, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilation and 6.System Flashing. (Click on the blue text to follow the link)
2.1.3 Viewing Screen Settings
After updating the image, you can run the following command in the command line to view the display parameters:
Connector: DPI-1: The screen node is named DPI-1;
bus_format[1011]: RGB888_1X7X4_SPWG: The RGB format uses RGB888_1X7X4_SPWG.
Display mode: 1024x600p52: Screen resolution is 1024x600;
clk[51200]: The display clock is 51.2 MHz;
- Here is a specific explanation of the H and V parameters.
H:
1024
1184
1185
1505
hdisplay = 1024
hsync_start = 1184
hsync_end = 1185
htotal = 1505
V:
600
612
613
648
vdisplay = 600
vsync_start = 640
vsync_end = 644
vtotal = 684
2.1.4 RGB Interface
List of Parallel RGB Interface Formats for the RK3568
Interface
RGB888
RGB666
RGB565
LCDC_CLK
LCDC_CLK
LCDC_CLK
LCDC_CLK
LCDC_HSYNC
LCDC_HSYNC
LCDC_HSYNC
LCDC_HSYNC
LCDC_VSYNC
LCDC_VSYNC
LCDC_VSYNC
LCDC_VSYNC
LCDC_DEN
LCDC_DEN
LCDC_DEN
LCDC_DEN
LCDC_D23
R7
R5
R4
LCDC_D22
R6
R4
R3
LCDC_D21
R5
R3
R2
LCDC_D20
R4
R2
R1
LCDC_D19
R3
R1
R0
LCDC_D18
R2
R0
LCDC_D17
R1
LCDC_D16
R0
LCDC_D15
G7
G5
G4
LCDC_D14
G6
G4
G3
LCDC_D13
G5
G3
G2
LCDC_D12
G4
G2
G1
LCDC_D11
G3
G1
G0
LCDC_D10
G2
G0
LCDC_D9
G1
LCDC_D8
G0
LCDC_D7
B7
B5
B4
LCDC_D6
B6
B4
B3
LCDC_D5
B5
B3
B2
LCDC_D4
B4
B2
B1
LCDC_D3
B3
B1
B0
LCDC_D2
B2
B0
LCDC_D1
B1
LCDC_D0
B0
2.2 LVDS Interface
2.2.1 Modifying the device tree
The device tree file path corresponding to OK3568-C:
OK3568_Linux_fs/kernel/arch/arm64/boot/dts/rockchip/OK3568-C-common.dtsi
Open the device tree file, locate the ''panel'' node, and modify the display parameters in accordance with the relevant screen manual. The following are the default display parameters in the source code:
Once you have modified the device tree, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilationand 6.System Flashing. (Click on the blue text to follow the link)
2.2.2 LVDS Signal Format Switching:
The LVDS signal format is defined in the kernel source file ''kernel/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c''.
In the specifications, ''1X7X3'' refers to three pairs of data cables; these are generally known as screens with a ''single six'' or ''double six'' signal format;
In the specifications, ''1X7X4'' refers to four pairs of data cables; this is generally known as a screen with a ''single-eight'' or ''double-eight'' signal format.
Once you have modified the source code, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilation and 6.System Flashing. (Click on the blue text to follow the link)
2.2.3 Switching Between Single- and dual-channel LVDS Signals
Modify the &lvds node in the device tree located at kernel/arch/arm64/boot/dts/rockchip/OK3568-C-common.dtsi. By default, lvds is single-channel; adding the ''dual-channel;'' statement changes it to dual-channel:
Once you have modified the device tree, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilation and 6.System Flashing.
2.2.4 Viewing Screen Settings
After updating the image, you can run the following command in the command line to view the display parameters:
Connector: LVDS-1: The screen node is named LVDS-1;
bus_format[1011]: RGB888_1X7X4_SPWG: The LVDS format uses RGB888_1X7X4_SPWG.
Display mode: 1280x800p60: Screen resolution is 1280x800p60;
clk[71000]: The display clock is 71 MHz;
- Here is a specific explanation of the H and V parameters.
H:
1280
1420
1430
1440
hdisplay = 1280
hsync_start = 1420
hsync_end = 1430
htotal = 1440
V:
800
802
822
823
vdisplay = 800
vsync_start = 802
vsync_end = 822
vtotal = 823
2.3 MIPI Interface
2.3.1 Modifying the device tree
The device tree file path corresponding to OK3568-C:
OK3568_Linux_fs/kernel/arch/arm64/boot/dts/rockchip/OK3568-C-common.dtsi
Open the device tree file, locate the ''& dsi1'' node, and modify the display parameters in accordance with the relevant screen manual. The following are the default display parameters in the source code:
Once you have modified the device tree, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilation and 6.System Flashing. (Click on the blue text to follow the link)
2.3.2 MIPI Initialization Sequence
2.3.2.1 MIPI Initialization Sequence Acquisition
Screen manufacturers generally provide an initialization sequence for MIPI screens, similar to the example below.
We need to convert this sequence into the format reserved in Rockchip’s display subsystem.
2.3.2.2 Initialization Sequence Conversion Rules
Here is an explanation of the first sequence.
39 00 04 ff 98 81 03
39
00
04
ff
98
81
03
Command type
Delay
Data Length
Command
Parameter
Parameter
Parameter
There are the following three types of commands:
39
Long Packet
Parameter > 2
15
Short Packet
Parameter≤ 2
05
Issue DCS commands only
Without parameters
e.g.: 05 78 01 11
Indicates a delay of 0x78=120ms before issuing command 11.
You can achieve the effect shown in the image below using VS Code or Notepad++; the shortcut is Shift+Alt+mouse click.
2.3.3 Switching Between Single- and dual-channel MIPI Signals
Locate the &dsi1 node in the device tree at kernel/arch/arm64/boot/dts/rockchip/OK3568-C-common.dtsi
dsi,lanes = 4 A value greater than 4 for this attribute in the device tree indicates dual-channel mode for the MIPI signal; this can be modified directly to match the display’s lane requirements.
Note: During actual screen debugging, the provided screen documentation may not be entirely accurate. For example, when the screen displays abnormally (color distortion, misalignment), the normal approach is to adjust the pixel format and fine-tune the clock. Consider an alternative perspective: during initial debugging, if the screen’s clock frequency is uncertain or its range is unknown, but the display is basically functional, then the clock setting is likely approximately correct. If the screen is displaying incorrectly and adjusting the settings in the usual way does not produce a noticeable improvement, you may wish to adjust the screen’s frame rate—for example, reducing it from 60 fps to 30 fps, or to another frame rate. The main idea is to make a broad adjustment to the clock frequency.
2.4 HDMI and EDP
HDMI and eDP automatically retrieve the EDID, so there is no need to manually adjust the display settings.
2.4.1 Setting a Fixed Screen Resolution for HDMI
1. Select HDMI display during the U-Boot phase
2. Edit the driver file ''kernel/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c'', locate the function ''dw_hdmi_connector_get_modes'', and add ''edid = NULL;''
3. Continue editing the driver file ''kernel/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c''. Locate the ''dw_hdmi_default_modes[]'' array, which defines a number of resolutions. Check whether it contains the resolution you require; retain only the resolution you need and comment out the rest. If the required resolution is not found in this array, you can look for it in the file ''kernel/drivers/gpu/drm/drm_edid.c'' and then add it to ''dw-hdmi.c''. Here, we will use retaining the 1280x720 resolution as an example:
4. Edit the device tree file ''kernel/arch/arm64/boot/dts/rockchip/OK3568-C-common.dtsi'' and add the following timing to the ''&route_hdmi'' section:
Note: The parameters in the device tree must match those in the driver’s ''default_modes''; otherwise, the logo will not display correctly.
Once you have modified the source code, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilation and 6.System Flashing. (Click on the blue text to follow the link)
2.4.2 Setting a Fixed Screen Resolution for EDP
Refer to document: rockchip_drm_integration_helper-zh.pdf
It can be found in the following path in the source code (this was found in the source code for Linux 4.19.206):
Modify the device tree file ''kernel/arch/arm64/boot/dts/rockchip/OK3568-C-common.dtsi'' to use the ''display-timings''structure, and directly enter the EDP display’s timing parameters into the DTS file (adjust the display parameters yourself according to the display manual):
Once you have modified the device tree, save the configuration, recompile the kernel to generate the boot.img image, and flash the image onto the board.
For specific instructions, please refer to the 4.Related Code Compilationand 6.System Flashing. (Click on the blue text to follow the link)
After the update, when selecting the screen to display ''edp'' during the U-Boot phase, the following output can be seen:
After starting up, you can see that the screen settings have taken effect: