Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343076
b: refs/heads/master
c: 7746383
h: refs/heads/master
v: v3
  • Loading branch information
Benjamin Tissoires authored and Jiri Kosina committed Nov 15, 2012
1 parent 414c058 commit a7b75ff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ccdd699411b77c463022ebac311eb4a06ca56db4
refs/heads/master: 774638386826621c984ab6994439f474709cac5e
16 changes: 15 additions & 1 deletion trunk/drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ static s32 item_sdata(struct hid_item *item)

static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
{
__u32 raw_value;
switch (item->tag) {
case HID_GLOBAL_ITEM_TAG_PUSH:

Expand Down Expand Up @@ -365,7 +366,14 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
return 0;

case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
parser->global.unit_exponent = item_sdata(item);
/* Units exponent negative numbers are given through a
* two's complement.
* See "6.2.2.7 Global Items" for more information. */
raw_value = item_udata(item);
if (!(raw_value & 0xfffffff0))
parser->global.unit_exponent = hid_snto32(raw_value, 4);
else
parser->global.unit_exponent = raw_value;
return 0;

case HID_GLOBAL_ITEM_TAG_UNIT:
Expand Down Expand Up @@ -865,6 +873,12 @@ static s32 snto32(__u32 value, unsigned n)
return value & (1 << (n - 1)) ? value | (-1 << n) : value;
}

s32 hid_snto32(__u32 value, unsigned n)
{
return snto32(value, n);
}
EXPORT_SYMBOL_GPL(hid_snto32);

/*
* Convert a signed 32-bit integer to a signed n-bit integer.
*/
Expand Down
13 changes: 9 additions & 4 deletions trunk/drivers/hid/hid-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ static int hidinput_setkeycode(struct input_dev *dev,
return -EINVAL;
}


/**
* hidinput_calc_abs_res - calculate an absolute axis resolution
* @field: the HID report field to calculate resolution for
Expand Down Expand Up @@ -235,17 +234,23 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
case ABS_MT_TOOL_Y:
case ABS_MT_TOUCH_MAJOR:
case ABS_MT_TOUCH_MINOR:
if (field->unit == 0x11) { /* If centimeters */
if (field->unit & 0xffffff00) /* Not a length */
return 0;
unit_exponent += hid_snto32(field->unit >> 4, 4) - 1;
switch (field->unit & 0xf) {
case 0x1: /* If centimeters */
/* Convert to millimeters */
unit_exponent += 1;
} else if (field->unit == 0x13) { /* If inches */
break;
case 0x3: /* If inches */
/* Convert to millimeters */
prev = physical_extents;
physical_extents *= 254;
if (physical_extents < prev)
return 0;
unit_exponent -= 1;
} else {
break;
default:
return 0;
}
break;
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ int hid_connect(struct hid_device *hid, unsigned int connect_mask);
void hid_disconnect(struct hid_device *hid);
const struct hid_device_id *hid_match_id(struct hid_device *hdev,
const struct hid_device_id *id);
s32 hid_snto32(__u32 value, unsigned n);

/**
* hid_map_usage - map usage input bits
Expand Down

0 comments on commit a7b75ff

Please sign in to comment.