---
# System prepended metadata

title: Qucomm MIPI DSI LCD Bring Up
tags: [Android BSP Development]

---

---
tags: Android BSP Development
---
# Qucomm MIPI DSI LCD Bring Up

## MIPI DSI介紹

**MIPI**是**Mobile Industry Processor Interface**的縮寫。MIPI是MIPI聯盟發起的為手機處理器制定的開放標準。
已經完成和正在計畫的規範如下：
![](https://i.imgur.com/nXvwjja.png)

##### 名詞解釋

- DCS (DisplayCommandSet)：DCS是一個標準化的命令集，用於命令模式的顯示模組
- DSI (DisplaySerialInterface) : DSI 定義一個介於處理器和顯示模组間的高速串行接口
- CSI (CameraSerialInterface) : CSI 定義一個介於處理器和攝像模组間的高速串行接口
- D-PHY：提供DSI和CSI的物理層定義

##### DSI分層結構

DSI分四層

- PHY層定義了傳輸媒介，輸入/輸出電路和和時鐘和信號機制。
- Lane Management層：發送和收集數據流到每條lane。
- Low Level Protocol層：定義了如何组帧和解析以及錯誤檢測等。
- Application層：描述高層編碼和解析數據流。

![](https://i.imgur.com/l2hn74G.png)
##### Command和Video模式
- DSI兼容的外設支持Command或Video操作模式，用哪個模式由外設的架構决定
- Command模式是指採用發送命令和數據到具有顯示缓存的控制器。主机通過命令間接的控制外設。Command模式採用雙向接口
- Video模式是指從主机傳輸到外設採用时实象素流。這種模式只能以**高速傳輸**。為减少複雜性和節約成本，只採用Video模式的系统可能只有一個單項數據路徑

## 使用Qcomm工具Bring up LCD

### Display Driver Development Procedure
1. Install the library by the command below. 

```
$ sudo apt-get install libxml-libxml-perl libxml-perl
```

2. Enter the tools directory *$ cd device/qcom/common/display/tools* which will show information as below: 

```
device/qcom/common/display/tools$ ls
panel_hx8394f_720p_video.xml  panel_ili9881c_720p_video.xml  panel_nt35590_720p_cmd.xml  panel_nt35596_1080p_video.xml  parser.pl  platform-msm8610.xml  README.txt
```

3. Copy the panel_nt35596_1080p_video.xml to a new <oem_panel_input_file>.xml, if the LCD is in
   video mode.

   In my case, LCD use vedio mode.

   ```
   $ cp panel_nt35596_1080p_video.xml panel_mydemo_1080p_video.xml
   ```

### Edit the new XML to configure the display parameters. (According my LCD spec)
#### Panel Information
   ```
    32 <GCDB>
    33   <Version>"1.0"</Version>
    34   <PanelId>mydemo-1080p-video</PanelId>
    35   <PanelH>mydemo_1080p_video</PanelH>
    36   <PanelEntry>
   ```

| XML Tag | Description                                     |
| ------- | ----------------------------------------------- |
| Version | Each version is bind to be a set of panel tags. |
| PanelId | Name used to generate the .dtsi file for kernel |
| PanelH  | Name used to generate the header file for LK    |

#### Panel configuration

```
 38         <!-- Panel configuration -->
 39         <PanelName>"my demo 1080p video mode dsi panel"</PanelName>
 40         <PanelController>"mdss_dsi0"</PanelController>
 41         <PanelInterface>10</PanelInterface>
 42         <PanelType>0</PanelType>
 43         <PanelDestination>"DISPLAY_1"</PanelDestination>
 44         <PanelOrientation>0</PanelOrientation>
 45         <PanelFrameRate>60</PanelFrameRate>
 46         <PanelChannelId>0</PanelChannelId>
 47         <DSIVirtualChannelId>0</DSIVirtualChannelId>
 48         <PanelBroadcastMode>0</PanelBroadcastMode>
 49         <!-- Optional Panel configuration -->
 50         <!--BitClockFrequency>0</BitClockFrequency -->
 51         <DSIStream>0</DSIStream>
 52         <PanelCompatible>"qcom,mdss-dsi-panel"</PanelCompatible>
 53         <InterleaveMode>0</InterleaveMode>
```

| XML Tag                                 | Description                                             | Value                                |
| --------------------------------------- | ------------------------------------------------------- | ------------------------------------ |
| PanelName                               | PanelName                                               | Name/label value                     |
| PanelType                               | Panel is in video mode or command mode                  | 0 = VIDEO_MODE<br />1 = COMMAND_MODE |
| PanelOrientation<br />(Only used in LK) | Panel rotation value.                                   | 1 = 0 degree<br />2 = 180 degree     |
| PanelFrameRate                          | An integer to define the panel refresh rate per second. | For example: 60 for 60fps panel.     |

#### Panel Resolution

```
 55         <!-- Panel Resolution -->
 56         <PanelWidth>1200</PanelWidth>
 57         <PanelHeight>1920</PanelHeight>
 58         <HFrontPorch>60</HFrontPorch>
 59         <HBackPorch>32</HBackPorch>
 60         <HPulseWidth>1</HPulseWidth>
 61         <HSyncSkew>0</HSyncSkew>
 62         <VBackPorch>25</VBackPorch>
 63         <VFrontPorch>35</VFrontPorch>
 64         <VPulseWidth>1</VPulseWidth>
 65         <HLeftBorder>0</HLeftBorder>
 66         <HRightBorder>0</HRightBorder>
 67         <VTopBorder>0</VTopBorder>
 68         <VBottomBorder>0</VBottomBorder>
 69         <!-- Optional Panel resolution configuration -->
 70         <!--HActiveRes>0</HActiveRes>
 71         <VActiveRes>100</VActiveRes>
 72         <InvertDataPolarity>0</InvertDataPolarity>
 73         <InvertVsyncPolarity>0</InvertVsyncPolarity>
 74         <InvertHsyncPolarity>0</InvertHsyncPolarity -->
```
![](https://i.imgur.com/yppziHp.png)

##### Panel Color Information

```
 76         <!-- Panel Color Information -->
 77         <ColorFormat>24</ColorFormat>
 78         <ColorOrder>0</ColorOrder>
 79         <UnderFlowColor>0xff</UnderFlowColor>
 80         <BorderColor>0</BorderColor>
```

| XML Tag     | Description                                                | Value                                                        |
| ----------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
| ColorFormat | Defines the bits per pixel.                                | 24 = 888_RGB<br />18 = 666_RGB<br />16 = 565_RGB<br />12 = 444_RGB<br />8 = 332_RGB<br />3 = 111_RGB |
| ColorOrder  | Defines pixel component color order between MSM and panel. | 0 = DSI_RGB_SWAP_RGB<br />1 = DSI_RGB_SWAP_RBG<br />2 = DSI_RGB_SWAP_BGR<br />3 = DSI_RGB_SWAP_BRG<br />4 = DSI_RGB_SWAP_GRB<br />5 = DSI_RGB_SWAP_GBR |

#### Video mode panel information

```
608         <!-- Video mode panel information -->
609         <HSyncPulse>1</HSyncPulse>
610         <HFPPowerMode>0</HFPPowerMode>
611         <HBPPowerMode>0</HBPPowerMode>
612         <HSAPowerMode>0</HSAPowerMode>
613         <BLLPEOFPowerMode>1</BLLPEOFPowerMode>
614         <BLLPPowerMode>1</BLLPPowerMode>
615         <TrafficMode>2</TrafficMode>
616         <DMADelayAfterVsync>0</DMADelayAfterVsync>
617         <BLLPEOFPower>0x9</BLLPEOFPower>
```

| XML Tag     | Description                                                  | Value                                                        |
| ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| HSyncPulse  | Horizontal sync pulses. <br />It determines whether the hardware <br />should send horizontal sync pulses<br />during the vertical blanking period. | 0 = Sync pulse disable<br />1 = Sync pulse enable            |
| TrafficMode | Panel traffic mode type                                      | 0 = non burst with sync pulses<br />1 = non burst with sync start event<br />2 = burst mode |

Usually these parameters do not need to be modified. The user may need to note the parameter
<TrafficMode> which may vary with the LCD chip.

#### Lane Configuration

```
619         <!-- Lane Configuration -->
620         <DSILanes>4</DSILanes>
621         <DSILaneMap>0</DSILaneMap>
622         <Lane0State>1</Lane0State>
623         <Lane1State>1</Lane1State>
624         <Lane2State>1</Lane2State>
625         <Lane3State>1</Lane3State>
```
![](https://i.imgur.com/3qT6sHk.png)

#### Backlight Configuration

```
634         <!-- Backlight -->
635         <BLInterfaceType>1</BLInterfaceType>
636         <BLMinLevel>100</BLMinLevel>
637         <BLMaxLevel>4095</BLMaxLevel>
638         <BLStep>100</BLStep>
639         <BLPMICModel>"PMIC_8941"</BLPMICModel>
640         <BLPMICControlType>0</BLPMICControlType>
```

| XML Tag           | Description                            | Value                                                        |
| ----------------- | -------------------------------------- | ------------------------------------------------------------ |
| BLMinLevel        | Minimum value of backlight.            |                                                              |
| BLMaxLevel        | Maximum value of backlight.            |                                                              |
| BLPMICControlType | PMIC controller for current backlight. | 0 = PWM GPIO<br />1 = WLED<br />2 = DCS COMMANDS<br />3 = LPG |

#### Panel Timing

| XML Tag      | Description                                                  |
| ------------ | ------------------------------------------------------------ |
| PanelTimings | An array of length 12 that specifies the physical timing settings for the panel |
| TClkPost     | DSI timing control clock post value                          |
| TClkPre      | DSI timing control clock pre value                           |

Generate PanelTimings Value
![](https://i.imgur.com/6acqNkH.png)

![](https://i.imgur.com/2HbE9R1.png)


```
627         <!-- Panel Timing -->
628         <PanelTimings>"0xf7, 0x3a, 0x28, 0x00, 0x6e, 0x72, 0x2c, 0x3e, 0x31, 0x03, 0x04, 0x00"</PanelTimings>
629         <DSIMDPTrigger>0</DSIMDPTrigger>
630         <DSIDMATrigger>4</DSIDMATrigger>
631         <TClkPost>0x2</TClkPost>
632         <TClkPre>0x2d</TClkPre>
```
#### Panel Command information
```
 82         <!-- Panel Command information -->
 83         <OnCommand>"0x05, 0x01, 0x00, 0x00, 0x96, 0x00, 0x02, 0x28, 0x00,
 84                 0x05, 0x01, 0x00, 0x00, 0x32, 0x00, 0x02, 0x10, 0x00,
 85                 0x05, 0x01, 0x00, 0x00, 0x96, 0x00, 0x02, 0x11, 0x00,
 86                 0x05, 0x01, 0x00, 0x00, 0x32, 0x00, 0x02, 0x29, 0x00"</OnCommand>
 87         <OffCommand>"0x05, 0x01, 0x00, 0x00, 0x32, 0x00, 0x02, 0x28, 0x00,
 88                                         0x05, 0x01, 0x00, 0x00, 0x78, 0x00, 0x02, 0x10, 0x00"</OffCommand>
 89         <OnCommandState>0</OnCommandState>
 90         <OffCommandState>1</OffCommandState>
```
| XML Tag         | Description                                                  | Value                                |
| --------------- | ------------------------------------------------------------ | ------------------------------------ |
| OnCommand       | Array of variable length that lists the initialization commands of the panel |                                      |
| OffCommand      | Array of variable length that lists the deinitialization commands of the panel |                                      |
| OnCommandState  | Panel state when sending the on command.                     | 0 = DSI_LP_MODE<br />1 = DSI_HP_MODE |
| OffCommandState | Panel state when sending the off command.                    |                                      |

Generally speaking, <OnCommandState> and <OffCommandState> only need to keep the default value.

#### Panel Reset Sequence

```
126         <!-- Panel Reset Sequence -->
127         <ResetSequence>
128                 <PinState1>1</PinState1>
129                 <PulseWidth1>20</PulseWidth1>
130                 <PinState2>0</PinState2>
131                 <PulseWidth2>1</PulseWidth2>
132                 <PinState3>1</PinState3>
133                 <PulseWidth3>20</PulseWidth3>
134                 <EnableBit>2</EnableBit>
135         </ResetSequence>
```

## Configure Kernel and LK
```
$ perl parser.pl panel_mydemo_1080p_video.xml panel
$ ls
dsi-panel-mydemo-1080p-video.dtsi  panel_ili9881c_720p_video.xml  panel_mydemo_1080p_video.xml  panel_nt35596_1080p_video.xml  platform-msm8610.xml
panel_hx8394f_720p_video.xml       panel_mydemo_1080p_video.h     panel_nt35590_720p_cmd.xml    parser.pl                      README.txt
```
#### Configure Kernel
copy *dsi-panel-mydemo-1080p-video.dtsi* to the following directory: kernel/msm-3.18/arch/arm/boot/dts/qcom/.

1. Include .dtsi files.
Path: kernel/msm-3.18/arch/arm/boot/dts/qcom/msm8953-mdss-panels.dtsi
![](https://i.imgur.com/Z1YCGsy.png)

2. Modify .dtsi files.
Add DSI PHY 2.0.0 timing config to the following directory: kernel/msm-3.18/arch/arm/boot/dts/qcom/msm8953-mdss-panels.dtsi.

![](https://i.imgur.com/iJclfP5.png)

The parameters of timing “*mdss-dsi-panel-timings-phy-v2*” are the same as that of the timimg configured in LK (bootable/bootloader/lk/dev/gcdb/display/include/panel_mydemo_1080p_video.h)
“mydemo_1080p_phy2_video_timings”.
![](https://i.imgur.com/Zks2wvH.png)


```
&dsi_mydemo_1080p_video {
        qcom,mdss-dsi-panel-timings-phy-v2 = [ 
         24 20 08 09 05 03 04 a0     /*Data 0*/
         24 20 08 09 05 03 04 a0     /*Data 1*/
         24 20 08 0a 05 03 04 a0     /*Data 2*/
         24 20 08 09 05 03 04 a0     /*Data 3*/
         24 1d 08 09 05 03 04 a0];   /*CLK lane*/
};
```
> For example,
![](https://i.imgur.com/rwEU53g.png)

The following part should be modified also:
Path: *kernel/msm-3.18/arch/arm/boot/dts/qcom/msm8953-mtp.dtsi*
![](https://i.imgur.com/lfaJUTu.png)

3. Configure the Backlight.
Path: kernel/msm-3.18/arch/arm/boot/dts/qcom/msm8953-mtp.dtsi
![](https://i.imgur.com/VBzDTcu.png)
The GPIO to control pwm is,
qcom,mdss-dsi-pwm-gpio = <&pm8953_mpps 4 0>;
![](https://i.imgur.com/GnlkRQM.png)

Configure backlight type
qcom,mdss-dsi-bl-pmic-control-type: a string that specifies the implementation of backlight control for this
panel.

"bl_ctrl_pwm" = Backlight controlled by PWM GPIO
"bl_ctrl_wled" = Backlight controlled by WLED
"bl_ctrl_dcs" = Backlight controlled by DCS commands(for OLED panel backlight controller) Others: Unknown backlight control. (default)

#### Configure LK
After the file panel_mydemo_1080p_video.h is generated, please copy it to the directory bootable/bootloader/lk/dev/gcdb/display/include/. Customers need to configure the LK to add a new panel.

1. Add several parameters to panel_mydemo_1080p_video.h to avoid compiling error.

![](https://i.imgur.com/MqY6gRA.png)

![](https://i.imgur.com/WB0FWTX.png)

2. Add the DSI PHY 2.0.0 timing config

![](https://i.imgur.com/KyjcKyR.png)

3. Add a new panel.
Path: bootable/bootloader/lk/target/msm8953/oem_panel.c

![](https://i.imgur.com/fWyKDJP.png)

![](https://i.imgur.com/k8vpcJh.png)

![](https://i.imgur.com/GVywfuc.png)

4. Add new panel selection branch in function “init_panel_data”.

![](https://i.imgur.com/poPO2y6.png)

5. Choose to use the new panel in function “oem_panel_select”. The “panel_id” will be passed to kernel.

![](https://i.imgur.com/ovKM7CE.png)
