From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jason Gerecke <killertofu@gmail.com>,
Jason Gerecke <jason.gerecke@wacom.com>,
Mario Limonciello <mario.limonciello@amd.com>,
Jiri Kosina <jkosina@suse.cz>, Sasha Levin <sashal@kernel.org>,
ping.cheng@wacom.com, jikos@kernel.org,
benjamin.tissoires@redhat.com, linux-input@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 16/19] HID: wacom: generic: Set battery quirk only when we see battery data
Date: Sat, 6 May 2023 20:34:14 -0400 [thread overview]
Message-ID: <20230507003417.4077259-16-sashal@kernel.org> (raw)
In-Reply-To: <20230507003417.4077259-1-sashal@kernel.org>
From: Jason Gerecke <killertofu@gmail.com>
[ Upstream commit bea407a427baa019758f29f4d31b26f008bb8cc6 ]
Some devices will include battery status usages in the HID descriptor
but we won't see that battery data for one reason or another. For example,
AES sensors won't send battery data unless an AES pen is in proximity.
If a user does not have an AES pen but instead only interacts with the
AES touchscreen with their fingers then there is no need for us to create
a battery object. Similarly, if a family of peripherals shares the same
HID descriptor between wired-only and wireless-capable SKUs, users of the
former may never see a battery event and will not want a power_supply
object created.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217062
Link: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2354
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/wacom_wac.c | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 9312d611db8e5..7fa3b6ccdb53b 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1929,18 +1929,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
struct hid_field *field, struct hid_usage *usage)
{
- struct wacom *wacom = hid_get_drvdata(hdev);
- struct wacom_wac *wacom_wac = &wacom->wacom_wac;
- struct wacom_features *features = &wacom_wac->features;
- unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
-
- switch (equivalent_usage) {
- case HID_DG_BATTERYSTRENGTH:
- case WACOM_HID_WD_BATTERY_LEVEL:
- case WACOM_HID_WD_BATTERY_CHARGING:
- features->quirks |= WACOM_QUIRK_BATTERY;
- break;
- }
+ return;
}
static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
@@ -1961,18 +1950,21 @@ static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *f
wacom_wac->hid_data.bat_connected = 1;
wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
}
+ wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
break;
case WACOM_HID_WD_BATTERY_LEVEL:
value = value * 100 / (field->logical_maximum - field->logical_minimum);
wacom_wac->hid_data.battery_capacity = value;
wacom_wac->hid_data.bat_connected = 1;
wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
+ wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
break;
case WACOM_HID_WD_BATTERY_CHARGING:
wacom_wac->hid_data.bat_charging = value;
wacom_wac->hid_data.ps_connected = value;
wacom_wac->hid_data.bat_connected = 1;
wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
+ wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
break;
}
}
@@ -1988,18 +1980,15 @@ static void wacom_wac_battery_report(struct hid_device *hdev,
{
struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
- struct wacom_features *features = &wacom_wac->features;
- if (features->quirks & WACOM_QUIRK_BATTERY) {
- int status = wacom_wac->hid_data.bat_status;
- int capacity = wacom_wac->hid_data.battery_capacity;
- bool charging = wacom_wac->hid_data.bat_charging;
- bool connected = wacom_wac->hid_data.bat_connected;
- bool powered = wacom_wac->hid_data.ps_connected;
+ int status = wacom_wac->hid_data.bat_status;
+ int capacity = wacom_wac->hid_data.battery_capacity;
+ bool charging = wacom_wac->hid_data.bat_charging;
+ bool connected = wacom_wac->hid_data.bat_connected;
+ bool powered = wacom_wac->hid_data.ps_connected;
- wacom_notify_battery(wacom_wac, status, capacity, charging,
- connected, powered);
- }
+ wacom_notify_battery(wacom_wac, status, capacity, charging,
+ connected, powered);
}
static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
--
2.39.2
next prev parent reply other threads:[~2023-05-07 0:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-07 0:33 [PATCH AUTOSEL 6.1 01/19] ASoC: jack: allow multiple interrupt per gpio Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 02/19] staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 03/19] HID: apple: Set the tilde quirk flag on the Geyser 4 and later Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 04/19] staging: axis-fifo: initialize timeouts in init only Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 05/19] ASoC: tegra: Support coupled mic-hp detection Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 06/19] ASoC: amd: yc: Add DMI entries to support HP OMEN 16-n0xxx (8A42) Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 07/19] HID: logitech-hidpp: Don't use the USB serial for USB devices Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 08/19] HID: logitech-hidpp: Reconcile USB and Unifying serials Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 09/19] spi: spi-imx: fix MX51_ECSPI_* macros when cs > 3 Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 10/19] usb: typec: ucsi: acpi: add quirk for ASUS Zenbook UM325 Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 11/19] ALSA: hda: LNL: add HD Audio PCI ID Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 12/19] ASoC: amd: Add Dell G15 5525 to quirks list Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 13/19] ASoC: amd: yc: Add ThinkBook 14 G5+ ARP to quirks list for acp6x Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 14/19] HID: apple: Set the tilde quirk flag on the Geyser 3 Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 15/19] HID: Ignore battery for ELAN touchscreen on ROG Flow X13 GV301RA Sasha Levin
2023-05-07 0:34 ` Sasha Levin [this message]
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 17/19] usb: typec: tcpm: fix multiple times discover svids error Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 18/19] serial: 8250: Reinit port->pm on port specific driver unbind Sasha Levin
2023-05-07 0:34 ` [PATCH AUTOSEL 6.1 19/19] mcb-pci: Reallocate memory region to avoid memory overlapping Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230507003417.4077259-16-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=benjamin.tissoires@redhat.com \
--cc=jason.gerecke@wacom.com \
--cc=jikos@kernel.org \
--cc=jkosina@suse.cz \
--cc=killertofu@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=ping.cheng@wacom.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox