Brightness 100% when connect or disconnect charger

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

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

What can I do to fix this issue?
 
This is not something new, I see it with 12.x and 13.x as well.
I never had a chance to investigate this, it gets to its original value when one of the brightness +/- keys is pressed.
I think, the easiest way to handle it would be adding the corresponding command to /etc/devd.conf at the event handling AC connection/disconnection. Maybe somebody knows how to fix the root cause though.
 
This is not something new, I see it with 12.x and 13.x as well.
I never had a chance to investigate this, it gets to its original value when one of the brightness +/- keys is pressed.
I think, the easiest way to handle it would be adding the corresponding command to /etc/devd.conf at the event handling AC connection/disconnection. Maybe somebody knows how to fix the root cause though.
Actually I did add devd handler but it will illuminate the screen to 100% for a second before restoring the original brightness and that makes your eyes sore in case you are like me use your PC in a dark room.
 
Probably an ACPI thing. Your laptop's ACPI is either erroneously calling a FreeBSD ACPI callback or it's making the change itself.

It probably doesn't do this under Windows which suggests their Windows driver likely sees one of these events and adjusts the brightness and contrast back to what is stored in some driver variable.
 
I have the same problem on my laptop. It started with the introduction of backlight(8) in the 13.0-RELEASE. It just a guess, but I think the acpi and backlight driver have some issues when used together.
 
I had a similar issue trying FreeBSD on a T480. it's one of many ACPI issues that turned me off; leading me back to macOS. Have you tried installing intel-backlight? That x270 is running an HD520 iGPU. Trying installing intel-backlight, then edit rc.conf to load during startup. It's been a while but that seem to resolve an issue of mine similar to yours. For custom adjustments with AC, you might have to script that using some sysctls. Here's a blog post I found years ago that might be helpful. There are default adjustment increments in the driver, but they can be adjusted using event codes for those function keys.
 
I had a similar issue trying FreeBSD on a T480. it's one of many ACPI issues that turned me off; leading me back to macOS. Have you tried installing intel-backlight? That x270 is running an HD520 iGPU. Trying installing intel-backlight, then edit rc.conf to load during startup. It's been a while but that seem to resolve an issue of mine similar to yours. For custom adjustments with AC, you might have to script that using some sysctls. Here's a blog post I found years ago that might be helpful. There are default adjustment increments in the driver, but they can be adjusted using event codes for those function keys.
How to load intel_backlight during startup?
 
How to load intel_backlight during startup?

I made a slight error. The file to edit is loader.conf.

Try this;

echo 'acpi_video_load="YES"' >> /boot/loader.conf

then

cp /usr/local/share/examples/intel-backlight/acpi-video-intel-backlight.conf \
/usr/local/etc/devd/


But still, you want custom adjustments when AC is connected/disconnected, or after resuming suspension; this sort of integration isn't built in due to lack of support from driver manufactures.

If you're running ZFS; I recommend doing a snapshot before attempting these steps. Allows for dumbproof rollbacks. :)

Also, try reading up on backlight(8), as the tool was added with FreeBSD 13.

Hope that helps.
 
Code:
#!/bin/sh
# /usr/local/bin/acpi_brightness_control.sh
set -x
CURRENT_LEVEL=$(sysctl -n hw.acpi.video.lcd0.brightness)
UP="$1"

if [ "$UP" == 1 ]; then
    for i in 1 2 4 6 9 12 16 20 25 30 36 43 51 60 70 80 90 100; do
        if [ "$CURRENT_LEVEL" -lt "$i" ]; then
            /usr/local/bin/set_brightness.sh $i
            exit
        fi
    done
fi

if [ "$UP" == 0 ]; then
    for i in 100 90 80 70 60 51 43 36 30 25 20 16 12 9 6 4 2 1; do
        if [ "$CURRENT_LEVEL" -gt "$i" ]; then
            /usr/local/bin/set_brightness.sh $i   
            exit
        fi
    done
fi




Code:
#!/bin/sh
#/usr/local/bin/set_brightness.sh

/sbin/sysctl hw.acpi.video.lcd0.brightness=$1
/usr/bin/backlight $1
/usr/local/bin/intel_backlight $1

Code:
# /etc/devd/acpi_brightness.conf
notify 20 {
 match "system" "ACPI";
 match "subsystem" "IBM";
 match "notify" "0x10";
 action "/usr/local/bin/acpi_brightness_control.sh 1";
};
notify 20 {
 match "system" "ACPI";
 match "subsystem" "IBM";
 match "notify" "0x11";
 action "/usr/local/bin/acpi_brightness_control.sh 0";
};



Code:
# /etc/devd/acpi_connect_charger.conf
notify 20 {
 match "system" "ACPI";
 match "subsystem" "ACAD";
 match "notify" "0x01"; 
 action "/usr/local/bin/set_brightness.sh 30";
};
notify 20 {
 match "system" "ACPI";
 match "subsystem" "ACAD";
 match "notify" "0x00"; 
 action "/usr/local/bin/set_brightness.sh 20";
};

but still has brightness to 100 after it is corrected again
any hints?
 
Your event codes are different between acpi_brightness.conf and acpi_connect_charger.conf. Those should be your brightness up/down keys. Try matching them.

In acpi_connect_charger.conf, change the event codes under the "notify" configuration substatement.
 
Back
Top