diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-24 15:44:59 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-24 15:44:59 -0400 |
| commit | 7c024e9534f9edd8d052380a1b40d376c8feb11b (patch) | |
| tree | 521eeb9d1eaa851e254a372bd008a07ab1f5e574 /drivers/hid/hid-input.c | |
| parent | 188e213dbc5758bbfb62f7ce0367c5c8de057f02 (diff) | |
| parent | d8692ac012104ebffb343c0bcb4a2b8642c821a6 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (47 commits)
HID: fix mismerge in hid-lg
HID: hidraw: fix window in hidraw_release
HID: hid-sony: override usbhid_output_raw_report for Sixaxis
HID: add absolute axis resolution calculation
HID: force feedback support for Logitech RumblePad gamepad
HID: support STmicroelectronics and Sitronix with hid-stantuml driver
HID: magicmouse: Adjust major / minor axes to scale
HID: Fix for problems with eGalax/DWAV multi-touch-screen
HID: waltop: add support for Waltop Slim Tablet 12.1 inch
HID: add NOGET quirk for AXIS 295 Video Surveillance Joystick
HID: usbhid: remove unused hiddev_driver
HID: magicmouse: Use hid-input parsing rather than bypassing it
HID: trivial formatting fix
HID: Add support for Logitech Speed Force Wireless gaming wheel
HID: don't Send Feature Reports on Interrupt Endpoint
HID: 3m: Adjust major / minor axes to scale
HID: 3m: Correct touchscreen emulation
HID: 3m: Convert to MT slots
HID: 3m: Output proper orientation range
HID: 3m: Adjust to sequential MT HID protocol
...
Diffstat (limited to 'drivers/hid/hid-input.c')
| -rw-r--r-- | drivers/hid/hid-input.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 6c03dcc5760a..834ef47b76d6 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
| @@ -149,6 +149,83 @@ static int hidinput_setkeycode(struct input_dev *dev, | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | 151 | ||
| 152 | /** | ||
| 153 | * hidinput_calc_abs_res - calculate an absolute axis resolution | ||
| 154 | * @field: the HID report field to calculate resolution for | ||
| 155 | * @code: axis code | ||
| 156 | * | ||
| 157 | * The formula is: | ||
| 158 | * (logical_maximum - logical_minimum) | ||
| 159 | * resolution = ---------------------------------------------------------- | ||
| 160 | * (physical_maximum - physical_minimum) * 10 ^ unit_exponent | ||
| 161 | * | ||
| 162 | * as seen in the HID specification v1.11 6.2.2.7 Global Items. | ||
| 163 | * | ||
| 164 | * Only exponent 1 length units are processed. Centimeters are converted to | ||
| 165 | * inches. Degrees are converted to radians. | ||
| 166 | */ | ||
| 167 | static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) | ||
| 168 | { | ||
| 169 | __s32 unit_exponent = field->unit_exponent; | ||
| 170 | __s32 logical_extents = field->logical_maximum - | ||
| 171 | field->logical_minimum; | ||
| 172 | __s32 physical_extents = field->physical_maximum - | ||
| 173 | field->physical_minimum; | ||
| 174 | __s32 prev; | ||
| 175 | |||
| 176 | /* Check if the extents are sane */ | ||
| 177 | if (logical_extents <= 0 || physical_extents <= 0) | ||
| 178 | return 0; | ||
| 179 | |||
| 180 | /* | ||
| 181 | * Verify and convert units. | ||
| 182 | * See HID specification v1.11 6.2.2.7 Global Items for unit decoding | ||
| 183 | */ | ||
| 184 | if (code == ABS_X || code == ABS_Y || code == ABS_Z) { | ||
| 185 | if (field->unit == 0x11) { /* If centimeters */ | ||
| 186 | /* Convert to inches */ | ||
| 187 | prev = logical_extents; | ||
| 188 | logical_extents *= 254; | ||
| 189 | if (logical_extents < prev) | ||
| 190 | return 0; | ||
| 191 | unit_exponent += 2; | ||
| 192 | } else if (field->unit != 0x13) { /* If not inches */ | ||
| 193 | return 0; | ||
| 194 | } | ||
| 195 | } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) { | ||
| 196 | if (field->unit == 0x14) { /* If degrees */ | ||
| 197 | /* Convert to radians */ | ||
| 198 | prev = logical_extents; | ||
| 199 | logical_extents *= 573; | ||
| 200 | if (logical_extents < prev) | ||
| 201 | return 0; | ||
| 202 | unit_exponent += 1; | ||
| 203 | } else if (field->unit != 0x12) { /* If not radians */ | ||
| 204 | return 0; | ||
| 205 | } | ||
| 206 | } else { | ||
| 207 | return 0; | ||
| 208 | } | ||
| 209 | |||
| 210 | /* Apply negative unit exponent */ | ||
| 211 | for (; unit_exponent < 0; unit_exponent++) { | ||
| 212 | prev = logical_extents; | ||
| 213 | logical_extents *= 10; | ||
| 214 | if (logical_extents < prev) | ||
| 215 | return 0; | ||
| 216 | } | ||
| 217 | /* Apply positive unit exponent */ | ||
| 218 | for (; unit_exponent > 0; unit_exponent--) { | ||
| 219 | prev = physical_extents; | ||
| 220 | physical_extents *= 10; | ||
| 221 | if (physical_extents < prev) | ||
| 222 | return 0; | ||
| 223 | } | ||
| 224 | |||
| 225 | /* Calculate resolution */ | ||
| 226 | return logical_extents / physical_extents; | ||
| 227 | } | ||
| 228 | |||
| 152 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 229 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
| 153 | struct hid_usage *usage) | 230 | struct hid_usage *usage) |
| 154 | { | 231 | { |
| @@ -336,6 +413,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 336 | map_key_clear(BTN_STYLUS); | 413 | map_key_clear(BTN_STYLUS); |
| 337 | break; | 414 | break; |
| 338 | 415 | ||
| 416 | case 0x46: /* TabletPick */ | ||
| 417 | map_key_clear(BTN_STYLUS2); | ||
| 418 | break; | ||
| 419 | |||
| 339 | default: goto unknown; | 420 | default: goto unknown; |
| 340 | } | 421 | } |
| 341 | break; | 422 | break; |
| @@ -537,6 +618,9 @@ mapped: | |||
| 537 | input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); | 618 | input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); |
| 538 | else input_set_abs_params(input, usage->code, a, b, 0, 0); | 619 | else input_set_abs_params(input, usage->code, a, b, 0, 0); |
| 539 | 620 | ||
| 621 | input_abs_set_res(input, usage->code, | ||
| 622 | hidinput_calc_abs_res(field, usage->code)); | ||
| 623 | |||
| 540 | /* use a larger default input buffer for MT devices */ | 624 | /* use a larger default input buffer for MT devices */ |
| 541 | if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0) | 625 | if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0) |
| 542 | input_set_events_per_packet(input, 60); | 626 | input_set_events_per_packet(input, 60); |
| @@ -659,6 +743,9 @@ void hidinput_report_event(struct hid_device *hid, struct hid_report *report) | |||
| 659 | { | 743 | { |
| 660 | struct hid_input *hidinput; | 744 | struct hid_input *hidinput; |
| 661 | 745 | ||
| 746 | if (hid->quirks & HID_QUIRK_NO_INPUT_SYNC) | ||
| 747 | return; | ||
| 748 | |||
| 662 | list_for_each_entry(hidinput, &hid->inputs, list) | 749 | list_for_each_entry(hidinput, &hid->inputs, list) |
| 663 | input_sync(hidinput->input); | 750 | input_sync(hidinput->input); |
| 664 | } | 751 | } |
