aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-input.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-07 08:52:04 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-07 08:52:04 -0700
commitb4dd05dee0dbd16afdbba83b698a7110c687be2d (patch)
tree8f39c491301f4f62eacc2294a4e0825c9bf16548 /drivers/hid/hid-input.c
parentMerge tag 'i3c/for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux (diff)
parentMerge branches 'for-5.1/upstream-fixes', 'for-5.2/core', 'for-5.2/ish', 'for-5.2/logitech', 'for-5.2/macally', 'for-5.2/picolcd', 'for-5.2/sensor' and 'for-5.2/u2fzero' into for-linus (diff)
downloadlinux-dev-b4dd05dee0dbd16afdbba83b698a7110c687be2d.tar.xz
linux-dev-b4dd05dee0dbd16afdbba83b698a7110c687be2d.zip
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - support for U2F Zero device, from Andrej Shadura - logitech-dj has historically been treating devices behind non-unifying receivers as generic devices, using the HID emulation in the receiver. That had several shortcomings (special keys handling, battery level monitoring, etc). The driver has been reworked to enumarate (and directly communicate with) the devices behind the receiver, to avoid the (too) generic HID implementation in the receiver itself. All the work done by Benjamin Tissoires and Hans de Goede. - restructuring of intel-ish driver in order to allow for multiple clients of the ISH implementation, from Srinivas Pandruvada - several other smaller fixes and assorted device ID additions * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (68 commits) HID: logitech-dj: fix spelling in printk HID: input: fix assignment of .value HID: input: make sure the wheel high resolution multiplier is set HID: logitech-dj: add usbhid dependency in Kconfig HID: logitech-hidpp: add support for HID++ 1.0 consumer keys reports HID: logitech-hidpp: add support for HID++ 1.0 extra mouse buttons reports HID: logitech-hidpp: add support for HID++ 1.0 wheel reports HID: logitech-hidpp: make hidpp10_set_register_bit a bit more generic HID: logitech-hidpp: add input_device ptr to struct hidpp_device HID: logitech-hidpp: do not hardcode very long report length HID: logitech-hidpp: handle devices attached to 27MHz wireless receivers HID: logitech-hidpp: use RAP instead of FAP to get the protocol version HID: logitech-hidpp: remove unused origin_is_hid_core function parameter HID: logitech-hidpp: remove double assignment from __hidpp_send_report HID: logitech-hidpp: do not make failure to get the name fatal HID: logitech-hidpp: ignore very-short or empty names HID: logitech-hidpp: make .probe usbhid capable HID: logitech-hidpp: allow non HID++ devices to be handled by this module HID: logitech-dj: add support for Logitech Bluetooth Mini-Receiver HID: logitech-dj: make appending of the HID++ descriptors conditional ...
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r--drivers/hid/hid-input.c81
1 files changed, 50 insertions, 31 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index b607286a0bc8..46c6efea1404 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1557,52 +1557,71 @@ static void hidinput_close(struct input_dev *dev)
hid_hw_close(hid);
}
-static void hidinput_change_resolution_multipliers(struct hid_device *hid)
+static bool __hidinput_change_resolution_multipliers(struct hid_device *hid,
+ struct hid_report *report, bool use_logical_max)
{
- struct hid_report_enum *rep_enum;
- struct hid_report *rep;
struct hid_usage *usage;
+ bool update_needed = false;
int i, j;
- rep_enum = &hid->report_enum[HID_FEATURE_REPORT];
- list_for_each_entry(rep, &rep_enum->report_list, list) {
- bool update_needed = false;
+ if (report->maxfield == 0)
+ return false;
- if (rep->maxfield == 0)
- continue;
+ /*
+ * If we have more than one feature within this report we
+ * need to fill in the bits from the others before we can
+ * overwrite the ones for the Resolution Multiplier.
+ */
+ if (report->maxfield > 1) {
+ hid_hw_request(hid, report, HID_REQ_GET_REPORT);
+ hid_hw_wait(hid);
+ }
- /*
- * If we have more than one feature within this report we
- * need to fill in the bits from the others before we can
- * overwrite the ones for the Resolution Multiplier.
+ for (i = 0; i < report->maxfield; i++) {
+ __s32 value = use_logical_max ?
+ report->field[i]->logical_maximum :
+ report->field[i]->logical_minimum;
+
+ /* There is no good reason for a Resolution
+ * Multiplier to have a count other than 1.
+ * Ignore that case.
*/
- if (rep->maxfield > 1) {
- hid_hw_request(hid, rep, HID_REQ_GET_REPORT);
- hid_hw_wait(hid);
- }
+ if (report->field[i]->report_count != 1)
+ continue;
- for (i = 0; i < rep->maxfield; i++) {
- __s32 logical_max = rep->field[i]->logical_maximum;
+ for (j = 0; j < report->field[i]->maxusage; j++) {
+ usage = &report->field[i]->usage[j];
- /* There is no good reason for a Resolution
- * Multiplier to have a count other than 1.
- * Ignore that case.
- */
- if (rep->field[i]->report_count != 1)
+ if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER)
continue;
- for (j = 0; j < rep->field[i]->maxusage; j++) {
- usage = &rep->field[i]->usage[j];
+ report->field[i]->value[j] = value;
+ update_needed = true;
+ }
+ }
+
+ return update_needed;
+}
- if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER)
- continue;
+static void hidinput_change_resolution_multipliers(struct hid_device *hid)
+{
+ struct hid_report_enum *rep_enum;
+ struct hid_report *rep;
+ int ret;
- *rep->field[i]->value = logical_max;
- update_needed = true;
+ rep_enum = &hid->report_enum[HID_FEATURE_REPORT];
+ list_for_each_entry(rep, &rep_enum->report_list, list) {
+ bool update_needed = __hidinput_change_resolution_multipliers(hid,
+ rep, true);
+
+ if (update_needed) {
+ ret = __hid_request(hid, rep, HID_REQ_SET_REPORT);
+ if (ret) {
+ __hidinput_change_resolution_multipliers(hid,
+ rep, false);
+ return;
}
}
- if (update_needed)
- hid_hw_request(hid, rep, HID_REQ_SET_REPORT);
}
/* refresh our structs */