Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 1 | /* |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 2 | * HID driver for N-Trig touchscreens |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 3 | * |
Stephane Chatty | 6549981 | 2010-04-06 22:22:58 +0200 | [diff] [blame] | 4 | * Copyright (c) 2008-2010 Rafi Rubin |
| 5 | * Copyright (c) 2009-2010 Stephane Chatty |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 6 | * |
| 7 | */ |
| 8 | |
| 9 | /* |
| 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) |
| 13 | * any later version. |
| 14 | */ |
| 15 | |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/hid.h> |
Stephane Chatty | 6549981 | 2010-04-06 22:22:58 +0200 | [diff] [blame] | 18 | #include <linux/usb.h> |
| 19 | #include "usbhid/usbhid.h" |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 20 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 21 | #include <linux/slab.h> |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 22 | |
| 23 | #include "hid-ids.h" |
| 24 | |
| 25 | #define NTRIG_DUPLICATE_USAGES 0x001 |
| 26 | |
| 27 | #define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ |
| 28 | EV_KEY, (c)) |
| 29 | |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 30 | struct ntrig_data { |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 31 | /* Incoming raw values for a single contact */ |
| 32 | __u16 x, y, w, h; |
| 33 | __u16 id; |
Rafi Rubin | 250d377 | 2010-05-03 05:08:29 -0400 | [diff] [blame^] | 34 | |
| 35 | bool tipswitch; |
| 36 | bool confidence; |
| 37 | bool first_contact_touch; |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 38 | |
| 39 | bool reading_mt; |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 40 | |
| 41 | __u8 mt_footer[4]; |
| 42 | __u8 mt_foot_count; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | /* |
| 46 | * this driver is aimed at two firmware versions in circulation: |
| 47 | * - dual pen/finger single touch |
| 48 | * - finger multitouch, pen not working |
| 49 | */ |
| 50 | |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 51 | static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 52 | struct hid_field *field, struct hid_usage *usage, |
| 53 | unsigned long **bit, int *max) |
| 54 | { |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 55 | /* No special mappings needed for the pen and single touch */ |
| 56 | if (field->physical) |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 57 | return 0; |
| 58 | |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 59 | switch (usage->hid & HID_USAGE_PAGE) { |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 60 | case HID_UP_GENDESK: |
| 61 | switch (usage->hid) { |
| 62 | case HID_GD_X: |
| 63 | hid_map_usage(hi, usage, bit, max, |
| 64 | EV_ABS, ABS_MT_POSITION_X); |
| 65 | input_set_abs_params(hi->input, ABS_X, |
| 66 | field->logical_minimum, |
| 67 | field->logical_maximum, 0, 0); |
| 68 | return 1; |
| 69 | case HID_GD_Y: |
| 70 | hid_map_usage(hi, usage, bit, max, |
| 71 | EV_ABS, ABS_MT_POSITION_Y); |
| 72 | input_set_abs_params(hi->input, ABS_Y, |
| 73 | field->logical_minimum, |
| 74 | field->logical_maximum, 0, 0); |
| 75 | return 1; |
| 76 | } |
| 77 | return 0; |
| 78 | |
| 79 | case HID_UP_DIGITIZER: |
| 80 | switch (usage->hid) { |
| 81 | /* we do not want to map these for now */ |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 82 | case HID_DG_CONTACTID: /* Not trustworthy, squelch for now */ |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 83 | case HID_DG_INPUTMODE: |
| 84 | case HID_DG_DEVICEINDEX: |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 85 | case HID_DG_CONTACTMAX: |
| 86 | return -1; |
| 87 | |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 88 | /* width/height mapped on TouchMajor/TouchMinor/Orientation */ |
| 89 | case HID_DG_WIDTH: |
| 90 | hid_map_usage(hi, usage, bit, max, |
| 91 | EV_ABS, ABS_MT_TOUCH_MAJOR); |
| 92 | return 1; |
| 93 | case HID_DG_HEIGHT: |
| 94 | hid_map_usage(hi, usage, bit, max, |
| 95 | EV_ABS, ABS_MT_TOUCH_MINOR); |
| 96 | input_set_abs_params(hi->input, ABS_MT_ORIENTATION, |
| 97 | 0, 1, 0, 0); |
| 98 | return 1; |
| 99 | } |
| 100 | return 0; |
| 101 | |
| 102 | case 0xff000000: |
| 103 | /* we do not want to map these: no input-oriented meaning */ |
| 104 | return -1; |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 105 | } |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 106 | |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
| 111 | struct hid_field *field, struct hid_usage *usage, |
| 112 | unsigned long **bit, int *max) |
| 113 | { |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 114 | /* No special mappings needed for the pen and single touch */ |
| 115 | if (field->physical) |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 116 | return 0; |
Rafi Rubin | b0549cf | 2010-02-11 22:14:06 -0500 | [diff] [blame] | 117 | |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 118 | if (usage->type == EV_KEY || usage->type == EV_REL |
| 119 | || usage->type == EV_ABS) |
| 120 | clear_bit(usage->code, *bit); |
| 121 | |
| 122 | return 0; |
| 123 | } |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 124 | |
| 125 | /* |
| 126 | * this function is called upon all reports |
| 127 | * so that we can filter contact point information, |
| 128 | * decide whether we are in multi or single touch mode |
| 129 | * and call input_mt_sync after each point if necessary |
| 130 | */ |
| 131 | static int ntrig_event (struct hid_device *hid, struct hid_field *field, |
| 132 | struct hid_usage *usage, __s32 value) |
| 133 | { |
| 134 | struct input_dev *input = field->hidinput->input; |
| 135 | struct ntrig_data *nd = hid_get_drvdata(hid); |
| 136 | |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 137 | /* No special handling needed for the pen */ |
| 138 | if (field->application == HID_DG_PEN) |
| 139 | return 0; |
| 140 | |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 141 | if (hid->claimed & HID_CLAIMED_INPUT) { |
| 142 | switch (usage->hid) { |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 143 | case 0xff000001: |
| 144 | /* Tag indicating the start of a multitouch group */ |
| 145 | nd->reading_mt = 1; |
Rafi Rubin | 250d377 | 2010-05-03 05:08:29 -0400 | [diff] [blame^] | 146 | nd->first_contact_touch = 0; |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 147 | break; |
Rafi Rubin | 2886539 | 2010-03-10 16:10:28 +0100 | [diff] [blame] | 148 | case HID_DG_TIPSWITCH: |
Rafi Rubin | 250d377 | 2010-05-03 05:08:29 -0400 | [diff] [blame^] | 149 | nd->tipswitch = value; |
Rafi Rubin | 2886539 | 2010-03-10 16:10:28 +0100 | [diff] [blame] | 150 | /* Prevent emission of touch until validated */ |
| 151 | return 1; |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 152 | case HID_DG_CONFIDENCE: |
| 153 | nd->confidence = value; |
| 154 | break; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 155 | case HID_GD_X: |
| 156 | nd->x = value; |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 157 | /* Clear the contact footer */ |
| 158 | nd->mt_foot_count = 0; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 159 | break; |
| 160 | case HID_GD_Y: |
| 161 | nd->y = value; |
| 162 | break; |
| 163 | case HID_DG_CONTACTID: |
| 164 | nd->id = value; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 165 | break; |
| 166 | case HID_DG_WIDTH: |
| 167 | nd->w = value; |
| 168 | break; |
| 169 | case HID_DG_HEIGHT: |
| 170 | nd->h = value; |
| 171 | /* |
| 172 | * when in single touch mode, this is the last |
| 173 | * report received in a finger event. We want |
| 174 | * to emit a normal (X, Y) position |
| 175 | */ |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 176 | if (!nd->reading_mt) { |
Rafi Rubin | 250d377 | 2010-05-03 05:08:29 -0400 | [diff] [blame^] | 177 | /* |
| 178 | * TipSwitch indicates the presence of a |
| 179 | * finger in single touch mode. |
| 180 | */ |
Rafi Rubin | 2170c5a | 2010-04-09 17:58:25 -0400 | [diff] [blame] | 181 | input_report_key(input, BTN_TOUCH, |
Rafi Rubin | 250d377 | 2010-05-03 05:08:29 -0400 | [diff] [blame^] | 182 | nd->tipswitch); |
| 183 | input_report_key(input, BTN_TOOL_DOUBLETAP, |
| 184 | nd->tipswitch); |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 185 | input_event(input, EV_ABS, ABS_X, nd->x); |
| 186 | input_event(input, EV_ABS, ABS_Y, nd->y); |
| 187 | } |
| 188 | break; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 189 | case 0xff000002: |
| 190 | /* |
| 191 | * we receive this when the device is in multitouch |
| 192 | * mode. The first of the three values tagged with |
| 193 | * this usage tells if the contact point is real |
| 194 | * or a placeholder |
| 195 | */ |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 196 | |
| 197 | /* Shouldn't get more than 4 footer packets, so skip */ |
| 198 | if (nd->mt_foot_count >= 4) |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 199 | break; |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 200 | |
| 201 | nd->mt_footer[nd->mt_foot_count++] = value; |
| 202 | |
| 203 | /* if the footer isn't complete break */ |
| 204 | if (nd->mt_foot_count != 4) |
| 205 | break; |
| 206 | |
| 207 | /* Pen activity signal, trigger end of touch. */ |
| 208 | if (nd->mt_footer[2]) { |
| 209 | nd->confidence = 0; |
| 210 | break; |
| 211 | } |
| 212 | |
| 213 | /* If the contact was invalid */ |
| 214 | if (!(nd->confidence && nd->mt_footer[0]) |
| 215 | || nd->w <= 250 |
| 216 | || nd->h <= 190) { |
| 217 | nd->confidence = 0; |
| 218 | break; |
| 219 | } |
| 220 | |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 221 | /* emit a normal (X, Y) for the first point only */ |
| 222 | if (nd->id == 0) { |
Rafi Rubin | 250d377 | 2010-05-03 05:08:29 -0400 | [diff] [blame^] | 223 | /* |
| 224 | * TipSwitch is superfluous in multitouch |
| 225 | * mode. The footer events tell us |
| 226 | * if there is a finger on the screen or |
| 227 | * not. |
| 228 | */ |
| 229 | nd->first_contact_touch = nd->confidence; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 230 | input_event(input, EV_ABS, ABS_X, nd->x); |
| 231 | input_event(input, EV_ABS, ABS_Y, nd->y); |
| 232 | } |
| 233 | input_event(input, EV_ABS, ABS_MT_POSITION_X, nd->x); |
| 234 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, nd->y); |
| 235 | if (nd->w > nd->h) { |
| 236 | input_event(input, EV_ABS, |
| 237 | ABS_MT_ORIENTATION, 1); |
| 238 | input_event(input, EV_ABS, |
| 239 | ABS_MT_TOUCH_MAJOR, nd->w); |
| 240 | input_event(input, EV_ABS, |
| 241 | ABS_MT_TOUCH_MINOR, nd->h); |
| 242 | } else { |
| 243 | input_event(input, EV_ABS, |
| 244 | ABS_MT_ORIENTATION, 0); |
| 245 | input_event(input, EV_ABS, |
| 246 | ABS_MT_TOUCH_MAJOR, nd->h); |
| 247 | input_event(input, EV_ABS, |
| 248 | ABS_MT_TOUCH_MINOR, nd->w); |
| 249 | } |
| 250 | input_mt_sync(field->hidinput->input); |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 251 | break; |
| 252 | |
| 253 | case HID_DG_CONTACTCOUNT: /* End of a multitouch group */ |
| 254 | if (!nd->reading_mt) |
| 255 | break; |
| 256 | |
| 257 | nd->reading_mt = 0; |
| 258 | |
Rafi Rubin | 250d377 | 2010-05-03 05:08:29 -0400 | [diff] [blame^] | 259 | if (nd->first_contact_touch) { |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 260 | switch (value) { |
| 261 | case 0: /* for single touch devices */ |
| 262 | case 1: |
| 263 | input_report_key(input, |
| 264 | BTN_TOOL_DOUBLETAP, 1); |
| 265 | break; |
| 266 | case 2: |
| 267 | input_report_key(input, |
| 268 | BTN_TOOL_TRIPLETAP, 1); |
| 269 | break; |
| 270 | case 3: |
| 271 | default: |
| 272 | input_report_key(input, |
| 273 | BTN_TOOL_QUADTAP, 1); |
| 274 | } |
| 275 | input_report_key(input, BTN_TOUCH, 1); |
| 276 | } else { |
| 277 | input_report_key(input, |
| 278 | BTN_TOOL_DOUBLETAP, 0); |
| 279 | input_report_key(input, |
| 280 | BTN_TOOL_TRIPLETAP, 0); |
| 281 | input_report_key(input, |
| 282 | BTN_TOOL_QUADTAP, 0); |
Rafi Rubin | 2886539 | 2010-03-10 16:10:28 +0100 | [diff] [blame] | 283 | input_report_key(input, BTN_TOUCH, 0); |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 284 | } |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 285 | break; |
| 286 | |
| 287 | default: |
| 288 | /* fallback to the generic hidinput handling */ |
| 289 | return 0; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | /* we have handled the hidinput part, now remains hiddev */ |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 294 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event) |
| 295 | hid->hiddev_hid_event(hid, field, usage, value); |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 296 | |
| 297 | return 1; |
| 298 | } |
| 299 | |
| 300 | static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) |
| 301 | { |
| 302 | int ret; |
| 303 | struct ntrig_data *nd; |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 304 | struct hid_input *hidinput; |
| 305 | struct input_dev *input; |
Stephane Chatty | 6549981 | 2010-04-06 22:22:58 +0200 | [diff] [blame] | 306 | struct hid_report *report; |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 307 | |
| 308 | if (id->driver_data) |
| 309 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 310 | |
| 311 | nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL); |
| 312 | if (!nd) { |
| 313 | dev_err(&hdev->dev, "cannot allocate N-Trig data\n"); |
| 314 | return -ENOMEM; |
| 315 | } |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 316 | |
| 317 | nd->reading_mt = 0; |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 318 | hid_set_drvdata(hdev, nd); |
| 319 | |
| 320 | ret = hid_parse(hdev); |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 321 | if (ret) { |
| 322 | dev_err(&hdev->dev, "parse failed\n"); |
| 323 | goto err_free; |
| 324 | } |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 325 | |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 326 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
| 327 | if (ret) { |
| 328 | dev_err(&hdev->dev, "hw start failed\n"); |
| 329 | goto err_free; |
| 330 | } |
Rafi Rubin | 837b475 | 2009-06-23 14:09:26 -0400 | [diff] [blame] | 331 | |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 332 | |
| 333 | list_for_each_entry(hidinput, &hdev->inputs, list) { |
Rafi Rubin | 2886539 | 2010-03-10 16:10:28 +0100 | [diff] [blame] | 334 | if (hidinput->report->maxfield < 1) |
| 335 | continue; |
| 336 | |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 337 | input = hidinput->input; |
| 338 | switch (hidinput->report->field[0]->application) { |
| 339 | case HID_DG_PEN: |
| 340 | input->name = "N-Trig Pen"; |
| 341 | break; |
| 342 | case HID_DG_TOUCHSCREEN: |
Rafi Rubin | 2886539 | 2010-03-10 16:10:28 +0100 | [diff] [blame] | 343 | /* These keys are redundant for fingers, clear them |
| 344 | * to prevent incorrect identification */ |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 345 | __clear_bit(BTN_TOOL_PEN, input->keybit); |
Rafi Rubin | 2886539 | 2010-03-10 16:10:28 +0100 | [diff] [blame] | 346 | __clear_bit(BTN_TOOL_FINGER, input->keybit); |
| 347 | __clear_bit(BTN_0, input->keybit); |
Rafi Rubin | dbf2b17 | 2010-02-12 21:13:05 -0500 | [diff] [blame] | 348 | /* |
| 349 | * A little something special to enable |
| 350 | * two and three finger taps. |
| 351 | */ |
| 352 | __set_bit(BTN_TOOL_DOUBLETAP, input->keybit); |
| 353 | __set_bit(BTN_TOOL_TRIPLETAP, input->keybit); |
| 354 | __set_bit(BTN_TOOL_QUADTAP, input->keybit); |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 355 | /* |
| 356 | * The physical touchscreen (single touch) |
| 357 | * input has a value for physical, whereas |
| 358 | * the multitouch only has logical input |
| 359 | * fields. |
| 360 | */ |
| 361 | input->name = |
| 362 | (hidinput->report->field[0] |
| 363 | ->physical) ? |
| 364 | "N-Trig Touchscreen" : |
| 365 | "N-Trig MultiTouch"; |
| 366 | break; |
| 367 | } |
| 368 | } |
| 369 | |
Jiri Kosina | c085855 | 2010-04-07 12:10:29 +0200 | [diff] [blame] | 370 | /* This is needed for devices with more recent firmware versions */ |
| 371 | report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a]; |
Stephane Chatty | 6549981 | 2010-04-06 22:22:58 +0200 | [diff] [blame] | 372 | if (report) |
| 373 | usbhid_submit_report(hdev, report, USB_DIR_OUT); |
| 374 | |
| 375 | |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 376 | return 0; |
| 377 | err_free: |
| 378 | kfree(nd); |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 379 | return ret; |
| 380 | } |
| 381 | |
| 382 | static void ntrig_remove(struct hid_device *hdev) |
| 383 | { |
| 384 | hid_hw_stop(hdev); |
| 385 | kfree(hid_get_drvdata(hdev)); |
| 386 | } |
| 387 | |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 388 | static const struct hid_device_id ntrig_devices[] = { |
| 389 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN), |
| 390 | .driver_data = NTRIG_DUPLICATE_USAGES }, |
| 391 | { } |
| 392 | }; |
| 393 | MODULE_DEVICE_TABLE(hid, ntrig_devices); |
| 394 | |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 395 | static const struct hid_usage_id ntrig_grabbed_usages[] = { |
| 396 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, |
Rafi Rubin | 943ed46 | 2010-02-11 22:14:05 -0500 | [diff] [blame] | 397 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1 } |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 398 | }; |
| 399 | |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 400 | static struct hid_driver ntrig_driver = { |
| 401 | .name = "ntrig", |
| 402 | .id_table = ntrig_devices, |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 403 | .probe = ntrig_probe, |
| 404 | .remove = ntrig_remove, |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 405 | .input_mapping = ntrig_input_mapping, |
| 406 | .input_mapped = ntrig_input_mapped, |
Stephane Chatty | 57fd637 | 2009-05-20 15:49:35 +0200 | [diff] [blame] | 407 | .usage_table = ntrig_grabbed_usages, |
| 408 | .event = ntrig_event, |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 409 | }; |
| 410 | |
Peter Huewe | a24f423b | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 411 | static int __init ntrig_init(void) |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 412 | { |
| 413 | return hid_register_driver(&ntrig_driver); |
| 414 | } |
| 415 | |
Peter Huewe | a24f423b | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 416 | static void __exit ntrig_exit(void) |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 417 | { |
| 418 | hid_unregister_driver(&ntrig_driver); |
| 419 | } |
| 420 | |
| 421 | module_init(ntrig_init); |
| 422 | module_exit(ntrig_exit); |
| 423 | MODULE_LICENSE("GPL"); |