]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.123/hid-logitech-hidpp-change-low-battery-level-threshol.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.123 / hid-logitech-hidpp-change-low-battery-level-threshol.patch
1 From 79c6e1a8a7c762d5a48e53379ff347054b0bbd61 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Fri, 22 Mar 2019 08:41:40 +0100
4 Subject: HID: logitech-hidpp: change low battery level threshold from 31 to 30
5 percent
6
7 [ Upstream commit 1f87b0cd32b3456d7efdfb017fcf74d0bfe3ec29 ]
8
9 According to hidpp20_batterylevel_get_battery_info my Logitech K270
10 keyboard reports only 2 battery levels. This matches with what I've seen
11 after testing with batteries at varying level of fullness, it always
12 reports either 5% or 30%.
13
14 Windows reports "battery good" for the 30% level. I've captured an USB
15 trace of Windows reading the battery and it is getting the same info
16 as the Linux hidpp code gets.
17
18 Now that Linux handles these devices as hidpp devices, it reports the
19 battery as being low as it treats anything under 31% as low, this leads
20 to the user constantly getting a "Keyboard battery is low" warning from
21 GNOME3, which is very annoying.
22
23 This commit fixes this by changing the low threshold to anything under
24 30%, which I assume is what Windows does.
25
26 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
27 Signed-off-by: Jiri Kosina <jkosina@suse.cz>
28 Signed-off-by: Sasha Levin <sashal@kernel.org>
29 ---
30 drivers/hid/hid-logitech-hidpp.c | 6 +++++-
31 1 file changed, 5 insertions(+), 1 deletion(-)
32
33 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
34 index d209b12057d59..b705cbb58ca6b 100644
35 --- a/drivers/hid/hid-logitech-hidpp.c
36 +++ b/drivers/hid/hid-logitech-hidpp.c
37 @@ -910,7 +910,11 @@ static int hidpp_map_battery_level(int capacity)
38 {
39 if (capacity < 11)
40 return POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
41 - else if (capacity < 31)
42 + /*
43 + * The spec says this should be < 31 but some devices report 30
44 + * with brand new batteries and Windows reports 30 as "Good".
45 + */
46 + else if (capacity < 30)
47 return POWER_SUPPLY_CAPACITY_LEVEL_LOW;
48 else if (capacity < 81)
49 return POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
50 --
51 2.20.1
52