aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-02-28 11:41:24 -0500
committerJiri Kosina <jkosina@suse.cz>2014-03-05 08:29:31 -0500
commite55f62008671f9200e124bcb3c736cfc3e661c2a (patch)
treec6f89de0cf8bc57f51a2beaa8cf66fe42e7dd4f2 /drivers/hid
parent0fa9c61618fe996c153d186e4087a61ca4e7b2ed (diff)
HID: multitouch: remove pen special handling
Pens have a special handling in hid-mt as hybrid pen/touch devices are quite common now. However, some fancy devices presents also useful collections like mouse or keyboard. The special case for the pen may not be a special case, and treat it as a generic case. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-multitouch.c61
1 files changed, 9 insertions, 52 deletions
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 3e81f4e1c7c1..8250cc0fd5f4 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -100,7 +100,6 @@ struct mt_device {
100 int cc_value_index; /* contact count value index in the field */ 100 int cc_value_index; /* contact count value index in the field */
101 unsigned last_slot_field; /* the last field of a slot */ 101 unsigned last_slot_field; /* the last field of a slot */
102 unsigned mt_report_id; /* the report ID of the multitouch device */ 102 unsigned mt_report_id; /* the report ID of the multitouch device */
103 unsigned pen_report_id; /* the report ID of the pen device */
104 __s16 inputmode; /* InputMode HID feature, -1 if non-existent */ 103 __s16 inputmode; /* InputMode HID feature, -1 if non-existent */
105 __s16 inputmode_index; /* InputMode HID feature index in the report */ 104 __s16 inputmode_index; /* InputMode HID feature index in the report */
106 __s16 maxcontact_report_id; /* Maximum Contact Number HID feature, 105 __s16 maxcontact_report_id; /* Maximum Contact Number HID feature,
@@ -342,45 +341,6 @@ static void mt_store_field(struct hid_usage *usage, struct mt_device *td,
342 f->usages[f->length++] = usage->hid; 341 f->usages[f->length++] = usage->hid;
343} 342}
344 343
345static int mt_pen_input_mapping(struct hid_device *hdev, struct hid_input *hi,
346 struct hid_field *field, struct hid_usage *usage,
347 unsigned long **bit, int *max)
348{
349 struct mt_device *td = hid_get_drvdata(hdev);
350
351 td->pen_report_id = field->report->id;
352
353 return 0;
354}
355
356static int mt_pen_input_mapped(struct hid_device *hdev, struct hid_input *hi,
357 struct hid_field *field, struct hid_usage *usage,
358 unsigned long **bit, int *max)
359{
360 return 0;
361}
362
363static int mt_pen_event(struct hid_device *hid, struct hid_field *field,
364 struct hid_usage *usage, __s32 value)
365{
366 /* let hid-input handle it */
367 return 0;
368}
369
370static void mt_pen_report(struct hid_device *hid, struct hid_report *report)
371{
372 struct hid_field *field = report->field[0];
373
374 input_sync(field->hidinput->input);
375}
376
377static void mt_pen_input_configured(struct hid_device *hdev,
378 struct hid_input *hi)
379{
380 /* force BTN_STYLUS to allow tablet matching in udev */
381 __set_bit(BTN_STYLUS, hi->input->keybit);
382}
383
384static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, 344static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
385 struct hid_field *field, struct hid_usage *usage, 345 struct hid_field *field, struct hid_usage *usage,
386 unsigned long **bit, int *max) 346 unsigned long **bit, int *max)
@@ -767,7 +727,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
767 return -1; 727 return -1;
768 728
769 if (field->physical == HID_DG_STYLUS) 729 if (field->physical == HID_DG_STYLUS)
770 return mt_pen_input_mapping(hdev, hi, field, usage, bit, max); 730 return 0;
771 731
772 return mt_touch_input_mapping(hdev, hi, field, usage, bit, max); 732 return mt_touch_input_mapping(hdev, hi, field, usage, bit, max);
773} 733}
@@ -777,7 +737,7 @@ static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
777 unsigned long **bit, int *max) 737 unsigned long **bit, int *max)
778{ 738{
779 if (field->physical == HID_DG_STYLUS) 739 if (field->physical == HID_DG_STYLUS)
780 return mt_pen_input_mapped(hdev, hi, field, usage, bit, max); 740 return 0;
781 741
782 return mt_touch_input_mapped(hdev, hi, field, usage, bit, max); 742 return mt_touch_input_mapped(hdev, hi, field, usage, bit, max);
783} 743}
@@ -790,25 +750,22 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
790 if (field->report->id == td->mt_report_id) 750 if (field->report->id == td->mt_report_id)
791 return mt_touch_event(hid, field, usage, value); 751 return mt_touch_event(hid, field, usage, value);
792 752
793 if (field->report->id == td->pen_report_id) 753 return 0;
794 return mt_pen_event(hid, field, usage, value);
795
796 /* ignore other reports */
797 return 1;
798} 754}
799 755
800static void mt_report(struct hid_device *hid, struct hid_report *report) 756static void mt_report(struct hid_device *hid, struct hid_report *report)
801{ 757{
802 struct mt_device *td = hid_get_drvdata(hid); 758 struct mt_device *td = hid_get_drvdata(hid);
759 struct hid_field *field = report->field[0];
803 760
804 if (!(hid->claimed & HID_CLAIMED_INPUT)) 761 if (!(hid->claimed & HID_CLAIMED_INPUT))
805 return; 762 return;
806 763
807 if (report->id == td->mt_report_id) 764 if (report->id == td->mt_report_id)
808 mt_touch_report(hid, report); 765 return mt_touch_report(hid, report);
809 766
810 if (report->id == td->pen_report_id) 767 if (field && field->hidinput && field->hidinput->input)
811 mt_pen_report(hid, report); 768 input_sync(field->hidinput->input);
812} 769}
813 770
814static void mt_set_input_mode(struct hid_device *hdev) 771static void mt_set_input_mode(struct hid_device *hdev)
@@ -895,7 +852,8 @@ static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
895 852
896 if (hi->report->field[0]->physical == HID_DG_STYLUS) { 853 if (hi->report->field[0]->physical == HID_DG_STYLUS) {
897 suffix = "Pen"; 854 suffix = "Pen";
898 mt_pen_input_configured(hdev, hi); 855 /* force BTN_STYLUS to allow tablet matching in udev */
856 __set_bit(BTN_STYLUS, hi->input->keybit);
899 } 857 }
900 858
901 if (suffix) { 859 if (suffix) {
@@ -957,7 +915,6 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
957 td->maxcontact_report_id = -1; 915 td->maxcontact_report_id = -1;
958 td->cc_index = -1; 916 td->cc_index = -1;
959 td->mt_report_id = -1; 917 td->mt_report_id = -1;
960 td->pen_report_id = -1;
961 hid_set_drvdata(hdev, td); 918 hid_set_drvdata(hdev, td);
962 919
963 td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields), 920 td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields),