u-boot的DTS中有背光的控制,LINUX中的DTS没有
echo 1 > /sys/class/backlight/pwm-backlight/bl_power ---这个使用要哪个dts配合?
离线
# echo 0 > /sys/class/backlight/pwm-backlight/brightness
-sh: can't create /sys/class/backlight/pwm-backlight/brightness: nonexistent directory
--------------------------------------------------------------------------------
dts:
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 1000000 0>;
brightness-levels = <0 30 40 50 60 70 100>;
default-brightness-level = <6>;
};
离线
# echo 0 > /sys/class/backlight/pwm-backlight/brightness
-sh: can't create /sys/class/backlight/pwm-backlight/brightness: nonexistent directory
--------------------------------------------------------------------------------
dts:
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 1000000 0>;
brightness-levels = <0 30 40 50 60 70 100>;
default-brightness-level = <6>;
};
我用荔枝派zero驱动4.3寸屏背光没有问题
但是用7寸屏背光非常的暗,图像显示是正常的
我修改了linux源码中的sun8i-v3s-licheepi-zero-with-lcd.dtsi/ {
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 1000000 0>;
brightness-levels = <0 30 40 50 60 70 100>;
default-brightness-level = <70>;
};
重新编译之后背光还是很暗
请问还有其他的办法吗?
离线
backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 5000000>;brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;power-supply = <&vdd_bl_reg>;
enable-gpios = <&gpio 58 0>;
post-pwm-on-delay-ms = <10>;
pwm-off-delay-ms = <10>;
};
凭感觉 /sys/class/backlight/pwm-backlight/bl_power 应该对应是 enable-gpios
离线
mark
离线
backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 5000000>;brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;power-supply = <&vdd_bl_reg>;
enable-gpios = <&gpio 58 0>;
post-pwm-on-delay-ms = <10>;
pwm-off-delay-ms = <10>;
};凭感觉 /sys/class/backlight/pwm-backlight/bl_power 应该对应是 enable-gpios
晕哥 power-supply = <&vdd_bl_reg>;
enable-gpios = <&gpio 58 0>;
post-pwm-on-delay-ms = <10>;
pwm-off-delay-ms = <10>;
这些参数配置是从哪来的 在v3s上没有这些参数 内核是5.2.y 该如何配置呢 按照默认配置背光控制不起任何作用
但是单独控制pwm是可以调光的
echo 1 > /sys/class/pwm/pwmchip0/export
echo 1000000 > /sys/class/pwm/pwmchip0/pwm1/period
echo 200000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable
使用echo 1 > brightness不起任何作用 是设备树中缺少某些配置吗
离线
0 4 8 16 32 64 128 255
这几组数字呢?
这几组也不行 没有任何效果 不i知道是不是又其他地方需要使能啊 单独使用pwm是可以的
我的配置如下:
backlight: backlight {
compatible = "pwm-backlight";
//pwms = <&pwm 0 1000000 0>;
pwms = <&pwm 0 5000000 0>;
//brightness-levels = <0 30 40 50 60 70 100>;
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;
status = "okay";
};
&pwm {
pinctrl-names = "default";
pinctrl-0 = <&pwm1_pins>;
status = "okay";
};
pwm1_pins: pwm1 {
pins = "PB5";
function = "pwm1";
};
离线
echo 0 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 1 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 7 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 6 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 5 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 4 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 3 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 0 > /sys/class/backlight/backlight/brightness
echo 1 > /sys/class/backlight/backlight/brightness
echo 2 > /sys/class/backlight/backlight/brightness
echo 3 > /sys/class/backlight/backlight/brightness
echo 4 > /sys/class/backlight/backlight/brightness
echo 5 > /sys/class/backlight/backlight/brightness
echo 6 > /sys/class/backlight/backlight/brightness
echo 7 > /sys/class/backlight/backlight/brightness
echo 8 > /sys/class/backlight/backlight/brightness
echo 9 > /sys/class/backlight/backlight/brightness
刚刚试了一下, V3s linux4.13-y 背光有反应
离线
echo 0 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 1 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 7 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 6 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 5 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 4 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 3 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 0 > /sys/class/backlight/backlight/brightness echo 1 > /sys/class/backlight/backlight/brightness echo 2 > /sys/class/backlight/backlight/brightness echo 3 > /sys/class/backlight/backlight/brightness echo 4 > /sys/class/backlight/backlight/brightness echo 5 > /sys/class/backlight/backlight/brightness echo 6 > /sys/class/backlight/backlight/brightness echo 7 > /sys/class/backlight/backlight/brightness echo 8 > /sys/class/backlight/backlight/brightness echo 9 > /sys/class/backlight/backlight/brightness
刚刚试了一下, V3s linux4.13-y 背光有反应
打开了 跟pwm的设置都打开了 单独控制pwm没有问题
CONFIG_BACKLIGHT_CLASS_DEVICE=y
ONFIG_BACKLIGHT_GENERIC=y
CONFIG_BACKLIGHT_PWM=y
回头测下zero开发板 开发板用的是pb4 我用的是pb5 pwm可以单独控制 那背光应该也是可以的
离线
echo 0 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 1 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 7 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 6 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 5 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 4 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 3 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 0 > /sys/class/backlight/backlight/brightness echo 1 > /sys/class/backlight/backlight/brightness echo 2 > /sys/class/backlight/backlight/brightness echo 3 > /sys/class/backlight/backlight/brightness echo 4 > /sys/class/backlight/backlight/brightness echo 5 > /sys/class/backlight/backlight/brightness echo 6 > /sys/class/backlight/backlight/brightness echo 7 > /sys/class/backlight/backlight/brightness echo 8 > /sys/class/backlight/backlight/brightness echo 9 > /sys/class/backlight/backlight/brightness
刚刚试了一下, V3s linux4.13-y 背光有反应
我昨晚测试了一下荔枝派zero 他们使用的是pb4作为背光 测试确实是可以调节背光的 但是我使用的pb5就死活不行 不知道是不是还需要哪里配置 另外必须在uboot中指定背光为pb4 如果不指定的话也是不行的 您帮忙测试下pb5作为背光的调节吗 是不是哪里还需要配置 我目前没有找到配置点 谢谢
离线
pwms = <&pwm 0 5000000 0>;
是不是这里面可以调到PB5?
离线
遇到同样问题,同样现象
离线
# ls /sys/class/backlight/backlight/
actual_brightness device scale uevent
bl_power max_brightness subsystem
brightness power type
# echo 1 > /sys/class/backlight/backlight/bl_power 可以关闭背光
# echo 0 > /sys/class/backlight/backlight/bl_power 可以打开背光
# echo 6 > /sys/class/backlight/backlight/brightness 最大为6,设备树定义的没生效?
# echo 7 > /sys/class/backlight/backlight/brightness
sh: write error: Invalid argument
# cat /sys/class/backlight/backlight/max_brightness
6
设备树:
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 1000000 0>;
brightness-levels = <0 30 40 50 60 70 100>;
default-brightness-level = <100>;
};
最近编辑记录 xfdr0805 (2021-04-01 15:28:32)
离线
建议直接用 devmem 读写寄存器测试,看是不是驱动程序有bug?
离线
建议直接用 devmem 读写寄存器测试,看是不是驱动程序有bug?
仔细看了下输出内容,有下边2话
[ 0.070763] pwm-backlight backlight: supply power not found, using dummy regulator
[ 0.071204] pwm-backlight backlight: invalid default brightness level: 80, using 10
设备树直接改成这样
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 1000000 0>;
brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>;
default-brightness-level = <80>;
power-supply = <®_vcc3v3>;
enable-gpios = <&pio 1 4 0>;
post-pwm-on-delay-ms = <10>;
pwm-off-delay-ms = <10>;
};
离线
我的背光也没有
设备树如下
/*
* Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/dts-v1/;
#include "sun8i-v3s.dtsi"
#include "sunxi-common-regulators.dtsi"
/ {
model = "Lichee Pi Zero";
compatible = "licheepi,licheepi-zero", "allwinner,sun8i-v3s";
aliases {
serial0 = &uart0;
};
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 1000000 0>;
brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>;
default-brightness-level = <30>;
power-supply = <®_vcc3v3>;
enable-gpios = <&pio 1 4 0>;
post-pwm-on-delay-ms = <10>;
pwm-off-delay-ms = <10>;
};
chosen {
stdout-path = "serial0:115200n8";
};
leds {
compatible = "gpio-leds";
blue_led {
label = "licheepi:blue:usr";
gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
};
};
};
&ehci0 {
status = "okay";
};
&mmc0 {
pinctrl-0 = <&mmc0_pins_a>;
pinctrl-names = "default";
broken-cd;
bus-width = <4>;
vmmc-supply = <®_vcc3v3>;
status = "okay";
};
&i2c0 {
status = "okay";
clock-frequency = <200000>;
/*
ns2009: ns2009@48 {
compatible = "nsiway,ns2009";
reg = <0x48>;
};*/
sht2x@40{
compatible = "sensirion,sht2x";
reg = <0x40>;
};
gt911: touchscreen@14 {
compatible = "goodix,gt911";
reg = <0x5d>;
interrupt-parent = <&pio>;
interrupts = <1 2 IRQ_TYPE_EDGE_FALLING>; /* (PB5) */
pinctrl-names = "default";
irq-gpios = <&pio 1 2 GPIO_ACTIVE_HIGH>; /* (PB5) */
reset-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; /* RST (PB3) */
/* touchscreen-swapped-x-y */
};
};
&ohci0 {
status = "okay";
};
&uart0 {
pinctrl-0 = <&uart0_pins_a>;
pinctrl-names = "default";
status = "okay";
};
&usb_otg {
dr_mode = "otg";
status = "okay";
};
&usbphy {
usb0_id_det-gpio = <&pio 5 6 GPIO_ACTIVE_HIGH>;
status = "okay";
};
/*
* Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "sun8i-v3s-licheepi-zero.dts"
#include <dt-bindings/input/input.h>
/ {
model = "Lichee Pi Zero with Dock";
compatible = "licheepi,licheepi-zero-dock", "licheepi,licheepi-zero",
"allwinner,sun8i-v3s";
aliases {
ethernet0 = &emac;
};
leds {
status = "okay";
};
};
&codec {
allwinner,audio-routing =
"Headphone", "HP",
"Headphone", "HPCOM",
"MIC1", "Mic",
"Mic", "HBIAS";
status = "okay";
};
&emac {
status = "okay";
};
&mmc1 {
broken-cd;
bus-width = <4>;
vmmc-supply = <®_vcc3v3>;
status = "okay";
};
/*
&lradc {
vref-supply = <®_vcc3v0>;
status = "okay";
button@200 {
label = "Volume Up";
linux,code = <KEY_VOLUMEUP>;
channel = <0>;
voltage = <200000>;
};
button@400 {
label = "Volume Down";
linux,code = <KEY_VOLUMEDOWN>;
channel = <0>;
voltage = <400000>;
};
button@600 {
label = "Select";
linux,code = <KEY_SELECT>;
channel = <0>;
voltage = <600000>;
};
button@800 {
label = "Start";
linux,code = <KEY_OK>;
channel = <0>;
voltage = <800000>;
};
};
*/
离线
能给一下设备树嘛,我和我的对比一下,我的写0关闭背光,1-9无变化
echo 0 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 1 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 7 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 6 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 5 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 4 > /sys/devices/platform/backlight/backlight/backlight/brightness echo 3 > /sys/devices/platform/backlight/backlight/backlight/brightness
echo 0 > /sys/class/backlight/backlight/brightness echo 1 > /sys/class/backlight/backlight/brightness echo 2 > /sys/class/backlight/backlight/brightness echo 3 > /sys/class/backlight/backlight/brightness echo 4 > /sys/class/backlight/backlight/brightness echo 5 > /sys/class/backlight/backlight/brightness echo 6 > /sys/class/backlight/backlight/brightness echo 7 > /sys/class/backlight/backlight/brightness echo 8 > /sys/class/backlight/backlight/brightness echo 9 > /sys/class/backlight/backlight/brightness
刚刚试了一下, V3s linux4.13-y 背光有反应
离线
我的sys/class/backlight 啥都没,是什么问题,没办法驱动显示屏背光,设备树配置好了 PWMpb4,也编译了。什么问题
离线
我的sys/class/backlight 啥都没,是什么问题,没办法驱动显示屏背光,设备树配置好了 PWMpb4,也编译了。什么问题https://whycan.com/files/members/6420/1625737944(1).png
我自行解决了,在 sun8i-v3s-licheepi-zero.dts 把backlight 代码改一下移植进去,然后内核编译dtb,然后把对应的dtb拉进去就有了,然后可以控制开关背光,可以ech 0-6等级暗度
离线
@luguanhong
老哥 方便给出你的设备树文件吗
用的linux-5.2. 用的是电容屏。 后来看了看原来 官方的自带的设备文件dts(编译要加入到开发板的文件dtb)没有backlight的,backlight配置在另外一个ts文件,在LCD_800*480dts文件移植过去的。然后也要在内核编译 驱动选择 pwm backlight lcd。然后接好线就可以了.
离线
离线
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 0 50000 0>;
brightness-levels = <0 30 40 50 60 70 100>;
default-brightness-level = <4>;
power-supply = <®_vcc3v3>;
//enable-gpios = <&pio 1 5 0>;
//post-pwm-on-delay-ms = <10>;
//pwm-off-delay-ms = <10>;
status = "okay";
};
&pwm {
pinctrl-names = "default";
//pinctrl-0 = <&pwm0_pins>,<&pwm1_pins>;
pinctrl-0 = <&pwm0_pins>;
status = "okay";
};
pb4可以用做背光,pb5就不行。
离线