aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-waltop.c
diff options
context:
space:
mode:
authorNikolai Kondrashov <spbnick@gmail.com>2012-03-20 10:01:33 -0400
committerJiri Kosina <jkosina@suse.cz>2012-03-28 04:40:22 -0400
commitd2ee4dd9a4d68543bddddb69d38cba51b4373e6b (patch)
tree05e0008abd923581e3e8491e4556208d93dad7be /drivers/hid/hid-waltop.c
parentb73b2da0353d15b712b27b1aed3c50856bdfc341 (diff)
HID: waltop: Add support for Sirius tablet
Add support for Waltop Sirius Battery Free Tablet. VisTablet Muse and Princeton PTB-S1BK are other possible names of this tablet. Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-waltop.c')
-rw-r--r--drivers/hid/hid-waltop.c189
1 files changed, 189 insertions, 0 deletions
diff --git a/drivers/hid/hid-waltop.c b/drivers/hid/hid-waltop.c
index 2cfd95c4467b..9a48438090a9 100644
--- a/drivers/hid/hid-waltop.c
+++ b/drivers/hid/hid-waltop.c
@@ -502,6 +502,142 @@ static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
502 0xC0 /* End Collection */ 502 0xC0 /* End Collection */
503}; 503};
504 504
505/*
506 * See Sirius Battery Free Tablet description, device and HID report descriptors
507 * at
508 * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Sirius_Battery_Free_Tablet
509 */
510
511/* Size of the original report descriptor of Sirius Battery Free Tablet */
512#define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE 335
513
514/* Fixed Sirius Battery Free Tablet descriptor */
515static __u8 sirius_battery_free_tablet_rdesc_fixed[] = {
516 0x05, 0x0D, /* Usage Page (Digitizer), */
517 0x09, 0x02, /* Usage (Pen), */
518 0xA1, 0x01, /* Collection (Application), */
519 0x85, 0x10, /* Report ID (16), */
520 0x09, 0x20, /* Usage (Stylus), */
521 0xA0, /* Collection (Physical), */
522 0x95, 0x01, /* Report Count (1), */
523 0x15, 0x01, /* Logical Minimum (1), */
524 0x25, 0x03, /* Logical Maximum (3), */
525 0x75, 0x02, /* Report Size (2), */
526 0x09, 0x42, /* Usage (Tip Switch), */
527 0x09, 0x44, /* Usage (Barrel Switch), */
528 0x09, 0x46, /* Usage (Tablet Pick), */
529 0x80, /* Input, */
530 0x14, /* Logical Minimum (0), */
531 0x25, 0x01, /* Logical Maximum (1), */
532 0x75, 0x01, /* Report Size (1), */
533 0x09, 0x3C, /* Usage (Invert), */
534 0x81, 0x02, /* Input (Variable), */
535 0x81, 0x03, /* Input (Constant, Variable), */
536 0x09, 0x32, /* Usage (In Range), */
537 0x81, 0x02, /* Input (Variable), */
538 0x95, 0x03, /* Report Count (3), */
539 0x81, 0x03, /* Input (Constant, Variable), */
540 0xA4, /* Push, */
541 0x05, 0x01, /* Usage Page (Desktop), */
542 0x55, 0xFD, /* Unit Exponent (-3), */
543 0x65, 0x13, /* Unit (Inch), */
544 0x34, /* Physical Minimum (0), */
545 0x14, /* Logical Minimum (0), */
546 0x75, 0x10, /* Report Size (16), */
547 0x95, 0x01, /* Report Count (1), */
548 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
549 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
550 0x09, 0x30, /* Usage (X), */
551 0x81, 0x02, /* Input (Variable), */
552 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
553 0x26, 0xE0, 0x2E, /* Logical Maximum (12000), */
554 0x09, 0x31, /* Usage (Y), */
555 0x81, 0x02, /* Input (Variable), */
556 0xB4, /* Pop, */
557 0x75, 0x10, /* Report Size (16), */
558 0x95, 0x01, /* Report Count (1), */
559 0x14, /* Logical Minimum (0), */
560 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
561 0x09, 0x30, /* Usage (Tip Pressure), */
562 0x81, 0x02, /* Input (Variable), */
563 0xA4, /* Push, */
564 0x55, 0xFE, /* Unit Exponent (-2), */
565 0x65, 0x12, /* Unit (Radians), */
566 0x35, 0x97, /* Physical Minimum (-105), */
567 0x45, 0x69, /* Physical Maximum (105), */
568 0x15, 0x97, /* Logical Minimum (-105), */
569 0x25, 0x69, /* Logical Maximum (105), */
570 0x75, 0x08, /* Report Size (8), */
571 0x95, 0x02, /* Report Count (2), */
572 0x09, 0x3D, /* Usage (X Tilt), */
573 0x09, 0x3E, /* Usage (Y Tilt), */
574 0x81, 0x02, /* Input (Variable), */
575 0xB4, /* Pop, */
576 0xC0, /* End Collection, */
577 0xC0, /* End Collection, */
578 0x05, 0x01, /* Usage Page (Desktop), */
579 0x09, 0x02, /* Usage (Mouse), */
580 0xA1, 0x01, /* Collection (Application), */
581 0x85, 0x01, /* Report ID (1), */
582 0x09, 0x01, /* Usage (Pointer), */
583 0xA0, /* Collection (Physical), */
584 0x75, 0x08, /* Report Size (8), */
585 0x95, 0x03, /* Report Count (3), */
586 0x81, 0x03, /* Input (Constant, Variable), */
587 0x09, 0x38, /* Usage (Wheel), */
588 0x15, 0xFF, /* Logical Minimum (-1), */
589 0x25, 0x01, /* Logical Maximum (1), */
590 0x75, 0x08, /* Report Size (8), */
591 0x95, 0x01, /* Report Count (1), */
592 0x81, 0x06, /* Input (Variable, Relative), */
593 0x75, 0x08, /* Report Size (8), */
594 0x95, 0x03, /* Report Count (3), */
595 0x81, 0x03, /* Input (Constant, Variable), */
596 0xC0, /* End Collection, */
597 0xC0, /* End Collection, */
598 0x05, 0x01, /* Usage Page (Desktop), */
599 0x09, 0x06, /* Usage (Keyboard), */
600 0xA1, 0x01, /* Collection (Application), */
601 0x85, 0x0D, /* Report ID (13), */
602 0x05, 0x07, /* Usage Page (Keyboard), */
603 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */
604 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */
605 0x14, /* Logical Minimum (0), */
606 0x25, 0x01, /* Logical Maximum (1), */
607 0x75, 0x01, /* Report Size (1), */
608 0x95, 0x08, /* Report Count (8), */
609 0x81, 0x02, /* Input (Variable), */
610 0x75, 0x08, /* Report Size (8), */
611 0x95, 0x01, /* Report Count (1), */
612 0x81, 0x01, /* Input (Constant), */
613 0x18, /* Usage Minimum (None), */
614 0x29, 0x65, /* Usage Maximum (KB Application), */
615 0x14, /* Logical Minimum (0), */
616 0x25, 0x65, /* Logical Maximum (101), */
617 0x75, 0x08, /* Report Size (8), */
618 0x95, 0x05, /* Report Count (5), */
619 0x80, /* Input, */
620 0xC0, /* End Collection, */
621 0x05, 0x0C, /* Usage Page (Consumer), */
622 0x09, 0x01, /* Usage (Consumer Control), */
623 0xA1, 0x01, /* Collection (Application), */
624 0x85, 0x0C, /* Report ID (12), */
625 0x09, 0xE9, /* Usage (Volume Inc), */
626 0x09, 0xEA, /* Usage (Volume Dec), */
627 0x14, /* Logical Minimum (0), */
628 0x25, 0x01, /* Logical Maximum (1), */
629 0x75, 0x01, /* Report Size (1), */
630 0x95, 0x02, /* Report Count (2), */
631 0x81, 0x02, /* Input (Variable), */
632 0x75, 0x06, /* Report Size (6), */
633 0x95, 0x01, /* Report Count (1), */
634 0x81, 0x03, /* Input (Constant, Variable), */
635 0x75, 0x10, /* Report Size (16), */
636 0x95, 0x03, /* Report Count (3), */
637 0x81, 0x03, /* Input (Constant, Variable), */
638 0xC0 /* End Collection */
639};
640
505struct waltop_state { 641struct waltop_state {
506 u8 pressure0; 642 u8 pressure0;
507 u8 pressure1; 643 u8 pressure1;
@@ -583,6 +719,12 @@ static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
583 *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed); 719 *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
584 } 720 }
585 break; 721 break;
722 case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET:
723 if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) {
724 rdesc = sirius_battery_free_tablet_rdesc_fixed;
725 *rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed);
726 }
727 break;
586 } 728 }
587 return rdesc; 729 return rdesc;
588} 730}
@@ -614,6 +756,51 @@ static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
614 } 756 }
615 } 757 }
616 758
759 /* If this is a pen input report of Sirius Battery Free Tablet */
760 if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET &&
761 report->type == HID_INPUT_REPORT &&
762 report->id == 16 &&
763 size == 10) {
764 /*
765 * The tablet reports tilt as roughly sin(a)*21 (18 means 60
766 * degrees).
767 *
768 * This array stores angles as radians * 100, corresponding to
769 * reported values up to 60 degrees, as expected by userspace.
770 */
771 static const s8 tilt_to_radians[] = {
772 0, 5, 10, 14, 19, 24, 29, 34, 40, 45,
773 50, 56, 62, 68, 74, 81, 88, 96, 105
774 };
775
776 s8 tilt_x = (s8)data[8];
777 s8 tilt_y = (s8)data[9];
778 s8 sign_x = tilt_x >= 0 ? 1 : -1;
779 s8 sign_y = tilt_y >= 0 ? 1 : -1;
780
781 tilt_x *= sign_x;
782 tilt_y *= sign_y;
783
784 /*
785 * Reverse the Y Tilt direction to match the HID standard and
786 * userspace expectations. See HID Usage Tables v1.12 16.3.2
787 * Tilt Orientation.
788 */
789 sign_y *= -1;
790
791 /*
792 * This effectively clamps reported tilt to 60 degrees - the
793 * range expected by userspace
794 */
795 if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1)
796 tilt_x = ARRAY_SIZE(tilt_to_radians) - 1;
797 if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1)
798 tilt_y = ARRAY_SIZE(tilt_to_radians) - 1;
799
800 data[8] = tilt_to_radians[tilt_x] * sign_x;
801 data[9] = tilt_to_radians[tilt_y] * sign_y;
802 }
803
617 return 0; 804 return 0;
618} 805}
619 806
@@ -638,6 +825,8 @@ static const struct hid_device_id waltop_devices[] = {
638 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 825 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
639 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, 826 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
640 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 827 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
828 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
829 USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
641 { } 830 { }
642}; 831};
643MODULE_DEVICE_TABLE(hid, waltop_devices); 832MODULE_DEVICE_TABLE(hid, waltop_devices);