Skip to content

Commit bebcc52

Browse files
bentissJiri Kosina
authored andcommitted
HID: core: for input reports, process the usages by priority list
Now that we have a list of fields/usages by priority order, walk through that list to process the inputs instead of using the order provided by the manufacturer. Note that this changes the way we update the values in the struct hid_field: Previously, once a field was processed, we updated the new values. Now we need to wait for the entire report to be processed to update the values. I don't think it will be an issue: because we were relying on the device ordering, there were no guarantees to have a field stored before an other. Which is why we introduced .report() in drivers to have those values updated. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Ping Cheng <ping.cheng@wacom.com> Acked-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 22f4b02 commit bebcc52

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

drivers/hid/hid-core.c

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,17 +1657,48 @@ static void hid_process_report(struct hid_device *hid,
16571657
int interrupt)
16581658
{
16591659
unsigned int a;
1660+
struct hid_field_entry *entry;
16601661
struct hid_field *field;
16611662

1662-
for (a = 0; a < report->maxfield; a++) {
1663-
field = report->field[a];
1663+
/* first retrieve all incoming values in data */
1664+
for (a = 0; a < report->maxfield; a++)
1665+
hid_input_fetch_field(hid, field = report->field[a], data);
1666+
1667+
if (!list_empty(&report->field_entry_list)) {
1668+
/* INPUT_REPORT, we have a priority list of fields */
1669+
list_for_each_entry(entry,
1670+
&report->field_entry_list,
1671+
list) {
1672+
field = entry->field;
1673+
1674+
if (field->flags & HID_MAIN_ITEM_VARIABLE)
1675+
hid_process_event(hid,
1676+
field,
1677+
&field->usage[entry->index],
1678+
field->new_value[entry->index],
1679+
interrupt);
1680+
else
1681+
hid_input_array_field(hid, field, interrupt);
1682+
}
16641683

1665-
hid_input_fetch_field(hid, field, data);
1684+
/* we need to do the memcpy at the end for var items */
1685+
for (a = 0; a < report->maxfield; a++) {
1686+
field = report->field[a];
16661687

1667-
if (field->flags & HID_MAIN_ITEM_VARIABLE)
1668-
hid_input_var_field(hid, field, interrupt);
1669-
else
1670-
hid_input_array_field(hid, field, interrupt);
1688+
if (field->flags & HID_MAIN_ITEM_VARIABLE)
1689+
memcpy(field->value, field->new_value,
1690+
field->report_count * sizeof(__s32));
1691+
}
1692+
} else {
1693+
/* FEATURE_REPORT, regular processing */
1694+
for (a = 0; a < report->maxfield; a++) {
1695+
field = report->field[a];
1696+
1697+
if (field->flags & HID_MAIN_ITEM_VARIABLE)
1698+
hid_input_var_field(hid, field, interrupt);
1699+
else
1700+
hid_input_array_field(hid, field, interrupt);
1701+
}
16711702
}
16721703
}
16731704

0 commit comments

Comments
 (0)