Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Lenovo Thinkpad T450 - ACPI Fn+key - brightness control
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
AlexanderKh
n00b
n00b


Joined: 21 Nov 2014
Posts: 21
Location: Ukraine

PostPosted: Mon Dec 09, 2019 5:46 am    Post subject: Lenovo Thinkpad T450 - ACPI Fn+key - brightness control Reply with quote

Hello.
After recent upgrade, brightness control stopped working via Fn+F5 and Fn+F6 on my laptop, i.e. it works, but only for one step below maximum (decreasing for ~7% only)

My kernel version is 4.19.86-gentoo. I have enabled some features in its config
Code:
lenovo ~ # zgrep -i thinkpad /proc/config.gz
CONFIG_THINKPAD_ACPI=m
CONFIG_THINKPAD_ACPI_ALSA_SUPPORT=y
# CONFIG_THINKPAD_ACPI_DEBUGFACILITIES is not set
# CONFIG_THINKPAD_ACPI_DEBUG is not set
CONFIG_THINKPAD_ACPI_UNSAFE_LEDS=y
CONFIG_THINKPAD_ACPI_VIDEO=y
CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y

Also updated /etc/default/grub
Code:
GRUB_CMDLINE_LINUX="... acpi_backlight=vendor ..."

Here are ACPI events occurring when I press these combinations:
Code:
lenovo ~ # acpi_listen
video/brightnessdown BRTDN 00000087 00000000 K
video/brightnessdown BRTDN 00000087 00000000

video/brightnessup BRTUP 00000086 00000000 K
video/brightnessup BRTUP 00000086 00000000

Code:
lenovo ~ # evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Lid Switch
/dev/input/event1:      Sleep Button
/dev/input/event2:      Power Button
/dev/input/event3:      Video Bus
/dev/input/event4:      PC Speaker
/dev/input/event5:      AT Translated Set 2 keyboard
/dev/input/event6:      HDA Intel PCH Dock Mic
/dev/input/event7:      HDA Intel PCH Mic
/dev/input/event8:      HDA Intel PCH Dock Headphone
/dev/input/event9:      HDA Intel PCH Headphone
/dev/input/event10:     HDA Intel HDMI HDMI
/dev/input/event11:     Integrated Camera: Integrated C
/dev/input/event12:     PS/2 Synaptics TouchPad
/dev/input/event13:     ThinkPad Extra Buttons
Select the device event number [0-13]: 13
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x17aa product 0x5054 version 0x4101
Input device name: "ThinkPad Extra Buttons"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 120 (KEY_SCALE)
    Event code 140 (KEY_CALC)
    Event code 142 (KEY_SLEEP)
    Event code 144 (KEY_FILE)
    Event code 148 (KEY_PROG1)
    Event code 152 (KEY_SCREENLOCK)
    Event code 156 (KEY_BOOKMARKS)
    Event code 158 (KEY_BACK)
    Event code 171 (KEY_CONFIG)
    Event code 173 (KEY_REFRESH)
    Event code 190 (KEY_F20)
    Event code 191 (KEY_F21)
    Event code 194 (KEY_F24)
    Event code 205 (KEY_SUSPEND)
    Event code 212 (KEY_CAMERA)
    Event code 217 (KEY_SEARCH)
    Event code 224 (KEY_BRIGHTNESSDOWN)
    Event code 225 (KEY_BRIGHTNESSUP)
    Event code 227 (KEY_SWITCHVIDEOMODE)
    Event code 228 (KEY_KBDILLUMTOGGLE)
    Event code 236 (KEY_BATTERY)
    Event code 237 (KEY_BLUETOOTH)
    Event code 238 (KEY_WLAN)
    Event code 240 (KEY_UNKNOWN)
    Event code 372 (KEY_ZOOM)
    Event code 374 (KEY_KEYBOARD)
    Event code 466 (KEY_FN_F1)
    Event code 475 (KEY_FN_F10)
    Event code 476 (KEY_FN_F11)
    Event code 582 (KEY_VOICECOMMAND)
    Event code 592 (KEY_BRIGHTNESS_MIN)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
  Event type 5 (EV_SW)
    Event code 3 (SW_RFKILL_ALL) state 1
Properties:
Testing ... (interrupt to exit)

Event: time 1575782399.906475, type 4 (EV_MSC), code 4 (MSC_SCAN), value 10
Event: time 1575782399.906475, type 1 (EV_KEY), code 224 (KEY_BRIGHTNESSDOWN), value 1
Event: time 1575782399.906475, -------------- SYN_REPORT ------------
Event: time 1575782399.906495, type 4 (EV_MSC), code 4 (MSC_SCAN), value 10
Event: time 1575782399.906495, type 1 (EV_KEY), code 224 (KEY_BRIGHTNESSDOWN), value 0
Event: time 1575782399.906495, -------------- SYN_REPORT ------------

Event: time 1575782403.366480, type 4 (EV_MSC), code 4 (MSC_SCAN), value 0f
Event: time 1575782403.366480, type 1 (EV_KEY), code 225 (KEY_BRIGHTNESSUP), value 1
Event: time 1575782403.366480, -------------- SYN_REPORT ------------
Event: time 1575782403.366502, type 4 (EV_MSC), code 4 (MSC_SCAN), value 0f
Event: time 1575782403.366502, type 1 (EV_KEY), code 225 (KEY_BRIGHTNESSUP), value 0
Event: time 1575782403.366502, -------------- SYN_REPORT ------------

Code:
lenovo ~ # acpid -c /etc/acpi/events/ -s /var/run/acpid.socket -f -d -l | tee tmp
Deprecated /proc/acpi/event was not found.  Trying netlink and the input layer...
input layer /dev/input/event0 (Lid Switch) opened successfully, fd 3
input layer /dev/input/event1 (Sleep Button) opened successfully, fd 4
input layer /dev/input/event10 (HDA Intel HDMI HDMI) opened successfully, fd 5
input layer /dev/input/event13 (ThinkPad Extra Buttons) opened successfully, fd 6
input layer /dev/input/event2 (Power Button) opened successfully, fd 7
input layer /dev/input/event3 (Video Bus) opened successfully, fd 8
input layer /dev/input/event5 (AT Translated Set 2 keyboard) opened successfully, fd 9
input layer /dev/input/event6 (HDA Intel PCH Dock Mic) opened successfully, fd 10
input layer /dev/input/event7 (HDA Intel PCH Mic) opened successfully, fd 11
input layer /dev/input/event8 (HDA Intel PCH Dock Headphone) opened successfully, fd 12
input layer /dev/input/event9 (HDA Intel PCH Headphone) opened successfully, fd 13
inotify fd: 14
inotify wd: 1
netlink opened successfully
starting up with netlink and the input layer
parsing conf file /etc/acpi/events//default
1 rule loaded
waiting for events: event logging is on

received input layer event "video/brightnessdown BRTDN 00000087 00000000 K"
rule from /etc/acpi/events//default matched
executing action "/etc/acpi/default.sh video/brightnessdown BRTDN 00000087 00000000 K"
action exited with status 0
1 total rule matched
completed input layer event "video/brightnessdown BRTDN 00000087 00000000 K"
received input layer event "video/brightnessdown BRTDN 00000087 00000000"
rule from /etc/acpi/events//default matched
executing action "/etc/acpi/default.sh video/brightnessdown BRTDN 00000087 00000000"
action exited with status 0
1 total rule matched
completed input layer event "video/brightnessdown BRTDN 00000087 00000000"

received input layer event "video/brightnessup BRTUP 00000086 00000000"
rule from /etc/acpi/events//default matched
executing action "/etc/acpi/default.sh video/brightnessup BRTUP 00000086 00000000"
action exited with status 0
1 total rule matched
completed input layer event "video/brightnessup BRTUP 00000086 00000000"
received input layer event "video/brightnessup BRTUP 00000086 00000000 K"
rule from /etc/acpi/events//default matched
executing action "/etc/acpi/default.sh video/brightnessup BRTUP 00000086 00000000 K"
action exited with status 0
1 total rule matched
completed input layer event "video/brightnessup BRTUP 00000086 00000000 K"

I have modified /etc/acpi/default.sh and added /etc/acpi/actions/backlight.sh using suggestions from this board.
Code:
lenovo ~ # cat /etc/acpi/default.sh       
#!/bin/sh
# /etc/acpi/default.sh
# Default acpi script that takes an entry for all actions

set $*

group=${1%%/*}
action=${1#*/}
device=$2
id=$3
value=$4

log_unhandled() {
        logger "ACPI event unhandled: $*"
}

case "$group" in
        video)
                case "$action" in
                        brightnessup)
                                /etc/acpi/actions/backlight.sh up
                                ;;
                        brightnessdown)
                                /etc/acpi/actions/backlight.sh down
                                ;;
                        *) log_unhandled
                                $*
                                ;;
                esac
                ;;

        button)
                case "$action" in
                        power)
                                /etc/acpi/actions/powerbtn.sh
                                ;;

                        # if your laptop doesnt turn on/off the display via hardware
                        # switch and instead just generates an acpi event, you can force
                        # X to turn off the display via dpms.  note you will have to run
                        # 'xhost +local:0' so root can access the X DISPLAY.
                        #lid)
                        #       xset dpms force off
                        #       ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        ac_adapter)
                case "$value" in
                        # Add code here to handle when the system is unplugged
                        # (maybe change cpu scaling to powersave mode).  For
                        # multicore systems, make sure you set powersave mode
                        # for each core!
                        #*0)
                        #       cpufreq-set -g powersave
                        #       ;;

                        # Add code here to handle when the system is plugged in
                        # (maybe change cpu scaling to performance mode).  For
                        # multicore systems, make sure you set performance mode
                        # for each core!
                        #*1)
                        #       cpufreq-set -g performance
                        #       ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        *)      log_unhandled $* ;;
esac

Code:
lenovo ~ # cat /etc/acpi/actions/backlight.sh
#!/bin/sh
set -e

backlight_sys_dir="/sys/class/backlight/intel_backlight"
read -r max_brightness < "${backlight_sys_dir}/max_brightness"
read -r curr_brightness < "${backlight_sys_dir}/brightness"

case "$1" in
      up) increment="+ 50" ;;
    down) increment="- 50" ;;
       *) exit 1 ;;
esac

new_brightness=$(($curr_brightness $increment))

if (($new_brightness < 1)) || (($new_brightness > $max_brightness)); then
    exit 1
else
    echo "$new_brightness" > ${backlight_sys_dir}/brightness
fi

But it didn't resolve the issue.

Meanwhile, the following commands change brightness correctly until the screen is almost black
/etc/acpi/actions/backlight.sh down
/etc/acpi/actions/backlight.sh up

But if I press Fn+F5 or Fn+F6, value in /sys/class/backlight/intel_backlight/brightness is changing between 809 and 852 only (from /sys/class/backlight/intel_backlight/max_brightness).

Please help.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum