wacom_wac.c (70ee06c5f447b9d50747b29d3e8d48ae7ef1cabe) wacom_wac.c (72b236d60218fe211a8e1210be31c31e81684b86)
1/*
2 * drivers/input/tablet/wacom_wac.c
3 *
4 * USB Wacom tablet support - Wacom specific code
5 *
6 */
7
8/*

--- 617 unchanged lines hidden (view full) ---

626 /* but reschedule a read of the current tool */
627 wacom_intuos_schedule_prox_event(wacom);
628 return 1;
629 }
630
631 return 0;
632}
633
1/*
2 * drivers/input/tablet/wacom_wac.c
3 *
4 * USB Wacom tablet support - Wacom specific code
5 *
6 */
7
8/*

--- 617 unchanged lines hidden (view full) ---

626 /* but reschedule a read of the current tool */
627 wacom_intuos_schedule_prox_event(wacom);
628 return 1;
629 }
630
631 return 0;
632}
633
634static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
635{
636 unsigned char *data = wacom_wac->data;
637 struct input_dev *input = wacom_wac->pad_input;
638 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
639 struct wacom_features *features = &wacom_wac->features;
640 int bat_charging, bat_percent, touch_ring_mode;
641 __u32 serial;
642 int i;
643
644 if (data[0] != WACOM_REPORT_REMOTE) {
645 dev_dbg(input->dev.parent,
646 "%s: received unknown report #%d", __func__, data[0]);
647 return 0;
648 }
649
650 serial = data[3] + (data[4] << 8) + (data[5] << 16);
651 wacom_wac->id[0] = PAD_DEVICE_ID;
652
653 input_report_key(input, BTN_0, (data[9] & 0x01));
654 input_report_key(input, BTN_1, (data[9] & 0x02));
655 input_report_key(input, BTN_2, (data[9] & 0x04));
656 input_report_key(input, BTN_3, (data[9] & 0x08));
657 input_report_key(input, BTN_4, (data[9] & 0x10));
658 input_report_key(input, BTN_5, (data[9] & 0x20));
659 input_report_key(input, BTN_6, (data[9] & 0x40));
660 input_report_key(input, BTN_7, (data[9] & 0x80));
661
662 input_report_key(input, BTN_8, (data[10] & 0x01));
663 input_report_key(input, BTN_9, (data[10] & 0x02));
664 input_report_key(input, BTN_A, (data[10] & 0x04));
665 input_report_key(input, BTN_B, (data[10] & 0x08));
666 input_report_key(input, BTN_C, (data[10] & 0x10));
667 input_report_key(input, BTN_X, (data[10] & 0x20));
668 input_report_key(input, BTN_Y, (data[10] & 0x40));
669 input_report_key(input, BTN_Z, (data[10] & 0x80));
670
671 input_report_key(input, BTN_BASE, (data[11] & 0x01));
672 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
673
674 if (data[12] & 0x80)
675 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
676 else
677 input_report_abs(input, ABS_WHEEL, 0);
678
679 bat_percent = data[7] & 0x7f;
680 bat_charging = !!(data[7] & 0x80);
681
682 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
683 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
684 else
685 input_report_abs(input, ABS_MISC, 0);
686
687 input_event(input, EV_MSC, MSC_SERIAL, serial);
688
689 /*Which mode select (LED light) is currently on?*/
690 touch_ring_mode = (data[11] & 0xC0) >> 6;
691
692 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
693 if (wacom_wac->serial[i] == serial)
694 wacom->led.select[i] = touch_ring_mode;
695 }
696
697 if (!wacom->battery &&
698 !(features->quirks & WACOM_QUIRK_BATTERY)) {
699 features->quirks |= WACOM_QUIRK_BATTERY;
700 INIT_WORK(&wacom->work, wacom_battery_work);
701 wacom_schedule_work(wacom_wac);
702 }
703
704 wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
705 bat_charging);
706
707 return 1;
708}
709
710static int wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
711{
712 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
713 unsigned char *data = wacom_wac->data;
714 int i;
715
716 if (data[0] != WACOM_REPORT_DEVICE_LIST)
717 return 0;
718
719 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
720 int j = i * 6;
721 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
722 bool connected = data[j+2];
723
724 if (connected) {
725 int k;
726
727 if (wacom_wac->serial[i] == serial)
728 continue;
729
730 if (wacom_wac->serial[i]) {
731 wacom_remote_destroy_attr_group(wacom,
732 wacom_wac->serial[i]);
733 }
734
735 /* A remote can pair more than once with an EKR,
736 * check to make sure this serial isn't already paired.
737 */
738 for (k = 0; k < WACOM_MAX_REMOTES; k++) {
739 if (wacom_wac->serial[k] == serial)
740 break;
741 }
742
743 if (k < WACOM_MAX_REMOTES) {
744 wacom_wac->serial[i] = serial;
745 continue;
746 }
747 wacom_remote_create_attr_group(wacom, serial, i);
748
749 } else if (wacom_wac->serial[i]) {
750 wacom_remote_destroy_attr_group(wacom,
751 wacom_wac->serial[i]);
752 }
753 }
754
755 return 0;
756}
757
634static void wacom_intuos_general(struct wacom_wac *wacom)
635{
636 struct wacom_features *features = &wacom->features;
637 unsigned char *data = wacom->data;
638 struct input_dev *input = wacom->pen_input;
639 unsigned int t;
640
641 /* general pen packet */

--- 1544 unchanged lines hidden (view full) ---

2186 case BAMBOO_PAD:
2187 sync = wacom_bamboo_pad_irq(wacom_wac, len);
2188 break;
2189
2190 case WIRELESS:
2191 sync = wacom_wireless_irq(wacom_wac, len);
2192 break;
2193
758static void wacom_intuos_general(struct wacom_wac *wacom)
759{
760 struct wacom_features *features = &wacom->features;
761 unsigned char *data = wacom->data;
762 struct input_dev *input = wacom->pen_input;
763 unsigned int t;
764
765 /* general pen packet */

--- 1544 unchanged lines hidden (view full) ---

2310 case BAMBOO_PAD:
2311 sync = wacom_bamboo_pad_irq(wacom_wac, len);
2312 break;
2313
2314 case WIRELESS:
2315 sync = wacom_wireless_irq(wacom_wac, len);
2316 break;
2317
2318 case REMOTE:
2319 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
2320 sync = wacom_remote_status_irq(wacom_wac, len);
2321 else
2322 sync = wacom_remote_irq(wacom_wac, len);
2323 break;
2324
2194 default:
2195 sync = false;
2196 break;
2197 }
2198
2199 if (sync) {
2200 if (wacom_wac->pen_input)
2201 input_sync(wacom_wac->pen_input);

--- 91 unchanged lines hidden (view full) ---

2293 * 0, whose HID descriptor has an application usage of 0xFF0D
2294 * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
2295 * out through the HID_GENERIC device created for interface 1,
2296 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
2297 */
2298 if (features->type == BAMBOO_PAD)
2299 features->device_type = WACOM_DEVICETYPE_TOUCH;
2300
2325 default:
2326 sync = false;
2327 break;
2328 }
2329
2330 if (sync) {
2331 if (wacom_wac->pen_input)
2332 input_sync(wacom_wac->pen_input);

--- 91 unchanged lines hidden (view full) ---

2424 * 0, whose HID descriptor has an application usage of 0xFF0D
2425 * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
2426 * out through the HID_GENERIC device created for interface 1,
2427 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
2428 */
2429 if (features->type == BAMBOO_PAD)
2430 features->device_type = WACOM_DEVICETYPE_TOUCH;
2431
2432 if (features->type == REMOTE)
2433 features->device_type = WACOM_DEVICETYPE_PAD;
2434
2301 if (wacom->hdev->bus == BUS_BLUETOOTH)
2302 features->quirks |= WACOM_QUIRK_BATTERY;
2303
2304 /* quirk for bamboo touch with 2 low res touches */
2305 if (features->type == BAMBOO_PT &&
2306 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
2307 features->x_max <<= 5;
2308 features->y_max <<= 5;

--- 403 unchanged lines hidden (view full) ---

2712
2713 __set_bit(BTN_LEFT, input_dev->keybit);
2714 __set_bit(BTN_FORWARD, input_dev->keybit);
2715 __set_bit(BTN_BACK, input_dev->keybit);
2716 __set_bit(BTN_RIGHT, input_dev->keybit);
2717
2718 break;
2719
2435 if (wacom->hdev->bus == BUS_BLUETOOTH)
2436 features->quirks |= WACOM_QUIRK_BATTERY;
2437
2438 /* quirk for bamboo touch with 2 low res touches */
2439 if (features->type == BAMBOO_PT &&
2440 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
2441 features->x_max <<= 5;
2442 features->y_max <<= 5;

--- 403 unchanged lines hidden (view full) ---

2846
2847 __set_bit(BTN_LEFT, input_dev->keybit);
2848 __set_bit(BTN_FORWARD, input_dev->keybit);
2849 __set_bit(BTN_BACK, input_dev->keybit);
2850 __set_bit(BTN_RIGHT, input_dev->keybit);
2851
2852 break;
2853
2854 case REMOTE:
2855 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
2856 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2857 break;
2858
2720 default:
2721 /* no pad supported */
2722 return -ENODEV;
2723 }
2724 return 0;
2725}
2726
2727static const struct wacom_features wacom_features_0x00 =

--- 453 unchanged lines hidden (view full) ---

3181 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
3182static const struct wacom_features wacom_features_0x319 =
3183 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
3184 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
3185static const struct wacom_features wacom_features_0x323 =
3186 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
3187 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3188 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2859 default:
2860 /* no pad supported */
2861 return -ENODEV;
2862 }
2863 return 0;
2864}
2865
2866static const struct wacom_features wacom_features_0x00 =

--- 453 unchanged lines hidden (view full) ---

3320 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
3321static const struct wacom_features wacom_features_0x319 =
3322 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
3323 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
3324static const struct wacom_features wacom_features_0x323 =
3325 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
3326 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3327 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3328static const struct wacom_features wacom_features_0x331 =
3329 { "Wacom Express Key Remote", 0, 0, 0, 0,
3330 REMOTE, 0, 0, 18, .check_for_hid_type = true,
3331 .hid_type = HID_TYPE_USBNONE };
3189
3190static const struct wacom_features wacom_features_HID_ANY_ID =
3191 { "Wacom HID", .type = HID_GENERIC };
3192
3193#define USB_DEVICE_WACOM(prod) \
3194 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3195 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3196

--- 139 unchanged lines hidden (view full) ---

3336 { USB_DEVICE_WACOM(0x317) },
3337 { USB_DEVICE_WACOM(0x318) },
3338 { USB_DEVICE_WACOM(0x319) },
3339 { USB_DEVICE_WACOM(0x323) },
3340 { USB_DEVICE_WACOM(0x32A) },
3341 { USB_DEVICE_WACOM(0x32B) },
3342 { USB_DEVICE_WACOM(0x32C) },
3343 { USB_DEVICE_WACOM(0x32F) },
3332
3333static const struct wacom_features wacom_features_HID_ANY_ID =
3334 { "Wacom HID", .type = HID_GENERIC };
3335
3336#define USB_DEVICE_WACOM(prod) \
3337 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3338 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3339

--- 139 unchanged lines hidden (view full) ---

3479 { USB_DEVICE_WACOM(0x317) },
3480 { USB_DEVICE_WACOM(0x318) },
3481 { USB_DEVICE_WACOM(0x319) },
3482 { USB_DEVICE_WACOM(0x323) },
3483 { USB_DEVICE_WACOM(0x32A) },
3484 { USB_DEVICE_WACOM(0x32B) },
3485 { USB_DEVICE_WACOM(0x32C) },
3486 { USB_DEVICE_WACOM(0x32F) },
3487 { USB_DEVICE_WACOM(0x331) },
3344 { USB_DEVICE_WACOM(0x333) },
3345 { USB_DEVICE_WACOM(0x335) },
3346 { USB_DEVICE_WACOM(0x336) },
3347 { USB_DEVICE_WACOM(0x4001) },
3348 { USB_DEVICE_WACOM(0x4004) },
3349 { USB_DEVICE_WACOM(0x5000) },
3350 { USB_DEVICE_WACOM(0x5002) },
3351 { USB_DEVICE_LENOVO(0x6004) },
3352
3353 { USB_DEVICE_WACOM(HID_ANY_ID) },
3354 { I2C_DEVICE_WACOM(HID_ANY_ID) },
3355 { }
3356};
3357MODULE_DEVICE_TABLE(hid, wacom_ids);
3488 { USB_DEVICE_WACOM(0x333) },
3489 { USB_DEVICE_WACOM(0x335) },
3490 { USB_DEVICE_WACOM(0x336) },
3491 { USB_DEVICE_WACOM(0x4001) },
3492 { USB_DEVICE_WACOM(0x4004) },
3493 { USB_DEVICE_WACOM(0x5000) },
3494 { USB_DEVICE_WACOM(0x5002) },
3495 { USB_DEVICE_LENOVO(0x6004) },
3496
3497 { USB_DEVICE_WACOM(HID_ANY_ID) },
3498 { I2C_DEVICE_WACOM(HID_ANY_ID) },
3499 { }
3500};
3501MODULE_DEVICE_TABLE(hid, wacom_ids);