From patchwork Sat Dec 17 07:26:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 34200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1415587wrn; Sat, 17 Dec 2022 00:27:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf4vRUvOdVlT75Kw7wh0YAOud1E0EquRAnYYu1K4sETfoEHX4CxCrrDjGKbspQkKZcUGr9CW X-Received: by 2002:a62:fb11:0:b0:56c:3696:ad68 with SMTP id x17-20020a62fb11000000b0056c3696ad68mr35724565pfm.8.1671265650651; Sat, 17 Dec 2022 00:27:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671265650; cv=pass; d=google.com; s=arc-20160816; b=mKsiKxkUoeNAviNoBGJigG+g5rniXLg0nyA6fPCnkXpCPrEmwylFi5YowrITskN/6J /a3mLRUDXHiPcIzIsweIuAuXxZ/gcQUUmtLa7f7UryTPe7G32X1SX8uxDn0UMNCqYJYG UiwrX3AcMht91xab3RGUkUbA5J84BHblPWzjte2lUtjhlEbnUg7MNBbGfabt5Y9g5x+c eaGBdPbs8G7rnD3lmo8yczbrm8lhTnefT8f3yaU616tufe3sWOhhDQCa7ZIMIQx4IPm3 kPk2N1x0og0y23TuzDLlEoaLs6Pq/hAFDT1hwG/5wMhLrbdji+M6sVQurS1oxJr0ZECS O0ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=bk3If8EM1PQyR4GLuYT5i2TprxcQAc76MEJqrGYRHl8=; b=J92U68xxcjn5J1H8alJsq9AgOGZXz3SL7jg5EAc2rvfx6ROd+/CS1sv6rrvcY1goRp xdgpEeikaJKbRgofs3gXboN57hULxVc511Ae/e6FB6xzG4QUGdpwKCdD2fXQMR5rnE0w NyQisGLn93KreVxPGXZVQJyjiXCzR6LQlfdPA4VKnJHnKziHggpzr7xM5SJqbgicIkph 0WkJb4Z3bxl0AFYg50Nrg8P8QXmgyo8DgDKrQJkYLdFVsQ4BS4iO9Uct0r7YgUpESCFE N3x+M3VwHgCnrH6KJnrSDSaUppyAxC/3fuuh/33CwWWTOF5rKDIjDE04JeWm2+JuG73h +o2Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=fFAnIpR1; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=live.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c25-20020aa78819000000b005786897552esi4622595pfo.33.2022.12.17.00.27.16; Sat, 17 Dec 2022 00:27:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=fFAnIpR1; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=live.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbiLQH0y (ORCPT + 99 others); Sat, 17 Dec 2022 02:26:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiLQH0v (ORCPT ); Sat, 17 Dec 2022 02:26:51 -0500 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2086.outbound.protection.outlook.com [40.92.103.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B98E17; Fri, 16 Dec 2022 23:26:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hfMSRWp23f3YmHYdekfMU21wW9WTXIkq7HLanWhj5o6ovgBJZEIzRrnXche44ZUYg4e3DK5oXr5MKOJn3hrdXXxzrvG82xqLrLZniDhKkKzB5mrV14hDgZGpT9FoOVFxs6meiduYi1TUZtZnNVrpw+KjkMSLmiU0/c80ankum7/kffXKnkU6pmDvx1dgwE+Ul1Y88vyW4OfWsJ12Md61tTZ5BUuG1AIvJtEcEYg3ZxwBB/Snr4ueIFMZlKEkGIOTlleKUt0iFpwOOkn6kqZcyyV4Fc31hXFJzYv4fiRq3RpVOeMsIc2Yo4aBsNXn9/PUlD4Z3Pg72biYyTAvAMfT7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bk3If8EM1PQyR4GLuYT5i2TprxcQAc76MEJqrGYRHl8=; b=LEl3y4tt2PGaGl9QFTAq67OuHaQ6DXtootYXgAhloEcPZ7JGp/Innn4Gxg7O7jRwqIqv7BadG+/ZNrXg9WdF8KkZP9DwcE3AQMXtq5CUD/CGgFQy4uSxwjNCfLE1/9wgs58Cj2DjmCkMjV0RXvNGvgboCuP3HnCtUrSi4wbpjYtILUHkxPHGRcRboIOffCyz9MKB6sReosegTn8au49ayw8ZM0XuGSDwpRyPyX8cI0fwloMaLjaE6YxE6nS2sJCXWuJ9YnJCQXkkjTdilYq0iGB0RfXtnkC73verWhPXhilRBnXD86ljjyVblHU88q4/0pWrOgOSfafIhocy8UQvTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bk3If8EM1PQyR4GLuYT5i2TprxcQAc76MEJqrGYRHl8=; b=fFAnIpR1ffgpMh56jfOkGpqxjuxd0N7Qx9L2gD4i66y+NG+T6Egnz61WTOHVFpMF65bwDHbCD5Op41XpLLYGkRRLymVA7mvKKmjWQc6MWtdD+HfisarJs+SsBaW0WYP4agegkjuu5IaJ/kkFYMsFltw6hL8BnXF5cfP+qQWT18QAzaUJJTAXENtAAqHgXb6NcJjWK/Z9gh8lhCryqR8mjXcJuBLYNR5OQLV+bYbTF6jyCY8o1cIPUukjLEAwTAMA2ZTdjLw/zpEAyApwmjrfZ1wFpVZ0bykQna+5P7s+S33TYpbQOEAWnDintAtTxjs0KvPhnFyya/YRq3UmWvXrOQ== Received: from BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:2::9) by PN0PR01MB5690.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:62::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11; Sat, 17 Dec 2022 07:26:42 +0000 Received: from BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM ([fe80::9758:2410:fd85:511a]) by BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM ([fe80::9758:2410:fd85:511a%7]) with mapi id 15.20.5924.016; Sat, 17 Dec 2022 07:26:42 +0000 From: Aditya Garg To: Jiri Kosina , "jkosina@suse.cz" , "benjamin.tissoires@redhat.com" , "jic23@kernel.org" , "srinivas.pandruvada@linux.intel.com" , "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-iio@vger.kernel.org" CC: Orlando Chamberlain Subject: [PATCH] HID: Recognize sensors with application collections too. Thread-Topic: [PATCH] HID: Recognize sensors with application collections too. Thread-Index: AQHZEejpxeN0O9mCjEWaxsQGHt35aQ== Date: Sat, 17 Dec 2022 07:26:42 +0000 Message-ID: <8DA00FF4-DB08-4CEC-A5B4-47A71DC09C13@live.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [NbbNw7J8Oljuf0+P9kWkQurrURltQfrd] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BM1PR01MB0931:EE_|PN0PR01MB5690:EE_ x-ms-office365-filtering-correlation-id: 234b38e8-b765-4a31-7354-08dae0000b92 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TMkiTrAxrWpI/5xyy8BIPDwGjorHtInvLDhFlnd+/aAdev0/PcAITFBsaRByYwSzzBLlscql3FfW+gbKzyDklCQYzoOuceAQpKGPyEWixQ5WsyEdP/FBNYDGsVg0GanbkiirpHZQ9VigZC9jTwa6TLOrCNEe0W/irj+EtLSbCCaGw0dWsW1CiPp45sXFEqZp+OxogC8K0ZK28z0j1jGiIUGWnwySlyct0IKindVFrPouHDnF5AAn0JjFYewLq7dnQRIx4gjKwKZqxyr9YD7QfKuYbM4RYRDVitfvsJk/eV4qyZXSC53NfLnUTyzAPL3sWIRR69JpSlzU7lfgVQrSjjj1iPV9hOjjHtGUk5BlEGExUAXSNiYJh65kGiu11eRp375vDKu22OnWgRlMmyi3WWtaktnxFO6/yNdfw3ZChHeUGq4juVTdI6vV270CrSqyS4EVfap/GEj9/hL8ZBJOq1ehawAALRPIcLsGpQPJioi5ZwKObRQ4HJyU+ZUgzX4ulsU8qgFNW/IlihDZW/O9x0rTHj7jLIjE6xJYs7I2b9WIorjdDWlRPbAAWpBonEGsU8YwnFrgLI61MfJ6lFtDcnK76RhTfEsAtxqbbZAxxd0= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?oKOEdrYBx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X6JLlK5/b5MxtIOwAhVVlNQS?= =?utf-8?q?VG3tQlnsyYy44OAMuB7UAqKZW47kAle3vekyEBjHVDQLVZa+Jzg4wD8wI376D+5/i?= =?utf-8?q?LvUc9bGyAp4ZW4aOj4xJQ1DQArjGecic0w4IQLSitncARGEWoMvlH5TLV49YYexMG?= =?utf-8?q?aUiuzrvcXbtdEmy21WtO4KM5QjkyPMDUiuxATMMkH0MAPHLZvRxRXOwmcYp+CKdLh?= =?utf-8?q?SqKtltI5oB98O0uN1mSrtTHYChHEoakULJjpRFsg/1f/FDGCM5JvJNnoKM+klOG4O?= =?utf-8?q?cgsIq+d74lEwew7rqjiDCGVWo+Znz7rltj4SXsoSaQdOOpMCnmK7BIPIF5uM6W13X?= =?utf-8?q?K1omf9DyUG/PcV7QQxE/cHTkNUzvTMnwg6uzgxQ=3D=3D?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-42ed3.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 234b38e8-b765-4a31-7354-08dae0000b92 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2022 07:26:42.4803 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN0PR01MB5690 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752449050690025536?= X-GMAIL-MSGID: =?utf-8?q?1752449050690025536?= From: Ronald Tschalär 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 recent MacBook Pro's which define the ALS in a top-level application collection. Signed-off-by: Ronald Tschalär Signed-off-by: Aditya Garg --- drivers/hid/hid-core.c | 3 ++- drivers/hid/hid-sensor-hub.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) -- 2.38.1 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index b7f5566e338d..8fcd663b10e2 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -804,7 +804,8 @@ static void hid_scan_collection(struct hid_parser *parser, unsigned type) int i; if (((parser->global.usage_page << 16) == HID_UP_SENSOR) && - type == HID_COLLECTION_PHYSICAL) + (type == HID_COLLECTION_PHYSICAL || + type == HID_COLLECTION_APPLICATION)) hid->group = HID_GROUP_SENSOR_HUB; if (hid->vendor == USB_VENDOR_ID_MICROSOFT && diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 6abd3e2a9094..d03dc4ca095f 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -397,7 +397,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, for (i = 0; i < report->maxfield; ++i) { field = report->field[i]; if (field->maxusage) { - if (field->physical == usage_id && + if ((field->physical == usage_id || + field->application == usage_id) && (field->logical == attr_usage_id || field->usage[0].hid == attr_usage_id) && @@ -506,7 +507,8 @@ static int sensor_hub_raw_event(struct hid_device *hdev, collection->usage); callback = sensor_hub_get_callback(hdev, - report->field[i]->physical, + report->field[i]->physical ?: + report->field[i]->application, report->field[i]->usage[0].collection_index, &hsdev, &priv); if (!callback) {