The LCD-TFT (Liquid Crystal Display-Thin Film Transistor) display controller provides a 24-bit parallel digital RGB (Red, Green, Blue) and delivers all signals to VO interface, which can be used by MIPI Display Serial Interface directly to a broad range of LCD and TFT panels.
Introduction
Realtek LCDC driver follows Linux’s DRM Framework architecture. The Linux Direct Rendering Manager (DRM) layer contains code intended to support the needs of complex graphics devices. Graphics drivers in the kernel may make use of DRM functions to make tasks like memory management, interrupt handling and DMA easier, and provide a uniform interface to applications.
The LCDC driver basically consists of two parts:
LCDC driver - The LCDC driver handles the liquid crystal display controller, send the command to the controller.
MIPI-DSI driver - The MIPI-DSI driver handles the MIPI-DSI device, send the command to the Device and get the reply.
Architecture
LCDC uses the DRM (Direct Rendering Manager) framework to driver the LCDC device. The LCDC software architecture is illustrated in figure below.
DRM software architecture
备注
LCDC has two parts, one is LCDC, and another is MIPI-DSI. DRM drivers the two parts.
For details of Linux DRM system, refer to
Implementation
The implementation of Realtek DRM driver lies in the following directories.
Driver location |
Introduction |
---|---|
|
Realtek LCDC Driver function. |
|
Realtek LCDC Driver related function declaration, macro definition, structure definition and the other header files quoted. |
|
Realtek LCDC Driver functions. |
|
Realtek MIPI-DSI Driver function. |
|
Realtek MIPI-DSI Driver related function declaration, macro definition, structure definition and the other header files quoted. |
|
Realtek DRM Driver common function |
|
Realtek DRM Driver common related function declaration, macro definition, structure definition and the other header files quoted. |
|
Realtek LCDC hardware function |
|
Realtek LCDC hardware related function declaration, macro definition, structure definition and the other header files quoted. |
|
Realtek MIPI_DSI hardware function. |
|
Realtek MIPI_DSI hardware related function declaration, macro definition, structure definition and the other header files quoted. |
Configuration
DTS Configure
The LCDC DTS includes two parts: LCDC and MIPI-DSI. The main DTS file locates at <dts>/rtl8730e-drm.dtsi
.
drm:drm@0x400D8000 {
compatible = "realtek,ameba-drm";
reg = <0x400D8000 0xE0>;
interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&rcc RTK_CKE_LCDCMIPI>;
memory-region = <&mem_drm_reserved>;
port {
#address-cells = <1>;
#size-cells = <0>;
dsi_out: endpoint@0 {
reg = <0>;
remote-endpoint = <&dsi_in>;
};
panel_out: endpoint@1 {
reg = <1>;
remote-endpoint = <&panel_in>;
};
};
};
dsi: dsi@0x400EA000 {
compatible = "realtek,ameba-dsi";
reg = <0x400EA000 0xC10>,
<0x4200825C 0x04>;
interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&rcc RTK_CKE_HPERI>;
rtk,lcdc-vo-clock = <&rcc>;
status = "disabled";
// 0 for input port
port {
#address-cells = <1>;
#size-cells = <0>;
dsi_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&dsi_out>;
};
};
};
<dts>/rtl8730e-pinctrl.dtsi
drm_disable_swd_pins:drm_swd@0 {
pins {
pinmux = <REALTEK_PINMUX('A',14, GPIO)>;
bias-disable;
swd-disable;
};
};
LCDC needs CMA (Contiguous Memory Allocation) support, according to different boards, modify <reserved-memory> in the DTS.
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;
/*reserver 32M mem for drm graphics , from 0x61000000 to 0x63000000*/
mem_drm_reserved: drm_buffer@0x61000000 {
compatible = "shared-dma-pool";
no-map;
reg = <0x61000000 0x2000000>;
};
};
The basic information of LCDC is not suggested to revise.
For driver and device matching: compatible.
LCDC device REG:
0x400D8000.MIPI_DSI
device REG:0x400EA000
LCDCMIPI Clock: <&rcc RTK_CKE_LCDCMIPI >
LCDC interrupt: irq num 33; MIPI_DSI interrupt: irq num 70.
The pin assignments of LCDC are listed in table below.
Port name |
Pin control DTS configuration |
---|---|
PA4 |
<&drm_disable_swd_pins> |
LCDC has only one pinmux, therefore, only one pin is defined. PA13, PA14 also can be used in SWD, when used in LCDC, should disable SWD in DTS.
LCDC needs CMA support, for different display resolution, CMA can be set to different size.
Build Configuration
To change LCDC driver config, type the following command and choose “Device Drivers” > “Drivers for Realtek” > “DRM driver” in order.
make kernelconfig
APIs
APIs for User Space
LCDC core APIs: The LCDC driver exports standard DRM interfaces to user space as bellow.
Interfaces |
Introduction |
---|---|
Open |
Open a DRM device ( |
Close |
Close a DRM device. |
Ioctl |
Interaction with DRM driver to read, write the property. |
Libdrm APIs: Libdrm is a standard library to interface with DRM in the Linux kernel. It is open-source. The aims are:
The library offers 100% of the functionality of the kernel API.
The library adds major improvements in usability, making the application code simpler and better looking.
Future fixes or compatibility code may be placed in the library code instead of the kernel driver.
For more details, refer to libdrm.
LCDC demo for user space locates at tests/fwk/display/libdrm
. There are many different test demos, shows in table below.
Demo name |
Demo description |
Location |
---|---|---|
drm_plane_test_demo |
Plane test demo |
|
drm_vbl_test |
Drm vblank event test |
|
The LCDC demo just enables demo drm_plane_test_demo and drm_vbl_test to compile in SDK while lunch the test product target, refer to System Application Note (Chapter: Building Environment) to compile the test cases.
After compiling and burning successfully, you can find the test case located in /bin/
directory.
APIs for Kernel Space
LCDC Function Interfaces
LCDC_Init
Items |
Description |
---|---|
Introduction |
Initialize the LCDC register value with the |
Parameters |
|
Return |
None |
LCDC_StructInit
Items |
Description |
---|---|
Introduction |
Initialize the parameters in the |
Parameters |
|
Return |
None |
LCDC_TrigerSHWReload
Items |
Description |
---|---|
Introduction |
Triger Layer’s shadow register reload to apply new configuration. |
Parameters |
|
Return |
None |
LCDC_SetBkgColor
Items |
Description |
---|---|
Introduction |
Set the back ground color |
Parameters |
|
Return |
None |
LCDC_SetPlaneSize
Items |
Description |
---|---|
Introduction |
Set the display plane size |
Parameters |
|
Return |
None |
LCDC_Cmd
Items |
Description |
---|---|
Introduction |
Enable or disable the LCDC. |
Parameters |
|
Return |
None |
LCDC_GetINTStatus
Items |
Description |
---|---|
Introduction |
Get LCDC interrupt status. |
Parameters |
|
Return |
The interrupt status |
LCDC_ClearINT
Items |
Description |
---|---|
Introduction |
Clears the LCDC’s interrupt pending bits. |
Parameters |
|
Return |
None |
LCDC_DMAModeConfig
Items |
Description |
---|---|
Introduction |
Configure LCDC DMA burst size. |
Parameters |
|
Return |
None |
LCDC_DMAUnderFlowConfig
Items |
Description |
---|---|
Introduction |
Configure LCDC DMA under flow mode and under flow error data . |
Parameters |
as |
Return |
None |
LCDC_GetCurPosStatus
Items |
Description |
---|---|
Introduction |
Get the current position. |
Parameters |
|
Return |
None |
LCDC_GetDmaUnINTCnt
Items |
Description |
---|---|
Introduction |
Get the DMA FIFO under flow interrupt count. |
Parameters |
|
Return |
None |
LCDC_INTConfig
Items |
Description |
---|---|
Introduction |
Enables or disables the specified LCDC interrupts. |
Parameters |
|
Return |
The read value |
LCDC_LineINTPosConfig
Items |
Description |
---|---|
Introduction |
Configure line interrupt position. |
Parameters |
|
Return |
None |
LCDC_LayerConfig
Items |
Description |
---|---|
Introduction |
Initializes the LCDC Layer according to the specified parameters in the |
Parameters |
|
Return |
None |
LCDC_CheckLCDCReady
Items |
Description |
---|---|
Introduction |
Check LCDC is ready to work with VO interface after LCDC is enable. |
Parameters |
|
Return |
Status:
|
MIPI_DSI Function Interfaces
MIPI_Init
Items |
Description |
---|---|
Introduction |
Initialize the MIPI register value with the |
Parameters |
|
Return |
None |
MIPI_DSI_init
Items |
Description |
---|---|
Introduction |
Initialize the MIPI_DSI register value with the |
Parameters |
|
Return |
None |
MIPI_DPHY_init
Items |
Description |
---|---|
Introduction |
Initialize the MIPI_D-PHY register value with the |
Parameters |
|
Return |
None |
MIPI_InitStruct_Config
Items |
Description |
---|---|
Introduction |
Initialize the parameters in the |
Parameters |
|
Return |
None |
MIPI_DSI_Mode_Switch
Items |
Description |
---|---|
Introduction |
Initialize the MIPI_DSI register value with the |
Parameters |
|
Return |
None |
MIPI_DSI_CMD_Send
Items |
Description |
---|---|
Introduction |
Send a short packet to the panel in command mode. |
Parameters |
|
Return |
None |
MIPI_DSI_CMD_LongPkt_MemQWordRW
Items |
Description |
---|---|
Introduction |
Send a long packet to the panel in command mode. |
Parameters |
|
Return |
None |
MIPI_DSI_CMD_Rxcv_CMD
Items |
Description |
---|---|
Introduction |
Get status or packet from the panel in command mode |
Parameters |
|
Return |
The value of |
MIPI_DSI_INT_Config
Items |
Description |
---|---|
Introduction |
Configure IRQ for MIPI_DIS. |
Parameters |
|
Return |
None |
MIPI_DSI_INTS_Get
Items |
Description |
---|---|
Introduction |
Get The Command Mode interrupt status. |
Parameters |
|
Return |
The Command Mode interrupt status |
MIPI_DSI_INTS_Clr
Items |
Description |
---|---|
Introduction |
Clears The Command Mode interrupt pending bits. |
Parameters |
|
Return |
None |
MIPI_DSI_INTS_ACPU_Get
Items |
Description |
---|---|
Introduction |
Get The Video Mode interrupt status. |
Parameters |
|
Return |
The Video Mode interrupt status, which is frame done interrupt. |
MIPI_DSI_INTS_ACPU_Clr
Items |
Description |
---|---|
Introduction |
Clears The Video Mode interrupt pending bits. |
Parameters |
|
Return |
None |