Bug 196913 - keyboard backlight max_brightness value outside allowable range on Dell Latitude E6410 laptop
Summary: keyboard backlight max_brightness value outside allowable range on Dell Latit...
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_other
Depends on:
Reported: 2017-09-12 06:04 UTC by Gabriel M. Elder
Modified: 2018-03-13 23:04 UTC (History)
5 users (show)

See Also:
Kernel Version: 4.12.9-300
Tree: Mainline
Regression: No

decrement one level for kbd_info.levels (492 bytes, patch)
2017-09-22 09:44 UTC, Kai-Heng Feng
Details | Diff

Description Gabriel M. Elder 2017-09-12 06:04:19 UTC
I previously reported this as https://bugs.freedesktop.org/show_bug.cgi?id=100041 and was ultimately referred here. The opening from that bug report:

On my Dell Latitude E6410, with the keyboard backlight brightness turned all the way up to the maximum brightness, when I:

$ cat /sys/class/leds/dell\:\:kbd_backlight/max_brightness

$ cat /sys/class/leds/dell\:\:kbd_backlight/brightness

The keyboard backlight brightness on this laptop has 10 discrete values, and, being zero-based, range from 0 through 9. After booting, upon powering up keyboard backlight, the brightness is indeed at the maximum of 9. The side-effects of max_brightness being 10 however, percolate up into the gui, where gnome-control-center queries the OS for max_brightness and sets the slider range accordingly. When the user dutifully slides the slider all the way to the right-most maximum of 10 (the 11th notched position), all appears well. Until the laptop is put to sleep. Upon awakening, gnome then queries the power settings for the current keyboard backlight brightness value, gets 10, and then sets the keyboard brightness to 10%10, i.e. 0. The user thinks the keyboard backlight is off, attempts to toggle it back on via pressing fn+->, but is in reality switching it off. Toggle it again, and it switches on, setting the brightness, once again, to 10 modulo 10, and disappointment follows. Move the keyboard backlight slider control back down to anything less than 10 but greater than 0 in the gnome-control-center power settings, and voilà, the keyboard is once again visibly and magically backlit.

Per Hans de Goede:
Things really are 0 based, so if on your dell max_brightness is 10, but you can only write up to 9 to the brightness attribute, that is a kernel bug and you should file a bug against the kernel for this.

Note I'm not saying there is no bug, just that the problem is not in upower and that it needs to be fixed in the right place.

Given the above, I'm closing this bug. Please file a bug at bugzilla.kernel.org and send a mail to:

[hans@shalem linux]$ scripts/get_maintainer.pl -f drivers/platform/x86/dell-laptop.c 
"Pali Rohár" <pali.rohar@gmail.com> (maintainer:DELL LAPTOP DRIVER)
Darren Hart <dvhart@infradead.org> (maintainer:X86 PLATFORM DRIVERS)
Andy Shevchenko <andy@infradead.org> (maintainer:X86 PLATFORM DRIVERS)
platform-driver-x86@vger.kernel.org (open list:DELL LAPTOP DRIVER)
linux-kernel@vger.kernel.org (open list)

So that's what I'm doing. FWIW, I browsed the led-class.c driver source, but haven't yet found where max_brightness (LED_FULL) is getting initialized with this improper max+1 value.
Comment 1 Gabriel M. Elder 2017-09-14 13:35:24 UTC
output from smbios-keyboard-ctl --info:

Libsmbios version : 2.3.0
smbios-keyboard-ctl version : 2.3.0

 Capabilities of KeyBoard Illumination on your system: 
 Supported USER Selectable Modes : 
	 Always OFF
	 Auto: ALS- and input-activity-based On; input-activity based Off
	 Auto: Input-activity-based On; input-activity based Off

 Supported Keyboard illumination type :  Backlight

 Supports Keyboard illumination on : 
	Any Keystroke
	Touchpad activity
	Pointing stick

 Can configure Keyboard illumination timeout unit in : 

 Supported Keyboard light brightness levels :  10

 Maximum acceptable seconds timeout value   :  255

 Maximum acceptable minutes timeout value   :  255

 Maximum acceptable hours timeout value     :  12

 Maximum acceptable days timeout value      :  0

output from smbios-keyboard-ctl --get-status:

Helper function to print current status of keyboard illumination

 Current status of KeyBoard Illumination setting on your system: 

 Configured mode state: 
	 Auto: Input-activity-based On; input-activity based Off

 Your Keyboard will illumination on: 
	Any Keystroke
	Touchpad activity
	Pointing stick

 Keyboard illumination timeout has bee set at: 10  Seconds

 Current setting of ALS value that turns the light on or off: 18
 Current ALS Reading : 16
 Current keyboard light level : 9
Comment 2 Gabriel M. Elder 2017-09-14 14:32:53 UTC
# smbios-keyboard-ctl --set-level=10; echo $?

Old Keyboard illumination level is: 9
	  Set Trigger Failed. Failed to write config
	 Error Return Code : cbRES1: 0x-2 cbRES2: 0x93512 cbRES3: 0xCFFFF 
Comment 3 Kai-Heng Feng 2017-09-22 09:44:03 UTC
Created attachment 258559 [details]
decrement one level for kbd_info.levels

Please try this patch.

If this patch works, we should ask the original author about this behavior.
Comment 4 Gabriel M. Elder 2017-09-28 23:05:55 UTC
Finally had a chance to make this mod, compile and try it out. Based on my testing, it seems to completely correct the problem.

Upon initially opening the power panel in gnome-control-center, the keyboard brightness slider is all the way over to the right, where one would expect it to be, as well as all of the brightness step levels. Closing the lid, putting it to sleep and waking it back up does not have the annoying keyboard backlight disabling side-effect that I described above.
Comment 5 Gabriel M. Elder 2017-10-02 19:09:10 UTC
# cat -v /sys/class/dmi/id/sys_vendor
Dell Inc.
# cat -v /sys/class/dmi/id/product_name
Latitude E6410
# cat -v /sys/class/dmi/id/sys_vendor | hexdump
0000000 6544 6c6c 4920 636e 0a2e               
# cat -v /sys/class/dmi/id/product_name | hexdump
0000000 614c 6974 7574 6564 4520 3436 3031 000a
Comment 6 Pali Rohár 2017-10-18 18:10:15 UTC
Here are proposed patches:
v1: https://patchwork.kernel.org/patch/10007167/
v2: https://patchwork.kernel.org/patch/10015149/
Comment 7 Gabriel M. Elder 2017-10-21 17:55:12 UTC
Based on my testing, the v2 patch seems to work fine.
Comment 8 Gabriel M. Elder 2017-11-12 17:04:35 UTC
If necessary, I am willing to test whatever final proposed patch the community recommends, settles on, and accepts. Would you all like me to test the v3 patch as well? Or are we calling it good at this point, and can expect this to be merged into a final stable kernel release sometime soon? I must admit, I'm looking forward to officially making this bug go bye-bye!
Comment 9 Stephanie Gawroriski 2018-03-10 15:08:43 UTC

This keyboard backlight issue also affects the Dell Latitude E6400, I can set the brightness to 9 but it is reported to have a maximum of 10 (10 can never be reached ever).

This does mess KDE up as it increments in units of 2, so it may only reach level 8 and the backlight meter does not fill completely. Sometimes when resuming from sleep the backlight might not be turned on and I need to adjust the levels before it turns on again.

This is the system identification:

root@oaktree:/home/stephanie# cat -v /sys/class/dmi/id/sys_vendor
Dell Inc.
root@oaktree:/home/stephanie# cat -v /sys/class/dmi/id/product_name
Latitude E6400                  
root@oaktree:/home/stephanie# cat -v /sys/class/dmi/id/sys_vendor | hexdump -C
00000000  44 65 6c 6c 20 49 6e 63  2e 0a                    |Dell Inc..|
root@oaktree:/home/stephanie# cat -v /sys/class/dmi/id/product_name | hexdump -C
00000000  4c 61 74 69 74 75 64 65  20 45 36 34 30 30 20 20  |Latitude E6400  |
00000010  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000020  0a                                                |.|

Running the previous commands in the log gives also:

root@oaktree:/home/stephanie# smbios-keyboard-ctl --set-level=10; echo $?

Old Keyboard illumination level is: 9
          Set Trigger Failed. Failed to write config
         Error Return Code : cbRES1: 0x-2 cbRES2: 0x0 cbRES3: 0x0 

Comment 10 Stephanie Gawroriski 2018-03-12 23:30:05 UTC
Adding a quirk for my system and using the same defined quirk makes the backlight operate as normal.
Comment 11 Pali Rohár 2018-03-13 23:04:49 UTC
Mario, should we add also Dell Latitude E6400 into that quirk list? Or is there any better way?

Note You need to log in before you can comment on or make changes to this bug.