diff options
| -rw-r--r-- | drivers/hid/hid-microsoft.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c index 96e7d3231d2f..72d983626afd 100644 --- a/drivers/hid/hid-microsoft.c +++ b/drivers/hid/hid-microsoft.c | |||
| @@ -22,12 +22,13 @@ | |||
| 22 | 22 | ||
| 23 | #include "hid-ids.h" | 23 | #include "hid-ids.h" |
| 24 | 24 | ||
| 25 | #define MS_HIDINPUT 0x01 | 25 | #define MS_HIDINPUT BIT(0) |
| 26 | #define MS_ERGONOMY 0x02 | 26 | #define MS_ERGONOMY BIT(1) |
| 27 | #define MS_PRESENTER 0x04 | 27 | #define MS_PRESENTER BIT(2) |
| 28 | #define MS_RDESC 0x08 | 28 | #define MS_RDESC BIT(3) |
| 29 | #define MS_NOGET 0x10 | 29 | #define MS_NOGET BIT(4) |
| 30 | #define MS_DUPLICATE_USAGES 0x20 | 30 | #define MS_DUPLICATE_USAGES BIT(5) |
| 31 | #define MS_SURFACE_DIAL BIT(6) | ||
| 31 | 32 | ||
| 32 | static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, | 33 | static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 33 | unsigned int *rsize) | 34 | unsigned int *rsize) |
| @@ -130,6 +131,30 @@ static int ms_presenter_8k_quirk(struct hid_input *hi, struct hid_usage *usage, | |||
| 130 | return 1; | 131 | return 1; |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 134 | static int ms_surface_dial_quirk(struct hid_input *hi, struct hid_field *field, | ||
| 135 | struct hid_usage *usage, unsigned long **bit, int *max) | ||
| 136 | { | ||
| 137 | switch (usage->hid & HID_USAGE_PAGE) { | ||
| 138 | case 0xff070000: | ||
| 139 | /* fall-through */ | ||
| 140 | case HID_UP_DIGITIZER: | ||
| 141 | /* ignore those axis */ | ||
| 142 | return -1; | ||
| 143 | case HID_UP_GENDESK: | ||
| 144 | switch (usage->hid) { | ||
| 145 | case HID_GD_X: | ||
| 146 | /* fall-through */ | ||
| 147 | case HID_GD_Y: | ||
| 148 | /* fall-through */ | ||
| 149 | case HID_GD_RFKILL_BTN: | ||
| 150 | /* ignore those axis */ | ||
| 151 | return -1; | ||
| 152 | } | ||
| 153 | } | ||
| 154 | |||
| 155 | return 0; | ||
| 156 | } | ||
| 157 | |||
| 133 | static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi, | 158 | static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 134 | struct hid_field *field, struct hid_usage *usage, | 159 | struct hid_field *field, struct hid_usage *usage, |
| 135 | unsigned long **bit, int *max) | 160 | unsigned long **bit, int *max) |
| @@ -146,6 +171,13 @@ static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 146 | ms_presenter_8k_quirk(hi, usage, bit, max)) | 171 | ms_presenter_8k_quirk(hi, usage, bit, max)) |
| 147 | return 1; | 172 | return 1; |
| 148 | 173 | ||
| 174 | if (quirks & MS_SURFACE_DIAL) { | ||
| 175 | int ret = ms_surface_dial_quirk(hi, field, usage, bit, max); | ||
| 176 | |||
| 177 | if (ret) | ||
| 178 | return ret; | ||
| 179 | } | ||
| 180 | |||
| 149 | return 0; | 181 | return 0; |
| 150 | } | 182 | } |
| 151 | 183 | ||
| @@ -229,6 +261,9 @@ static int ms_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 229 | if (quirks & MS_NOGET) | 261 | if (quirks & MS_NOGET) |
| 230 | hdev->quirks |= HID_QUIRK_NOGET; | 262 | hdev->quirks |= HID_QUIRK_NOGET; |
| 231 | 263 | ||
| 264 | if (quirks & MS_SURFACE_DIAL) | ||
| 265 | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; | ||
| 266 | |||
| 232 | ret = hid_parse(hdev); | 267 | ret = hid_parse(hdev); |
| 233 | if (ret) { | 268 | if (ret) { |
| 234 | hid_err(hdev, "parse failed\n"); | 269 | hid_err(hdev, "parse failed\n"); |
| @@ -281,6 +316,8 @@ static const struct hid_device_id ms_devices[] = { | |||
| 281 | 316 | ||
| 282 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT), | 317 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT), |
| 283 | .driver_data = MS_PRESENTER }, | 318 | .driver_data = MS_PRESENTER }, |
| 319 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x091B), | ||
| 320 | .driver_data = MS_SURFACE_DIAL }, | ||
| 284 | { } | 321 | { } |
| 285 | }; | 322 | }; |
| 286 | MODULE_DEVICE_TABLE(hid, ms_devices); | 323 | MODULE_DEVICE_TABLE(hid, ms_devices); |
