Lines Matching +full:abs +full:- +full:fuzz

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * USB Wacom tablet support - Wacom specific code
25 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
43 struct input_dev *input = wacom_wac->pen_input; in wacom_force_proxout()
45 wacom_wac->shared->stylus_in_proximity = 0; in wacom_force_proxout()
51 input_report_key(input, wacom_wac->tool[0], 0); in wacom_force_proxout()
52 if (wacom_wac->serial[0]) { in wacom_force_proxout()
57 wacom_wac->tool[0] = 0; in wacom_force_proxout()
58 wacom_wac->id[0] = 0; in wacom_force_proxout()
59 wacom_wac->serial[0] = 0; in wacom_force_proxout()
67 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_idleprox_timeout()
69 if (!wacom_wac->hid_data.sense_state) { in wacom_idleprox_timeout()
73 hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__); in wacom_idleprox_timeout()
93 bool changed = battery->bat_status != bat_status || in __wacom_notify_battery()
94 battery->battery_capacity != bat_capacity || in __wacom_notify_battery()
95 battery->bat_charging != bat_charging || in __wacom_notify_battery()
96 battery->bat_connected != bat_connected || in __wacom_notify_battery()
97 battery->ps_connected != ps_connected; in __wacom_notify_battery()
100 battery->bat_status = bat_status; in __wacom_notify_battery()
101 battery->battery_capacity = bat_capacity; in __wacom_notify_battery()
102 battery->bat_charging = bat_charging; in __wacom_notify_battery()
103 battery->bat_connected = bat_connected; in __wacom_notify_battery()
104 battery->ps_connected = ps_connected; in __wacom_notify_battery()
106 if (battery->battery) in __wacom_notify_battery()
107 power_supply_changed(battery->battery); in __wacom_notify_battery()
116 bool bat_initialized = wacom->battery.battery; in wacom_notify_battery()
117 bool has_quirk = wacom_wac->features.quirks & WACOM_QUIRK_BATTERY; in wacom_notify_battery()
122 __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity, in wacom_notify_battery()
128 unsigned char *data = wacom->data; in wacom_penpartner_irq()
129 struct input_dev *input = wacom->pen_input; in wacom_penpartner_irq()
134 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; in wacom_penpartner_irq()
135 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; in wacom_penpartner_irq()
136 input_report_key(input, wacom->tool[0], 1); in wacom_penpartner_irq()
137 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ in wacom_penpartner_irq()
141 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127)); in wacom_penpartner_irq()
144 input_report_key(input, wacom->tool[0], 0); in wacom_penpartner_irq()
146 input_report_abs(input, ABS_PRESSURE, -1); in wacom_penpartner_irq()
157 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); in wacom_penpartner_irq()
162 dev_dbg(input->dev.parent, in wacom_penpartner_irq()
172 struct wacom_features *features = &wacom->features; in wacom_pl_irq()
173 unsigned char *data = wacom->data; in wacom_pl_irq()
174 struct input_dev *input = wacom->pen_input; in wacom_pl_irq()
178 dev_dbg(input->dev.parent, in wacom_pl_irq()
185 if (!wacom->id[0]) { in wacom_pl_irq()
187 wacom->tool[0] = BTN_TOOL_RUBBER; in wacom_pl_irq()
188 wacom->id[0] = ERASER_DEVICE_ID; in wacom_pl_irq()
191 wacom->tool[0] = BTN_TOOL_PEN; in wacom_pl_irq()
192 wacom->id[0] = STYLUS_DEVICE_ID; in wacom_pl_irq()
197 * mis-detected the type and notice that STYLUS2 isn't set in wacom_pl_irq()
200 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { in wacom_pl_irq()
204 wacom->tool[0] = BTN_TOOL_PEN; in wacom_pl_irq()
205 wacom->id[0] = STYLUS_DEVICE_ID; in wacom_pl_irq()
210 if (features->pressure_max > 255) in wacom_pl_irq()
212 pressure += (features->pressure_max + 1) / 2; in wacom_pl_irq()
221 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20)); in wacom_pl_irq()
225 wacom->id[0] = 0; in wacom_pl_irq()
226 input_report_key(input, wacom->tool[0], prox); in wacom_pl_irq()
227 input_report_abs(input, ABS_MISC, wacom->id[0]); in wacom_pl_irq()
233 unsigned char *data = wacom->data; in wacom_ptu_irq()
234 struct input_dev *input = wacom->pen_input; in wacom_ptu_irq()
237 dev_dbg(input->dev.parent, in wacom_ptu_irq()
245 wacom->id[0] = ERASER_DEVICE_ID; in wacom_ptu_irq()
249 wacom->id[0] = STYLUS_DEVICE_ID; in wacom_ptu_irq()
251 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ in wacom_ptu_irq()
262 unsigned char *data = wacom->data; in wacom_dtu_irq()
263 struct input_dev *input = wacom->pen_input; in wacom_dtu_irq()
266 dev_dbg(input->dev.parent, in wacom_dtu_irq()
271 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; in wacom_dtu_irq()
272 if (wacom->tool[0] == BTN_TOOL_PEN) in wacom_dtu_irq()
273 wacom->id[0] = STYLUS_DEVICE_ID; in wacom_dtu_irq()
275 wacom->id[0] = ERASER_DEVICE_ID; in wacom_dtu_irq()
283 if (!prox) /* out-prox */ in wacom_dtu_irq()
284 wacom->id[0] = 0; in wacom_dtu_irq()
285 input_report_key(input, wacom->tool[0], prox); in wacom_dtu_irq()
286 input_report_abs(input, ABS_MISC, wacom->id[0]); in wacom_dtu_irq()
292 unsigned char *data = wacom->data; in wacom_dtus_irq()
293 struct input_dev *input = wacom->pen_input; in wacom_dtus_irq()
297 dev_dbg(input->dev.parent, in wacom_dtus_irq()
301 input = wacom->pad_input; in wacom_dtus_irq()
314 wacom->tool[0] = BTN_TOOL_RUBBER; in wacom_dtus_irq()
315 wacom->id[0] = ERASER_DEVICE_ID; in wacom_dtus_irq()
319 wacom->tool[0] = BTN_TOOL_PEN; in wacom_dtus_irq()
320 wacom->id[0] = STYLUS_DEVICE_ID; in wacom_dtus_irq()
333 if (!prox) /* out-prox */ in wacom_dtus_irq()
334 wacom->id[0] = 0; in wacom_dtus_irq()
335 input_report_key(input, wacom->tool[0], prox); in wacom_dtus_irq()
336 input_report_abs(input, ABS_MISC, wacom->id[0]); in wacom_dtus_irq()
343 struct wacom_features *features = &wacom->features; in wacom_graphire_irq()
344 unsigned char *data = wacom->data; in wacom_graphire_irq()
345 struct input_dev *input = wacom->pen_input; in wacom_graphire_irq()
346 struct input_dev *pad_input = wacom->pad_input; in wacom_graphire_irq()
352 if (features->type == GRAPHIRE_BT) { in wacom_graphire_irq()
354 dev_dbg(input->dev.parent, in wacom_graphire_irq()
360 dev_dbg(input->dev.parent, in wacom_graphire_irq()
366 if (prox || wacom->id[0]) { in wacom_graphire_irq()
371 wacom->tool[0] = BTN_TOOL_PEN; in wacom_graphire_irq()
372 wacom->id[0] = STYLUS_DEVICE_ID; in wacom_graphire_irq()
376 wacom->tool[0] = BTN_TOOL_RUBBER; in wacom_graphire_irq()
377 wacom->id[0] = ERASER_DEVICE_ID; in wacom_graphire_irq()
385 wacom->tool[0] = BTN_TOOL_MOUSE; in wacom_graphire_irq()
386 wacom->id[0] = CURSOR_DEVICE_ID; in wacom_graphire_irq()
392 if (wacom->tool[0] != BTN_TOOL_MOUSE) { in wacom_graphire_irq()
393 if (features->type == GRAPHIRE_BT) in wacom_graphire_irq()
405 if (features->type == WACOM_G4 || in wacom_graphire_irq()
406 features->type == WACOM_MO) { in wacom_graphire_irq()
408 rw = (data[7] & 0x04) - (data[7] & 0x03); in wacom_graphire_irq()
409 } else if (features->type == GRAPHIRE_BT) { in wacom_graphire_irq()
411 rw = 44 - (data[6] >> 2); in wacom_graphire_irq()
418 rw = (data[6] & 0x01) ? -1 : in wacom_graphire_irq()
425 rw = -(signed char)data[6]; in wacom_graphire_irq()
431 wacom->id[0] = 0; in wacom_graphire_irq()
432 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ in wacom_graphire_irq()
433 input_report_key(input, wacom->tool[0], prox); in wacom_graphire_irq()
438 switch (features->type) { in wacom_graphire_irq()
441 if (prox || wacom->id[1]) { in wacom_graphire_irq()
442 wacom->id[1] = PAD_DEVICE_ID; in wacom_graphire_irq()
445 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); in wacom_graphire_irq()
448 wacom->id[1] = 0; in wacom_graphire_irq()
449 input_report_abs(pad_input, ABS_MISC, wacom->id[1]); in wacom_graphire_irq()
456 if (prox || wacom->id[1]) { in wacom_graphire_irq()
457 wacom->id[1] = PAD_DEVICE_ID; in wacom_graphire_irq()
464 wacom->id[1] = 0; in wacom_graphire_irq()
465 input_report_abs(pad_input, ABS_MISC, wacom->id[1]); in wacom_graphire_irq()
471 if (prox || wacom->id[1]) { in wacom_graphire_irq()
472 wacom->id[1] = PAD_DEVICE_ID; in wacom_graphire_irq()
476 wacom->id[1] = 0; in wacom_graphire_irq()
477 input_report_abs(pad_input, ABS_MISC, wacom->id[1]); in wacom_graphire_irq()
484 if (features->type == GRAPHIRE_BT) { in wacom_graphire_irq()
499 struct wacom_features *features = &wacom_wac->features; in wacom_intuos_schedule_prox_event()
503 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]); in wacom_intuos_schedule_prox_event()
504 if (features->type == INTUOSHT2) in wacom_intuos_schedule_prox_event()
505 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID]; in wacom_intuos_schedule_prox_event()
507 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1]; in wacom_intuos_schedule_prox_event()
509 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT); in wacom_intuos_schedule_prox_event()
515 struct wacom_features *features = &wacom->features; in wacom_intuos_pad()
516 unsigned char *data = wacom->data; in wacom_intuos_pad()
517 struct input_dev *input = wacom->pad_input; in wacom_intuos_pad()
519 int buttons = 0, nbuttons = features->numbered_buttons; in wacom_intuos_pad()
532 if (features->type >= INTUOS4S && features->type <= INTUOS4L) { in wacom_intuos_pad()
535 } else if (features->type == DTK) { in wacom_intuos_pad()
537 } else if (features->type == WACOM_13HD) { in wacom_intuos_pad()
539 } else if (features->type == WACOM_24HD) { in wacom_intuos_pad()
558 if (features->oPid) { in wacom_intuos_pad()
561 wacom->shared->is_touch_on = in wacom_intuos_pad()
562 !wacom->shared->is_touch_on; in wacom_intuos_pad()
566 } else if (features->type == WACOM_27QHD) { in wacom_intuos_pad()
573 if (features->oPid) { in wacom_intuos_pad()
576 wacom->shared->is_touch_on = in wacom_intuos_pad()
577 !wacom->shared->is_touch_on; in wacom_intuos_pad()
584 } else if (features->type == CINTIQ_HYBRID) { in wacom_intuos_pad()
590 * d-pad right -> data[4] & 0x10 in wacom_intuos_pad()
591 * d-pad up -> data[4] & 0x20 in wacom_intuos_pad()
592 * d-pad left -> data[4] & 0x40 in wacom_intuos_pad()
593 * d-pad down -> data[4] & 0x80 in wacom_intuos_pad()
594 * d-pad center -> data[3] & 0x01 in wacom_intuos_pad()
597 } else if (features->type == CINTIQ_COMPANION_2) { in wacom_intuos_pad()
598 /* d-pad right -> data[2] & 0x10 in wacom_intuos_pad()
599 * d-pad up -> data[2] & 0x20 in wacom_intuos_pad()
600 * d-pad left -> data[2] & 0x40 in wacom_intuos_pad()
601 * d-pad down -> data[2] & 0x80 in wacom_intuos_pad()
602 * d-pad center -> data[1] & 0x01 in wacom_intuos_pad()
608 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) { in wacom_intuos_pad()
619 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { in wacom_intuos_pad()
623 if (features->type == WACOM_22HD) { in wacom_intuos_pad()
653 if (wacom->shared && wacom->shared->touch_input) { in wacom_intuos_pad()
654 input_report_switch(wacom->shared->touch_input, in wacom_intuos_pad()
656 !wacom->shared->is_touch_on); in wacom_intuos_pad()
657 input_sync(wacom->shared->touch_input); in wacom_intuos_pad()
666 input_report_key(input, wacom->tool[1], prox ? 1 : 0); in wacom_intuos_pad()
735 struct input_dev *input = wacom->pen_input; in wacom_exit_report()
736 struct wacom_features *features = &wacom->features; in wacom_exit_report()
737 unsigned char *data = wacom->data; in wacom_exit_report()
738 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; in wacom_exit_report()
742 * when in-prox next time in wacom_exit_report()
749 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { in wacom_exit_report()
763 if (features->type >= INTUOS3S) in wacom_exit_report()
766 input_report_key(input, wacom->tool[idx], 0); in wacom_exit_report()
768 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); in wacom_exit_report()
769 wacom->id[idx] = 0; in wacom_exit_report()
774 struct wacom_features *features = &wacom->features; in wacom_intuos_inout()
775 unsigned char *data = wacom->data; in wacom_intuos_inout()
776 struct input_dev *input = wacom->pen_input; in wacom_intuos_inout()
777 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; in wacom_intuos_inout()
787 wacom->serial[idx] = ((__u64)(data[3] & 0x0f) << 28) + in wacom_intuos_inout()
791 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) | in wacom_intuos_inout()
794 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]); in wacom_intuos_inout()
796 wacom->shared->stylus_in_proximity = true; in wacom_intuos_inout()
802 if (features->type != INTUOSHT2) in wacom_intuos_inout()
803 wacom->shared->stylus_in_proximity = true; in wacom_intuos_inout()
806 if (wacom->reporting_data) { in wacom_intuos_inout()
809 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max); in wacom_intuos_inout()
817 wacom->shared->stylus_in_proximity = false; in wacom_intuos_inout()
818 wacom->reporting_data = false; in wacom_intuos_inout()
821 if (!wacom->id[idx]) in wacom_intuos_inout()
833 return wacom_wac->probe_complete && in touch_is_muted()
834 wacom_wac->shared->has_mute_touch_switch && in touch_is_muted()
835 !wacom_wac->shared->is_touch_on; in touch_is_muted()
840 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1); in report_touch_events()
845 return (wacom->shared->touch_down && touch_arbitration); in delay_pen_events()
850 struct wacom_features *features = &wacom->features; in wacom_intuos_general()
851 unsigned char *data = wacom->data; in wacom_intuos_general()
852 struct input_dev *input = wacom->pen_input; in wacom_intuos_general()
853 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; in wacom_intuos_general()
865 if (!wacom->id[idx]) { in wacom_intuos_general()
875 if ((!((wacom->id[idx] >> 16) & 0x01) && in wacom_intuos_general()
876 (features->type == WACOM_21UX2)) || in wacom_intuos_general()
878 (wacom->tool[idx] == BTN_TOOL_LENS && in wacom_intuos_general()
879 (features->type == INTUOS3 || in wacom_intuos_general()
880 features->type == INTUOS3S || in wacom_intuos_general()
881 features->type == INTUOS4 || in wacom_intuos_general()
882 features->type == INTUOS4S || in wacom_intuos_general()
883 features->type == INTUOS5 || in wacom_intuos_general()
884 features->type == INTUOS5S || in wacom_intuos_general()
885 features->type == INTUOSPM || in wacom_intuos_general()
886 features->type == INTUOSPS)) || in wacom_intuos_general()
888 (features->type == CINTIQ && !(data[1] & 0x40))) in wacom_intuos_general()
894 if (features->type < INTUOS3S) { in wacom_intuos_general()
899 if (features->type == INTUOSHT2) in wacom_intuos_general()
900 distance = features->distance_max - distance; in wacom_intuos_general()
912 if (features->pressure_max < 2047) in wacom_intuos_general()
915 if (features->type != INTUOSHT2) { in wacom_intuos_general()
917 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); in wacom_intuos_general()
918 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); in wacom_intuos_general()
930 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); in wacom_intuos_general()
931 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); in wacom_intuos_general()
936 if (features->type >= INTUOS3S) { in wacom_intuos_general()
939 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : in wacom_intuos_general()
940 ((t-1) / 2 + 450)) : (450 - t / 2) ; in wacom_intuos_general()
946 ((t - 1) / 2) : -t / 2); in wacom_intuos_general()
959 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); in wacom_intuos_general()
968 - ((data[7] & 0x40) >> 6)); in wacom_intuos_general()
973 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); in wacom_intuos_general()
974 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); in wacom_intuos_general()
978 if (wacom->tool[idx] == BTN_TOOL_MOUSE) { in wacom_intuos_general()
984 - ((data[8] & 0x02) >> 1)); in wacom_intuos_general()
987 if (features->type >= INTUOS3S && features->type <= INTUOS3L) { in wacom_intuos_general()
992 else if (wacom->tool[idx] == BTN_TOOL_LENS) { in wacom_intuos_general()
1014 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */ in wacom_intuos_general()
1015 input_report_key(input, wacom->tool[idx], 1); in wacom_intuos_general()
1016 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); in wacom_intuos_general()
1017 wacom->reporting_data = true; in wacom_intuos_general()
1023 unsigned char *data = wacom->data; in wacom_intuos_irq()
1024 struct input_dev *input = wacom->pen_input; in wacom_intuos_irq()
1035 dev_dbg(input->dev.parent, in wacom_intuos_irq()
1048 return result - 1; in wacom_intuos_irq()
1053 return result - 1; in wacom_intuos_irq()
1060 unsigned char *data = wacom_wac->data; in wacom_remote_irq()
1063 struct wacom_remote *remote = wacom->remote; in wacom_remote_irq()
1066 int i, index = -1; in wacom_remote_irq()
1070 hid_dbg(wacom->hdev, "%s: received unknown report #%d", in wacom_remote_irq()
1076 wacom_wac->id[0] = PAD_DEVICE_ID; in wacom_remote_irq()
1078 spin_lock_irqsave(&remote->remote_lock, flags); in wacom_remote_irq()
1081 if (remote->remotes[i].serial == serial) { in wacom_remote_irq()
1087 if (index < 0 || !remote->remotes[index].registered) in wacom_remote_irq()
1090 remote->remotes[i].active_time = ktime_get(); in wacom_remote_irq()
1091 input = remote->remotes[index].input; in wacom_remote_irq()
1115 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1); in wacom_remote_irq()
1135 if (remote->remotes[i].serial == serial) in wacom_remote_irq()
1136 wacom->led.groups[i].select = touch_ring_mode; in wacom_remote_irq()
1139 __wacom_notify_battery(&remote->remotes[index].battery, in wacom_remote_irq()
1144 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_irq()
1151 unsigned char *data = wacom_wac->data; in wacom_remote_status_irq()
1152 struct wacom_remote *remote = wacom->remote; in wacom_remote_status_irq()
1169 spin_lock_irqsave(&remote->remote_lock, flags); in wacom_remote_status_irq()
1171 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data)); in wacom_remote_status_irq()
1173 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_status_irq()
1174 hid_err(wacom->hdev, "Can't queue Remote status event.\n"); in wacom_remote_status_irq()
1178 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_status_irq()
1185 int x = x2 - x1; in int_dist()
1186 int y = y2 - y1; in int_dist()
1194 memcpy(wacom->data, data, 10); in wacom_intuos_bt_process_data()
1197 input_sync(wacom->pen_input); in wacom_intuos_bt_process_data()
1198 if (wacom->pad_input) in wacom_intuos_bt_process_data()
1199 input_sync(wacom->pad_input); in wacom_intuos_bt_process_data()
1208 memcpy(data, wacom->data, len); in wacom_intuos_bt_irq()
1230 dev_dbg(wacom->pen_input->dev.parent, in wacom_intuos_bt_irq()
1240 struct input_dev *input = wacom->touch_input; in wacom_wac_finger_count_touches()
1241 unsigned touch_max = wacom->features.touch_max; in wacom_wac_finger_count_touches()
1249 return test_bit(BTN_TOUCH, input->key) && in wacom_wac_finger_count_touches()
1252 for (i = 0; i < input->mt->num_slots; i++) { in wacom_wac_finger_count_touches()
1253 struct input_mt_slot *ps = &input->mt->slots[i]; in wacom_wac_finger_count_touches()
1266 struct input_dev *pen_input = wacom->pen_input; in wacom_intuos_pro2_bt_pen()
1267 unsigned char *data = wacom->data; in wacom_intuos_pro2_bt_pen()
1273 if (wacom->features.type == INTUOSP2_BT || in wacom_intuos_pro2_bt_pen()
1274 wacom->features.type == INTUOSP2S_BT) { in wacom_intuos_pro2_bt_pen()
1275 wacom->serial[0] = get_unaligned_le64(&data[99]); in wacom_intuos_pro2_bt_pen()
1276 wacom->id[0] = get_unaligned_le16(&data[107]); in wacom_intuos_pro2_bt_pen()
1280 wacom->serial[0] = get_unaligned_le64(&data[33]); in wacom_intuos_pro2_bt_pen()
1281 wacom->id[0] = get_unaligned_le16(&data[41]); in wacom_intuos_pro2_bt_pen()
1286 if (wacom->serial[0] >> 52 == 1) { in wacom_intuos_pro2_bt_pen()
1287 /* Add back in missing bits of ID for non-USI pens */ in wacom_intuos_pro2_bt_pen()
1288 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; in wacom_intuos_pro2_bt_pen()
1301 if (wacom->hid_data.time_delayed) in wacom_intuos_pro2_bt_pen()
1302 time_interval = ktime_get() - wacom->hid_data.time_delayed; in wacom_intuos_pro2_bt_pen()
1304 wacom->hid_data.time_delayed = time_packet_received; in wacom_intuos_pro2_bt_pen()
1313 int frames_number_reversed = number_of_valid_frames - i - 1; in wacom_intuos_pro2_bt_pen()
1314 ktime_t event_timestamp = time_packet_received - frames_number_reversed * time_interval; in wacom_intuos_pro2_bt_pen()
1320 wacom->shared->stylus_in_proximity = false; in wacom_intuos_pro2_bt_pen()
1324 wacom->tool[0] = 0; in wacom_intuos_pro2_bt_pen()
1325 wacom->id[0] = 0; in wacom_intuos_pro2_bt_pen()
1326 wacom->serial[0] = 0; in wacom_intuos_pro2_bt_pen()
1327 wacom->hid_data.time_delayed = 0; in wacom_intuos_pro2_bt_pen()
1332 if (!wacom->tool[0]) { /* first in range */ in wacom_intuos_pro2_bt_pen()
1335 wacom->tool[0] = BTN_TOOL_RUBBER; in wacom_intuos_pro2_bt_pen()
1336 else if (wacom->id[0]) in wacom_intuos_pro2_bt_pen()
1337 wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]); in wacom_intuos_pro2_bt_pen()
1339 wacom->tool[0] = BTN_TOOL_PEN; in wacom_intuos_pro2_bt_pen()
1345 if (wacom->features.type == INTUOSP2_BT || in wacom_intuos_pro2_bt_pen()
1346 wacom->features.type == INTUOSP2S_BT) { in wacom_intuos_pro2_bt_pen()
1353 rotation -= 1800; in wacom_intuos_pro2_bt_pen()
1365 if (wacom->tool[0]) { in wacom_intuos_pro2_bt_pen()
1367 if (wacom->features.type == INTUOSP2_BT || in wacom_intuos_pro2_bt_pen()
1368 wacom->features.type == INTUOSP2S_BT) { in wacom_intuos_pro2_bt_pen()
1370 range ? frame[13] : wacom->features.distance_max); in wacom_intuos_pro2_bt_pen()
1373 range ? frame[7] : wacom->features.distance_max); in wacom_intuos_pro2_bt_pen()
1380 input_report_key(pen_input, wacom->tool[0], prox); in wacom_intuos_pro2_bt_pen()
1381 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]); in wacom_intuos_pro2_bt_pen()
1383 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */ in wacom_intuos_pro2_bt_pen()
1386 wacom->shared->stylus_in_proximity = prox; in wacom_intuos_pro2_bt_pen()
1401 struct input_dev *touch_input = wacom->touch_input; in wacom_intuos_pro2_bt_touch()
1402 unsigned char *data = wacom->data; in wacom_intuos_pro2_bt_touch()
1416 * packet in series will have non-zero current_num_contacts. in wacom_intuos_pro2_bt_touch()
1419 wacom->num_contacts_left = current_num_contacts; in wacom_intuos_pro2_bt_touch()
1421 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); in wacom_intuos_pro2_bt_touch()
1445 wacom->num_contacts_left -= contacts_to_send; in wacom_intuos_pro2_bt_touch()
1446 if (wacom->num_contacts_left <= 0) { in wacom_intuos_pro2_bt_touch()
1447 wacom->num_contacts_left = 0; in wacom_intuos_pro2_bt_touch()
1448 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); in wacom_intuos_pro2_bt_touch()
1453 if (wacom->num_contacts_left == 0) { in wacom_intuos_pro2_bt_touch()
1464 struct input_dev *pad_input = wacom->pad_input; in wacom_intuos_pro2_bt_pad()
1465 unsigned char *data = wacom->data; in wacom_intuos_pro2_bt_pad()
1466 int nbuttons = wacom->features.numbered_buttons; in wacom_intuos_pro2_bt_pad()
1475 ring = 71 - ring; in wacom_intuos_pro2_bt_pad()
1478 ring -= 72; in wacom_intuos_pro2_bt_pad()
1481 expresskeys | (center << (nbuttons - 1))); in wacom_intuos_pro2_bt_pad()
1485 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0); in wacom_intuos_pro2_bt_pad()
1494 unsigned char *data = wacom->data; in wacom_intuos_pro2_bt_battery()
1505 struct input_dev *pad_input = wacom->pad_input; in wacom_intuos_gen3_bt_pad()
1506 unsigned char *data = wacom->data; in wacom_intuos_gen3_bt_pad()
1512 input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0); in wacom_intuos_gen3_bt_pad()
1521 unsigned char *data = wacom->data; in wacom_intuos_gen3_bt_battery()
1532 unsigned char *data = wacom->data; in wacom_intuos_pro2_bt_irq()
1535 dev_dbg(wacom->pen_input->dev.parent, in wacom_intuos_pro2_bt_irq()
1541 if (wacom->features.type == INTUOSP2_BT || in wacom_intuos_pro2_bt_irq()
1542 wacom->features.type == INTUOSP2S_BT) { in wacom_intuos_pro2_bt_irq()
1555 struct input_dev *input = wacom->touch_input; in wacom_24hdt_irq()
1556 unsigned char *data = wacom->data; in wacom_24hdt_irq()
1564 if (touch_is_muted(wacom) && !wacom->shared->touch_down) in wacom_24hdt_irq()
1567 if (wacom->features.type == WACOM_27QHDT) { in wacom_24hdt_irq()
1576 * packet in series will have non-zero current_num_contacts. in wacom_24hdt_irq()
1579 wacom->num_contacts_left = current_num_contacts; in wacom_24hdt_irq()
1581 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); in wacom_24hdt_irq()
1600 if (wacom->features.type != WACOM_27QHDT) { in wacom_24hdt_irq()
1616 wacom->num_contacts_left -= contacts_to_send; in wacom_24hdt_irq()
1617 if (wacom->num_contacts_left <= 0) { in wacom_24hdt_irq()
1618 wacom->num_contacts_left = 0; in wacom_24hdt_irq()
1619 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); in wacom_24hdt_irq()
1626 struct input_dev *input = wacom->touch_input; in wacom_mt_touch()
1627 unsigned char *data = wacom->data; in wacom_mt_touch()
1634 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B) in wacom_mt_touch()
1635 x_offset = -4; in wacom_mt_touch()
1639 * packet in series will have non-zero current_num_contacts. in wacom_mt_touch()
1642 wacom->num_contacts_left = current_num_contacts; in wacom_mt_touch()
1645 contacts_to_send = min(5, wacom->num_contacts_left); in wacom_mt_touch()
1667 wacom->num_contacts_left -= contacts_to_send; in wacom_mt_touch()
1668 if (wacom->num_contacts_left <= 0) { in wacom_mt_touch()
1669 wacom->num_contacts_left = 0; in wacom_mt_touch()
1670 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); in wacom_mt_touch()
1677 struct input_dev *input = wacom->touch_input; in wacom_tpc_mt_touch()
1678 unsigned char *data = wacom->data; in wacom_tpc_mt_touch()
1698 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); in wacom_tpc_mt_touch()
1705 unsigned char *data = wacom->data; in wacom_tpc_single_touch()
1706 struct input_dev *input = wacom->touch_input; in wacom_tpc_single_touch()
1710 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG) in wacom_tpc_single_touch()
1734 wacom->shared->touch_down = prox; in wacom_tpc_single_touch()
1741 unsigned char *data = wacom->data; in wacom_tpc_pen()
1742 struct input_dev *input = wacom->pen_input; in wacom_tpc_pen()
1745 if (!wacom->shared->stylus_in_proximity) /* first in prox */ in wacom_tpc_pen()
1747 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; in wacom_tpc_pen()
1750 wacom->shared->stylus_in_proximity = prox; in wacom_tpc_pen()
1762 input_report_key(input, wacom->tool[0], prox); in wacom_tpc_pen()
1771 unsigned char *data = wacom->data; in wacom_tpc_irq()
1773 if (wacom->pen_input) { in wacom_tpc_irq()
1774 dev_dbg(wacom->pen_input->dev.parent, in wacom_tpc_irq()
1781 else if (wacom->touch_input) { in wacom_tpc_irq()
1782 dev_dbg(wacom->touch_input->dev.parent, in wacom_tpc_irq()
1814 struct input_absinfo *abs = &input->absinfo[usage->code]; in wacom_offset_rotation() local
1815 int range = (abs->maximum - abs->minimum + 1); in wacom_offset_rotation()
1818 if (value > abs->maximum) in wacom_offset_rotation()
1819 value -= range; in wacom_offset_rotation()
1820 else if (value < abs->minimum) in wacom_offset_rotation()
1872 struct hid_field *field, __u8 type, __u16 code, int fuzz) in wacom_map_usage() argument
1875 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_map_usage()
1876 struct wacom_features *features = &wacom_wac->features; in wacom_map_usage()
1877 int fmin = field->logical_minimum; in wacom_map_usage()
1878 int fmax = field->logical_maximum; in wacom_map_usage()
1879 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_map_usage()
1890 fmin += features->offset_left; in wacom_map_usage()
1891 fmax -= features->offset_right; in wacom_map_usage()
1894 fmin += features->offset_top; in wacom_map_usage()
1895 fmax -= features->offset_bottom; in wacom_map_usage()
1898 usage->type = type; in wacom_map_usage()
1899 usage->code = code; in wacom_map_usage()
1903 input_set_abs_params(input, code, fmin, fmax, fuzz, 0); in wacom_map_usage()
1933 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_battery_event()
1934 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_battery_event()
1939 wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN; in wacom_wac_battery_event()
1942 value = value * 100 / (field->logical_maximum - field->logical_minimum); in wacom_wac_battery_event()
1943 wacom_wac->hid_data.battery_capacity = value; in wacom_wac_battery_event()
1944 wacom_wac->hid_data.bat_connected = 1; in wacom_wac_battery_event()
1945 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; in wacom_wac_battery_event()
1947 wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY; in wacom_wac_battery_event()
1950 value = value * 100 / (field->logical_maximum - field->logical_minimum); in wacom_wac_battery_event()
1951 wacom_wac->hid_data.battery_capacity = value; in wacom_wac_battery_event()
1952 wacom_wac->hid_data.bat_connected = 1; in wacom_wac_battery_event()
1953 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; in wacom_wac_battery_event()
1954 wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY; in wacom_wac_battery_event()
1957 wacom_wac->hid_data.bat_charging = value; in wacom_wac_battery_event()
1958 wacom_wac->hid_data.ps_connected = value; in wacom_wac_battery_event()
1959 wacom_wac->hid_data.bat_connected = 1; in wacom_wac_battery_event()
1960 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; in wacom_wac_battery_event()
1961 wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY; in wacom_wac_battery_event()
1976 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_battery_report()
1978 int status = wacom_wac->hid_data.bat_status; in wacom_wac_battery_report()
1979 int capacity = wacom_wac->hid_data.battery_capacity; in wacom_wac_battery_report()
1980 bool charging = wacom_wac->hid_data.bat_charging; in wacom_wac_battery_report()
1981 bool connected = wacom_wac->hid_data.bat_connected; in wacom_wac_battery_report()
1982 bool powered = wacom_wac->hid_data.ps_connected; in wacom_wac_battery_report()
1992 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pad_usage_mapping()
1993 struct wacom_features *features = &wacom_wac->features; in wacom_wac_pad_usage_mapping()
1994 struct input_dev *input = wacom_wac->pad_input; in wacom_wac_pad_usage_mapping()
1995 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_pad_usage_mapping()
1999 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); in wacom_wac_pad_usage_mapping()
2001 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2004 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); in wacom_wac_pad_usage_mapping()
2006 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2009 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); in wacom_wac_pad_usage_mapping()
2011 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2020 wacom_numbered_button_to_key(features->numbered_buttons), in wacom_wac_pad_usage_mapping()
2022 features->numbered_buttons++; in wacom_wac_pad_usage_mapping()
2023 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2027 wacom_wac->is_soft_touch_switch = true; in wacom_wac_pad_usage_mapping()
2038 wacom_wac->has_mute_touch_switch = true; in wacom_wac_pad_usage_mapping()
2039 usage->type = EV_SW; in wacom_wac_pad_usage_mapping()
2040 usage->code = SW_MUTE_DEVICE; in wacom_wac_pad_usage_mapping()
2044 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2048 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2051 if (field->flags & HID_MAIN_ITEM_RELATIVE) { in wacom_wac_pad_usage_mapping()
2052 wacom_wac->relring_count++; in wacom_wac_pad_usage_mapping()
2053 if (wacom_wac->relring_count == 1) { in wacom_wac_pad_usage_mapping()
2055 set_bit(REL_WHEEL, input->relbit); in wacom_wac_pad_usage_mapping()
2057 else if (wacom_wac->relring_count == 2) { in wacom_wac_pad_usage_mapping()
2059 set_bit(REL_HWHEEL, input->relbit); in wacom_wac_pad_usage_mapping()
2062 wacom_wac->absring_count++; in wacom_wac_pad_usage_mapping()
2063 if (wacom_wac->absring_count == 1) in wacom_wac_pad_usage_mapping()
2065 else if (wacom_wac->absring_count == 2) in wacom_wac_pad_usage_mapping()
2068 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2075 usage->type = EV_ABS; in wacom_wac_pad_usage_mapping()
2076 usage->code = ABS_WHEEL; in wacom_wac_pad_usage_mapping()
2077 set_bit(EV_ABS, input->evbit); in wacom_wac_pad_usage_mapping()
2078 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2082 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2086 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2090 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2094 if (!wacom_wac->has_mode_change) { in wacom_wac_pad_usage_mapping()
2095 wacom_wac->has_mode_change = true; in wacom_wac_pad_usage_mapping()
2096 wacom_wac->is_direct_mode = true; in wacom_wac_pad_usage_mapping()
2098 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2105 wacom_numbered_button_to_key(features->numbered_buttons), in wacom_wac_pad_usage_mapping()
2107 features->numbered_buttons++; in wacom_wac_pad_usage_mapping()
2108 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_wac_pad_usage_mapping()
2117 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pad_event()
2118 struct input_dev *input = wacom_wac->pad_input; in wacom_wac_pad_event()
2119 struct wacom_features *features = &wacom_wac->features; in wacom_wac_pad_event()
2120 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_pad_event()
2128 if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE) in wacom_wac_pad_event()
2131 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) { in wacom_wac_pad_event()
2132 bool is_abs_touchring = usage->hid == WACOM_HID_WD_TOUCHRING && in wacom_wac_pad_event()
2133 !(field->flags & HID_MAIN_ITEM_RELATIVE); in wacom_wac_pad_event()
2136 wacom_wac->hid_data.inrange_state |= value; in wacom_wac_pad_event()
2145 if (wacom_wac->shared->touch_input) { in wacom_wac_pad_event()
2146 bool *is_touch_on = &wacom_wac->shared->is_touch_on; in wacom_wac_pad_event()
2153 input_report_switch(wacom_wac->shared->touch_input, in wacom_wac_pad_event()
2155 input_sync(wacom_wac->shared->touch_input); in wacom_wac_pad_event()
2168 * tablet's left. HID events "should" be clockwise- in wacom_wac_pad_event()
2170 * Pro and 2nd-gen Intuos Pro don't do this... in wacom_wac_pad_event()
2172 if (hdev->vendor == 0x56a && in wacom_wac_pad_event()
2173 (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */ in wacom_wac_pad_event()
2174 hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */ in wacom_wac_pad_event()
2175 hdev->product == 0x392 || /* Intuos Pro 2 */ in wacom_wac_pad_event()
2176 hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */ in wacom_wac_pad_event()
2177 hdev->product == 0x3AA)) { /* MobileStudio Pro */ in wacom_wac_pad_event()
2178 value = (field->logical_maximum - value); in wacom_wac_pad_event()
2180 if (hdev->product == 0x357 || hdev->product == 0x358 || in wacom_wac_pad_event()
2181 hdev->product == 0x392) in wacom_wac_pad_event()
2183 else if (hdev->product == 0x34d || hdev->product == 0x34e || in wacom_wac_pad_event()
2184 hdev->product == 0x398 || hdev->product == 0x399 || in wacom_wac_pad_event()
2185 hdev->product == 0x3AA) in wacom_wac_pad_event()
2188 else if (field->flags & HID_MAIN_ITEM_RELATIVE) { in wacom_wac_pad_event()
2189 int hires_value = value * 120 / usage->resolution_multiplier; in wacom_wac_pad_event()
2193 if (usage->code == REL_WHEEL_HI_RES) { in wacom_wac_pad_event()
2200 hires_value = -hires_value; in wacom_wac_pad_event()
2201 ring_value = &wacom_wac->hid_data.ring_value; in wacom_wac_pad_event()
2204 else if (usage->code == REL_HWHEEL_HI_RES) { in wacom_wac_pad_event()
2212 ring_value = &wacom_wac->hid_data.ring2_value; in wacom_wac_pad_event()
2216 hid_err(wacom->hdev, "unrecognized relative wheel with code %d\n", in wacom_wac_pad_event()
2217 usage->code); in wacom_wac_pad_event()
2225 * units of hi-res travel. in wacom_wac_pad_event()
2227 if (*ring_value >= 120 || *ring_value <= -120) { in wacom_wac_pad_event()
2230 input_event(input, usage->type, lowres_code, clicks); in wacom_wac_pad_event()
2231 *ring_value -= clicks * 120; in wacom_wac_pad_event()
2241 input_event(input, usage->type, usage->code, 0); in wacom_wac_pad_event()
2245 if (wacom_wac->is_direct_mode != value) { in wacom_wac_pad_event()
2246 wacom_wac->is_direct_mode = value; in wacom_wac_pad_event()
2247 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE); in wacom_wac_pad_event()
2252 for (i = 0; i < wacom->led.count; i++) in wacom_wac_pad_event()
2253 wacom_update_led(wacom, features->numbered_buttons, in wacom_wac_pad_event()
2262 input_event(input, usage->type, usage->code, value); in wacom_wac_pad_event()
2264 wacom_wac->hid_data.pad_input_event_flag = true; in wacom_wac_pad_event()
2272 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pad_pre_report()
2274 wacom_wac->hid_data.inrange_state = 0; in wacom_wac_pad_pre_report()
2281 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pad_report()
2282 struct input_dev *input = wacom_wac->pad_input; in wacom_wac_pad_report()
2283 bool active = wacom_wac->hid_data.inrange_state != 0; in wacom_wac_pad_report()
2286 if (wacom_wac->hid_data.pad_input_event_flag) { in wacom_wac_pad_report()
2290 wacom_wac->hid_data.pad_input_event_flag = false; in wacom_wac_pad_report()
2296 struct input_dev *input = wacom_wac->pen_input; in wacom_set_barrel_switch3_usage()
2297 struct wacom_features *features = &wacom_wac->features; in wacom_set_barrel_switch3_usage()
2299 if (!(features->quirks & WACOM_QUIRK_AESPEN) && in wacom_set_barrel_switch3_usage()
2300 wacom_wac->hid_data.barrelswitch && in wacom_set_barrel_switch3_usage()
2301 wacom_wac->hid_data.barrelswitch2 && in wacom_set_barrel_switch3_usage()
2302 wacom_wac->hid_data.serialhi && in wacom_set_barrel_switch3_usage()
2303 !wacom_wac->hid_data.barrelswitch3) { in wacom_set_barrel_switch3_usage()
2305 features->quirks |= WACOM_QUIRK_PEN_BUTTON3; in wacom_set_barrel_switch3_usage()
2313 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pen_usage_mapping()
2314 struct wacom_features *features = &wacom_wac->features; in wacom_wac_pen_usage_mapping()
2315 struct input_dev *input = wacom_wac->pen_input; in wacom_wac_pen_usage_mapping()
2316 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_pen_usage_mapping()
2357 wacom_wac->hid_data.barrelswitch = true; in wacom_wac_pen_usage_mapping()
2362 wacom_wac->hid_data.barrelswitch2 = true; in wacom_wac_pen_usage_mapping()
2367 features->quirks |= WACOM_QUIRK_TOOLSERIAL; in wacom_wac_pen_usage_mapping()
2374 features->quirks |= WACOM_QUIRK_SENSE; in wacom_wac_pen_usage_mapping()
2378 wacom_wac->hid_data.serialhi = true; in wacom_wac_pen_usage_mapping()
2387 wacom_wac->hid_data.barrelswitch3 = true; in wacom_wac_pen_usage_mapping()
2389 features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3; in wacom_wac_pen_usage_mapping()
2392 wacom_wac->hid_data.sequence_number = -1; in wacom_wac_pen_usage_mapping()
2401 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pen_event()
2402 struct wacom_features *features = &wacom_wac->features; in wacom_wac_pen_event()
2403 struct input_dev *input = wacom_wac->pen_input; in wacom_wac_pen_event()
2404 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_pen_event()
2406 if (wacom_wac->is_invalid_bt_frame) in wacom_wac_pen_event()
2416 value = field->logical_maximum - value; in wacom_wac_pen_event()
2419 mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100)); in wacom_wac_pen_event()
2420 wacom_wac->hid_data.inrange_state = value; in wacom_wac_pen_event()
2421 if (!(features->quirks & WACOM_QUIRK_SENSE)) in wacom_wac_pen_event()
2422 wacom_wac->hid_data.sense_state = value; in wacom_wac_pen_event()
2425 wacom_wac->hid_data.invert_state = value; in wacom_wac_pen_event()
2429 wacom_wac->hid_data.tipswitch |= value; in wacom_wac_pen_event()
2432 wacom_wac->hid_data.barrelswitch = value; in wacom_wac_pen_event()
2435 wacom_wac->hid_data.barrelswitch2 = value; in wacom_wac_pen_event()
2439 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); in wacom_wac_pen_event()
2440 wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size); in wacom_wac_pen_event()
2445 if (!wacom_is_art_pen(wacom_wac->id[0])) return; in wacom_wac_pen_event()
2455 wacom_wac->hid_data.sense_state = value; in wacom_wac_pen_event()
2459 __u32 raw_value = wacom_s32tou(value, field->report_size); in wacom_wac_pen_event()
2461 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF); in wacom_wac_pen_event()
2462 wacom_wac->serial[0] |= ((__u64)raw_value) << 32; in wacom_wac_pen_event()
2464 * Non-USI EMR devices may contain additional tool type in wacom_wac_pen_event()
2469 wacom_wac->id[0] |= raw_value & 0xFFFFF; in wacom_wac_pen_event()
2481 wacom_wac->id[0] |= wacom_s32tou(value, field->report_size); in wacom_wac_pen_event()
2484 if (features->offset_left && value != features->offset_left) in wacom_wac_pen_event()
2486 "%d -> %d\n", __func__, value, in wacom_wac_pen_event()
2487 features->offset_left); in wacom_wac_pen_event()
2488 features->offset_left = value; in wacom_wac_pen_event()
2491 if (features->offset_right && value != features->offset_right) in wacom_wac_pen_event()
2493 "%d -> %d\n", __func__, value, in wacom_wac_pen_event()
2494 features->offset_right); in wacom_wac_pen_event()
2495 features->offset_right = value; in wacom_wac_pen_event()
2498 if (features->offset_top && value != features->offset_top) in wacom_wac_pen_event()
2500 "%d -> %d\n", __func__, value, in wacom_wac_pen_event()
2501 features->offset_top); in wacom_wac_pen_event()
2502 features->offset_top = value; in wacom_wac_pen_event()
2505 if (features->offset_bottom && value != features->offset_bottom) in wacom_wac_pen_event()
2507 "%d -> %d\n", __func__, value, in wacom_wac_pen_event()
2508 features->offset_bottom); in wacom_wac_pen_event()
2509 features->offset_bottom = value; in wacom_wac_pen_event()
2512 wacom_wac->is_invalid_bt_frame = !value; in wacom_wac_pen_event()
2515 wacom_wac->hid_data.barrelswitch3 = value; in wacom_wac_pen_event()
2518 if (wacom_wac->hid_data.sequence_number != value && in wacom_wac_pen_event()
2519 wacom_wac->hid_data.sequence_number >= 0) { in wacom_wac_pen_event()
2520 int sequence_size = field->logical_maximum - field->logical_minimum + 1; in wacom_wac_pen_event()
2521 int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size; in wacom_wac_pen_event()
2524 wacom_wac->hid_data.sequence_number = value + 1; in wacom_wac_pen_event()
2525 if (wacom_wac->hid_data.sequence_number > field->logical_maximum) in wacom_wac_pen_event()
2526 wacom_wac->hid_data.sequence_number = field->logical_minimum; in wacom_wac_pen_event()
2533 if (!usage->type || delay_pen_events(wacom_wac)) in wacom_wac_pen_event()
2537 if (wacom_wac->hid_data.inrange_state) in wacom_wac_pen_event()
2538 input_event(input, usage->type, usage->code, value); in wacom_wac_pen_event()
2539 else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state) in wacom_wac_pen_event()
2540 input_event(input, usage->type, usage->code, 0); in wacom_wac_pen_event()
2547 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pen_pre_report()
2549 wacom_wac->is_invalid_bt_frame = false; in wacom_wac_pen_pre_report()
2557 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pen_report()
2558 struct input_dev *input = wacom_wac->pen_input; in wacom_wac_pen_report()
2559 bool range = wacom_wac->hid_data.inrange_state; in wacom_wac_pen_report()
2560 bool sense = wacom_wac->hid_data.sense_state; in wacom_wac_pen_report()
2561 bool entering_range = !wacom_wac->tool[0] && range; in wacom_wac_pen_report()
2563 if (wacom_wac->is_invalid_bt_frame) in wacom_wac_pen_report()
2568 if (wacom_wac->hid_data.invert_state) in wacom_wac_pen_report()
2569 wacom_wac->tool[0] = BTN_TOOL_RUBBER; in wacom_wac_pen_report()
2570 else if (wacom_wac->features.quirks & WACOM_QUIRK_AESPEN) in wacom_wac_pen_report()
2571 wacom_wac->tool[0] = BTN_TOOL_PEN; in wacom_wac_pen_report()
2572 else if (wacom_wac->id[0]) in wacom_wac_pen_report()
2573 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]); in wacom_wac_pen_report()
2575 wacom_wac->tool[0] = BTN_TOOL_PEN; in wacom_wac_pen_report()
2579 wacom_wac->shared->stylus_in_proximity = sense; in wacom_wac_pen_report()
2581 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { in wacom_wac_pen_report()
2582 int id = wacom_wac->id[0]; in wacom_wac_pen_report()
2583 if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3) { in wacom_wac_pen_report()
2584 int sw_state = wacom_wac->hid_data.barrelswitch | in wacom_wac_pen_report()
2585 (wacom_wac->hid_data.barrelswitch2 << 1); in wacom_wac_pen_report()
2586 wacom_wac->hid_data.barrelswitch = sw_state == 1; in wacom_wac_pen_report()
2587 wacom_wac->hid_data.barrelswitch2 = sw_state == 2; in wacom_wac_pen_report()
2588 wacom_wac->hid_data.barrelswitch3 = sw_state == 3; in wacom_wac_pen_report()
2590 input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch); in wacom_wac_pen_report()
2591 input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2); in wacom_wac_pen_report()
2592 input_report_key(input, BTN_STYLUS3, wacom_wac->hid_data.barrelswitch3); in wacom_wac_pen_report()
2595 * Non-USI EMR tools should have their IDs mangled to in wacom_wac_pen_report()
2598 if (wacom_wac->serial[0] >> 52 == 1) in wacom_wac_pen_report()
2602 * To ensure compatibility with xf86-input-wacom, we should in wacom_wac_pen_report()
2607 wacom_wac->hid_data.tipswitch); in wacom_wac_pen_report()
2608 input_report_key(input, wacom_wac->tool[0], sense); in wacom_wac_pen_report()
2609 if (wacom_wac->serial[0]) { in wacom_wac_pen_report()
2611 * xf86-input-wacom does not accept a serial number in wacom_wac_pen_report()
2615 __u32 serial_lo = wacom_wac->serial[0] & 0xFFFFFFFFu; in wacom_wac_pen_report()
2616 __u32 serial_hi = wacom_wac->serial[0] >> 32; in wacom_wac_pen_report()
2621 wacom_wac->hid_data.tipswitch = false; in wacom_wac_pen_report()
2627 if (wacom_wac->features.quirks & WACOM_QUIRK_AESPEN) { in wacom_wac_pen_report()
2629 cancel_delayed_work(&wacom->aes_battery_work); in wacom_wac_pen_report()
2631 schedule_delayed_work(&wacom->aes_battery_work, in wacom_wac_pen_report()
2636 wacom_wac->tool[0] = 0; in wacom_wac_pen_report()
2637 wacom_wac->id[0] = 0; in wacom_wac_pen_report()
2638 wacom_wac->serial[0] = 0; in wacom_wac_pen_report()
2646 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_finger_usage_mapping()
2647 struct input_dev *input = wacom_wac->touch_input; in wacom_wac_finger_usage_mapping()
2648 unsigned touch_max = wacom_wac->features.touch_max; in wacom_wac_finger_usage_mapping()
2649 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_finger_usage_mapping()
2676 wacom_wac->hid_data.cc_report = field->report->id; in wacom_wac_finger_usage_mapping()
2677 wacom_wac->hid_data.cc_index = field->index; in wacom_wac_finger_usage_mapping()
2678 wacom_wac->hid_data.cc_value_index = usage->usage_index; in wacom_wac_finger_usage_mapping()
2681 if ((field->logical_maximum - field->logical_minimum) < touch_max) { in wacom_wac_finger_usage_mapping()
2687 field->logical_maximum = 255; in wacom_wac_finger_usage_mapping()
2699 struct hid_data *hid_data = &wacom_wac->hid_data; in wacom_wac_finger_slot()
2700 bool mt = wacom_wac->features.touch_max > 1; in wacom_wac_finger_slot()
2701 bool touch_down = hid_data->tipswitch && hid_data->confidence; in wacom_wac_finger_slot()
2705 if (!wacom_wac->shared->touch_down) in wacom_wac_finger_slot()
2710 wacom_wac->hid_data.num_received++; in wacom_wac_finger_slot()
2711 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected) in wacom_wac_finger_slot()
2717 slot = input_mt_get_slot_by_key(input, hid_data->id); in wacom_wac_finger_slot()
2721 struct input_mt_slot *ps = &input->mt->slots[slot]; in wacom_wac_finger_slot()
2725 // No data to send for this slot; short-circuit in wacom_wac_finger_slot()
2739 hid_data->x); in wacom_wac_finger_slot()
2741 hid_data->y); in wacom_wac_finger_slot()
2743 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) { in wacom_wac_finger_slot()
2744 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height)); in wacom_wac_finger_slot()
2745 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height)); in wacom_wac_finger_slot()
2746 if (hid_data->width != hid_data->height) in wacom_wac_finger_slot()
2747 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1); in wacom_wac_finger_slot()
2756 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_finger_event()
2757 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_finger_event()
2758 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_wac_finger_event()
2760 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down) in wacom_wac_finger_event()
2763 if (wacom_wac->is_invalid_bt_frame) in wacom_wac_finger_event()
2768 wacom_wac->hid_data.confidence = value; in wacom_wac_finger_event()
2771 wacom_wac->hid_data.x = value; in wacom_wac_finger_event()
2774 wacom_wac->hid_data.y = value; in wacom_wac_finger_event()
2777 wacom_wac->hid_data.width = value; in wacom_wac_finger_event()
2780 wacom_wac->hid_data.height = value; in wacom_wac_finger_event()
2783 wacom_wac->hid_data.id = value; in wacom_wac_finger_event()
2786 wacom_wac->hid_data.tipswitch = value; in wacom_wac_finger_event()
2789 wacom_wac->is_invalid_bt_frame = !value; in wacom_wac_finger_event()
2792 if (!features->touch_max) { in wacom_wac_finger_event()
2793 features->touch_max = value; in wacom_wac_finger_event()
2795 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max " in wacom_wac_finger_event()
2796 "%d -> %d\n", __func__, features->touch_max, value); in wacom_wac_finger_event()
2801 if (usage->usage_index + 1 == field->report_count) { in wacom_wac_finger_event()
2802 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) in wacom_wac_finger_event()
2803 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); in wacom_wac_finger_event()
2811 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_finger_pre_report()
2812 struct hid_data* hid_data = &wacom_wac->hid_data; in wacom_wac_finger_pre_report()
2815 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down) in wacom_wac_finger_pre_report()
2818 wacom_wac->is_invalid_bt_frame = false; in wacom_wac_finger_pre_report()
2820 hid_data->confidence = true; in wacom_wac_finger_pre_report()
2822 hid_data->cc_report = 0; in wacom_wac_finger_pre_report()
2823 hid_data->cc_index = -1; in wacom_wac_finger_pre_report()
2824 hid_data->cc_value_index = -1; in wacom_wac_finger_pre_report()
2826 for (i = 0; i < report->maxfield; i++) { in wacom_wac_finger_pre_report()
2827 struct hid_field *field = report->field[i]; in wacom_wac_finger_pre_report()
2830 for (j = 0; j < field->maxusage; j++) { in wacom_wac_finger_pre_report()
2831 struct hid_usage *usage = &field->usage[j]; in wacom_wac_finger_pre_report()
2833 wacom_equivalent_usage(usage->hid); in wacom_wac_finger_pre_report()
2844 hid_data->last_slot_field = equivalent_usage; in wacom_wac_finger_pre_report()
2847 hid_data->cc_report = report->id; in wacom_wac_finger_pre_report()
2848 hid_data->cc_index = i; in wacom_wac_finger_pre_report()
2849 hid_data->cc_value_index = j; in wacom_wac_finger_pre_report()
2855 if (hid_data->cc_report != 0 && in wacom_wac_finger_pre_report()
2856 hid_data->cc_index >= 0) { in wacom_wac_finger_pre_report()
2857 struct hid_field *field = report->field[hid_data->cc_index]; in wacom_wac_finger_pre_report()
2858 int value = field->value[hid_data->cc_value_index]; in wacom_wac_finger_pre_report()
2860 hid_data->num_expected = value; in wacom_wac_finger_pre_report()
2861 hid_data->num_received = 0; in wacom_wac_finger_pre_report()
2865 hid_data->num_expected = wacom_wac->features.touch_max; in wacom_wac_finger_pre_report()
2866 hid_data->num_received = 0; in wacom_wac_finger_pre_report()
2874 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_finger_report()
2875 struct input_dev *input = wacom_wac->touch_input; in wacom_wac_finger_report()
2876 unsigned touch_max = wacom_wac->features.touch_max; in wacom_wac_finger_report()
2879 if (wacom_wac->hid_data.num_expected == 0) in wacom_wac_finger_report()
2886 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected) in wacom_wac_finger_report()
2893 wacom_wac->hid_data.num_received = 0; in wacom_wac_finger_report()
2894 wacom_wac->hid_data.num_expected = 0; in wacom_wac_finger_report()
2897 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac); in wacom_wac_finger_report()
2904 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_usage_mapping()
2905 struct wacom_features *features = &wacom_wac->features; in wacom_wac_usage_mapping()
2908 features->device_type |= WACOM_DEVICETYPE_DIRECT; in wacom_wac_usage_mapping()
2926 if (wacom->wacom_wac.features.type != HID_GENERIC) in wacom_wac_event()
2929 if (value > field->logical_maximum || value < field->logical_minimum) in wacom_wac_event()
2937 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) in wacom_wac_event()
2939 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) in wacom_wac_event()
2949 for (r = field_index; r < report->maxfield; r++) { in wacom_report_events()
2953 field = report->field[r]; in wacom_report_events()
2954 count = field->report_count; in wacom_report_events()
2956 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in wacom_report_events()
2960 if (field->usage[n].collection_index == collection_index) in wacom_report_events()
2961 wacom_wac_event(hdev, field, &field->usage[n], in wacom_report_events()
2962 field->value[n]); in wacom_report_events()
2978 * Non-input reports may be sent prior to the device being in wacom_wac_collection()
2981 * been called to prevent potential crashes in the report- in wacom_wac_collection()
2984 if (report->type != HID_INPUT_REPORT) in wacom_wac_collection()
2985 return -1; in wacom_wac_collection()
2989 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) in wacom_wac_collection()
2991 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) in wacom_wac_collection()
3000 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_report()
3005 int prev_collection = -1; in wacom_wac_report()
3007 if (wacom_wac->features.type != HID_GENERIC) in wacom_wac_report()
3010 for (r = 0; r < report->maxfield; r++) { in wacom_wac_report()
3011 field = report->field[r]; in wacom_wac_report()
3019 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) in wacom_wac_report()
3025 if (pad_in_hid_field && wacom_wac->pad_input) in wacom_wac_report()
3027 if (pen_in_hid_field && wacom_wac->pen_input) in wacom_wac_report()
3029 if (finger_in_hid_field && wacom_wac->touch_input) in wacom_wac_report()
3032 for (r = 0; r < report->maxfield; r++) { in wacom_wac_report()
3033 field = report->field[r]; in wacom_wac_report()
3035 if (field->usage[0].collection_index != prev_collection) { in wacom_wac_report()
3037 field->usage[0].collection_index, field, r) < 0) in wacom_wac_report()
3039 prev_collection = field->usage[0].collection_index; in wacom_wac_report()
3045 if (true_pad && wacom_wac->pad_input) in wacom_wac_report()
3051 struct wacom_features *features = &wacom->features; in wacom_bpt_touch()
3052 struct input_dev *input = wacom->touch_input; in wacom_bpt_touch()
3053 struct input_dev *pad_input = wacom->pad_input; in wacom_bpt_touch()
3054 unsigned char *data = wacom->data; in wacom_bpt_touch()
3070 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) { in wacom_bpt_touch()
3085 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); in wacom_bpt_touch()
3092 struct wacom_features *features = &wacom->features; in wacom_bpt3_touch_msg()
3093 struct input_dev *input = wacom->touch_input; in wacom_bpt3_touch_msg()
3110 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) { in wacom_bpt3_touch_msg()
3115 * "a" is a scaled-down area which we assume is in wacom_bpt3_touch_msg()
3135 struct input_dev *input = wacom->pad_input; in wacom_bpt3_button_msg()
3136 struct wacom_features *features = &wacom->features; in wacom_bpt3_button_msg()
3138 if (features->type == INTUOSHT || features->type == INTUOSHT2) { in wacom_bpt3_button_msg()
3151 unsigned char *data = wacom->data; in wacom_bpt3_touch()
3158 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */ in wacom_bpt3_touch()
3172 if (wacom->touch_input && touch_changed) { in wacom_bpt3_touch()
3173 input_mt_sync_frame(wacom->touch_input); in wacom_bpt3_touch()
3174 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); in wacom_bpt3_touch()
3182 struct wacom_features *features = &wacom->features; in wacom_bpt_pen()
3183 struct input_dev *input = wacom->pen_input; in wacom_bpt_pen()
3184 unsigned char *data = wacom->data; in wacom_bpt_pen()
3196 wacom->shared->stylus_in_proximity = range; in wacom_bpt_pen()
3211 wacom->tool[0] = BTN_TOOL_RUBBER; in wacom_bpt_pen()
3212 wacom->id[0] = ERASER_DEVICE_ID; in wacom_bpt_pen()
3214 wacom->tool[0] = BTN_TOOL_PEN; in wacom_bpt_pen()
3215 wacom->id[0] = STYLUS_DEVICE_ID; in wacom_bpt_pen()
3217 wacom->reporting_data = true; in wacom_bpt_pen()
3226 if (data[8] <= features->distance_max) in wacom_bpt_pen()
3227 d = features->distance_max - data[8]; in wacom_bpt_pen()
3229 wacom->id[0] = 0; in wacom_bpt_pen()
3232 if (wacom->reporting_data) { in wacom_bpt_pen()
3244 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */ in wacom_bpt_pen()
3245 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */ in wacom_bpt_pen()
3249 wacom->reporting_data = false; in wacom_bpt_pen()
3257 struct wacom_features *features = &wacom->features; in wacom_bpt_irq()
3259 if ((features->type == INTUOSHT2) && in wacom_bpt_irq()
3260 (features->device_type & WACOM_DEVICETYPE_PEN)) in wacom_bpt_irq()
3289 * No need to check if wacom->shared->pen is valid, hid_input_report() in wacom_bamboo_pad_pen_event()
3292 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data, in wacom_bamboo_pad_pen_event()
3301 struct input_dev *input = wacom->touch_input; in wacom_bamboo_pad_touch_event()
3309 for (id = 0; id < wacom->features.touch_max; id++) { in wacom_bamboo_pad_touch_event()
3333 wacom->shared->touch_down = !!prefix && report_touch_events(wacom); in wacom_bamboo_pad_touch_event()
3340 unsigned char *data = wacom->data; in wacom_bamboo_pad_irq()
3358 unsigned char *data = wacom->data; in wacom_wireless_irq()
3368 if ((wacom->shared->type == INTUOSHT || in wacom_wireless_irq()
3369 wacom->shared->type == INTUOSHT2) && in wacom_wireless_irq()
3370 wacom->shared->touch_input && in wacom_wireless_irq()
3371 wacom->shared->touch_max) { in wacom_wireless_irq()
3372 input_report_switch(wacom->shared->touch_input, in wacom_wireless_irq()
3374 input_sync(wacom->shared->touch_input); in wacom_wireless_irq()
3380 if (wacom->pid != pid) { in wacom_wireless_irq()
3381 wacom->pid = pid; in wacom_wireless_irq()
3388 } else if (wacom->pid != 0) { in wacom_wireless_irq()
3390 wacom->pid = 0; in wacom_wireless_irq()
3401 struct wacom_features *features = &wacom_wac->features; in wacom_status_irq()
3402 unsigned char *data = wacom_wac->data; in wacom_status_irq()
3407 if ((features->type == INTUOSHT || in wacom_status_irq()
3408 features->type == INTUOSHT2) && in wacom_status_irq()
3409 wacom_wac->shared->touch_input && in wacom_status_irq()
3410 features->touch_max) { in wacom_status_irq()
3411 input_report_switch(wacom_wac->shared->touch_input, in wacom_status_irq()
3413 input_sync(wacom_wac->shared->touch_input); in wacom_status_irq()
3420 features->quirks |= WACOM_QUIRK_BATTERY; in wacom_status_irq()
3424 else if ((features->quirks & WACOM_QUIRK_BATTERY) && in wacom_status_irq()
3425 wacom->battery.battery) { in wacom_status_irq()
3426 features->quirks &= ~WACOM_QUIRK_BATTERY; in wacom_status_irq()
3436 switch (wacom_wac->features.type) { in wacom_wac_irq()
3502 else if (wacom_wac->data[0] == WACOM_REPORT_USB) in wacom_wac_irq()
3528 if (wacom_wac->data[0] == WACOM_REPORT_USB) in wacom_wac_irq()
3544 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST) in wacom_wac_irq()
3556 if (wacom_wac->pen_input) in wacom_wac_irq()
3557 input_sync(wacom_wac->pen_input); in wacom_wac_irq()
3558 if (wacom_wac->touch_input) in wacom_wac_irq()
3559 input_sync(wacom_wac->touch_input); in wacom_wac_irq()
3560 if (wacom_wac->pad_input) in wacom_wac_irq()
3561 input_sync(wacom_wac->pad_input); in wacom_wac_irq()
3567 struct input_dev *input_dev = wacom_wac->pen_input; in wacom_setup_basic_pro_pen()
3571 __set_bit(BTN_TOOL_PEN, input_dev->keybit); in wacom_setup_basic_pro_pen()
3572 __set_bit(BTN_STYLUS, input_dev->keybit); in wacom_setup_basic_pro_pen()
3573 __set_bit(BTN_STYLUS2, input_dev->keybit); in wacom_setup_basic_pro_pen()
3576 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0); in wacom_setup_basic_pro_pen()
3581 struct input_dev *input_dev = wacom_wac->pen_input; in wacom_setup_cintiq()
3582 struct wacom_features *features = &wacom_wac->features; in wacom_setup_cintiq()
3586 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); in wacom_setup_cintiq()
3587 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit); in wacom_setup_cintiq()
3588 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit); in wacom_setup_cintiq()
3589 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit); in wacom_setup_cintiq()
3592 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0); in wacom_setup_cintiq()
3594 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0); in wacom_setup_cintiq()
3600 struct input_dev *input_dev = wacom_wac->pen_input; in wacom_setup_intuos()
3606 __set_bit(BTN_LEFT, input_dev->keybit); in wacom_setup_intuos()
3607 __set_bit(BTN_RIGHT, input_dev->keybit); in wacom_setup_intuos()
3608 __set_bit(BTN_MIDDLE, input_dev->keybit); in wacom_setup_intuos()
3609 __set_bit(BTN_SIDE, input_dev->keybit); in wacom_setup_intuos()
3610 __set_bit(BTN_EXTRA, input_dev->keybit); in wacom_setup_intuos()
3611 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); in wacom_setup_intuos()
3612 __set_bit(BTN_TOOL_LENS, input_dev->keybit); in wacom_setup_intuos()
3614 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); in wacom_setup_intuos()
3616 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); in wacom_setup_intuos()
3621 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_setup_device_quirks()
3622 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_setup_device_quirks()
3625 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 || in wacom_setup_device_quirks()
3626 features->type == DTUS || in wacom_setup_device_quirks()
3627 (features->type >= INTUOS3S && features->type <= WACOM_MO)) { in wacom_setup_device_quirks()
3628 if (features->device_type & WACOM_DEVICETYPE_PEN) in wacom_setup_device_quirks()
3629 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_setup_device_quirks()
3633 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) { in wacom_setup_device_quirks()
3634 features->x_max = 1023; in wacom_setup_device_quirks()
3635 features->y_max = 1023; in wacom_setup_device_quirks()
3644 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) || in wacom_setup_device_quirks()
3645 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) { in wacom_setup_device_quirks()
3646 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { in wacom_setup_device_quirks()
3647 if (features->touch_max) in wacom_setup_device_quirks()
3648 features->device_type |= WACOM_DEVICETYPE_TOUCH; in wacom_setup_device_quirks()
3649 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT) in wacom_setup_device_quirks()
3650 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_setup_device_quirks()
3652 if (features->type == INTUOSHT2) { in wacom_setup_device_quirks()
3653 features->x_max = features->x_max / 10; in wacom_setup_device_quirks()
3654 features->y_max = features->y_max / 10; in wacom_setup_device_quirks()
3657 features->x_max = 4096; in wacom_setup_device_quirks()
3658 features->y_max = 4096; in wacom_setup_device_quirks()
3661 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) { in wacom_setup_device_quirks()
3662 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_setup_device_quirks()
3673 if (features->type == BAMBOO_PEN && in wacom_setup_device_quirks()
3674 features->pktlen == WACOM_PKGLEN_BBTOUCH3) in wacom_setup_device_quirks()
3675 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_setup_device_quirks()
3678 * Raw Wacom-mode pen and touch events both come from interface in wacom_setup_device_quirks()
3684 if (features->type == BAMBOO_PAD) in wacom_setup_device_quirks()
3685 features->device_type = WACOM_DEVICETYPE_TOUCH; in wacom_setup_device_quirks()
3687 if (features->type == REMOTE) in wacom_setup_device_quirks()
3688 features->device_type = WACOM_DEVICETYPE_PAD; in wacom_setup_device_quirks()
3690 if (features->type == INTUOSP2_BT || in wacom_setup_device_quirks()
3691 features->type == INTUOSP2S_BT) { in wacom_setup_device_quirks()
3692 features->device_type |= WACOM_DEVICETYPE_PEN | in wacom_setup_device_quirks()
3695 features->quirks |= WACOM_QUIRK_BATTERY; in wacom_setup_device_quirks()
3698 if (features->type == INTUOSHT3_BT) { in wacom_setup_device_quirks()
3699 features->device_type |= WACOM_DEVICETYPE_PEN | in wacom_setup_device_quirks()
3701 features->quirks |= WACOM_QUIRK_BATTERY; in wacom_setup_device_quirks()
3704 switch (features->type) { in wacom_setup_device_quirks()
3727 features->device_type |= WACOM_DEVICETYPE_DIRECT; in wacom_setup_device_quirks()
3731 if (wacom->hdev->bus == BUS_BLUETOOTH) in wacom_setup_device_quirks()
3732 features->quirks |= WACOM_QUIRK_BATTERY; in wacom_setup_device_quirks()
3735 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) && in wacom_setup_device_quirks()
3736 features->pktlen == WACOM_PKGLEN_BBTOUCH) { in wacom_setup_device_quirks()
3737 features->x_max <<= 5; in wacom_setup_device_quirks()
3738 features->y_max <<= 5; in wacom_setup_device_quirks()
3739 features->x_fuzz <<= 5; in wacom_setup_device_quirks()
3740 features->y_fuzz <<= 5; in wacom_setup_device_quirks()
3741 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; in wacom_setup_device_quirks()
3744 if (features->type == WIRELESS) { in wacom_setup_device_quirks()
3745 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) { in wacom_setup_device_quirks()
3746 features->quirks |= WACOM_QUIRK_BATTERY; in wacom_setup_device_quirks()
3750 if (features->type == REMOTE) in wacom_setup_device_quirks()
3751 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR; in wacom_setup_device_quirks()
3753 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots in wacom_setup_device_quirks()
3756 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) { in wacom_setup_device_quirks()
3757 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL; in wacom_setup_device_quirks()
3758 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit); in wacom_setup_device_quirks()
3759 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit); in wacom_setup_device_quirks()
3760 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit); in wacom_setup_device_quirks()
3761 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit); in wacom_setup_device_quirks()
3762 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit); in wacom_setup_device_quirks()
3763 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit); in wacom_setup_device_quirks()
3764 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit); in wacom_setup_device_quirks()
3765 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit); in wacom_setup_device_quirks()
3766 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit); in wacom_setup_device_quirks()
3767 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit); in wacom_setup_device_quirks()
3768 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit); in wacom_setup_device_quirks()
3775 struct wacom_features *features = &wacom_wac->features; in wacom_setup_pen_input_capabilities()
3777 if (!(features->device_type & WACOM_DEVICETYPE_PEN)) in wacom_setup_pen_input_capabilities()
3778 return -ENODEV; in wacom_setup_pen_input_capabilities()
3780 if (features->device_type & WACOM_DEVICETYPE_DIRECT) in wacom_setup_pen_input_capabilities()
3781 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); in wacom_setup_pen_input_capabilities()
3783 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); in wacom_setup_pen_input_capabilities()
3785 if (features->type == HID_GENERIC) in wacom_setup_pen_input_capabilities()
3789 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in wacom_setup_pen_input_capabilities()
3790 __set_bit(BTN_TOUCH, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3791 __set_bit(ABS_MISC, input_dev->absbit); in wacom_setup_pen_input_capabilities()
3793 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left, in wacom_setup_pen_input_capabilities()
3794 features->x_max - features->offset_right, in wacom_setup_pen_input_capabilities()
3795 features->x_fuzz, 0); in wacom_setup_pen_input_capabilities()
3796 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top, in wacom_setup_pen_input_capabilities()
3797 features->y_max - features->offset_bottom, in wacom_setup_pen_input_capabilities()
3798 features->y_fuzz, 0); in wacom_setup_pen_input_capabilities()
3800 features->pressure_max, features->pressure_fuzz, 0); in wacom_setup_pen_input_capabilities()
3803 input_abs_set_res(input_dev, ABS_X, features->x_resolution); in wacom_setup_pen_input_capabilities()
3804 input_abs_set_res(input_dev, ABS_Y, features->y_resolution); in wacom_setup_pen_input_capabilities()
3806 switch (features->type) { in wacom_setup_pen_input_capabilities()
3808 __clear_bit(ABS_MISC, input_dev->absbit); in wacom_setup_pen_input_capabilities()
3814 features->distance_max, in wacom_setup_pen_input_capabilities()
3815 features->distance_fuzz, 0); in wacom_setup_pen_input_capabilities()
3821 __set_bit(BTN_LEFT, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3822 __set_bit(BTN_RIGHT, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3823 __set_bit(BTN_MIDDLE, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3825 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3826 __set_bit(BTN_TOOL_PEN, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3827 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3828 __set_bit(BTN_STYLUS, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3829 __set_bit(BTN_STYLUS2, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3842 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); in wacom_setup_pen_input_capabilities()
3854 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); in wacom_setup_pen_input_capabilities()
3871 features->distance_max, in wacom_setup_pen_input_capabilities()
3872 features->distance_fuzz, 0); in wacom_setup_pen_input_capabilities()
3874 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); in wacom_setup_pen_input_capabilities()
3888 __clear_bit(ABS_MISC, input_dev->absbit); in wacom_setup_pen_input_capabilities()
3895 __set_bit(BTN_TOOL_PEN, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3896 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3897 __set_bit(BTN_STYLUS, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3898 __set_bit(BTN_STYLUS2, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3902 __set_bit(BTN_STYLUS2, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3906 __set_bit(BTN_TOOL_PEN, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3907 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3908 __set_bit(BTN_STYLUS, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3916 if (features->type == INTUOSHT2 || in wacom_setup_pen_input_capabilities()
3917 features->type == INTUOSHT3_BT) { in wacom_setup_pen_input_capabilities()
3920 __clear_bit(ABS_MISC, input_dev->absbit); in wacom_setup_pen_input_capabilities()
3921 __set_bit(BTN_TOOL_PEN, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3922 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3923 __set_bit(BTN_STYLUS, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3924 __set_bit(BTN_STYLUS2, input_dev->keybit); in wacom_setup_pen_input_capabilities()
3926 features->distance_max, in wacom_setup_pen_input_capabilities()
3927 features->distance_fuzz, 0); in wacom_setup_pen_input_capabilities()
3931 __clear_bit(ABS_MISC, input_dev->absbit); in wacom_setup_pen_input_capabilities()
3940 struct wacom_features *features = &wacom_wac->features; in wacom_setup_touch_input_capabilities()
3942 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH)) in wacom_setup_touch_input_capabilities()
3943 return -ENODEV; in wacom_setup_touch_input_capabilities()
3945 if (features->device_type & WACOM_DEVICETYPE_DIRECT) in wacom_setup_touch_input_capabilities()
3946 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); in wacom_setup_touch_input_capabilities()
3948 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); in wacom_setup_touch_input_capabilities()
3950 if (features->type == HID_GENERIC) in wacom_setup_touch_input_capabilities()
3954 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in wacom_setup_touch_input_capabilities()
3955 __set_bit(BTN_TOUCH, input_dev->keybit); in wacom_setup_touch_input_capabilities()
3957 if (features->touch_max == 1) { in wacom_setup_touch_input_capabilities()
3959 features->x_max, features->x_fuzz, 0); in wacom_setup_touch_input_capabilities()
3961 features->y_max, features->y_fuzz, 0); in wacom_setup_touch_input_capabilities()
3963 features->x_resolution); in wacom_setup_touch_input_capabilities()
3965 features->y_resolution); in wacom_setup_touch_input_capabilities()
3967 else if (features->touch_max > 1) { in wacom_setup_touch_input_capabilities()
3969 features->x_max, features->x_fuzz, 0); in wacom_setup_touch_input_capabilities()
3971 features->y_max, features->y_fuzz, 0); in wacom_setup_touch_input_capabilities()
3973 features->x_resolution); in wacom_setup_touch_input_capabilities()
3975 features->y_resolution); in wacom_setup_touch_input_capabilities()
3978 switch (features->type) { in wacom_setup_touch_input_capabilities()
3981 input_dev->evbit[0] |= BIT_MASK(EV_SW); in wacom_setup_touch_input_capabilities()
3982 __set_bit(SW_MUTE_DEVICE, input_dev->swbit); in wacom_setup_touch_input_capabilities()
3984 if (wacom_wac->shared->touch->product == 0x361) { in wacom_setup_touch_input_capabilities()
3990 else if (wacom_wac->shared->touch->product == 0x360) { in wacom_setup_touch_input_capabilities()
3996 else if (wacom_wac->shared->touch->product == 0x393) { in wacom_setup_touch_input_capabilities()
4013 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); in wacom_setup_touch_input_capabilities()
4014 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0); in wacom_setup_touch_input_capabilities()
4015 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); in wacom_setup_touch_input_capabilities()
4019 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); in wacom_setup_touch_input_capabilities()
4020 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); in wacom_setup_touch_input_capabilities()
4021 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); in wacom_setup_touch_input_capabilities()
4026 if (wacom_wac->shared->touch->product == 0x32C || in wacom_setup_touch_input_capabilities()
4027 wacom_wac->shared->touch->product == 0xF6) { in wacom_setup_touch_input_capabilities()
4028 input_dev->evbit[0] |= BIT_MASK(EV_SW); in wacom_setup_touch_input_capabilities()
4029 __set_bit(SW_MUTE_DEVICE, input_dev->swbit); in wacom_setup_touch_input_capabilities()
4030 wacom_wac->has_mute_touch_switch = true; in wacom_setup_touch_input_capabilities()
4031 wacom_wac->is_soft_touch_switch = true; in wacom_setup_touch_input_capabilities()
4039 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); in wacom_setup_touch_input_capabilities()
4048 input_dev->evbit[0] |= BIT_MASK(EV_SW); in wacom_setup_touch_input_capabilities()
4049 __set_bit(SW_MUTE_DEVICE, input_dev->swbit); in wacom_setup_touch_input_capabilities()
4054 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { in wacom_setup_touch_input_capabilities()
4057 0, features->x_max, 0, 0); in wacom_setup_touch_input_capabilities()
4060 0, features->y_max, 0, 0); in wacom_setup_touch_input_capabilities()
4062 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); in wacom_setup_touch_input_capabilities()
4066 input_mt_init_slots(input_dev, features->touch_max, in wacom_setup_touch_input_capabilities()
4068 __set_bit(BTN_LEFT, input_dev->keybit); in wacom_setup_touch_input_capabilities()
4069 __set_bit(BTN_RIGHT, input_dev->keybit); in wacom_setup_touch_input_capabilities()
4080 return BTN_A + (n-10); in wacom_numbered_button_to_key()
4082 return BTN_BASE + (n-16); in wacom_numbered_button_to_key()
4096 __set_bit(key, input_dev->keybit); in wacom_setup_numbered_buttons()
4117 hid_err(wacom->hdev, "can't find LED %d in group %d\n", in wacom_24hd_update_leds()
4122 led->held = true; in wacom_24hd_update_leds()
4123 led_trigger_event(&led->trigger, LED_FULL); in wacom_24hd_update_leds()
4125 led->held = false; in wacom_24hd_update_leds()
4140 if (wacom->wacom_wac.features.type == WACOM_21UX2) in wacom_is_led_toggled()
4141 group = 1 - group; in wacom_is_led_toggled()
4143 group_button = group * (button_count/wacom->led.count); in wacom_is_led_toggled()
4145 if (wacom->wacom_wac.features.type == INTUOSP2_BT) in wacom_is_led_toggled()
4158 if (wacom->wacom_wac.features.type == WACOM_24HD) in wacom_update_led()
4162 cur = wacom->led.groups[group].select; in wacom_update_led()
4166 hid_err(wacom->hdev, "can't find current LED %d in group %d\n", in wacom_update_led()
4172 led->held = false; in wacom_update_led()
4176 if (led->held && pressed) in wacom_update_led()
4181 hid_err(wacom->hdev, "can't find next LED in group %d\n", in wacom_update_led()
4188 next_led->held = true; in wacom_update_led()
4189 led_trigger_event(&next_led->trigger, in wacom_update_led()
4199 for (i = 0; i < wacom->led.count; i++) in wacom_report_numbered_buttons()
4213 struct wacom_features *features = &wacom_wac->features; in wacom_setup_pad_input_capabilities()
4215 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0) in wacom_setup_pad_input_capabilities()
4216 features->device_type |= WACOM_DEVICETYPE_PAD; in wacom_setup_pad_input_capabilities()
4218 if (!(features->device_type & WACOM_DEVICETYPE_PAD)) in wacom_setup_pad_input_capabilities()
4219 return -ENODEV; in wacom_setup_pad_input_capabilities()
4221 if (features->type == REMOTE && input_dev == wacom_wac->pad_input) in wacom_setup_pad_input_capabilities()
4222 return -ENODEV; in wacom_setup_pad_input_capabilities()
4224 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in wacom_setup_pad_input_capabilities()
4226 /* kept for making legacy xf86-input-wacom working with the wheels */ in wacom_setup_pad_input_capabilities()
4227 __set_bit(ABS_MISC, input_dev->absbit); in wacom_setup_pad_input_capabilities()
4229 /* kept for making legacy xf86-input-wacom accepting the pad */ in wacom_setup_pad_input_capabilities()
4230 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum || in wacom_setup_pad_input_capabilities()
4231 input_dev->absinfo[ABS_X].maximum))) in wacom_setup_pad_input_capabilities()
4233 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum || in wacom_setup_pad_input_capabilities()
4234 input_dev->absinfo[ABS_Y].maximum))) in wacom_setup_pad_input_capabilities()
4238 __set_bit(BTN_STYLUS, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4240 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons); in wacom_setup_pad_input_capabilities()
4242 switch (features->type) { in wacom_setup_pad_input_capabilities()
4252 __set_bit(BTN_BACK, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4253 __set_bit(BTN_LEFT, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4254 __set_bit(BTN_FORWARD, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4255 __set_bit(BTN_RIGHT, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4260 __set_bit(BTN_BACK, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4261 __set_bit(BTN_FORWARD, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4266 __set_bit(KEY_PROG1, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4267 __set_bit(KEY_PROG2, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4268 __set_bit(KEY_PROG3, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4270 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4271 __set_bit(KEY_INFO, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4273 if (!features->oPid) in wacom_setup_pad_input_capabilities()
4274 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4281 __set_bit(KEY_PROG1, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4282 __set_bit(KEY_PROG2, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4283 __set_bit(KEY_PROG3, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4285 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4286 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4288 if (!features->oPid) in wacom_setup_pad_input_capabilities()
4289 __set_bit(KEY_CONTROLPANEL, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4290 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0); in wacom_setup_pad_input_capabilities()
4292 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0); in wacom_setup_pad_input_capabilities()
4294 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0); in wacom_setup_pad_input_capabilities()
4296 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit); in wacom_setup_pad_input_capabilities()
4300 __set_bit(KEY_PROG1, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4301 __set_bit(KEY_PROG2, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4302 __set_bit(KEY_PROG3, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4304 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4305 __set_bit(KEY_INFO, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4345 __set_bit(BTN_STYLUS, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4358 __clear_bit(ABS_MISC, input_dev->absbit); in wacom_setup_pad_input_capabilities()
4360 __set_bit(BTN_LEFT, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4361 __set_bit(BTN_FORWARD, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4362 __set_bit(BTN_BACK, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4363 __set_bit(BTN_RIGHT, input_dev->keybit); in wacom_setup_pad_input_capabilities()
4378 return -ENODEV; in wacom_setup_pad_input_capabilities()
4696 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4702 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4723 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4729 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4750 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4829 { "ISD-V4", 12800, 8000, 255, 0,