Commit 0b43615a authored by Jiri Kosina's avatar Jiri Kosina

Merge branch 'for-6.8/wacom' into for-linus

- functional fix for handling Confidence in Wacom driver (Jason Gerecke)
- power management fix for Wacom userspace battery exporting (Tatsunosuke Tobita)

Conflicts:
	tools/testing/selftests/hid/tests/test_wacom_generic.py
parents 53eb9356 b0fb904d
...@@ -164,6 +164,7 @@ struct wacom { ...@@ -164,6 +164,7 @@ struct wacom {
struct work_struct battery_work; struct work_struct battery_work;
struct work_struct remote_work; struct work_struct remote_work;
struct delayed_work init_work; struct delayed_work init_work;
struct delayed_work aes_battery_work;
struct wacom_remote *remote; struct wacom_remote *remote;
struct work_struct mode_change_work; struct work_struct mode_change_work;
struct timer_list idleprox_timer; struct timer_list idleprox_timer;
......
...@@ -1813,6 +1813,13 @@ static void wacom_destroy_battery(struct wacom *wacom) ...@@ -1813,6 +1813,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, static ssize_t wacom_show_speed(struct device *dev,
struct device_attribute struct device_attribute
*attr, char *buf) *attr, char *buf)
...@@ -2794,6 +2801,7 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -2794,6 +2801,7 @@ static int wacom_probe(struct hid_device *hdev,
mutex_init(&wacom->lock); mutex_init(&wacom->lock);
INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work); 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->wireless_work, wacom_wireless_work);
INIT_WORK(&wacom->battery_work, wacom_battery_work); INIT_WORK(&wacom->battery_work, wacom_battery_work);
INIT_WORK(&wacom->remote_work, wacom_remote_work); INIT_WORK(&wacom->remote_work, wacom_remote_work);
......
...@@ -2528,11 +2528,12 @@ static void wacom_wac_pen_report(struct hid_device *hdev, ...@@ -2528,11 +2528,12 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
struct input_dev *input = wacom_wac->pen_input; struct input_dev *input = wacom_wac->pen_input;
bool range = wacom_wac->hid_data.inrange_state; bool range = wacom_wac->hid_data.inrange_state;
bool sense = wacom_wac->hid_data.sense_state; bool sense = wacom_wac->hid_data.sense_state;
bool entering_range = !wacom_wac->tool[0] && range;
if (wacom_wac->is_invalid_bt_frame) if (wacom_wac->is_invalid_bt_frame)
return; return;
if (!wacom_wac->tool[0] && range) { /* first in range */ if (entering_range) { /* first in range */
/* Going into range select tool */ /* Going into range select tool */
if (wacom_wac->hid_data.invert_state) if (wacom_wac->hid_data.invert_state)
wacom_wac->tool[0] = BTN_TOOL_RUBBER; wacom_wac->tool[0] = BTN_TOOL_RUBBER;
...@@ -2583,6 +2584,15 @@ static void wacom_wac_pen_report(struct hid_device *hdev, ...@@ -2583,6 +2584,15 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
input_sync(input); 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) { if (!sense) {
wacom_wac->tool[0] = 0; wacom_wac->tool[0] = 0;
wacom_wac->id[0] = 0; wacom_wac->id[0] = 0;
...@@ -2649,8 +2659,8 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, ...@@ -2649,8 +2659,8 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
{ {
struct hid_data *hid_data = &wacom_wac->hid_data; struct hid_data *hid_data = &wacom_wac->hid_data;
bool mt = wacom_wac->features.touch_max > 1; bool mt = wacom_wac->features.touch_max > 1;
bool prox = hid_data->tipswitch && bool touch_down = hid_data->tipswitch && hid_data->confidence;
report_touch_events(wacom_wac); bool prox = touch_down && report_touch_events(wacom_wac);
if (touch_is_muted(wacom_wac)) { if (touch_is_muted(wacom_wac)) {
if (!wacom_wac->shared->touch_down) if (!wacom_wac->shared->touch_down)
...@@ -2700,24 +2710,6 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, ...@@ -2700,24 +2710,6 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
} }
} }
static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
{
struct input_mt *mt = dev->mt;
struct input_mt_slot *s;
if (!mt)
return false;
for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
if (s->key == key &&
input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
return true;
}
}
return false;
}
static void wacom_wac_finger_event(struct hid_device *hdev, static void wacom_wac_finger_event(struct hid_device *hdev,
struct hid_field *field, struct hid_usage *usage, __s32 value) struct hid_field *field, struct hid_usage *usage, __s32 value)
{ {
...@@ -2768,14 +2760,8 @@ static void wacom_wac_finger_event(struct hid_device *hdev, ...@@ -2768,14 +2760,8 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
} }
if (usage->usage_index + 1 == field->report_count) { if (usage->usage_index + 1 == field->report_count) {
if (equivalent_usage == wacom_wac->hid_data.last_slot_field) { if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input, wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
if (wacom_wac->hid_data.confidence || touch_removed) {
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
}
}
} }
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define WACOM_MAX_REMOTES 5 #define WACOM_MAX_REMOTES 5
#define WACOM_STATUS_UNKNOWN 255 #define WACOM_STATUS_UNKNOWN 255
#define WACOM_REMOTE_BATTERY_TIMEOUT 21000000000ll #define WACOM_REMOTE_BATTERY_TIMEOUT 21000000000ll
#define WACOM_AES_BATTERY_TIMEOUT 1800000
/* packet length for individual models */ /* packet length for individual models */
#define WACOM_PKGLEN_BBFUN 9 #define WACOM_PKGLEN_BBFUN 9
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment