Edit online

RGB

4 Dec 2024
Read time: 4 minute(s)

配置 Uboot

在 Luban 根目录下执行 make um,进入 uboot 的功能配置界面,使能显示模块驱动:
Device Drivers
    Graphics support
        ArtInChip Graphics  --->
            [*]   Enable ArtInChip Video Support
            [*]   ArtInChip display rgb support
            [ ]   ArtInChip display lvds support
            [ ]   ArtInChip display mipi-dsi support
            <*>   ArtInChip Panel Drivers (ArtInChip general RGB panel)  --->

配置 Kernel

在 Luban 根目录下执行 make km,进入 Kernel 的功能配置界面,使能显示模块驱动:

Device Drivers
    Graphics support
        ArtInChip Graphics  --->
            <*> ArtInChip Framebuffer support
            [*]   ArtInChip display rgb support
            [ ]   ArtInChip display lvds support
            [ ]   ArtInChip display mipi-dsi support
            <*>   ArtInChip Panel Drivers (ArtInChip general RGB panel)  --->

uboot dts

Uboot 如果要进行显示,则声明相应的配置为预加载,以 demo88_nand 工程为例,文件为 target/d211/demo88_nand/board-u-boot.dtsi

声明通路
&disp {
    u-boot,dm-pre-reloc;
    fb0: fb@0 {
        u-boot,dm-pre-reloc;
        port {
            fb0_out: endpoint {
                u-boot,dm-pre-reloc;
            }
        };
    };
};

&de0 {
    u-boot,dm-pre-reloc;
    port@0 {
        de0_in: endpoint {
            u-boot,dm-pre-reloc;
        };
    };

    port@1 {
        de0_out: endpoint {
            u-boot,dm-pre-reloc;
        };
    };
};
&rgb0 {                             //RGB
    u-boot,dm-pre-reloc;
    port@0 {
        rgb0_in: endpoint {
            u-boot,dm-pre-reloc;
        };
    };

    port@1 {
        rgb0_out: endpoint {
            u-boot,dm-pre-reloc;
        };
    };
};
声明屏幕参数
panel_rgb {
    u-boot,dm-pre-reloc;
    port {
        panel_rgb_in: endpoint {
        u-boot,dm-pre-reloc;
        };
    };

    display-timings {
        u-boot,dm-pre-reloc;
        timing0: 1024x600 {
            u-boot,dm-pre-reloc;
        };
    };
};
声明屏幕引脚
lcd_rgb565_ld_pins: lcd-1 {
    u-boot,dm-pre-reloc;
    pins {
        u-boot,dm-pre-reloc;
    };
};

系统 dts

系统的 dts 将进行完整的功能配置,以 demo88_nand 工程为例,文件为 target/d211/demo88_nand/board.dts
  1. 配置通路
    通过 port 和 status 结点,定义一条数据通道:
    fb       |      de    |     |     rgb    |     panel
    port  --> port0   port1 -->  port0   port1 -->  port
    &fb0 {
        port {
            fb0_out: endpoint {
                remote-endpoint = <&de0_in>;
            };
        };
    };
    
    &de0 {
        status = "okay";
        port@0 {
            reg = <0>;
            de0_in: endpoint {
            remote-endpoint = <&fb0_out>;
        };
    
        port@1 {
            reg = <1>;
            de0_out: endpoint {
                remote-endpoint = <&rgb0_in>;   //RGB
            }
        };
    };
    
    &rgb0 {
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&lcd_rgb565_ld_pins>;          //RGB
        pinctrl-1 = <&lcd_rgb565_ld_sleep_pins>;
        status = "okay";
        port@0 {
            reg = <0>;
            rgb0_in: endpoint {
                remote-endpoint = <&de0_out>;
            }
        };
    
        port@1 {
            reg = <1>;
            rgb0_out: endpoint {
                remote-endpoint = <&panel_rgb_in>;  //RGB
            };
        };
    }
  2. 配置屏幕参数

    其中类似 enable-gpios 控制引脚需要根据实际显示屏的需要增加或减少,驱动中做相应修改, rgb-modeinterface-format 需要从规格书中获取, data-order data-mirror 需要根据板级走线的顺序设置相关参数。 clock-phase 需要根据最终实际的显示效果做相应调整。 关于参数详细的解析,参考 Panel_RGB 的配置说明。

    panel_rgb {
    compatible = "artinchip,aic-general-rgb-panel";
    status = "okay";
    
    enable-gpios = <&gpio_e 19 GPIO_ACTIVE_HIGH>;
    sleep-gpios = <&gpio_e 15 GPIO_ACTIVE_HIGH>;
    rgb-mode = <PRGB>;
    interface-format = <PRGB_16BIT_LD>;
    clock-phase = <DEGREE_0>;
    data-order = <RGB>;
    disp-dither = <DITHER_RGB565>;
    
    port {
        panel_rgb_in: endpoint {
        remote-endpoint = <&rgb0_out>;
        };
    };
    
    display-timings {
        native-mode = <&timing0>;
        timing0: 1024x600 {
            lock-frequency = <52000000>;
            hactive = <1024>;
            vactive = <600>;
            hback-porch = <160>;
            hfront-porch = <160>;
            hsync-len = <20>;
            vback-porch = <12>;
            vfront-porch = <20>;
            vsync-len = <3>;
            de-active = <1>;
            pixelclk-active = <1>;
        };
    };
  3. 配置引脚

    引脚的配置统一在 d211-pinctrl.dtsi 中完成,在 rgb0 节点中直接进行了引用:

    &rgb0 {
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&lcd_rgb565_ld_pins>;
        pinctrl-1 = <&lcd_rgb565_ld_sleep_pins>;
        status = "okay";
        ......
    };