From afa2f1974d234f02b67ad28e73d426c2d15759de Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: May 25 2023 07:19:31 +0000 Subject: HID: wacom: generic: Set battery quirk only when we see battery data (git-fixes). --- diff --git a/patches.suse/HID-wacom-generic-Set-battery-quirk-only-when-we-see.patch b/patches.suse/HID-wacom-generic-Set-battery-quirk-only-when-we-see.patch new file mode 100644 index 0000000..623380f --- /dev/null +++ b/patches.suse/HID-wacom-generic-Set-battery-quirk-only-when-we-see.patch @@ -0,0 +1,104 @@ +From bea407a427baa019758f29f4d31b26f008bb8cc6 Mon Sep 17 00:00:00 2001 +From: Jason Gerecke +Date: Thu, 13 Apr 2023 11:17:43 -0700 +Subject: [PATCH] HID: wacom: generic: Set battery quirk only when we see battery data +Git-commit: bea407a427baa019758f29f4d31b26f008bb8cc6 +Patch-mainline: v6.4-rc1 +References: git-fixes + +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 +Tested-by: Mario Limonciello +Signed-off-by: Jiri Kosina +Acked-by: Takashi Iwai + +--- + 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 0351bce362d2..dc0f7d9a992c 100644 +--- a/drivers/hid/wacom_wac.c ++++ b/drivers/hid/wacom_wac.c +@@ -1968,18 +1968,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, +@@ -2000,18 +1989,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; + } + } +@@ -2027,18 +2019,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.35.3 + diff --git a/series.conf b/series.conf index 15686f0..e5dd435 100644 --- a/series.conf +++ b/series.conf @@ -19965,6 +19965,7 @@ patches.suse/HID-logitech-hidpp-Don-t-use-the-USB-serial-for-USB-.patch patches.suse/HID-logitech-hidpp-Reconcile-USB-and-Unifying-serial.patch patches.suse/HID-wacom-Set-a-default-resolution-for-older-tablets.patch + patches.suse/HID-wacom-generic-Set-battery-quirk-only-when-we-see.patch patches.suse/usb-host-xhci-rcar-remove-leftover-quirk-handling.patch patches.suse/usb-dwc3-gadget-Change-condition-for-processing-susp.patch patches.suse/usb-gadget-udc-renesas_usb3-Fix-use-after-free-bug-i.patch