Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HID: wacom: Remove AES power_supply after extended inactivity #404

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 4.5/wacom.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,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;
Expand Down
8 changes: 8 additions & 0 deletions 4.5/wacom_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,13 @@ static void wacom_destroy_battery(struct wacom *wacom)
}
}

static void wacom_aes_battery_handler(struct work_struct *work)
{
struct wacom *wacom = container_of(work, struct wacom, aes_battery_work.work);

wacom_destroy_battery(wacom);
}

static ssize_t wacom_show_speed(struct device *dev,
struct device_attribute
*attr, char *buf)
Expand Down Expand Up @@ -2873,6 +2880,7 @@ static int wacom_probe(struct hid_device *hdev,

mutex_init(&wacom->lock);
INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
INIT_DELAYED_WORK(&wacom->aes_battery_work, wacom_aes_battery_handler);
INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
INIT_WORK(&wacom->battery_work, wacom_battery_work);
INIT_WORK(&wacom->remote_work, wacom_remote_work);
Expand Down
12 changes: 11 additions & 1 deletion 4.5/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2554,11 +2554,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;
Expand Down Expand Up @@ -2609,6 +2610,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;
Expand Down
1 change: 1 addition & 0 deletions 4.5/wacom_wac.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#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
Expand Down
Loading