RK平台mipi屏初始化序列配置

RK平台mipi屏初始化序列都是在dts中进行配置,有两种方式,下面分别介绍两种方式的配置方法。

方式一

RK平台较老的SDK采用下面方式配置mipi参数,如:RK3128 5.1 SDK中就是采用的下面方式。

示例:

/ {
    /* about mipi */
    disp_mipi_init: mipi_dsi_init{
        compatible = "rockchip,mipi_dsi_init";
        rockchip,screen_init    = <1>;
        rockchip,dsi_lane       = <4>;
        rockchip,dsi_hs_clk     = <550>;
        rockchip,mipi_dsi_num   = <1>;
    };
    
    disp_mipi_power_ctr: mipi_power_ctr {
        compatible = "rockchip,mipi_power_ctr";
        
        /*
        mipi_lcd_rst:mipi_lcd_rst{
            compatible = "rockchip,lcd_rst";
            rockchip,gpios = <&gpio2 GPIO_D1 GPIO_ACTIVE_HIGH>;
            rockchip,delay = <20>;
        };
        
        mipi_lcd_en:mipi_lcd_en {
            compatible = "rockchip,lcd_en";
            rockchip,gpios = <&gpio2 GPIO_D0 GPIO_ACTIVE_LOW>;
            rockchip,delay = <100>;
        };
        */
    };
    
    disp_mipi_init_cmds: screen-on-cmds {
        compatible = "rockchip,screen-on-cmds";
        rockchip,cmd_debug = <1>;
        
        rockchip,on-cmds1 {
            compatible = "rockchip,on-cmds";
            rockchip,cmd_type = <LPDT>;
            rockchip,dsi_id = <0>;
            rockchip,cmd = <0x15 0xE0 0x00>;
            rockchip,cmd_delay = <0>;
        };
        
        rockchip,on-cmds2 {
            compatible = "rockchip,on-cmds";
            rockchip,cmd_type = <LPDT>;
            rockchip,dsi_id = <0>;
            rockchip,cmd = <0x39 0x55 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10>;
            rockchip,cmd_delay = <0>;
        };

        //SLP OUT
        rockchip,on-cmds3 {
            compatible = "rockchip,on-cmds";
            rockchip,cmd_type = <LPDT>;
            rockchip,dsi_id = <0>;
            rockchip,cmd = <0x05 0x11>;
            rockchip,cmd_delay = <120>;
        };

        //DISP ON
        rockchip,on-cmds4 {
            compatible = "rockchip,on-cmds";
            rockchip,cmd_type = <LPDT>;
            rockchip,dsi_id = <0>;
            rockchip,cmd = <0x05 0x29>;
            rockchip,cmd_delay = <5>;
        };
    };

    disp_timings: display-timings {
        native-mode = <&timing0>;
        compatible = "rockchip,display-timings";
        timing0: timing0 {
            screen-type = <SCREEN_MIPI>;
            lvds-format = <LVDS_8BIT_2>;
            out-face    = <OUT_P888>;
            
            clock-frequency = <67330000>;
            hactive = <800>;             
            vactive = <1280>;       
            hback-porch = <18>;           
            hfront-porch = <18>;          
            vback-porch = <10>;         
            vfront-porch = <20>;          
            hsync-len = <18>;            
            vsync-len = <4>;
            
            hsync-active = <0>;
            vsync-active = <0>;
            de-active = <0>;
            pixelclk-active = <0>;
            swap-rb = <0>;
            swap-rg = <0>;
            swap-gb = <0>;
        };
    };
};

这里只分析disp_mipi_init_cmds的配置规则,disp_mipi_init、disp_mipi_power_ctl、disp_timings不分析,其中disp_timings可以参考“如何确定lcd timing参数”。

下面代码段为一条mipi初始化数据,主要关心的参数有“rockchip,cmd”和“rockchip,cmd_delay”。

rockchip,on-cmds1 {
    compatible = "rockchip,on-cmds";
    rockchip,cmd_type = <LPDT>;
    rockchip,dsi_id = <0>;
    rockchip,cmd = <0x15 0xE0 0x00>;
    rockchip,cmd_delay = <0>;
};

rockchip,cmd

命令格式如下:

0x15 0xE0 0x00
 |     |   |
 |     |   数据
 |     寄存器地址
 命令类型(0x05: 单字节数据 0x15: 双字节数据 0x39: 多字节数据)

单字节数据举例:

rockchip,on-cmds3 {
    compatible = "rockchip,on-cmds";
    rockchip,cmd_type = <LPDT>;
    rockchip,dsi_id = <0>;
    rockchip,cmd = <0x05 0x11>;
    rockchip,cmd_delay = <120>;
};

双字节数据举例:

rockchip,on-cmds1 {
    compatible = "rockchip,on-cmds";
    rockchip,cmd_type = <LPDT>;
    rockchip,dsi_id = <0>;
    rockchip,cmd = <0x15 0xE0 0x00>;
    rockchip,cmd_delay = <0>;
};

多字节数据举例:

rockchip,on-cmds2 {
    compatible = "rockchip,on-cmds";
    rockchip,cmd_type = <LPDT>;
    rockchip,dsi_id = <0>;
    rockchip,cmd = <0x39 0x55 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10>;
    rockchip,cmd_delay = <0>;
};

rockchip,cmd_delay

此字段定义发送完命令后延时时长,单位毫秒(ms),大部分命令无须延时。

方式二

RK平台新的SDK已经统一采用下面方式配置mipi参数,如:RK3288 8.1 SDK中就是采用的下面方式。

示例:

&dsi0 {
    status = "okay";
    rockchip,lane-rate = <600>;

    panel: panel {
        compatible = "simple-panel-dsi";
        reg = <0>;
        backlight = <&backlight>;
        enable-gpios = <&gpio7 3 GPIO_ACTIVE_HIGH>;
        //reset-gpios = <&gpio7 4 GPIO_ACTIVE_HIGH>;
        power-supply = <&vcc_lcd>;
        dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST)>;
        dsi,format = <MIPI_DSI_FMT_RGB888>;
        dsi,lanes = <4>;
        reset-delay-ms = <20>;
        init-delay-ms = <20>;
        enable-delay-ms = <120>;
        prepare-delay-ms = <120>;
        status = "okay";
    
        panel-init-sequence = [
            15 00 02 80 77
            15 00 02 81 77
            15 00 02 82 77
            15 00 02 83 77
            15 00 02 84 77
            15 00 02 85 77
            15 00 02 86 77
            05 64 01 11
            05 14 01 29
        ];

        panel-exit-sequence = [
            05 64 01 28
            05 96 01 10
        ];

        disp_timings: display-timings {
            native-mode = <&timing2>;
            timing2: timing0 {
                clock-frequency = <52000000>;
                hactive = <1024>;
                vactive = <600>;
                hback-porch = <160>;
                hfront-porch = <160>;
                vback-porch = <23>;
                vfront-porch = <12>;
                hsync-len = <10>;
                vsync-len = <10>;
                hsync-active = <0>;
                vsync-active = <0>;
                de-active = <0>;
                pixelclk-active = <0>;
            };
        };
    };
};

这里依然只分析panel-init-sequence和panel-exit-sequence的配置规则,其它配置可以参考“如何确定lcd timing参数”。

新的mipi初始化序列配置规则与老方法其实是一致的,只是改写了表达方式,如下:

panel-init-sequence = [
    15 00 02 80 77
    15 00 02 81 77
    15 00 02 82 77
    15 00 02 83 77
    15 00 02 84 77
    15 00 02 85 77
    15 00 02 86 77
    39 00 0D C3 01 66 13 23 00 66 85 33 20 38 38 00
    05 64 01 11
    05 14 01 29
];

中括号里的内容,每一行表示一串命令字,规则如下:

15 00 02 80 77
 |  |  | |  |
 |  |  | |  数据
 |  |  | | 寄存器地址
 |  |  数据长度
 |  延时
 命令类型(0x05: 单字节数据 0x15: 双字节数据 0x39: 多字节数据)

单字节数据举例:

05 64 01 11

双字节数据举例:

15 00 02 86 77

多字节数据举例:

39 00 0D C3 01 66 13 23 00 66 85 33 20 38 38 00

 

如何确定lcd timing参数

这里以Rockchip平台为例,Rockchip平台lcd timing常见参数配置如下:

disp_timings: display-timings {
    native-mode = <&timing0>;
    timing0: timing0 {
        clock-frequency = <31000000>;
        hactive = <480>;
        vactive = <854>;
        hback-porch = <24>;
        hfront-porch = <72>;
        vback-porch = <10>;
        vfront-porch = <12>;
        hsync-len = <24>;
        vsync-len = <2>;
        hsync-active = <0>;
        vsync-active = <0>;
        de-active = <0>;
        pixelclk-active = <0>;
    };
};

常规参数

其中以下参数根据屏的规格书填写:

hactive = <480>;        // 分辨率-宽
vactive = <854>;        // 分辨率-高
hback-porch = <24>;     // 行可视范围前肩
hfront-porch = <72>;    // 行可视范围后肩
vback-porch = <10>;     // 帧可视前肩
vfront-porch = <12>;    // 帧可视后肩
hsync-len = <24>;       // 行同步肪冲宽度
vsync-len = <2>;        // 场同步脉冲宽度

以下参数表示对应信号的有效电平,默认为低电平(0):

hsync-active = <0>;     // 行同步信号
vsync-active = <0>;     // 场同步信号
de-active = <0>;        // de信号
pixelclk-active = <0>;  // clk信号

clock-frequency 的计算方法

已知下面参数:

  • fps: 屏幕刷新率(默认:60帧)
  • htotal: hactive + hback-porch + hfront-porch + hsync-len
  • vtotal: vactive + hfront-porch + vfront-porch + vsync-len

求clock-frequency公式如下:

htotal * vtotal * fps = clock-frequency

按照上面参考参数计算如下:

(480 + 24 + 72 + 24) x (854 + 10 + 12 + 2) x 60 = 31608000

计算出来的准确值为31608000,我们取整:

clock-frequency = <31000000>;

dsi_hs_clk 的计算方法

100 + ((htotal * vtotal * fps) * 3 * 8 / lanes)

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值