Edit online

屏幕配置

Read time: 22 minute(s)
提示:

尽量在 RT-Thread 中完成屏幕调试后,再移植到 Bootloader 中。

Edit online

RGB

Read time: 22 minute(s)

RGB 屏幕 (无需初始化)

对于无需初始化的 RGB 屏幕,使用 ``simple-panel`` 驱动,在 menuconfig 界面中配置屏幕规格书中的时序和规格参数即可。具体流程如下所示:

  1. Luban-Lite 根目录下执行 me,进入 menuconfig 的功能配置界面。
  2. 选择显示接口 Display RGB interface
    Board options  --->
        [*] Using Display Engine (DE)
            Display Parameter  --->
                select Display interface (Display RGB interface)  --->
                RGB interface options  --->
  3. 配置 RGB interface options 中的接口参数:
    Board options  --->
     Graphics Support  --->
         Graphics support
             [*] Display Support
                 select Display interface (Display RGB interface)  --->
                 RGB interface options  --->
                     rgb mode (PRGB)  --->
                     interface format (PRGB 16 BIT LD)  --->
                     data order (RGB)  --->
                     clock phase select(0 degree)  --->
    注: 显示接口参数详解可参考 Luban-Lite SDK 指南 Display 使用指南章节
  4. 选择 simple-panel 驱动:
    Board options  --->
            [*] Using Display Engine (DE)
                Display Parameter  --->
                        Display Panels  --->
                            ArtInChip Panel Drivers (ArtInChip simple panel)  --->
  5. 配置 simple-panel 的时序参数:
    Board options  --->
            [*] Using Display Engine (DE)
                Display Parameter  --->
                        Display Panels  --->
                            ArtInChip Panel Drivers (ArtInChip simple panel)  --->
                            display timing of simple panel  --->
                            (52) pixelclock in MHZ
                            (1024) hactive
                            (600) vactive
                            (160) hback-porch
                            (160) hfront-porch
                            (20) hsync-len
                            (12) vback-porch
                            (20) vfront-porch
                            (2) vsync-len
  6. 配置引脚功能。在 pinmux.c 文件中添加 LCD 的功能 (功能 2)引脚。

    demo128-nand 工程为例,在配置文件 target/d21x/demo128-nand/pinmux.c 中添加所需引脚。例如,对于 D213 芯片型号, PRGB 16 BIT LD 模式引脚配置如下所示:

    #ifdef AIC_PRGB_24BIT // rgb mode = PRGB, interface format = PRGB 16 BIT LD
            {2, PIN_PULL_DIS, 3, "PD.9"},
            {2, PIN_PULL_DIS, 3, "PD.10"},
            {2, PIN_PULL_DIS, 3, "PD.11"},
            {2, PIN_PULL_DIS, 3, "PD.12"},
            {2, PIN_PULL_DIS, 3, "PD.13"},
            {2, PIN_PULL_DIS, 3, "PD.14"},
            {2, PIN_PULL_DIS, 3, "PD.15"},
            {2, PIN_PULL_DIS, 3, "PD.16"},
            {2, PIN_PULL_DIS, 3, "PD.17"},
            {2, PIN_PULL_DIS, 3, "PD.18"},
            {2, PIN_PULL_DIS, 3, "PD.19"},
            {2, PIN_PULL_DIS, 3, "PD.20"},
            {2, PIN_PULL_DIS, 3, "PD.21"},
            {2, PIN_PULL_DIS, 3, "PD.22"},
            {2, PIN_PULL_DIS, 3, "PD.23"},
            {2, PIN_PULL_DIS, 3, "PD.24"},
            {2, PIN_PULL_DIS, 3, "PD.25"},
            {2, PIN_PULL_DIS, 3, "PD.26"},
            {2, PIN_PULL_DIS, 3, "PD.27"},
        #endif
    RGB 显示接口引脚取决于芯片型号,rgb mode 和 interface format。以 D213 芯片型号为例,其定义图如下:

RGB 屏幕 (SPI 初始化)

对于需要通过 SPI 发送初始化命令的 RGB 屏幕,需根据屏厂提供的资料,开发一款专用的驱动。开发步骤如下:
  1. 创建屏驱动
    • 复制模板文件 ``panel_rgb_st7701s.c``
    • 将新文件重命名为 ``panel_rgb_xxx.c`` (xxx 为屏驱 IC 型号)
  2. 注册新驱动文件
    • 修改 bsp\artinchip\drv\display\panel\Kconfig 文件,添加下列配置项,使新驱动在 menuconfig 界面可见:
      config AIC_PANEL_RGB_XXX
                  bool "ArtInChip RGB XXX panel"
                  depends on AIC_DISP_RGB
                  select AIC_PANEL_SPI_EMULATION
    • 修改 bsp/artinchip/SConscript 文件,添加编译规则:
      if GetDepend('AIC_PANEL_RGB_XXX'):
                  src += Glob('drv/display/panel/panel_rgb_xxx.c')
  3. 注册新 struct aic_panel 结构体。
    • 修改 panel_rgb_xxx.cstruct aic_panel 命名,重命名格式为 ``rgb_xxx``。
    • panel_com.h` 中 extern struct aic_panel rgb_xxx
      // panel_com.h
              extern struct aic_panel rgb_xxx;
    • panel_com.h 中 extern struct aic_panel rgb_xxx
      // panel_com.c
              static struct aic_panel *panels[] = {
                  ...
                  #ifdef AIC_PANEL_RGB_XXX
                      &rgb_xxx,
                  #endif
              };
  4. 设置屏幕时序和接口参数。
    • 修改 struct display_timing 结构体,根据 LCD 屏幕规格书修改时序参数:
      static struct display_timing xxx_timing = {
                  .pixelclock = 42000000,
                  .hactive = 400,
                  .hfront_porch = 100,
                  .hback_porch = 100,
                  .hsync_len = 10,
                  .vactive = 960,
                  .vfront_porch = 80,
                  .vback_porch = 100,
                  .vsync_len = 20,
              };
    • 修改 struct panel_rgb 结构体,根据 LCD 屏幕规格书和 PCB 连线修改显示接口参数:
      static struct panel_rgb rgb = {
                  .mode = PRGB,
                  .format = PRGB_24BIT,
                  .clock_phase = DEGREE_0,
                  .data_order = RGB,
                  .data_mirror = 0,
              };
    • 注: 显示接口参数详解可参考Display 使用指南
  5. 添加初始化操作
    • 重新实现 ``struct aic_panel_funcs`` 结构体中的 `prepare` 或者 `enable` 接口,发送初始化命令
      static struct aic_panel_funcs st7701s_funcs = {
                  .disable = panel_default_disable,
                  .unprepare = panel_default_unprepare,
                  .prepare = panel_default_prepare,
                  .enable = panel_enable,
                  .register_callback = panel_register_callback,
              };
    • 根据板卡原理图添加 ``reset`` 或 ``power`` 控制引脚的逻辑

      如果不需要软件控制 reset 引脚,该步骤可省略

      #define RESET_PIN "PE.1"
              static struct gpio_desc reset_gpio;
              static struct gpio_desc sleep_gpio;
      
              static void panel_gpio_init(void)
              {
                  panel_get_gpio(&reset_gpio, RESET_PIN);
                  panel_get_gpio(&sleep_gpio, SLEEP_PIN);
      
                  panel_gpio_set_value(&sleep_gpio, 1);
                  aic_delay_ms(2);
                  panel_gpio_set_value(&reset_gpio, 0);
                  aic_delay_ms(20);
                  panel_gpio_set_value(&reset_gpio, 1);
                  aic_delay_ms(120);
              }
  6. 配置 SPI 引脚
    • 根据板卡原理图指定 SPI 引脚
      #define CS         "PE.3"
              #define SCL        "PA.8"
              #define SDI        "PA.9"
    • 在 SPI 发送前初始化相关引脚
      static int panel_enable(struct aic_panel *panel)
              {
                  panel_spi_device_emulation(CS, SDI, SCL);
                  ...
                  // 发送初始化命令
              }
  7. 配置引脚功能

    在 pinmux.c 文件中添加引脚功能,包括 LCD 引脚,SPI 引脚 和 reset 控制引脚

    demo128-nand 工程为例,在 target/d21x/demo128-nand/pinmux.c 文件中添加所需引脚:

    • 按板卡原理图添加控制引脚和 SPI 引脚,设置功能 1
      #ifdef AIC_PANEL_RGB_XXX
                  ...
                  {1, PIN_PULL_DIS, 3, "PE.3"}, // CS
                  {1, PIN_PULL_DIS, 3, "PA.8"}, // SCL
                  {1, PIN_PULL_DIS, 3, "PA.9"}, // SDA
                  {1, PIN_PULL_DIS, 3, "PE.1"}, // RESET_PIN
              #endif
    • 根据芯片型号和显示接口参数,添加 LCD 引脚,配置功能 2
      #ifdef AIC_PANEL_RGB_XXX // D213, mode = PRGB, format = PRGB_24BIT
                  {2, PIN_PULL_DIS, 3, "PD.0"},
                  {2, PIN_PULL_DIS, 3, "PD.1"},
                  {2, PIN_PULL_DIS, 3, "PD.2"},
                  {2, PIN_PULL_DIS, 3, "PD.3"},
                  {2, PIN_PULL_DIS, 3, "PD.4"},
                  {2, PIN_PULL_DIS, 3, "PD.5"},
                  {2, PIN_PULL_DIS, 3, "PD.6"},
                  {2, PIN_PULL_DIS, 3, "PD.7"},
                  {2, PIN_PULL_DIS, 3, "PD.8"},
                  {2, PIN_PULL_DIS, 3, "PD.9"},
                  {2, PIN_PULL_DIS, 3, "PD.10"},
                  {2, PIN_PULL_DIS, 3, "PD.11"},
                  {2, PIN_PULL_DIS, 3, "PD.12"},
                  {2, PIN_PULL_DIS, 3, "PD.13"},
                  {2, PIN_PULL_DIS, 3, "PD.14"},
                  {2, PIN_PULL_DIS, 3, "PD.15"},
                  {2, PIN_PULL_DIS, 3, "PD.16"},
                  {2, PIN_PULL_DIS, 3, "PD.17"},
                  {2, PIN_PULL_DIS, 3, "PD.18"},
                  {2, PIN_PULL_DIS, 3, "PD.19"},
                  {2, PIN_PULL_DIS, 3, "PD.20"},
                  {2, PIN_PULL_DIS, 3, "PD.21"},
                  {2, PIN_PULL_DIS, 3, "PD.22"},
                  {2, PIN_PULL_DIS, 3, "PD.23"},
                  {2, PIN_PULL_DIS, 3, "PD.24"},
                  {2, PIN_PULL_DIS, 3, "PD.25"},
                  {2, PIN_PULL_DIS, 3, "PD.26"},
                  {2, PIN_PULL_DIS, 3, "PD.27"},
              #endif
    • RGB 显示接口引脚定义图如下:
  8. 使能新建的 panel 驱动

    在 Luban-Lite 根目录下执行 me,进入 menuconfig 的功能配置界面。

    • 选择显示接口 Display RGB interface:
      Board options  --->
                  [*] Using Display Engine (DE)
                      Display Parameter  --->
                          select Display interface (Display RGB interface)  --->
                          RGB interface options  --->
    • 选择新建的 ArtInChip RGB XXX panel 驱动:
      Board options  --->
                  [*] Using Display Engine (DE)
                      Display Parameter  --->
                              Display Panels  --->
                                  ArtInChip Panel Drivers (ArtInChip RGB XXX panel)  --->
Edit online

LVDS

Read time: 22 minute(s)

调试 LVDS 屏,使用 simple-panel 驱动,在 menuconfig 界面配置屏规格书中的时序和规格参数即可。配置流程如下:

在 Luban-Lite 根目录下执行 me,进入 menuconfig 的功能配置界面。

  1. 选择显示接口:
    Board options  --->
        [*] Using Display Engine (DE)
            Display Parameter  --->
                select Display interface (Display LVDS interface)  --->
                LVDS interface options  --->
    
  2. 配置下列接口参数:
    Board options  --->
      Graphics Support  --->
          Graphics support
              [*] Display Support
                  select Display interface (Display LVDS interface)  --->
                  LVDS interface options  --->
                      lvds mode (vesa-24)  --->
                      lvds link mode (single link 1)  --->
    
  3. 配置屏参数:
    Board options  --->
        Graphics Support  --->
            Graphics support
                [*] Display Support
                    select Display interface (Display LVDS interface)  --->
                    LVDS interface options  --->
                    Display Panels  --->
                        ArtInChip Panel Drivers (ArtInChip simple panel)  --->
                        display timing of simple panel  --->
    
  4. 配置 LVDS Link 通道顺序和极性

    根据原理图修改配置文件 ``bsp/artinchip/drv/display/disp_conf.h``

    使用硬件设计指南的推荐设计,不需要修改下列参数

    注: 显示接口参数详解可参考 Luban-Lite SDK 指南 Display 使用指南章节
    /* lvds link swap enable, swap lvds link0 and link1 */
        #define AIC_LVDS_LINK_SWAP_EN   0
    
        /**
        * lvds channel output order
        *
        * default LVDS_LANES(LVDS_D3, LVDS_CK, LVDS_D2, LVDS_D1, LVDS_D0)
        *
        * link 0 default D3         CK         D2         D1         D0
        *                PD26/PD27  PD24/PD25  PD22/PD23  PD20/PD21  PD18/PD19
        *
        * link 1 default D3         CK         D2         D1         D0
        *                PD16/PD17  PD14/PD15  PD12/PD13  PD10/PD11  PD8/PD9
        *
        *
        * link 0 example LVDS_LANES(LVDS_D2, LVDS_CK, LVDS_D3, LVDS_D1, LVDS_D0)
        *
        *                D2         CK         D3         D1         D0
        *                PD26/PD27  PD24/PD25  PD22/PD23  PD20/PD21  PD18/PD19
        *
        * link1 example is the same as link0
        */
        #define AIC_LVDS_LINK0_LANES      LVDS_LANES(LVDS_D3, LVDS_CK, LVDS_D2, LVDS_D1, LVDS_D0)
        #define AIC_LVDS_LINK1_LANES      LVDS_LANES(LVDS_D3, LVDS_CK, LVDS_D2, LVDS_D1, LVDS_D0)
    
        /**
        * lvds channel polarities
        *
        * link 0 default 0b00000
        *                PD26/PD27  PD24/PD25  PD22/PD23  PD20/PD21  PD18/PD19
        *                N/P        N/P        N/P        N/P        N/P
        *
        * link 1 default 0b00000
        *                PD16/PD17  PD14/PD15  PD12/PD13  PD10/PD11  PD8/PD9
        *                N/P        N/P        N/P        N/P        N/P
        *
        *
        * link 0 example 0b01010
        *                PD26/PD27  PD24/PD25  PD22/PD23  PD20/PD21  PD18/PD19
        *                N/P        P/N        N/P        P/N        N/P
        *
        * link1 example is the same as link0
        */
        #define AIC_LVDS_LINK0_POL        0b00000
        #define AIC_LVDS_LINK1_POL        0b00000
  5. 编辑 pinmux.c 文件配置引脚。

    以 demo128-nand 工程为例,在 target/d21x/demo128-nand/pinmux.c 中添加以下配置:

    LVDS 有三组引脚配置,根据使用的模式进行选择,以下为 LVDS 引脚组合:

    #ifdef AIC_LVDS_LINK_0 // lvds link mode = single link 0
            {3, PIN_PULL_DIS, 3, "PD.18"},
            {3, PIN_PULL_DIS, 3, "PD.19"},
            {3, PIN_PULL_DIS, 3, "PD.20"},
            {3, PIN_PULL_DIS, 3, "PD.21"},
            {3, PIN_PULL_DIS, 3, "PD.22"},
            {3, PIN_PULL_DIS, 3, "PD.23"},
            {3, PIN_PULL_DIS, 3, "PD.24"},
            {3, PIN_PULL_DIS, 3, "PD.25"},
            {3, PIN_PULL_DIS, 3, "PD.26"},
            {3, PIN_PULL_DIS, 3, "PD.27"},
        #endif#ifdef AIC_LVDS_LINK_1 // lvds link mode = single link 1
            {3, PIN_PULL_DIS, 3, "PD.8"},
            {3, PIN_PULL_DIS, 3, "PD.9"},
            {3, PIN_PULL_DIS, 3, "PD.10"},
            {3, PIN_PULL_DIS, 3, "PD.11"},
            {3, PIN_PULL_DIS, 3, "PD.12"},
            {3, PIN_PULL_DIS, 3, "PD.13"},
            {3, PIN_PULL_DIS, 3, "PD.14"},
            {3, PIN_PULL_DIS, 3, "PD.15"},
            {3, PIN_PULL_DIS, 3, "PD.16"},
            {3, PIN_PULL_DIS, 3, "PD.17"},
        #endif#if defined(AIC_LVDS_DOUBLE_SCREEN) || defined(AIC_LVDS_DUAL_LINK) // lvds link mode = double screen / dual link
            {3, PIN_PULL_DIS, 3, "PD.8"},
            {3, PIN_PULL_DIS, 3, "PD.9"},
            {3, PIN_PULL_DIS, 3, "PD.10"},
            {3, PIN_PULL_DIS, 3, "PD.11"},
            {3, PIN_PULL_DIS, 3, "PD.12"},
            {3, PIN_PULL_DIS, 3, "PD.13"},
            {3, PIN_PULL_DIS, 3, "PD.14"},
            {3, PIN_PULL_DIS, 3, "PD.15"},
            {3, PIN_PULL_DIS, 3, "PD.16"},
            {3, PIN_PULL_DIS, 3, "PD.17"},
            {3, PIN_PULL_DIS, 3, "PD.18"},
            {3, PIN_PULL_DIS, 3, "PD.19"},
            {3, PIN_PULL_DIS, 3, "PD.20"},
            {3, PIN_PULL_DIS, 3, "PD.21"},
            {3, PIN_PULL_DIS, 3, "PD.22"},
            {3, PIN_PULL_DIS, 3, "PD.23"},
            {3, PIN_PULL_DIS, 3, "PD.24"},
            {3, PIN_PULL_DIS, 3, "PD.25"},
            {3, PIN_PULL_DIS, 3, "PD.26"},
            {3, PIN_PULL_DIS, 3, "PD.27"},
        #endif
Edit online

MIPI

Read time: 22 minute(s)
MIPI-DSI 屏幕通常需要初始化,调试时需根据屏厂提供的资料,开发一款专用的驱动。开发步骤如下:。
  1. 新增一款屏驱动:
    • 复制模块文件 ``panel_dsi_xm91080.c``
    • 将新文件重命名为 ``panel_dsi_xxx.c`` (xxx 为屏驱 IC 型号)
  2. 注册新驱动文件。
    • 修改 ``bsp\artinchip\drv\display\panel\Kconfig`` 文件,添加配置项,让新驱动在 menuconfig 界面可见。

      config AIC_PANEL_DSI_XXX
                  bool "ArtInChip MIPI DSI XXX panel"
                  depends on AIC_DISP_MIPI_DSI
    • 修改 bsp/artinchip/SConscript 文件,添加编译规则。

      if GetDepend('AIC_PANEL_DSI_XXX'):
                  src += Glob('drv/display/panel/panel_dsi_xxx.c')
  3. 注册新 struct aic_panel 结构体:
    • 修改 panel_dsi_xxx.c 的 struct aic_panel 命名,重命名为 dsi_xxx
    • 在 panel_com.h 中 extern struct aic_panel dsi_xxx
      // panel_com.h
              extern struct aic_panel dsi_xxx;
    • 将 dsi_xxx 添加到 ``panel_com.c`` 文件的 panels[] 指针数组中
      // panel_com.c
              static struct aic_panel *panels[] = {
                  ...
                  #ifdef AIC_PANEL_DSI_XXX
                      &dsi_xxx,
                  #endif
              };
  4. 设置屏幕时序和接口参数*。
    • 修改 ``struct display_timing`` 结构体,根据 LCD 屏幕规格书修改时序参数
      static struct display_timing xxx_timing = {
                  .pixelclock = 130000000,
                  .hactive = 1080,
                  .hfront_porch = 160,
                  .hback_porch = 160,
                  .hsync_len = 40,
                  .vactive = 1920,
                  .vfront_porch = 10,
                  .vback_porch = 20,
                  .vsync_len = 8,
              };
    • 修改 struct panel_dsi 结构体,根据 LCD 屏幕规格书修改显示接口参数
      struct panel_dsi dsi = {
                  .mode = DSI_MOD_VID_BURST,
                  .format = DSI_FMT_RGB888,
                  .lane_num = 4,
              };
    • 根据 PCB 原理图修改 MIPI-DSI 通道顺序和极性

      修改 bsp\artinchip\drv\display\disp_conf.h 文件下列宏定义

      使用硬件设计指南的推荐设计,不需要修改下列参数

      /**
              * MIPI-DSI options
              */
      
              /**
              * data lane assignments, default 0x3210
              *
              * default D3          D2          D1          D0
              *         PD26/PD27   PD24/PD25   PD20/PD21   PD18/PD19
              *
              * example 0x0123
              *         D0          D1          D2          D3
              *         PD26/PD27   PD24/PD25   PD20/PD21   PD18/PD19
              */
              #define LANE_ASSIGNMENTS 0x3210
      
              /**
              * data lane polarities, default 0b0000
              *
              * default PD26/PD27   PD24/PD25   PD19/PD20   PD17/PD18
              *         N/P         N/P         N/P         N/P
              *
              * example 0b1010
              *         PD26/PD27   PD24/PD25   PD19/PD20   PD17/PD18
              *         P/N         N/P         P/N         N/P
              *
              * LANE_POLARITIES 0b1010
              */
              #define LANE_POLARITIES  0b0000
      
              /**
              * data clk inverse, default 0
              *
              * default PD22/PD23
              *         N/P
              *
              * example 1
              *         PD23/PD22
              *         P/N
              */
              #define CLK_INVERSE      0
    注: 部分 MIPI 屏幕对 timing 时序较为敏感,时序不匹配可能会导致颜色异常,图像错位等显示问题。增大消隐区,更换 video mode 可以改善显示异常问题, 推荐使用 DSI_MOD_VID_BURST mode,显示异常时增大 hbp hfp
  5. 添加初始化操作*。
    • 重新实现 struct aic_panel_funcs 结构体中的 prepare 或者 enable 接口,发送初始化命令
      static struct aic_panel_funcs st7701s_funcs = {
                  .disable = panel_default_disable,
                  .unprepare = panel_default_unprepare,
                  .prepare = panel_default_prepare,
                  .enable = panel_enable,
                  .register_callback = panel_register_callback,
              };
    • 根据板卡原理图添加 ``reset`` 或 ``power`` 控制引脚的逻辑

      如果不需要软件控制 reset 引脚,该步骤可省略

      #define RESET_PIN "PE.14"
              static struct gpio_desc reset_gpio;
      
              static void panel_gpio_init(void)
              {
                  panel_get_gpio(&reset_gpio, RESET_PIN);
      
                  panel_gpio_set_value(&reset_gpio, 1);
                  aic_delay_ms(120);
              }
  6. 配置屏幕引脚功能。

    在 pinmux.c 文件中添加屏幕引脚

    以 demo128-nand 工程为例,在 target/d21x/demo128-nand/pinmux.c 中配置屏幕引脚

    • 添加 reset 等控制引脚,配置功能 1

      如果不需要软件控制 reset 引脚,该步骤可省略

      #ifdef AIC_DISP_MIPI_DSI
                  ...
                  {1, PIN_PULL_DIS, 3, "PE.14"},  // reset gpio
              #endif
    • 添加 MIPI-DSI 信号引脚,配置功能 4
      #ifdef AIC_DISP_MIPI_DSI // MIPI DSI 只有一组 pinmux 配置,根据使用的通道数量和原理图接线进行修改
                  {4, PIN_PULL_DIS, 3, "PD.18"},
                  {4, PIN_PULL_DIS, 3, "PD.19"},
                  {4, PIN_PULL_DIS, 3, "PD.20"},
                  {4, PIN_PULL_DIS, 3, "PD.21"},
                  {4, PIN_PULL_DIS, 3, "PD.22"},
                  {4, PIN_PULL_DIS, 3, "PD.23"},
                  {4, PIN_PULL_DIS, 3, "PD.24"},
                  {4, PIN_PULL_DIS, 3, "PD.25"},
                  {4, PIN_PULL_DIS, 3, "PD.26"},
                  {4, PIN_PULL_DIS, 3, "PD.27"},
              #endif
  7. 使能新建的 panel 驱动

    在 Luban-Lite 根目录下执行 me,进入 menuconfig 的功能配置界面。

    • 配置显示接口:
      Board options  --->
                  [*] Using Display Engine (DE)
                      Display Parameter  --->
                          select Display interface (Display MIPI-DSI interface)  --->
    • 选择新建的 ArtInChip MIPI DSI panel 驱动:
      Board options  --->
                  [*] Using Display Engine (DE)
                      Display Parameter  --->
                          Display Panels  --->
                              ArtInChip Panel Drivers (ArtInChip MIPI DSI XXX panel)  --->
Edit online

MIPI-DBI

Read time: 22 minute(s)

本节介绍了开发一款新的 ArtInChip MIPI-DBI 屏驱动的流程,以确保驱动能够正确初始化并工作。

ArtInChip 平台支持以下 MIPI-DBI 类型:

  • Type C: SPI
  • Type B: I8080
MIPI-DBI 屏幕通常需要初始化,调试时需根据屏厂提供的资料,开发一款专用的驱动。开发步骤如下:
  1. 新增一款屏驱动。

    根据屏幕的接口类型 (Type B: I8080 或 Type C: SPI),从现有的参考文件中复制代码。

    • Type B I8080 接口可参考:panel_dbi_st7789.c
    • Type C SPI 接口可参考:panel_dbi_st7789t3.c
  2. 将新文件重命名为 panel_dbi_xxx.c,其中 xxx 为屏驱 IC 型号。

    例如,屏驱 IC 型号为 st77903,则新文件名称为 panel_dbi_st77903.c。以下均以 st77903 屏驱 IC 型号为例。

  3. 注册新驱动文件。
    • 修改 bsp/artinchip/drv/display/panel/Kconfig 文件,添加配置项,让新驱动在 menuconfig 界面可见:
      config AIC_PANEL_DBI_ST77903
                  bool "ArtInChip MIPI DBI ST77903 panel"
                  depends on AIC_DISP_MIPI_DBI
    • 修改 bsp/artinchip/SConscript 文件,添加编译规则:
      if GetDepend('AIC_PANEL_DBI_ST77903):
                  src += Glob('drv/display/panel/panel_dbi_st77903.c')
  4. 注册新 struct aic_panel 结构体。
    • 修改 panel_dbi_st77903.c 的 struct aic_panel 命名,重命名为 dbi_st77903。
    • panel_com.h 中添加 extern struct aic_panel dbi_st77903
      // panel_com.h
              extern struct aic_panel dbi_xxx;
    • 将 dbi_st77903 添加到 panel_com.c 文件的 panels[] 指针数组中:
      // panel_com.c
              static struct aic_panel *panels[] = {
                  ...
                  #ifdef AIC_PANEL_DBI_st77903
                      &dbi_st77903,
                  #endif
              };
  5. 设置屏幕时序和接口参数。
    • 修改 struct display_timing 结构体,根据 LCD 屏幕规格书修改时序参数。
      static struct display_timing st77903_timing = {
                  .pixelclock = 130000000,
                  .hactive = 1080,
                  .hfront_porch = 160,
                  .hback_porch = 160,
                  .hsync_len = 40,
                  .vactive = 1920,
                  .vfront_porch = 10,
                  .vback_porch = 20,
                  .vsync_len = 8,
              };
    • 修改 struct panel_dbi 结构体,根据 LCD 屏幕规格书修改显示接口类型并添加初始化命令。
      static struct panel_dbi dbi = {
                  .type = SPI,
                  .format = SPI_4LINE_RGB565,
                  .commands = {
                      .buf = st7789t3_commands,
                      .len = ARRAY_SIZE(st7789t3_commands),
                  }
              };
  6. pinmux.c 文件中添加屏幕引脚,配置屏幕引脚功能。
    以 demo128-nand 工程为例,在 target/d21x/demo128-nand/pinmux.c 中配置屏幕引脚,根据芯片型号和接口参数添加 MIPI-DBI 信号引脚,配置功能 2:
    #ifdef AIC_PANEL_DBI_XXX
                {2, PIN_PULL_DIS, 3, "PD.16"},
                {2, PIN_PULL_DIS, 3, "PD.17"},
                {2, PIN_PULL_DIS, 3, "PD.18"},
                {2, PIN_PULL_DIS, 3, "PD.19"},
                {2, PIN_PULL_DIS, 3, "PD.20"},
                {2, PIN_PULL_DIS, 3, "PD.21"},
                {2, PIN_PULL_DIS, 3, "PD.22"},
                {2, PIN_PULL_DIS, 3, "PD.23"},
                {2, PIN_PULL_DIS, 3, "PD.24"},
                {2, PIN_PULL_DIS, 3, "PD.25"},
                {2, PIN_PULL_DIS, 3, "PD.26"},
                {2, PIN_PULL_DIS, 3, "PD.27"},
            #endif
    • Type B I8080 引脚定义如下:


    • Type C SPI 引脚定义如下:

  7. 使能新建的 panel 驱动。

    在 Luban-Lite 根目录下执行 me,进入 menuconfig 的功能配置界面。

    • 选择显示接口类型 Display MIPI-DBI interface:
      Board options  --->
                  [*] Using Display Engine (DE)
                      Display Parameter  --->
                          select Display interface (Display MIPI-DBI interface)  --->
    • 选择新建的 ArtInChip MIPI DBI panel 驱动,即 ArtInChip MIPI DBI st77903 panel:
      Board options  --->
                  [*] Using Display Engine (DE)
                      Display Parameter  --->
                              Display Panels  --->
                                  ArtInChip Panel Drivers (ArtInChip MIPI DBI st77903 panel)  --->
Edit online

背光配置

Read time: 22 minute(s)
根据是否需要调节背光亮度,用户可以选择以下任意方式控制背光:
  • GPIO 控制背光:如果没有调节背光亮度需求,仅仅是亮或黑屏。

    打开 menuconfig 配置界面,选择 GPIO 方式控制背光,以字符串的形式指定 GPIO 引脚,背光 GPIO 引脚默认高电平有效。

    Board options  --->
        [*] Using Display Engine (DE)
            Display Parameter  --->
                panel backlight control (gpio)  --->
            (PE.19) panel backlight enable pin
            [ ] panel backlight enable pin low active
  • PWM 控制背光:如果有调节背光亮度的需求。
    1. 打开 menuconfig 配置界面。,
    2. 使能 PWM,选择 PWM 方式控制背光。
      Board options  --->
          [*] Using PWM3
    3. 配置 PWM-BACKLIGHT 的通道和默认占空比 [0, 100]
      Board options  --->
          [*] Using Display Engine (DE)
              Display Parameter  --->
                  panel backlight control (pwm)  --->
              (3) pwm backlight channel
              (80)default brightness level
    4. 如果需要修改 PWM-BACKLIGHT 频率,如下:

      部分 PWM 频点可能会导致啸叫,修改源码 bsp/artinchip/drv/display/panel/panel_com.c

      void panel_backlight_enable(struct aic_panel *panel, u32 ms)
              {
                  ...
                  // 默认 1KHz
                  /* pwm frequency: 1KHz = 1000000ns */
                  rt_pwm_set(pwm_dev, AIC_PWM_BACKLIGHT_CHANNEL,
                          1000000, 10000 * AIC_PWM_BRIGHTNESS_LEVEL);
              }
Edit online

启动 log

Read time: 22 minute(s)
显示子系统在初始化时会打印当前 Panel 和 Framebuffer 地址,可初步判断 Panel 是否被成功加载。
[I] aic_find_panel()106 find panel driver : panel-lvds
    [I] aicfb_probe()1037 fb0 allocated at 0x41000040
  1. 出现 failed to find panel component 打印信息:
    • 未注册 panel,按 BringUp 流程检查遗漏步骤。
  2. 出现 alloc frame buffer failed 错误打印信息:
    • 当前内存不足,申请 Framebuffer 失败。
    • 更换 Framebuffer format, 使用 RGB565 格式。
    • 使用大容量封装型号。