我是靠谱客的博主 追寻猎豹,最近开发中收集的这篇文章主要介绍【f1c200s/f1c100s】屏幕背光驱动适配前言设备树修改内核配置结果,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

屏幕背光启驱动适配

  • 前言
  • 设备树修改
  • 内核配置
  • 结果

前言

目前大部分嵌入式设备还是采用PWM调光的方式,当然我的mangopi也是采用这种方式进行背光调节的。linux是自带背光控制驱动程序的,要使用背光控制接口首先得调通PWM得驱动,可以参考上一篇博客PWM驱动适配。
既然都有了PWM驱动了,其实就可以控制屏幕背光了,还去调专用的背光控制接口也仅仅是为了简化控制方法吧。

设备树修改

PWM驱动调试成功以后,还需要在设备树根节点中添加backlight节点,如下所示:

backlight: backlight {
		compatible = "pwm-backlight"; //适配内核pwm-backlight驱动
		pwms = <&pwm 1 500000 0>; //引用PWM1 也就是PWM驱动
		pwm-names = "backlight";
		brightness-levels = <0 4 8 16 32 64 128 255>;
		default-brightness-level = <7>;
		status = "okay";
	};

其中关于节点中的各属性含义可参考内核绑定文档Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt。引用如下:

equired properties:
  - compatible: "pwm-backlight"
  - pwms: OF device-tree PWM specification (see PWM binding[0])
  - power-supply: regulator for supply voltage

Optional properties:
  - pwm-names: a list of names for the PWM devices specified in the
               "pwms" property (see PWM binding[0])
  - enable-gpios: contains a single GPIO specifier for the GPIO which enables
                  and disables the backlight (see GPIO binding[1])
  - post-pwm-on-delay-ms: Delay in ms between setting an initial (non-zero) PWM
                          and enabling the backlight using GPIO.
  - pwm-off-delay-ms: Delay in ms between disabling the backlight using GPIO
                      and setting PWM value to 0.
  - brightness-levels: Array of distinct brightness levels. Typically these
                       are in the range from 0 to 255, but any range starting at
                       0 will do. The actual brightness level (PWM duty cycle)
                       will be interpolated from these values. 0 means a 0% duty
                       cycle (darkest/off), while the last value in the array
                       represents a 100% duty cycle (brightest).
  - default-brightness-level: The default brightness level (index into the
                              array defined by the "brightness-levels" property).
  - num-interpolated-steps: Number of interpolated steps between each value
                            of brightness-levels table. This way a high
                            resolution pwm duty cycle can be used without
                            having to list out every possible value in the
                            brightness-level array.

其中brightness-levels意思就是:
这是一个描述亮度等级的数组,一般是从0到255,0代表亮度为0,255代表亮度为最亮。中间的亮度通过插值进行确定。
在这里brightness-levels = <0 4 8 16 32 64 128 255>,一共分为了8个等级(从0到7)。
default-brightness-level:默认的亮度等级,这里设置为最高亮度等级7。

内核配置

在menuconfig中打开以下选项以使能PWM背光控制:
在这里插入图片描述

结果

启动系统后,在目录/sys/class/backlight/backlight中可以看到和背光相关的目录:

root@mangopi:/sys/class/backlight/backlight# ls
actual_brightness  brightness  max_brightness  subsystem  uevent
bl_power           device      power           type

通过修改brightness即可修改屏幕亮度:

echo 7 > brightness
echo 6 > brightness

最后

以上就是追寻猎豹为你收集整理的【f1c200s/f1c100s】屏幕背光驱动适配前言设备树修改内核配置结果的全部内容,希望文章能够帮你解决【f1c200s/f1c100s】屏幕背光驱动适配前言设备树修改内核配置结果所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(37)

评论列表共有 0 条评论

立即
投稿
返回
顶部