Skip to content

Commit e04955d

Browse files
roadrunner2Jiri Kosina
authored andcommitted
HID: Recognize sensors with application collections
According to HUTRR39 logical sensor devices may be nested inside physical collections or may be specified in multiple top-level application collections (see page 59, strategies 1 and 2). However, the current code was only recognizing those with physical collections. This issue turned up in the T2 MacBook Pros which define the ALS in a top-level application collection. Signed-off-by: Ronald Tschalär <[email protected]> Signed-off-by: Aditya Garg <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 52d2253 commit e04955d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/hid/hid-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ static void hid_scan_collection(struct hid_parser *parser, unsigned type)
804804
int i;
805805

806806
if (((parser->global.usage_page << 16) == HID_UP_SENSOR) &&
807-
type == HID_COLLECTION_PHYSICAL)
807+
(type == HID_COLLECTION_PHYSICAL ||
808+
type == HID_COLLECTION_APPLICATION))
808809
hid->group = HID_GROUP_SENSOR_HUB;
809810

810811
if (hid->vendor == USB_VENDOR_ID_MICROSOFT &&

drivers/hid/hid-sensor-hub.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
397397
for (i = 0; i < report->maxfield; ++i) {
398398
field = report->field[i];
399399
if (field->maxusage) {
400-
if (field->physical == usage_id &&
400+
if ((field->physical == usage_id ||
401+
field->application == usage_id) &&
401402
(field->logical == attr_usage_id ||
402403
field->usage[0].hid ==
403404
attr_usage_id) &&
@@ -506,7 +507,8 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
506507
collection->usage);
507508

508509
callback = sensor_hub_get_callback(hdev,
509-
report->field[i]->physical,
510+
report->field[i]->physical ? report->field[i]->physical :
511+
report->field[i]->application,
510512
report->field[i]->usage[0].collection_index,
511513
&hsdev, &priv);
512514
if (!callback) {

0 commit comments

Comments
 (0)