diff options
author | Hans de Goede <hdegoede@redhat.com> | 2019-03-22 08:41:40 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-31 06:46:28 -0700 |
commit | 2cd236c271576d32927ea6b8b1e4d69c65ebfa30 (patch) | |
tree | 1479e2bf78aa4c59ea929d66fba42957c2adf7ee /drivers/hid | |
parent | fb2c65b4a27971bf06bb2b6fe44aef6189270111 (diff) | |
download | linux-stable-2cd236c271576d32927ea6b8b1e4d69c65ebfa30.tar.gz linux-stable-2cd236c271576d32927ea6b8b1e4d69c65ebfa30.tar.bz2 linux-stable-2cd236c271576d32927ea6b8b1e4d69c65ebfa30.zip |
HID: logitech-hidpp: change low battery level threshold from 31 to 30 percent
[ Upstream commit 1f87b0cd32b3456d7efdfb017fcf74d0bfe3ec29 ]
According to hidpp20_batterylevel_get_battery_info my Logitech K270
keyboard reports only 2 battery levels. This matches with what I've seen
after testing with batteries at varying level of fullness, it always
reports either 5% or 30%.
Windows reports "battery good" for the 30% level. I've captured an USB
trace of Windows reading the battery and it is getting the same info
as the Linux hidpp code gets.
Now that Linux handles these devices as hidpp devices, it reports the
battery as being low as it treats anything under 31% as low, this leads
to the user constantly getting a "Keyboard battery is low" warning from
GNOME3, which is very annoying.
This commit fixes this by changing the low threshold to anything under
30%, which I assume is what Windows does.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-logitech-hidpp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index edf224ad1336..e642cfaf303b 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -910,7 +910,11 @@ static int hidpp_map_battery_level(int capacity) { if (capacity < 11) return POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; - else if (capacity < 31) + /* + * The spec says this should be < 31 but some devices report 30 + * with brand new batteries and Windows reports 30 as "Good". + */ + else if (capacity < 30) return POWER_SUPPLY_CAPACITY_LEVEL_LOW; else if (capacity < 81) return POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; |