Re: Brightness 100% when connect or disconnect charger
Date: Fri, 10 Nov 2023 13:58:30 UTC
It's working! I just added return 0; below if_def_linux so it will always return 0 and when I plug and unplug my charger it never goes to 100 Thank You Dr. Amr Osman Thank You Dr. Amr Osman On Fri, Nov 10, 2023 at 1:10 PM Emmanuel Vadot <manu@bidouilliste.com> wrote: > > On Thu, 9 Nov 2023 09:19:31 +0100 > Emmanuel Vadot <manu@bidouilliste.com> wrote: > > > On Wed, 8 Nov 2023 21:57:21 +0200 > > "Dr. Amr Osman" <dr3mro@gmail.com> wrote: > > > > > Hello, > > > I have installed freeBSD 14rc4 on Lenovo Thinkpad x270 and xfce desktop and > > > when I > > > 1) connect the charger > > > 2) disconnect the charger > > > 3) resume from suspend > > > The LCD brightness is 100% which is really disturbing specially when I am > > > in dark room > > > > I don't have the issue on my Thinkpad X390 with suspend/resume but I > > do have it with the charger. > > I'm pretty sure that it's a hardware thing and we can't do anything > > about it without having some framework for sensors that can handle > > power supply connection/disconnection and events. > > > > > hw.acpi.video.lcd0.economy: 20 > > > hw.acpi.video.lcd0.fullpower: 30 > > > I have loaded acpi_video and acpi_ibm > > > and if I tried to adjust brightness it goes suddenly from 100 to 20 if I > > > press fn +f5/f6 > > > > You shouldn't need to load acpi_video on modern laptop, backlight(9) > > and backlight(8) is enought (if you have drm loaded). > > > > > What can I do to fix this issue? > > So I had a better look at I was only ~50% right :) > There is some harware thing that happens, when some external events > happens (docking, plugging charger, suspend/resume etc ...) the > gpu firmware (or the IP not sure about which) generates some interrupts > and the i915 driver get some messages via some mailbox. We seem to get > a set backlight message for those events, it's happening > https://github.com/freebsd/drm-kmod/blob/dce1b3ba0d1ff8ccbbbec09d74480a3a0de346e4/drivers/gpu/drm/i915/display/intel_opregion.c#L420 > There is a few things that I still don't understand : > - Why do we get a message to set the backlight at 100% for any of > those events ? > - Linux checks the backlight type and if it's "native" they discard > this call. Still unsure what "native" really means, looking at some > code it seems that if acpi_video is used it's not considered as a > native backlight unless there is a quirk for the computer or if in the > ACPI table it's says that it's a windows 8 laptop or some chromebook. > - Modifying the above function to always returns 0 (so faking that we > have a "native" backlight) obviously don't change the backlight value, > but I'm unsure if this is the correct hack or if there will be some > problems with it. > > So it will be interesting for people who have this problem to know if > modifying the code to always do a return 0; at the beginning fixes > everything. I'd also like to know if the keyboard keys to modify the > backlight still works correctly after this (mine don't do a thing and > never did, one day I should have a look at how to use them). > > Cheers, > > -- > Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>