Zhengdian Atom embedded linux driver development – RGB to HDMI

At present, most displays provide HDMI interfaces, and the application range of HDMI is becoming wider and wider. However, the STM32MP157 chip does not natively support HDMI display. You can convert RGB signals to HDMI signals through the RGB to HDMI chip, so that you can connect to an HDMI display. In this chapter, we will learn how to convert RGB to HDMI on the STM32MP1 development board of Atom.

Introduction to RGB to HDMI

The STM32MP157 SOC does not have HDMI peripherals and only has an RGB screen interface, so HDMI connection can only be achieved through an RGB to HDMI chip. The effect is definitely not comparable to that of SOCs that natively support HDMI interface. It is still okay to play with it as a toy. Therefore, it is essentially an RGB driver, not a native HDMI driver.

The STM32MP1 development board of Zhengdian Atom provides an RGB to HDMI module, as shown in the figure below:

SiI9022A chip

The SiI9022A chip is used here to complete the RGB to HDMI conversion. SiI9022A was formerly produced by Silicon Image, but Silicon Image was later acquired by Lattice.

SiI9022A is an HDMI transmission chip, suitable for high-definition portable cameras, digital cameras and personal mobile devices. It can flexibly convert other audio and video interfaces to HDMI or DVI formats. The SiI9022A supports pre-programmed HDCP keycodes for fully automated HDCP detection and authentication. SiI9022A is a video conversion chip that supports input video formats: xvYCC, BTA-T1004, ITU-R.656, and the built-in DE generator supports SYNC format (RGB format). Output format support: HDMI, HDCP and DVI, up to 1080P video output, HDMI A, HDMI C and Micro-D connectors. SiI9022A has many functions, and specific functions need to be configured. Therefore, SiI9022A provides an I2C interface for configuration.

Hardware schematic analysis

First analyze the hardware principle of SiI9022A and open the development board base schematic diagram. The principle is as shown in the figure below:

SiI9022A schematic

The picture above shows the onboard HDMI interface. It can be seen from the picture that the HDMI module is divided into 4 parts: RGB interface, I2C2 interface, I2S2 audio interface and HDMI_CEC interface. The RGB interface pins are mainly used to obtain display data. SiI9022A uses I2C for configuration. Herethe I2C2 interface of STM32MP1 is used, and the two pins PH4 and PH5 are used. There is also an interrupt INT and a reset HDMI_RESET connected to the PH6 and PA3 pins respectively. In this note, the main purpose is to implement the display function of HDMI, leaving other interfaces alone.

Experiment-driven writing

Modify device tree

Set I2C2 pinmux

If you want to implement HDMI display, you must provide SiI9022A with an RGB interface and an I2C2 interface. The RGB interface has been studied in previous experiments with LCD screens and will not be explained here. Mainly look at the pinmux configuration of the I2C2 interface, open the stm32mp15-pinctrl.dtsi file, and then find the following content:

Sample code 42. 3.1.1 pinmux of I2C2
1 i2c2_pins_a: i2c2-0 {<!-- -->
2 pins {<!-- -->
3 pinmux = <STM32_PINMUX('H', 4, AF4)>, /* I2C2_SCL */
4 <STM32_PINMUX('H', 5, AF4)>; /* I2C2_SDA */
5 bias-disable;
6 drive-open-drain;
7 slew-rate = <0>;
8      }; 
9  }; 
10
11 i2c2_pins_sleep_a: i2c2-1 {<!-- -->
12 pins {<!-- -->
13 pinmux = <STM32_PINMUX('H', 4, ANALOG)>, /* I2C2_SCL */
14 <STM32_PINMUX('H', 5, ANALOG)>; /* I2C2_SDA */
15};
16};

In the sample code 42.3.1.1, the two pinmux configurations of the I2C2 interface are defined: i2c2_pins_a and i2c2_pins_sleep_a. The first one is used in the default state, and the second one is used in the sleep state.

Add HDMI power node

Sii9022A requires a 1.2V voltage, which is already provided on this development board. The XC6206P122MR chip on the schematic diagram is a 1.2V power supply chip. It is also necessary to add a 1.2V voltage node to the device tree for use by the Sii9022A driver. Open the stm32mp157d-atk.dts file and add the following content under the root node:

Sample code 42. 3.1.2 HDMI power node
1 v1v2_hdmi regulator v1v2 hdmi {<!-- -->
2 compatible "regulator fixed"
3 regulator name "v1v2_
4 regulator min microvolt 1200000
5 regulator max microvolt 1200000
6 regulator always on
7 regulator boot on
8 };

This is to provide a simple voltage.

Add HDMI sub-node to i2c2 node

When studying LCD driver, I learned that the RGB interface does not need to be modified again. It only needs to provide an interface to receive LTDC data. HDMI is used to receive the LTDC interface. In the stm32mp157d-atk.dts file, use the append node method to append the following content to the i2c2 node:

Sample code 4 2.3.1.3 Additional I 2C2 node content
1 &i2c2 {<!-- -->
2 pinctrl-names = "default", "sleep";
3 pinctrl-0 = < & amp;i2c2_pins_a>;
4 pinctrl-1 = < & amp;i2c2_pins_sleep_a>;
5 status = "okay";
6
7 hdmi: hdmi-transmitter@39 {<!-- -->
8 compatible = "sil,sii9022";
9 reg = 9;
10 iovcc-supply = < & amp;v3v3>;
11 cvcc12-supply = < & amp;v1v2_hdmi>;
12 reset-gpios = < & amp;gpioa 3 GPIO_ACTIVE_LOW>;
13 interrupts = <6 IRQ_TYPE_EDGE_FALLING>;
14 interrupt-parent = < & amp;gpioh>;
15 #sound-dai-cells = <1>;
16 status = "okay";
17
18 ports {<!-- -->
19 #address-cells = <1>;
20 #size-cells =<0>;
twenty one
22 port@0 {<!-- -->
23 reg = <0>;
24 sii9022_in: endpoint {<!-- -->
25 remote-endpoint = < & amp;ltdc_ep0_out>;
26};
27};
28};
29};
30};

Lines 2-4 configure the two pinmux settings of I2C2.

Lines 7-29 are the HDMI sub-nodes under I2C2, and then we analyze the role of the more important attributes of this node. Line 12, set the reset pin to PA3, which is valid at low voltage. Lines 13-14, set the interrupt pin to PH6, valid on the falling edge. Lines 22-27, the port node is the interface used to receive LTDC data, and line 25 refers to the ltdc_ep0_out node.

Here we only tell HDMI to obtain data from the LTDC interface. We also need to tell the LTDC node to output data to HDMI. We need to modify the ltdc node. After the modification is completed, the ltdc node is as follows:

Sample code 4 2.3.1.4 LTDC based on HDMI interface
1 & amp;ltdc {<!-- -->
2 pinctrl-names = "default", "sleep";
3 pinctrl-0 = < & amp;ltdc_pins_b>;
4 pinctrl-1 = < & amp;ltdc_pins_sleep_b>;
5 status = "okay";
6
7 port {<!-- -->
8 #address-cells = <1>;
9 #size-cells = <0>;
10
11 ltdc_ep0_out: endpoint@0 {<!-- -->
12 reg = <0>;
13 remote-endpoint = < & amp;sii9022_in>;
14};
15};
16};

Line 13 tells the LTDC interface to output data to HDMI.

Note that the panel_rgb node needs to be blocked, otherwise the following warning will appear when compiling the device tree:

Warning (graph_endpoint): /panel-rgb/port/endpoint: graph connection to node ‘/soc/display-controller@5a001000/port/endpoint@0’ is not bidirectional

Finally, execute the “make dtbs” command to recompile the device tree.

Enable the kernel’s own sii902x driver

The Linux kernel provided by ST has integrated the sii902x driver and has enabled it. You still need to see how to enable this configuration. The configuration path is as follows:

-> Device Drivers
-> Graphics support
-> Display Interface Bridges
-> <*> Silicon Image sii902x RGB/HDMI bridge //selected

Compile the sii902x driver into the Linux kernel, as shown in the following figure:

Enable sii902x driver

The kernel has enabled the sii902x driver by default. If it is not enabled, enable it according to the above method, and then recompile the kernel to get a new kernel and device tree.

RGB to HDMI test

Use an HDMI cable to connect the development board and the monitor, and then start the development board using the newly compiled kernel and device tree. If the driver works normally, information will be displayed on the HDMI monitor, as shown in the following figure (screenshot):

Monitor display

At this point, the HDMI driver is working normally and you can use an HDMI monitor for graphics development under Linux. However, the LCD screen will still be used in the follow-up of this tutorial. You can choose an HDMI monitor or an LCD screen according to your preference.

Summary

This chapter is relatively simple. Just add the HDMI power node in the device tree, then add the HDMI sub-node under the i2c2 node, and finally change the remote-endpoint of the ltdc node to HDMI. This allows you to use an HDMI display for development.