diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-03-19 02:38:50 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-03-19 02:38:50 -0400 |
commit | 97eb3f24352ec6632c2127b35d8087d2a809a9b9 (patch) | |
tree | 722948059bbd325bbca232269490124231df80d4 /drivers/hid/hid-input.c | |
parent | 439581ec07fa9cf3f519dd461a2cf41cfd3adcb4 (diff) | |
parent | def179c271ac9b5020deca798470521f14d11edd (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r-- | drivers/hid/hid-input.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index bb0b3659437b..ba2aeea2cbf9 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -174,7 +174,7 @@ static int hidinput_setkeycode(struct input_dev *dev, | |||
174 | 174 | ||
175 | clear_bit(*old_keycode, dev->keybit); | 175 | clear_bit(*old_keycode, dev->keybit); |
176 | set_bit(usage->code, dev->keybit); | 176 | set_bit(usage->code, dev->keybit); |
177 | dbg_hid(KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", | 177 | dbg_hid("Assigned keycode %d to HID usage code %x\n", |
178 | usage->code, usage->hid); | 178 | usage->code, usage->hid); |
179 | 179 | ||
180 | /* | 180 | /* |
@@ -203,8 +203,8 @@ static int hidinput_setkeycode(struct input_dev *dev, | |||
203 | * | 203 | * |
204 | * as seen in the HID specification v1.11 6.2.2.7 Global Items. | 204 | * as seen in the HID specification v1.11 6.2.2.7 Global Items. |
205 | * | 205 | * |
206 | * Only exponent 1 length units are processed. Centimeters are converted to | 206 | * Only exponent 1 length units are processed. Centimeters and inches are |
207 | * inches. Degrees are converted to radians. | 207 | * converted to millimeters. Degrees are converted to radians. |
208 | */ | 208 | */ |
209 | static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) | 209 | static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) |
210 | { | 210 | { |
@@ -225,13 +225,16 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) | |||
225 | */ | 225 | */ |
226 | if (code == ABS_X || code == ABS_Y || code == ABS_Z) { | 226 | if (code == ABS_X || code == ABS_Y || code == ABS_Z) { |
227 | if (field->unit == 0x11) { /* If centimeters */ | 227 | if (field->unit == 0x11) { /* If centimeters */ |
228 | /* Convert to inches */ | 228 | /* Convert to millimeters */ |
229 | prev = logical_extents; | 229 | unit_exponent += 1; |
230 | logical_extents *= 254; | 230 | } else if (field->unit == 0x13) { /* If inches */ |
231 | if (logical_extents < prev) | 231 | /* Convert to millimeters */ |
232 | prev = physical_extents; | ||
233 | physical_extents *= 254; | ||
234 | if (physical_extents < prev) | ||
232 | return 0; | 235 | return 0; |
233 | unit_exponent += 2; | 236 | unit_exponent -= 1; |
234 | } else if (field->unit != 0x13) { /* If not inches */ | 237 | } else { |
235 | return 0; | 238 | return 0; |
236 | } | 239 | } |
237 | } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) { | 240 | } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) { |
@@ -287,6 +290,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
287 | goto ignore; | 290 | goto ignore; |
288 | } | 291 | } |
289 | 292 | ||
293 | if (field->report_type == HID_FEATURE_REPORT) { | ||
294 | if (device->driver->feature_mapping) { | ||
295 | device->driver->feature_mapping(device, hidinput, field, | ||
296 | usage); | ||
297 | } | ||
298 | goto ignore; | ||
299 | } | ||
300 | |||
290 | if (device->driver->input_mapping) { | 301 | if (device->driver->input_mapping) { |
291 | int ret = device->driver->input_mapping(device, hidinput, field, | 302 | int ret = device->driver->input_mapping(device, hidinput, field, |
292 | usage, &bit, &max); | 303 | usage, &bit, &max); |
@@ -316,21 +327,21 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
316 | 327 | ||
317 | switch (field->application) { | 328 | switch (field->application) { |
318 | case HID_GD_MOUSE: | 329 | case HID_GD_MOUSE: |
319 | case HID_GD_POINTER: code += 0x110; break; | 330 | case HID_GD_POINTER: code += BTN_MOUSE; break; |
320 | case HID_GD_JOYSTICK: | 331 | case HID_GD_JOYSTICK: |
321 | if (code <= 0xf) | 332 | if (code <= 0xf) |
322 | code += BTN_JOYSTICK; | 333 | code += BTN_JOYSTICK; |
323 | else | 334 | else |
324 | code += BTN_TRIGGER_HAPPY; | 335 | code += BTN_TRIGGER_HAPPY; |
325 | break; | 336 | break; |
326 | case HID_GD_GAMEPAD: code += 0x130; break; | 337 | case HID_GD_GAMEPAD: code += BTN_GAMEPAD; break; |
327 | default: | 338 | default: |
328 | switch (field->physical) { | 339 | switch (field->physical) { |
329 | case HID_GD_MOUSE: | 340 | case HID_GD_MOUSE: |
330 | case HID_GD_POINTER: code += 0x110; break; | 341 | case HID_GD_POINTER: code += BTN_MOUSE; break; |
331 | case HID_GD_JOYSTICK: code += 0x120; break; | 342 | case HID_GD_JOYSTICK: code += BTN_JOYSTICK; break; |
332 | case HID_GD_GAMEPAD: code += 0x130; break; | 343 | case HID_GD_GAMEPAD: code += BTN_GAMEPAD; break; |
333 | default: code += 0x100; | 344 | default: code += BTN_MISC; |
334 | } | 345 | } |
335 | } | 346 | } |
336 | 347 | ||
@@ -814,14 +825,14 @@ static int hidinput_open(struct input_dev *dev) | |||
814 | { | 825 | { |
815 | struct hid_device *hid = input_get_drvdata(dev); | 826 | struct hid_device *hid = input_get_drvdata(dev); |
816 | 827 | ||
817 | return hid->ll_driver->open(hid); | 828 | return hid_hw_open(hid); |
818 | } | 829 | } |
819 | 830 | ||
820 | static void hidinput_close(struct input_dev *dev) | 831 | static void hidinput_close(struct input_dev *dev) |
821 | { | 832 | { |
822 | struct hid_device *hid = input_get_drvdata(dev); | 833 | struct hid_device *hid = input_get_drvdata(dev); |
823 | 834 | ||
824 | hid->ll_driver->close(hid); | 835 | hid_hw_close(hid); |
825 | } | 836 | } |
826 | 837 | ||
827 | /* | 838 | /* |
@@ -836,7 +847,6 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
836 | struct hid_input *hidinput = NULL; | 847 | struct hid_input *hidinput = NULL; |
837 | struct input_dev *input_dev; | 848 | struct input_dev *input_dev; |
838 | int i, j, k; | 849 | int i, j, k; |
839 | int max_report_type = HID_OUTPUT_REPORT; | ||
840 | 850 | ||
841 | INIT_LIST_HEAD(&hid->inputs); | 851 | INIT_LIST_HEAD(&hid->inputs); |
842 | 852 | ||
@@ -853,10 +863,11 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
853 | return -1; | 863 | return -1; |
854 | } | 864 | } |
855 | 865 | ||
856 | if (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) | 866 | for (k = HID_INPUT_REPORT; k <= HID_FEATURE_REPORT; k++) { |
857 | max_report_type = HID_INPUT_REPORT; | 867 | if (k == HID_OUTPUT_REPORT && |
868 | hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) | ||
869 | continue; | ||
858 | 870 | ||
859 | for (k = HID_INPUT_REPORT; k <= max_report_type; k++) | ||
860 | list_for_each_entry(report, &hid->report_enum[k].report_list, list) { | 871 | list_for_each_entry(report, &hid->report_enum[k].report_list, list) { |
861 | 872 | ||
862 | if (!report->maxfield) | 873 | if (!report->maxfield) |
@@ -868,7 +879,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
868 | if (!hidinput || !input_dev) { | 879 | if (!hidinput || !input_dev) { |
869 | kfree(hidinput); | 880 | kfree(hidinput); |
870 | input_free_device(input_dev); | 881 | input_free_device(input_dev); |
871 | err_hid("Out of memory during hid input probe"); | 882 | hid_err(hid, "Out of memory during hid input probe\n"); |
872 | goto out_unwind; | 883 | goto out_unwind; |
873 | } | 884 | } |
874 | 885 | ||
@@ -877,8 +888,8 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
877 | hid->ll_driver->hidinput_input_event; | 888 | hid->ll_driver->hidinput_input_event; |
878 | input_dev->open = hidinput_open; | 889 | input_dev->open = hidinput_open; |
879 | input_dev->close = hidinput_close; | 890 | input_dev->close = hidinput_close; |
880 | input_dev->setkeycode_new = hidinput_setkeycode; | 891 | input_dev->setkeycode = hidinput_setkeycode; |
881 | input_dev->getkeycode_new = hidinput_getkeycode; | 892 | input_dev->getkeycode = hidinput_getkeycode; |
882 | 893 | ||
883 | input_dev->name = hid->name; | 894 | input_dev->name = hid->name; |
884 | input_dev->phys = hid->phys; | 895 | input_dev->phys = hid->phys; |
@@ -909,6 +920,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
909 | hidinput = NULL; | 920 | hidinput = NULL; |
910 | } | 921 | } |
911 | } | 922 | } |
923 | } | ||
912 | 924 | ||
913 | if (hidinput && input_register_device(hidinput->input)) | 925 | if (hidinput && input_register_device(hidinput->input)) |
914 | goto out_cleanup; | 926 | goto out_cleanup; |