HID: wacom: Remove AES power_supply after extended inactivity
Subsystems (2)
PATCH 1/1 HID: wacom: Remove AES power_supply after extended inactivity
From: Tatsunosuke Tobita <[email protected]>
Even if a user does not use their AES pen for an extended period, the battery power supply attributes continue to exist. This results in the desktop showing battery status for a pen that is no longer in use and which may in fact be in a different state (e.g. the user may be charging the pen).
To avoid confusion and ensure userspace has an accurate view of the battery state, this patch automatically removes the power_supply after 30 minutes of inactivity.
Signed-off-by Tatsunosuke Tobita <[email protected]>
Reviewed-by Jason Gerecke <[email protected]>
Reviewed-by Aaron Skomra <[email protected]>
Reviewed-by Josh Dickens <[email protected]>
--- drivers/hid/wacom.h | 2 ++ drivers/hid/wacom_sys.c | 52 ++++++++++++++++++++++++++++++----------- drivers/hid/wacom_wac.c | 19 +++++++++++---- drivers/hid/wacom_wac.h | 5 ++-- 4 files changed, 58 insertions(+), 20 deletions(-)
drivers/hid/wacom.h +2 -0
@@ -150,6 +150,7 @@ struct wacom_remote {struct input_dev *input;bool registered;struct wacom_battery battery; +ktime_t active_time; } remotes[WACOM_MAX_REMOTES ]; };
@@ -163,6 +164,7 @@ struct wacom {struct work_struct battery_work;struct work_struct remote_work;struct delayed_work init_work; +struct delayed_work aes_battery_work;struct wacom_remote *remote;struct work_struct mode_change_work;struct timer_list idleprox_timer;
drivers/hid/wacom_sys.c +39 -13
120 lines not on this page · raw message
drivers/hid/wacom_wac.c +14 -5
@@ -1134,6 +1134,7 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)if (index <0 || !remote->remotes[index].registered) goto out; + remote->remotes[i].active_time =ktime_get (); input = remote->remotes[index].input;input_report_key (input,BTN_0 , (data[9 ] &0x01 ));
@@ -1196,22 +1197,20 @@ static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);unsigned char *data = wacom_wac->data;struct wacom_remote *remote = wacom->remote; -struct wacom_remote_data remote_data; +struct wacom_remote_work_data remote_data;unsigned long flags;int i, ret;if (data[0 ] !=WACOM_REPORT_DEVICE_LIST )return ; -memset (&remote_data,0 ,sizeof (struct wacom_remote_data )); +memset (&remote_data,0 ,sizeof (struct wacom_remote_work_data ));for (i =0 ; i <WACOM_MAX_REMOTES ; i++) {int j = i *6 ;int serial = (data[j+6 ] <<16 ) + (data[j+5 ] <<8 ) + data[j+4 ]; -bool connected = data[j+2 ]; remote_data.remote[i].serial = serial; - remote_data.remote[i].connected = connected; }spin_lock_irqsave (&remote->remote_lock, flags);
@@ -2529,11 +2528,12 @@ static void wacom_wac_pen_report(struct hid_device *hdev,struct input_dev *input = wacom_wac->pen_input;bool range = wacom_wac->hid_data.inrange_state;bool sense = wacom_wac->hid_data.sense_state; +bool entering_range = !wacom_wac->tool[0 ] && range;if (wacom_wac->is_invalid_bt_frame)return ; -if (!wacom_wac->tool[0 ] && range) {/* first in range */ +if (entering_range) {/* first in range */ /* Going into range select tool */ if (wacom_wac->hid_data.invert_state) wacom_wac->tool[0 ] =BTN_TOOL_RUBBER ;
@@ -2584,6 +2584,15 @@ static void wacom_wac_pen_report(struct hid_device *hdev,input_sync (input); } +/* Handle AES battery timeout behavior */ +if (wacom_wac->features.quirks &WACOM_QUIRK_AESPEN ) { +if (entering_range) +cancel_delayed_work (&wacom->aes_battery_work); +if (!sense) +schedule_delayed_work (&wacom->aes_battery_work, +msecs_to_jiffies (WACOM_AES_BATTERY_TIMEOUT )); + } +if (!sense) { wacom_wac->tool[0 ] =0 ; wacom_wac->id[0 ] =0 ;
drivers/hid/wacom_wac.h +3 -2
@@ -13,6 +13,8 @@#define WACOM_NAME_MAX 64#define WACOM_MAX_REMOTES 5#define WACOM_STATUS_UNKNOWN 255 +#define WACOM_REMOTE_BATTERY_TIMEOUT 21000000000ll +#define WACOM_AES_BATTERY_TIMEOUT 1800000/* packet length for individual models */ #define WACOM_PKGLEN_BBFUN 9
@@ -327,10 +329,9 @@ struct hid_data {ktime_t time_delayed; }; -struct wacom_remote_data { +struct wacom_remote_work_data {struct {u32 serial; -bool connected; } remote[WACOM_MAX_REMOTES ]; };
Signature · 1 line
2.34.1