2 * HID driver for N-Trig touchscreens
4 * Copyright (c) 2008-2010 Rafi Rubin
5 * Copyright (c) 2009-2010 Stephane Chatty
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
16 #include <linux/device.h>
17 #include <linux/hid.h>
18 #include <linux/usb.h>
19 #include "usbhid/usbhid.h"
20 #include <linux/module.h>
21 #include <linux/slab.h>
25 #define NTRIG_DUPLICATE_USAGES 0x001
27 static unsigned int min_width
;
28 module_param(min_width
, uint
, 0644);
29 MODULE_PARM_DESC(min_width
, "Minimum touch contact width to accept.");
31 static unsigned int min_height
;
32 module_param(min_height
, uint
, 0644);
33 MODULE_PARM_DESC(min_height
, "Minimum touch contact height to accept.");
35 static unsigned int activate_slack
= 1;
36 module_param(activate_slack
, uint
, 0644);
37 MODULE_PARM_DESC(activate_slack
, "Number of touch frames to ignore at "
38 "the start of touch input.");
40 static unsigned int deactivate_slack
= 4;
41 module_param(deactivate_slack
, uint
, 0644);
42 MODULE_PARM_DESC(deactivate_slack
, "Number of empty frames to ignore before "
43 "deactivating touch.");
45 static unsigned int activation_width
= 64;
46 module_param(activation_width
, uint
, 0644);
47 MODULE_PARM_DESC(activation_width
, "Width threshold to immediately start "
48 "processing touch events.");
50 static unsigned int activation_height
= 32;
51 module_param(activation_height
, uint
, 0644);
52 MODULE_PARM_DESC(activation_height
, "Height threshold to immediately start "
53 "processing touch events.");
56 /* Incoming raw values for a single contact */
62 bool first_contact_touch
;
69 /* The current activation state. */
72 /* Empty frames to ignore before recognizing the end of activity */
73 __s8 deactivate_slack
;
75 /* Frames to ignore before acknowledging the start of activity */
78 /* Minimum size contact to accept */
82 /* Threshold to override activation slack */
83 __u16 activation_width
;
84 __u16 activation_height
;
86 __u16 sensor_logical_width
;
87 __u16 sensor_logical_height
;
88 __u16 sensor_physical_width
;
89 __u16 sensor_physical_height
;
94 * This function converts the 4 byte raw firmware code into
95 * a string containing 5 comma separated numbers.
97 static int ntrig_version_string(unsigned char *raw
, char *buf
)
99 __u8 a
= (raw
[1] & 0x0e) >> 1;
100 __u8 b
= (raw
[0] & 0x3c) >> 2;
101 __u8 c
= ((raw
[0] & 0x03) << 3) | ((raw
[3] & 0xe0) >> 5);
102 __u8 d
= ((raw
[3] & 0x07) << 3) | ((raw
[2] & 0xe0) >> 5);
103 __u8 e
= raw
[2] & 0x07;
106 * As yet unmapped bits:
107 * 0b11000000 0b11110001 0b00011000 0b00011000
110 return sprintf(buf
, "%u.%u.%u.%u.%u", a
, b
, c
, d
, e
);
113 static void ntrig_report_version(struct hid_device
*hdev
)
117 struct usb_device
*usb_dev
= hid_to_usb_dev(hdev
);
118 unsigned char *data
= kmalloc(8, GFP_KERNEL
);
123 ret
= usb_control_msg(usb_dev
, usb_rcvctrlpipe(usb_dev
, 0),
124 USB_REQ_CLEAR_FEATURE
,
125 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
|
128 USB_CTRL_SET_TIMEOUT
);
131 ret
= ntrig_version_string(&data
[2], buf
);
133 hid_info(hdev
, "Firmware version: %s (%02x%02x %02x%02x)\n",
134 buf
, data
[2], data
[3], data
[4], data
[5]);
141 static ssize_t
show_phys_width(struct device
*dev
,
142 struct device_attribute
*attr
,
145 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
146 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
148 return sprintf(buf
, "%d\n", nd
->sensor_physical_width
);
151 static DEVICE_ATTR(sensor_physical_width
, S_IRUGO
, show_phys_width
, NULL
);
153 static ssize_t
show_phys_height(struct device
*dev
,
154 struct device_attribute
*attr
,
157 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
158 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
160 return sprintf(buf
, "%d\n", nd
->sensor_physical_height
);
163 static DEVICE_ATTR(sensor_physical_height
, S_IRUGO
, show_phys_height
, NULL
);
165 static ssize_t
show_log_width(struct device
*dev
,
166 struct device_attribute
*attr
,
169 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
170 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
172 return sprintf(buf
, "%d\n", nd
->sensor_logical_width
);
175 static DEVICE_ATTR(sensor_logical_width
, S_IRUGO
, show_log_width
, NULL
);
177 static ssize_t
show_log_height(struct device
*dev
,
178 struct device_attribute
*attr
,
181 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
182 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
184 return sprintf(buf
, "%d\n", nd
->sensor_logical_height
);
187 static DEVICE_ATTR(sensor_logical_height
, S_IRUGO
, show_log_height
, NULL
);
189 static ssize_t
show_min_width(struct device
*dev
,
190 struct device_attribute
*attr
,
193 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
194 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
196 return sprintf(buf
, "%d\n", nd
->min_width
*
197 nd
->sensor_physical_width
/
198 nd
->sensor_logical_width
);
201 static ssize_t
set_min_width(struct device
*dev
,
202 struct device_attribute
*attr
,
203 const char *buf
, size_t count
)
205 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
206 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
210 if (strict_strtoul(buf
, 0, &val
))
213 if (val
> nd
->sensor_physical_width
)
216 nd
->min_width
= val
* nd
->sensor_logical_width
/
217 nd
->sensor_physical_width
;
222 static DEVICE_ATTR(min_width
, S_IWUSR
| S_IRUGO
, show_min_width
, set_min_width
);
224 static ssize_t
show_min_height(struct device
*dev
,
225 struct device_attribute
*attr
,
228 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
229 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
231 return sprintf(buf
, "%d\n", nd
->min_height
*
232 nd
->sensor_physical_height
/
233 nd
->sensor_logical_height
);
236 static ssize_t
set_min_height(struct device
*dev
,
237 struct device_attribute
*attr
,
238 const char *buf
, size_t count
)
240 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
241 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
245 if (strict_strtoul(buf
, 0, &val
))
248 if (val
> nd
->sensor_physical_height
)
251 nd
->min_height
= val
* nd
->sensor_logical_height
/
252 nd
->sensor_physical_height
;
257 static DEVICE_ATTR(min_height
, S_IWUSR
| S_IRUGO
, show_min_height
,
260 static ssize_t
show_activate_slack(struct device
*dev
,
261 struct device_attribute
*attr
,
264 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
265 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
267 return sprintf(buf
, "%d\n", nd
->activate_slack
);
270 static ssize_t
set_activate_slack(struct device
*dev
,
271 struct device_attribute
*attr
,
272 const char *buf
, size_t count
)
274 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
275 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
279 if (strict_strtoul(buf
, 0, &val
))
285 nd
->activate_slack
= val
;
290 static DEVICE_ATTR(activate_slack
, S_IWUSR
| S_IRUGO
, show_activate_slack
,
293 static ssize_t
show_activation_width(struct device
*dev
,
294 struct device_attribute
*attr
,
297 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
298 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
300 return sprintf(buf
, "%d\n", nd
->activation_width
*
301 nd
->sensor_physical_width
/
302 nd
->sensor_logical_width
);
305 static ssize_t
set_activation_width(struct device
*dev
,
306 struct device_attribute
*attr
,
307 const char *buf
, size_t count
)
309 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
310 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
314 if (strict_strtoul(buf
, 0, &val
))
317 if (val
> nd
->sensor_physical_width
)
320 nd
->activation_width
= val
* nd
->sensor_logical_width
/
321 nd
->sensor_physical_width
;
326 static DEVICE_ATTR(activation_width
, S_IWUSR
| S_IRUGO
, show_activation_width
,
327 set_activation_width
);
329 static ssize_t
show_activation_height(struct device
*dev
,
330 struct device_attribute
*attr
,
333 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
334 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
336 return sprintf(buf
, "%d\n", nd
->activation_height
*
337 nd
->sensor_physical_height
/
338 nd
->sensor_logical_height
);
341 static ssize_t
set_activation_height(struct device
*dev
,
342 struct device_attribute
*attr
,
343 const char *buf
, size_t count
)
345 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
346 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
350 if (strict_strtoul(buf
, 0, &val
))
353 if (val
> nd
->sensor_physical_height
)
356 nd
->activation_height
= val
* nd
->sensor_logical_height
/
357 nd
->sensor_physical_height
;
362 static DEVICE_ATTR(activation_height
, S_IWUSR
| S_IRUGO
,
363 show_activation_height
, set_activation_height
);
365 static ssize_t
show_deactivate_slack(struct device
*dev
,
366 struct device_attribute
*attr
,
369 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
370 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
372 return sprintf(buf
, "%d\n", -nd
->deactivate_slack
);
375 static ssize_t
set_deactivate_slack(struct device
*dev
,
376 struct device_attribute
*attr
,
377 const char *buf
, size_t count
)
379 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
380 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
384 if (strict_strtoul(buf
, 0, &val
))
388 * No more than 8 terminal frames have been observed so far
389 * and higher slack is highly likely to leave the single
390 * touch emulation stuck down.
395 nd
->deactivate_slack
= -val
;
400 static DEVICE_ATTR(deactivate_slack
, S_IWUSR
| S_IRUGO
, show_deactivate_slack
,
401 set_deactivate_slack
);
403 static struct attribute
*sysfs_attrs
[] = {
404 &dev_attr_sensor_physical_width
.attr
,
405 &dev_attr_sensor_physical_height
.attr
,
406 &dev_attr_sensor_logical_width
.attr
,
407 &dev_attr_sensor_logical_height
.attr
,
408 &dev_attr_min_height
.attr
,
409 &dev_attr_min_width
.attr
,
410 &dev_attr_activate_slack
.attr
,
411 &dev_attr_activation_width
.attr
,
412 &dev_attr_activation_height
.attr
,
413 &dev_attr_deactivate_slack
.attr
,
417 static struct attribute_group ntrig_attribute_group
= {
422 * this driver is aimed at two firmware versions in circulation:
423 * - dual pen/finger single touch
424 * - finger multitouch, pen not working
427 static int ntrig_input_mapping(struct hid_device
*hdev
, struct hid_input
*hi
,
428 struct hid_field
*field
, struct hid_usage
*usage
,
429 unsigned long **bit
, int *max
)
431 struct ntrig_data
*nd
= hid_get_drvdata(hdev
);
433 /* No special mappings needed for the pen and single touch */
437 switch (usage
->hid
& HID_USAGE_PAGE
) {
439 switch (usage
->hid
) {
441 hid_map_usage(hi
, usage
, bit
, max
,
442 EV_ABS
, ABS_MT_POSITION_X
);
443 input_set_abs_params(hi
->input
, ABS_X
,
444 field
->logical_minimum
,
445 field
->logical_maximum
, 0, 0);
447 if (!nd
->sensor_logical_width
) {
448 nd
->sensor_logical_width
=
449 field
->logical_maximum
-
450 field
->logical_minimum
;
451 nd
->sensor_physical_width
=
452 field
->physical_maximum
-
453 field
->physical_minimum
;
454 nd
->activation_width
= activation_width
*
455 nd
->sensor_logical_width
/
456 nd
->sensor_physical_width
;
457 nd
->min_width
= min_width
*
458 nd
->sensor_logical_width
/
459 nd
->sensor_physical_width
;
463 hid_map_usage(hi
, usage
, bit
, max
,
464 EV_ABS
, ABS_MT_POSITION_Y
);
465 input_set_abs_params(hi
->input
, ABS_Y
,
466 field
->logical_minimum
,
467 field
->logical_maximum
, 0, 0);
469 if (!nd
->sensor_logical_height
) {
470 nd
->sensor_logical_height
=
471 field
->logical_maximum
-
472 field
->logical_minimum
;
473 nd
->sensor_physical_height
=
474 field
->physical_maximum
-
475 field
->physical_minimum
;
476 nd
->activation_height
= activation_height
*
477 nd
->sensor_logical_height
/
478 nd
->sensor_physical_height
;
479 nd
->min_height
= min_height
*
480 nd
->sensor_logical_height
/
481 nd
->sensor_physical_height
;
487 case HID_UP_DIGITIZER
:
488 switch (usage
->hid
) {
489 /* we do not want to map these for now */
490 case HID_DG_CONTACTID
: /* Not trustworthy, squelch for now */
491 case HID_DG_INPUTMODE
:
492 case HID_DG_DEVICEINDEX
:
493 case HID_DG_CONTACTMAX
:
496 /* width/height mapped on TouchMajor/TouchMinor/Orientation */
498 hid_map_usage(hi
, usage
, bit
, max
,
499 EV_ABS
, ABS_MT_TOUCH_MAJOR
);
502 hid_map_usage(hi
, usage
, bit
, max
,
503 EV_ABS
, ABS_MT_TOUCH_MINOR
);
504 input_set_abs_params(hi
->input
, ABS_MT_ORIENTATION
,
511 /* we do not want to map these: no input-oriented meaning */
518 static int ntrig_input_mapped(struct hid_device
*hdev
, struct hid_input
*hi
,
519 struct hid_field
*field
, struct hid_usage
*usage
,
520 unsigned long **bit
, int *max
)
522 /* No special mappings needed for the pen and single touch */
526 if (usage
->type
== EV_KEY
|| usage
->type
== EV_REL
527 || usage
->type
== EV_ABS
)
528 clear_bit(usage
->code
, *bit
);
534 * this function is called upon all reports
535 * so that we can filter contact point information,
536 * decide whether we are in multi or single touch mode
537 * and call input_mt_sync after each point if necessary
539 static int ntrig_event (struct hid_device
*hid
, struct hid_field
*field
,
540 struct hid_usage
*usage
, __s32 value
)
542 struct ntrig_data
*nd
= hid_get_drvdata(hid
);
543 struct input_dev
*input
;
545 /* Skip processing if not a claimed input */
546 if (!(hid
->claimed
& HID_CLAIMED_INPUT
))
547 goto not_claimed_input
;
549 /* This function is being called before the structures are fully
551 if(!(field
->hidinput
&& field
->hidinput
->input
))
554 input
= field
->hidinput
->input
;
556 /* No special handling needed for the pen */
557 if (field
->application
== HID_DG_PEN
)
560 if (hid
->claimed
& HID_CLAIMED_INPUT
) {
561 switch (usage
->hid
) {
563 /* Tag indicating the start of a multitouch group */
565 nd
->first_contact_touch
= 0;
567 case HID_DG_TIPSWITCH
:
568 nd
->tipswitch
= value
;
569 /* Prevent emission of touch until validated */
571 case HID_DG_CONFIDENCE
:
572 nd
->confidence
= value
;
576 /* Clear the contact footer */
577 nd
->mt_foot_count
= 0;
582 case HID_DG_CONTACTID
:
591 * when in single touch mode, this is the last
592 * report received in a finger event. We want
593 * to emit a normal (X, Y) position
595 if (!nd
->reading_mt
) {
597 * TipSwitch indicates the presence of a
598 * finger in single touch mode.
600 input_report_key(input
, BTN_TOUCH
,
602 input_report_key(input
, BTN_TOOL_DOUBLETAP
,
604 input_event(input
, EV_ABS
, ABS_X
, nd
->x
);
605 input_event(input
, EV_ABS
, ABS_Y
, nd
->y
);
610 * we receive this when the device is in multitouch
611 * mode. The first of the three values tagged with
612 * this usage tells if the contact point is real
616 /* Shouldn't get more than 4 footer packets, so skip */
617 if (nd
->mt_foot_count
>= 4)
620 nd
->mt_footer
[nd
->mt_foot_count
++] = value
;
622 /* if the footer isn't complete break */
623 if (nd
->mt_foot_count
!= 4)
626 /* Pen activity signal. */
627 if (nd
->mt_footer
[2]) {
629 * When the pen deactivates touch, we see a
630 * bogus frame with ContactCount > 0.
632 * save a bit of work by ensuring act_state < 0
633 * even if deactivation slack is turned off.
635 nd
->act_state
= deactivate_slack
- 1;
641 * The first footer value indicates the presence of a
644 if (nd
->mt_footer
[0]) {
646 * We do not want to process contacts under
647 * the size threshold, but do not want to
648 * ignore them for activation state
650 if (nd
->w
< nd
->min_width
||
651 nd
->h
< nd
->min_height
)
656 if (nd
->act_state
> 0) {
658 * Contact meets the activation size threshold
660 if (nd
->w
>= nd
->activation_width
&&
661 nd
->h
>= nd
->activation_height
) {
664 * first contact, activate now
669 * avoid corrupting this frame
670 * but ensure next frame will
678 * Defer adjusting the activation state
679 * until the end of the frame.
684 /* Discarding this contact */
688 /* emit a normal (X, Y) for the first point only */
691 * TipSwitch is superfluous in multitouch
692 * mode. The footer events tell us
693 * if there is a finger on the screen or
696 nd
->first_contact_touch
= nd
->confidence
;
697 input_event(input
, EV_ABS
, ABS_X
, nd
->x
);
698 input_event(input
, EV_ABS
, ABS_Y
, nd
->y
);
702 input_event(input
, EV_ABS
, ABS_MT_POSITION_X
, nd
->x
);
703 input_event(input
, EV_ABS
, ABS_MT_POSITION_Y
, nd
->y
);
706 * Translate from height and width to size
710 input_event(input
, EV_ABS
,
711 ABS_MT_ORIENTATION
, 1);
712 input_event(input
, EV_ABS
,
713 ABS_MT_TOUCH_MAJOR
, nd
->w
);
714 input_event(input
, EV_ABS
,
715 ABS_MT_TOUCH_MINOR
, nd
->h
);
717 input_event(input
, EV_ABS
,
718 ABS_MT_ORIENTATION
, 0);
719 input_event(input
, EV_ABS
,
720 ABS_MT_TOUCH_MAJOR
, nd
->h
);
721 input_event(input
, EV_ABS
,
722 ABS_MT_TOUCH_MINOR
, nd
->w
);
724 input_mt_sync(field
->hidinput
->input
);
727 case HID_DG_CONTACTCOUNT
: /* End of a multitouch group */
728 if (!nd
->reading_mt
) /* Just to be sure */
735 * Activation state machine logic:
737 * Fundamental states:
738 * state > 0: Inactive
740 * state < -deactivate_slack:
741 * Pen termination of touch
743 * Specific values of interest
744 * state == activate_slack
745 * no valid input since the last reset
748 * general operational state
750 * state == -deactivate_slack
751 * read sufficient empty frames to accept
752 * the end of input and reset
755 if (nd
->act_state
> 0) { /* Currently inactive */
758 * Consider each live contact as
759 * evidence of intentional activity.
761 nd
->act_state
= (nd
->act_state
> value
)
762 ? nd
->act_state
- value
766 * Empty frame before we hit the
767 * activity threshold, reset.
769 nd
->act_state
= nd
->activate_slack
;
772 * Entered this block inactive and no
773 * coordinates sent this frame, so hold off
777 } else { /* Currently active */
778 if (value
&& nd
->act_state
>=
779 nd
->deactivate_slack
)
781 * Live point: clear accumulated
782 * deactivation count.
785 else if (nd
->act_state
<= nd
->deactivate_slack
)
787 * We've consumed the deactivation
788 * slack, time to deactivate and reset.
792 else { /* Move towards deactivation */
798 if (nd
->first_contact_touch
&& nd
->act_state
<= 0) {
800 * Check to see if we're ready to start
801 * emitting touch events.
803 * Note: activation slack will decrease over
804 * the course of the frame, and it will be
805 * inconsistent from the start to the end of
806 * the frame. However if the frame starts
807 * with slack, first_contact_touch will still
808 * be 0 and we will not get to this point.
810 input_report_key(input
, BTN_TOOL_DOUBLETAP
, 1);
811 input_report_key(input
, BTN_TOUCH
, 1);
813 input_report_key(input
, BTN_TOOL_DOUBLETAP
, 0);
814 input_report_key(input
, BTN_TOUCH
, 0);
819 /* fall-back to the generic hidinput handling */
826 /* we have handled the hidinput part, now remains hiddev */
827 if ((hid
->claimed
& HID_CLAIMED_HIDDEV
) && hid
->hiddev_hid_event
)
828 hid
->hiddev_hid_event(hid
, field
, usage
, value
);
833 static int ntrig_probe(struct hid_device
*hdev
, const struct hid_device_id
*id
)
836 struct ntrig_data
*nd
;
837 struct hid_input
*hidinput
;
838 struct input_dev
*input
;
839 struct hid_report
*report
;
842 hdev
->quirks
|= HID_QUIRK_MULTI_INPUT
;
844 nd
= kmalloc(sizeof(struct ntrig_data
), GFP_KERNEL
);
846 hid_err(hdev
, "cannot allocate N-Trig data\n");
853 nd
->activate_slack
= activate_slack
;
854 nd
->act_state
= activate_slack
;
855 nd
->deactivate_slack
= -deactivate_slack
;
856 nd
->sensor_logical_width
= 0;
857 nd
->sensor_logical_height
= 0;
858 nd
->sensor_physical_width
= 0;
859 nd
->sensor_physical_height
= 0;
861 hid_set_drvdata(hdev
, nd
);
863 ret
= hid_parse(hdev
);
865 hid_err(hdev
, "parse failed\n");
869 ret
= hid_hw_start(hdev
, HID_CONNECT_DEFAULT
& ~HID_CONNECT_FF
);
871 hid_err(hdev
, "hw start failed\n");
876 list_for_each_entry(hidinput
, &hdev
->inputs
, list
) {
877 if (hidinput
->report
->maxfield
< 1)
880 input
= hidinput
->input
;
881 switch (hidinput
->report
->field
[0]->application
) {
883 input
->name
= "N-Trig Pen";
885 case HID_DG_TOUCHSCREEN
:
886 /* These keys are redundant for fingers, clear them
887 * to prevent incorrect identification */
888 __clear_bit(BTN_TOOL_PEN
, input
->keybit
);
889 __clear_bit(BTN_TOOL_FINGER
, input
->keybit
);
890 __clear_bit(BTN_0
, input
->keybit
);
891 __set_bit(BTN_TOOL_DOUBLETAP
, input
->keybit
);
893 * The physical touchscreen (single touch)
894 * input has a value for physical, whereas
895 * the multitouch only has logical input
899 (hidinput
->report
->field
[0]
901 "N-Trig Touchscreen" :
907 /* This is needed for devices with more recent firmware versions */
908 report
= hdev
->report_enum
[HID_FEATURE_REPORT
].report_id_hash
[0x0a];
910 usbhid_submit_report(hdev
, report
, USB_DIR_OUT
);
912 ntrig_report_version(hdev
);
914 ret
= sysfs_create_group(&hdev
->dev
.kobj
,
915 &ntrig_attribute_group
);
923 static void ntrig_remove(struct hid_device
*hdev
)
925 sysfs_remove_group(&hdev
->dev
.kobj
,
926 &ntrig_attribute_group
);
928 kfree(hid_get_drvdata(hdev
));
931 static const struct hid_device_id ntrig_devices
[] = {
932 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN
),
933 .driver_data
= NTRIG_DUPLICATE_USAGES
},
934 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1
),
935 .driver_data
= NTRIG_DUPLICATE_USAGES
},
936 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2
),
937 .driver_data
= NTRIG_DUPLICATE_USAGES
},
938 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3
),
939 .driver_data
= NTRIG_DUPLICATE_USAGES
},
940 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4
),
941 .driver_data
= NTRIG_DUPLICATE_USAGES
},
942 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5
),
943 .driver_data
= NTRIG_DUPLICATE_USAGES
},
944 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6
),
945 .driver_data
= NTRIG_DUPLICATE_USAGES
},
946 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7
),
947 .driver_data
= NTRIG_DUPLICATE_USAGES
},
948 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8
),
949 .driver_data
= NTRIG_DUPLICATE_USAGES
},
950 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9
),
951 .driver_data
= NTRIG_DUPLICATE_USAGES
},
952 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10
),
953 .driver_data
= NTRIG_DUPLICATE_USAGES
},
954 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11
),
955 .driver_data
= NTRIG_DUPLICATE_USAGES
},
956 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12
),
957 .driver_data
= NTRIG_DUPLICATE_USAGES
},
958 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13
),
959 .driver_data
= NTRIG_DUPLICATE_USAGES
},
960 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14
),
961 .driver_data
= NTRIG_DUPLICATE_USAGES
},
962 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15
),
963 .driver_data
= NTRIG_DUPLICATE_USAGES
},
964 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16
),
965 .driver_data
= NTRIG_DUPLICATE_USAGES
},
966 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17
),
967 .driver_data
= NTRIG_DUPLICATE_USAGES
},
968 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18
),
969 .driver_data
= NTRIG_DUPLICATE_USAGES
},
972 MODULE_DEVICE_TABLE(hid
, ntrig_devices
);
974 static const struct hid_usage_id ntrig_grabbed_usages
[] = {
975 { HID_ANY_ID
, HID_ANY_ID
, HID_ANY_ID
},
976 { HID_ANY_ID
- 1, HID_ANY_ID
- 1, HID_ANY_ID
- 1 }
979 static struct hid_driver ntrig_driver
= {
981 .id_table
= ntrig_devices
,
982 .probe
= ntrig_probe
,
983 .remove
= ntrig_remove
,
984 .input_mapping
= ntrig_input_mapping
,
985 .input_mapped
= ntrig_input_mapped
,
986 .usage_table
= ntrig_grabbed_usages
,
987 .event
= ntrig_event
,
990 static int __init
ntrig_init(void)
992 return hid_register_driver(&ntrig_driver
);
995 static void __exit
ntrig_exit(void)
997 hid_unregister_driver(&ntrig_driver
);
1000 module_init(ntrig_init
);
1001 module_exit(ntrig_exit
);
1002 MODULE_LICENSE("GPL");