Laptop eDP display backlight constantly reset to full brightness after ~5 seconds

OS: Fedora 35
Kernel: 5.16.19-200.fc35.x86_64
Laptop: Lenovo ThinkPad P17 Gen 2i, model 20YU002QUS
Laptop BIOS: N37ET37W (1.18 )
NVIDIA Driver: 510.60.02, via rpmfusion repo
Integrated graphics: disabled in BIOS
Discrete graphics: NVIDIA GPU NVIDIA RTX A3000 Laptop GPU (GA104GL-A)
XWayland disabled via /etc/gdm/custom.comf WaylandEnable=false

Things that may be relevant:

ServerLayout is configured for two (separate) screens, Xinerama is not enabled, twinview is not enabled. Each screen has its own screen/monitor/device section. Laptop internal eDP is HiDPI native resolution 3840x2160, but configured to use 1920x1080 via nvidia-auto-select{ViewPortIn=1920x1080} MetaMode.

Desktop environment isn’t gnome, it’s fvwm – which means all the gnome display settings utilities don’t work because gnome-settings-daemon isn’t running.

Here’s what is weird:

xrandr --output DP-4 --brightness .5 works immediately, and sets the display to 50% brightness. Then, about 5 seconds later, the display gets set back to 100% brightness.

The /sys/class/backlight/nvidia_0 device exists, but nothing there is in sync with reality. echo 10 > brightness actually sets the value to 10, and I can read it back, but the brightness of the display doesn’t change.

I saw reference on the Lenovo forums that there was a bug in the nvidia drivers and the laptop bios back in Feb 2022, that post mentioned it being fixed in the nvidia 510 driver, and “an upcoming BIOS release”; I did update the laptop’s BIOS, the most recent release is 1.18 also from Feb 2022 :(

I’ve tried video.acpi_backlight=native, video.acpi_backlight=nvidia-drm and video.acpi_backlight=vendor (even though according to kenel docs that’s wrong) and none appear to have any impact on setting the laptop backlight brightness correctly.

Does setting kernel parameter
nvidia.NVreg_RegistryDwords=EnableBrightnessControl=1
help?

Nope, the /sys/class/backlight/nvidia_0 files still have no effect, and the display gets reset back to 100% brightness shortly after xrandr --output DP-4 --brightness .5 actually manages to change the display backlight brightness.

Anybody have any ideas what tries to set the display brightness automatically? Do I need to reach out to Lenovo about the BIOS doing it somehow?

xrandr --brightness only manipulates the gamma value, not the backlight. i.e. it’s using darker colors. Might be reset by colord if you have that running.
Does backlight control work with nouveau?

Ok, you’re correct - xrandr adjusts the gamma only. I actually had to run xrandr --brightness 0.1 and then cup my hand around the laptop’s LCD (it was a bright room at the time) to see the backlight was still on. As soon as that clicked, I realized it’s redshift that was resetting the gamma back to normal. So, disabling redshift I can … sort-of … emulate darkening the screen.

Yes, under intel+nouveau I could use brightnessctl s 10 to lower the display brightness.

What is intensely frustrating to me is it looks like the lenovo laptop’s hardware is setup such that the intel video card is only connected to the laptop’s eDP display, and the external HDMI, and USB-C (e.g. displayport) connectors are only connected to the NVidia card. To get proper external displays working under X in my preferred setup (e.g. not twinview, not xinerama, two separate displays) I had to disable the Intel integrated graphics, and it’s still not working quite right :(

So your desire is running an Xserver with separate Xscreens both driven by the nvidia driver?

Yep. I have it working, but further development of the NVidia driver over time has made things more difficult … like the removal of the Option "TwinView" "off" setting, which appears to be resulting in the driver defaulting to putting all the CRTCs on the first X screen, which … is the internal eDP display, and is mostly useless to me because I’ll never be mirroring my internal display to an external display (e.g. a projector). I’ll always use the second display for that.

Anyway, that’s a separate thread, not this one where backlight control is broken.

If the backlight is broken with the intel gpu turned off, it’s an alternative getting things to work your way with it turned on. Basically, it’s a zaphod head setup with prime used on the first head. Don’t know whether that works but doesn’t sound impossible.

Uh, yeah. That’s reverse prime, and ended up being a complete and total loss. I had the nvidia driver fighting over the external outputs when it was just a GPUDevice, causing the entire X display to hang for a half a second each time the nvidia driver tried to probe/configure the external display.

Unfortunately it appears that the intel display isn’t even connected to the external ports on this laptop, just the eDP for the internal LCD. For the life of me I couldn’t get ZaopodHeads to work properly, even though I did have it working back on a Lenovo W540 (work laptop from the last job) and a Lenovo W530 (personal laptop, still have).

The backlight should operate when the integrated graphics are disabled in the bios, failing that if the future is “IGD+GPU only” then the capability of turning off the integrated graphics should be removed entirely and work on reverse prime w/ separate displays could be worked on.