一、DTS根节点增加节点
在根节点/{}下增加flash_rgb13h节点,节点内容如下:
flash_rgb13h: flash-rgb13h {
status = "okay";
compatible = "led,rgb13h";
label = "gpio-flash";
pinctrl-names = "default";
pinctrl-0 = <&flash_led_gpios>;
led-max-microamp = <20000>;
flash-max-microamp = <20000>;
flash-max-timeout-us = <1000000>;
enable-gpio = <&gpio2 RK_PC5 GPIO_ACTIVE_HIGH>;
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "back";
};
二、内核中添加rgb13h的驱动
驱动源文件leds-rgb13h.c在SDK的\kernel\drivers\leds路径下。
cd到kernel目录,启动配置界面,执行以下指令:
cd kernel
make ARCH=arm64 menuconfig
Device Drivers ------>
LED Support ------>
<*> LED Flash Class Support
<*> LED support for DL3020RGB13H flash LED controller
如果需要 V4L2 的API操作flash,需要选中V4L2 flash API for LED flash class devices
Device Drivers ------>
Multimedia support ------>
<*> V4L2 flash API for LED flash class devices
然后选择save,再选择exit退出配置界面。
然后命令行执行以下指令保存配置:
cp .config arch/arm64/configs/rockchip_linux_defconfig
返回上一级目录,然后重新编译内核:
cd ..
./build.sh kernel
编译好之后再烧写boot.img。
三、测试
启动之后/sys/class/leds路径下会出现gpio-flash
打开flash
echo 1 > gpio-flash/brightness
关闭flash
echo 0 > gpio-flash/brightness