更改亮度仅在系统从睡眠状态恢复后才有效

更改亮度仅在系统从睡眠状态恢复后才有效

我有一台 Lenovo Legion Slim 7 笔记本电脑 (15ACH6),在内核 5.17 上运行 Manjaro 21.2.3。

我面临的问题是,在干净启动时,我无法更改系统亮度(使用 Fn 键或更改brightnessin的实际值/sys/class/backlight)。然而,在让系统进入睡眠状态然后恢复后,亮度控制工作得很好——尽管亮度级别没有保留。

内容/sys/class/backlight

amdgpu_bl1 -> ../../devices/pci0000:00/0000:00:08.1/0000:05:00.0/backlight/amdgpu_bl1/
nvidia_0 -> ../../devices/pci0000:00/0000:00:01.1/0000:01:00.0/backlight/nvidia_0/
nvidia_wmi_ec_backlight -> ../../devices/pci0000:00/PNP0C14:00/wmi_bus/wmi_bus-PNP0C14:00/603E9613-EF25-4338-A3D0-C46177516DB7/backlight/nvidia_wmi_ec_backlight/

实际的亮度值写入nvidia_wmi_ec_backlight/brightness文件,其他2保持不变。

加载的 nVidia 内核模块:

nvidia_uvm           2650112  0
nvidia_drm             73728  2
nvidia_modeset       1163264  3 nvidia_drm
nvidia_wmi_ec_backlight    16384  0
nvidia              39133184  99 nvidia_uvm,nvidia_modeset
wmi                    40960  3 nvidia_wmi_ec_backlight,wmi_bmof,ideapad_laptop

在 < 5.16 的内核上,该nvidia_wmi_ec_backlight模块不存在,并且我无法更改亮度。我想知道是什么原因导致该模块正常运行仅在从睡眠中恢复后

我怀疑某种竞争条件或者初始化不当。为了了解这种行为,我应该进行什么样的调查?


内核模块的源代码在这里:nvidia-wmi-ec-backlight.c


输出inxi -Fz

System:
  Kernel: 5.17.0-1-MANJARO x86_64 bits: 64 Desktop: GNOME 41.3
    Distro: Manjaro Linux
Machine:
  Type: Laptop System: LENOVO product: 82K8 v: Legion S7 15ACH6
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: NO DPK serial: <superuser required>
    UEFI: LENOVO v: HACN27WW date: 08/02/2021
Battery:
  ID-1: BAT0 charge: 64.3 Wh (90.6%) condition: 71.0/71.0 Wh (100.0%)
CPU:
  Info: 8-core model: AMD Ryzen 9 5900HX with Radeon Graphics bits: 64
    type: MT MCP cache: L2: 4 MiB
  Speed (MHz): avg: 1526 min/max: 400/4680 cores: 1: 1397 2: 1397 3: 1397
    4: 1395 5: 1396 6: 1395 7: 1397 8: 1397 9: 1397 10: 3482 11: 1395 12: 1396
    13: 1396 14: 1395 15: 1397 16: 1397
Graphics:
  Device-1: NVIDIA GA106M [GeForce RTX 3060 Mobile / Max-Q] driver: nvidia
    v: 510.47.03
  Device-2: AMD Cezanne driver: amdgpu v: kernel
  Device-3: Syntek Integrated Camera type: USB driver: uvcvideo
  Display: x11 server: X.org 1.21.1.3 driver: loaded: amdgpu,ati,nvidia
    unloaded: modesetting,nouveau,radeon resolution: <missing: xdpyinfo>
  OpenGL: renderer: AMD RENOIR (DRM 3.44.0 5.17.0-1-MANJARO LLVM 13.0.0)
    v: 4.6 Mesa 21.3.5
Audio:
  Device-1: NVIDIA driver: snd_hda_intel
  Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor driver: N/A
  Device-3: AMD Family 17h HD Audio driver: snd_hda_intel
  Sound Server-1: ALSA v: k5.17.0-1-MANJARO running: yes
  Sound Server-2: PulseAudio v: 15.0 running: yes
Network:
  Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi
  IF: wlp2s0 state: up mac: <filter>
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb
  Report: rfkill ID: hci0 rfk-id: 4 state: down bt-service: enabled,running
    rfk-block: hardware: no software: yes address: see --recommends
Drives:
  Local Storage: total: 953.87 GiB used: 169.04 GiB (17.7%)
  ID-1: /dev/nvme0n1 vendor: SK Hynix model: HFS001TDE9X084N
    size: 953.87 GiB
Partition:
  ID-1: / size: 905.83 GiB used: 169.04 GiB (18.7%) fs: ext4
    dev: /dev/nvme0n1p3
  ID-2: /boot/efi size: 511 MiB used: 288 KiB (0.1%) fs: vfat
    dev: /dev/nvme0n1p1
Swap:
  ID-1: swap-1 type: partition size: 32 GiB used: 0 KiB (0.0%)
    dev: /dev/nvme0n1p2
Sensors:
  System Temperatures: cpu: N/A mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 452 Uptime: 8m Memory: 30.79 GiB used: 3.68 GiB (12.0%)
  Shell: Zsh inxi: 3.3.12

更新:看来在干净启动时我可以使用amdgpu_bl1控制器控制亮度:

echo 50 | sudo tee /sys/class/backlight/amdgpu_bl1/brightness

从睡眠中恢复后,nvidia_wmi_ec_backlight变得有责任。

答案1

作为后备方案,您可以使用 xrandr 从命令行控制亮度。假设输出设备名为 DP-1(运行 xrandr 即可找到),可以使用以下命令进行设置:

xrandr --output DP-1 --brightness .8

这会将亮度设置为 80%。您还可以创建一个 Bash 函数来设置亮度,例如:

brightness() {
    DEV=$(xrandr |grep ' connected' |awk '{print $1}')
    (($1 >= 15 && $1 <= 115)) &&
       xrandr --output "${DEV}" --brightness \
         $(awk -v n="$1" 'BEGIN { printf "%.2f", n / 100 }') ||
    echo "invalid input"
 }

这将接受 15 到 115 之间的值作为亮度级别(以允许伽玛轻微过饱和):

brightness 100   # full brightness
brighness 40    # 40%, very dim
brightness 105  # over-saturated

答案2

我联系了该模块的作者 Daniel Dadap nvidia-wmi-ec-backlight,他提出了一个补丁来解决我的问题。

您可以关注此处邮件列表中的讨论: https://patchwork.kernel.org/project/platform-driver-x86/patch/[电子邮件受保护]/

相关内容