diff options
| -rw-r--r-- | drivers/hid/hid-core.c | 11 | ||||
| -rw-r--r-- | drivers/hid/hid-input.c | 13 |
2 files changed, 10 insertions, 14 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 5a8c01112a23..a9ca93c1192c 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -319,7 +319,7 @@ static s32 item_sdata(struct hid_item *item) | |||
| 319 | 319 | ||
| 320 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) | 320 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) |
| 321 | { | 321 | { |
| 322 | __u32 raw_value; | 322 | __s32 raw_value; |
| 323 | switch (item->tag) { | 323 | switch (item->tag) { |
| 324 | case HID_GLOBAL_ITEM_TAG_PUSH: | 324 | case HID_GLOBAL_ITEM_TAG_PUSH: |
| 325 | 325 | ||
| @@ -370,10 +370,11 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) | |||
| 370 | return 0; | 370 | return 0; |
| 371 | 371 | ||
| 372 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: | 372 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: |
| 373 | /* Units exponent negative numbers are given through a | 373 | /* Many devices provide unit exponent as a two's complement |
| 374 | * two's complement. | 374 | * nibble due to the common misunderstanding of HID |
| 375 | * See "6.2.2.7 Global Items" for more information. */ | 375 | * specification 1.11, 6.2.2.7 Global Items. Attempt to handle |
| 376 | raw_value = item_udata(item); | 376 | * both this and the standard encoding. */ |
| 377 | raw_value = item_sdata(item); | ||
| 377 | if (!(raw_value & 0xfffffff0)) | 378 | if (!(raw_value & 0xfffffff0)) |
| 378 | parser->global.unit_exponent = hid_snto32(raw_value, 4); | 379 | parser->global.unit_exponent = hid_snto32(raw_value, 4); |
| 379 | else | 380 | else |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 8741d953dcc8..d97f2323af57 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
| @@ -192,6 +192,7 @@ static int hidinput_setkeycode(struct input_dev *dev, | |||
| 192 | return -EINVAL; | 192 | return -EINVAL; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | |||
| 195 | /** | 196 | /** |
| 196 | * hidinput_calc_abs_res - calculate an absolute axis resolution | 197 | * hidinput_calc_abs_res - calculate an absolute axis resolution |
| 197 | * @field: the HID report field to calculate resolution for | 198 | * @field: the HID report field to calculate resolution for |
| @@ -234,23 +235,17 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) | |||
| 234 | case ABS_MT_TOOL_Y: | 235 | case ABS_MT_TOOL_Y: |
| 235 | case ABS_MT_TOUCH_MAJOR: | 236 | case ABS_MT_TOUCH_MAJOR: |
| 236 | case ABS_MT_TOUCH_MINOR: | 237 | case ABS_MT_TOUCH_MINOR: |
| 237 | if (field->unit & 0xffffff00) /* Not a length */ | 238 | if (field->unit == 0x11) { /* If centimeters */ |
| 238 | return 0; | ||
| 239 | unit_exponent += hid_snto32(field->unit >> 4, 4) - 1; | ||
| 240 | switch (field->unit & 0xf) { | ||
| 241 | case 0x1: /* If centimeters */ | ||
| 242 | /* Convert to millimeters */ | 239 | /* Convert to millimeters */ |
| 243 | unit_exponent += 1; | 240 | unit_exponent += 1; |
| 244 | break; | 241 | } else if (field->unit == 0x13) { /* If inches */ |
| 245 | case 0x3: /* If inches */ | ||
| 246 | /* Convert to millimeters */ | 242 | /* Convert to millimeters */ |
| 247 | prev = physical_extents; | 243 | prev = physical_extents; |
| 248 | physical_extents *= 254; | 244 | physical_extents *= 254; |
| 249 | if (physical_extents < prev) | 245 | if (physical_extents < prev) |
| 250 | return 0; | 246 | return 0; |
| 251 | unit_exponent -= 1; | 247 | unit_exponent -= 1; |
| 252 | break; | 248 | } else { |
| 253 | default: | ||
| 254 | return 0; | 249 | return 0; |
| 255 | } | 250 | } |
| 256 | break; | 251 | break; |
