aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2016-07-13 12:06:07 -0400
committerJiri Kosina <jkosina@suse.cz>2016-08-05 07:39:18 -0400
commit7c35dc3cd4d114019ed4b26cab313e253396d7c9 (patch)
tree17d24cce6ecbdc28d39510b5643a565875ec6846
parente7749f6e5f9d33da189f7bc7d757349ad4716f00 (diff)
HID: wacom: EKR: allocate one input node per remote
Thanks to devres, we can now afford to create more than one input node without having to overload the remove/failure paths. Having one input node per remote is something which should have been implemented from start but the probability of having users with several remotes is quite low. Anyway, still, better looking at the future and implement things properly. Remote input nodes will be freed/unregistered magically as they are created in the devres group &remote->remotes[index]. We need to open the hid node now that the remotes are dynamically allocated. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/wacom.h2
-rw-r--r--drivers/hid/wacom_sys.c30
-rw-r--r--drivers/hid/wacom_wac.c35
3 files changed, 62 insertions, 5 deletions
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index 6b8df67b3653..393b5af871d9 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -123,6 +123,8 @@ struct wacom_remote {
123 struct { 123 struct {
124 struct attribute_group group; 124 struct attribute_group group;
125 u32 serial; 125 u32 serial;
126 struct input_dev *input;
127 bool registered;
126 } remotes[WACOM_MAX_REMOTES]; 128 } remotes[WACOM_MAX_REMOTES];
127}; 129};
128 130
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index c3b269237af5..f2f5b4b248cb 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1905,6 +1905,11 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
1905 struct wacom_remote *remote = wacom->remote; 1905 struct wacom_remote *remote = wacom->remote;
1906 u32 serial = remote->remotes[index].serial; 1906 u32 serial = remote->remotes[index].serial;
1907 int i; 1907 int i;
1908 unsigned long flags;
1909
1910 spin_lock_irqsave(&remote->remote_lock, flags);
1911 remote->remotes[index].registered = false;
1912 spin_unlock_irqrestore(&remote->remote_lock, flags);
1908 1913
1909 if (remote->remotes[index].group.name) 1914 if (remote->remotes[index].group.name)
1910 devres_release_group(&wacom->hdev->dev, 1915 devres_release_group(&wacom->hdev->dev,
@@ -1914,6 +1919,7 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
1914 if (remote->remotes[i].serial == serial) { 1919 if (remote->remotes[i].serial == serial) {
1915 remote->remotes[i].serial = 0; 1920 remote->remotes[i].serial = 0;
1916 remote->remotes[i].group.name = NULL; 1921 remote->remotes[i].group.name = NULL;
1922 remote->remotes[i].registered = false;
1917 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; 1923 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
1918 } 1924 }
1919 } 1925 }
@@ -1946,8 +1952,32 @@ static int wacom_remote_create_one(struct wacom *wacom, u32 serial,
1946 if (error) 1952 if (error)
1947 goto fail; 1953 goto fail;
1948 1954
1955 remote->remotes[index].input = wacom_allocate_input(wacom);
1956 if (!remote->remotes[index].input) {
1957 error = -ENOMEM;
1958 goto fail;
1959 }
1960 remote->remotes[index].input->uniq = remote->remotes[index].group.name;
1961 remote->remotes[index].input->name = wacom->wacom_wac.pad_name;
1962
1963 if (!remote->remotes[index].input->name) {
1964 error = -EINVAL;
1965 goto fail;
1966 }
1967
1968 error = wacom_setup_pad_input_capabilities(remote->remotes[index].input,
1969 &wacom->wacom_wac);
1970 if (error)
1971 goto fail;
1972
1949 remote->remotes[index].serial = serial; 1973 remote->remotes[index].serial = serial;
1950 1974
1975 error = input_register_device(remote->remotes[index].input);
1976 if (error)
1977 goto fail;
1978
1979 remote->remotes[index].registered = true;
1980
1951 devres_close_group(dev, &remote->remotes[index]); 1981 devres_close_group(dev, &remote->remotes[index]);
1952 return 0; 1982 return 0;
1953 1983
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index aee07613040d..99d688a3ee71 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -751,23 +751,38 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
751static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len) 751static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
752{ 752{
753 unsigned char *data = wacom_wac->data; 753 unsigned char *data = wacom_wac->data;
754 struct input_dev *input = wacom_wac->pad_input; 754 struct input_dev *input;
755 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); 755 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
756 struct wacom_remote *remote = wacom->remote; 756 struct wacom_remote *remote = wacom->remote;
757 struct wacom_features *features = &wacom_wac->features; 757 struct wacom_features *features = &wacom_wac->features;
758 int bat_charging, bat_percent, touch_ring_mode; 758 int bat_charging, bat_percent, touch_ring_mode;
759 __u32 serial; 759 __u32 serial;
760 int i; 760 int i, index = -1;
761 unsigned long flags;
761 762
762 if (data[0] != WACOM_REPORT_REMOTE) { 763 if (data[0] != WACOM_REPORT_REMOTE) {
763 dev_dbg(input->dev.parent, 764 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
764 "%s: received unknown report #%d", __func__, data[0]); 765 __func__, data[0]);
765 return 0; 766 return 0;
766 } 767 }
767 768
768 serial = data[3] + (data[4] << 8) + (data[5] << 16); 769 serial = data[3] + (data[4] << 8) + (data[5] << 16);
769 wacom_wac->id[0] = PAD_DEVICE_ID; 770 wacom_wac->id[0] = PAD_DEVICE_ID;
770 771
772 spin_lock_irqsave(&remote->remote_lock, flags);
773
774 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
775 if (remote->remotes[i].serial == serial) {
776 index = i;
777 break;
778 }
779 }
780
781 if (index < 0 || !remote->remotes[index].registered)
782 goto out;
783
784 input = remote->remotes[index].input;
785
771 input_report_key(input, BTN_0, (data[9] & 0x01)); 786 input_report_key(input, BTN_0, (data[9] & 0x01));
772 input_report_key(input, BTN_1, (data[9] & 0x02)); 787 input_report_key(input, BTN_1, (data[9] & 0x02));
773 input_report_key(input, BTN_2, (data[9] & 0x04)); 788 input_report_key(input, BTN_2, (data[9] & 0x04));
@@ -804,6 +819,8 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
804 819
805 input_event(input, EV_MSC, MSC_SERIAL, serial); 820 input_event(input, EV_MSC, MSC_SERIAL, serial);
806 821
822 input_sync(input);
823
807 /*Which mode select (LED light) is currently on?*/ 824 /*Which mode select (LED light) is currently on?*/
808 touch_ring_mode = (data[11] & 0xC0) >> 6; 825 touch_ring_mode = (data[11] & 0xC0) >> 6;
809 826
@@ -821,7 +838,9 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
821 wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1, 838 wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
822 bat_charging); 839 bat_charging);
823 840
824 return 1; 841out:
842 spin_unlock_irqrestore(&remote->remote_lock, flags);
843 return 0;
825} 844}
826 845
827static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) 846static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
@@ -2458,6 +2477,9 @@ void wacom_setup_device_quirks(struct wacom *wacom)
2458 features->quirks |= WACOM_QUIRK_BATTERY; 2477 features->quirks |= WACOM_QUIRK_BATTERY;
2459 } 2478 }
2460 } 2479 }
2480
2481 if (features->type == REMOTE)
2482 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
2461} 2483}
2462 2484
2463int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, 2485int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
@@ -2762,6 +2784,9 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
2762 if (!(features->device_type & WACOM_DEVICETYPE_PAD)) 2784 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
2763 return -ENODEV; 2785 return -ENODEV;
2764 2786
2787 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
2788 return -ENODEV;
2789
2765 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 2790 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2766 2791
2767 /* kept for making legacy xf86-input-wacom working with the wheels */ 2792 /* kept for making legacy xf86-input-wacom working with the wheels */