Edit online

背光配置

14 Nov 2024
Read time: 3 minute(s)
如果没有调节背光亮度需求,仅仅是亮或黑屏,则用 GPIO 控制较为简单,只需要在 dts panel 节点中一个地方配置好就可以,如下:
注:
屏幕的调试尽量在 kernel 中完成,然后再移植到 uboot 中。
panel_xxx {
    compatible = "artinchip,aic-general-lvds-panel";
    status = "okay";

    enable-gpios = <&gpio_c 7 GPIO_ACTIVE_HIGH>; //背光控制引脚,须和原理图一致
    port {
        panel_lvds_in: endpoint {
            remote-endpoint = <&lvds0_out>;
        };
};

PWM 控制背光

如果有调节背光亮度的需求,则需要使用 PWM 来控制背光,配置如下参数,详细流程如下所示:
  1. board.dts 的 panel 节点,添加 backlight 节点:
    panel_xxx {
        compatible = "artinchip,aic-general-lvds-panel";
        status = "okay";
    
        //enable-gpios = <&gpio_c 7 GPIO_ACTIVE_HIGH>;
        backlight = <&backlight>;//添加 backlight
        port {
            panel_lvds_in: endpoint {
                remote-endpoint = <&lvds0_out>;
            };
    };
  2. board.dts 中,使能 backlight 节点:
    backlight: backlight {
         compatible = "pwm-backlight";
         /* pwm node name; pwm device No.; period_ns; pwm_polarity */
         pwms = <&pwm 0 1000000 0>; //硬件对应的哪一路 PWM 接口,需要和原理图确认
         brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; //每一级对应的占空百分比
         default-brightness-level = <6>;
         status = "okay";
    };
  3. board.dts 中,使能对应的 PWM:
    &pwm {
        status = "okay";    //PWM 节点总开关
        pinctrl-names = "default";
        pinctrl-0 = <&pwm0_pins_d>;    //添加背光控制 pinmux 引脚
        /* mode: up-count, down-count, up-down-count
           action: none, low, high, inverse */
        pwm0 {
            aic,mode = "up-count";
            aic,tb-clk-rate = <24000000>;
            aic,rise-edge-delay = <10>;
            aic,fall-edge-delay = <10>;
            /*            CBD,    CBU,    CAD,    CAU,    PRD,   ZRO */
            aic,action0 = "none", "none", "none", "low", "none", "high";
            aic,action1 = "none", "none", "none", "high", "none", "low";
            status = "okay";    //使能硬件对应那一路的 PWM 子节点
        };
        ......
    };
  4. board-u-boot.dtsi 中,添加对应的 PWM 节点:
    / {
        ......
        backlight: backlight {
            u-boot,dm-pre-reloc;
        };
    };
    
    &pwm {
        u-boot,dm-pre-reloc;
        pwm0 {
            u-boot,dm-pre-reloc;
        };
        ......
    };
    
    &pinctrl {
        ......
        pwm0_pins_d: pwm0-3 {
            u-boot,dm-pre-reloc;
            pins {
                u-boot,dm-pre-reloc;
            };
        };
        ......
    };
  5. 确认内核中,打开如下配置
    CONFIG_PWM=y
    CONFIG_PWM_ARTINCHIP=y
    CONFIG_BACKLIGHT_PWM=y
  6. 确认 uboot 中,打开如下配置
    CONFIG_PWM_ARTINCHIP=y
    CONFIG_BACKLIGHT_PWM=y

PWM 背光测试调试

  • 确认硬件信号的连通性。

  • 查看启动 log 是否有异常。

  • 查看如下命令节点是否存在,并通过命令调节背光或测试 PWM 输出信号:
    echo 5 > /sys/class/backlight/backlight/brightness //设置 brightness 级数, 对应到 backlight 节点设置的占空百分比。