From patchwork Tue Jan 10 08:57:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 41369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2638230wrt; Tue, 10 Jan 2023 01:09:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXslfkhelKUlbJrmTEtgS1mc9LmnNJNdEDIXWmRv+8FpkedULcf+N1kKgsSu4jFtUdZxI5I0 X-Received: by 2002:a17:902:ce08:b0:189:81dd:6b8b with SMTP id k8-20020a170902ce0800b0018981dd6b8bmr95543475plg.63.1673341779137; Tue, 10 Jan 2023 01:09:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673341779; cv=pass; d=google.com; s=arc-20160816; b=QgwVH5IkJ09JrzLqiCQhDT7jf/P659b/y7vBbsnclNlCSq9C3WmLZhlcC00S5ch6FX 5G8TERsZc5m/IB3wRDUhpAjmlYq9YOjj81Ecs6Q5rkA7ope6RMWCWqDGChAVxmtWXqRl ExGjpvgATwp9+wmJZVf/MJ8Om3SkNmqzPAOh/OnA0r6O1XhhffdUfdlA998csRADrExS tAYdKbdgYdY2xfXnVABnSwARHm35LiVoabbtch1gUV/0bpWLbSmjISOmGkKTKJXiOswi QT79wpvjQOZkGKqLjb/HJLbfV5ylpEWLbdz3SL1hx4ZOF7fqch776ppKpGVSE+I+WX69 nIKw== 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:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=DJ+JSh8VdcdlVdhK3YrfTF+0PHYj5uvFL/qOQS5mtrs=; b=cvnPaNqgRjcPNYzstPcbuF3qKp1gt3Hx2u1WKoOEwwsHnCnKH60Hg9m7IorWgx0PaO Cp9AHlBS6nL5yJulo3DYwIjGzy7q3DGlUFxGjnlaD5bQV8yUaw686wm/QjdnFlLpqVDl FV2HfsjFpdlFXwD4VrPu/s4BR3jkTjhyFNzGyalwTqP65k9+yqL7md2OA/OBOOEvGbYG NM6mZSu3zp/FWO5gnTeA4a8XhNn0Bq2+tFaNyggQ+31Ref0a2cmRWwqjRlR6kpF0dDRz 60Rw4m4lKK5pASP+YMRCJNBz2nSTfFuuSbGM+aecPHZ+eyNXvO+uvRHHA4wHSucKP6yn Dd4A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=LqyW5NSY; 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 z6-20020a170902ccc600b001898141f0edsi11309504ple.159.2023.01.10.01.09.27; Tue, 10 Jan 2023 01:09:39 -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=LqyW5NSY; 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 S231240AbjAJJEa (ORCPT + 99 others); Tue, 10 Jan 2023 04:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238430AbjAJI70 (ORCPT ); Tue, 10 Jan 2023 03:59:26 -0500 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2050.outbound.protection.outlook.com [40.92.103.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B3B4FD71; Tue, 10 Jan 2023 00:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aUl8Sn0Yb2JiSiXSvvcnWxGJuhMATG2BsBjRITUf4udE32iYCDH8F2v7gPC3vEPRD9+h8Cabi6mms9nOf2PVERSr5mr3LUiBR6GYQVu0Si+Judq6ht9L6eT27SOzy5WCGsFs1BPHvWP5HByarrjZfPF+mu3U0iQvH70M4VUa+uVPj2L0J1/nAFmYd8MJ6kwGRabxJrDgtdGFdrjjCBfKpFyg+Z/B2XevhzzgInhF/MTlyAXoJkS3DPtS6UQvHFndcBjUFqKSN/O4XY0eIapkEpbKMvrNko6//Caincq6USmhsIDZ+tXw5O/udz+7QbIXvmFcnmR/Nc/XPHld8AlVlg== 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=DJ+JSh8VdcdlVdhK3YrfTF+0PHYj5uvFL/qOQS5mtrs=; b=lz0aUG0LqwdlGwbNNqDDxz1DD2LE0E3J/Ekryr06CXavSwlLaGlv3uda8pKIGbOuY+23mEOqU62tclzdzoN1Hb/MiR0GVXGbtcD1elZiJuBxmgh3N3zPYT+ajqI43v0SZZOYIhTX9o2ZtmrvSXxij+6+zj3RYvV/fwhwJyl86Sta9nmAqAiEknPSoyupp8okuLvKH2jVcg0b/5mnqwivN5RUF9IAGMbT2sm1sJ1kUcTMiBiMC2E5JlAKYTtXMybPGDlk7jUGG0BhnqlqtKxQWto8wT387kNtCP2cX2ImM6AXTuCaDL09FvhZTjscbi8/Rv2T6t3QMWQDCmQnkpgF3w== 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=DJ+JSh8VdcdlVdhK3YrfTF+0PHYj5uvFL/qOQS5mtrs=; b=LqyW5NSYk0BGAdUlc0RxmgYjgC7R/ryzsm2/MoXcdvgmImQCUhpw37KbE8mhHD+vVtaqBMCpFOV8Ee+bH/oOKBYMCYRvr0yGdpRSCKfRduR4vBQtUWbVKOvfBHICMqb0nZcyo34Wd7S/PJPxvRJHyR+86SNsbBPO80njapGO8emdVYTrIIUKLMrTF0lIq8poSl0/PZYBfVAN0vKl+xhhyxq3grh9LwJ9J808LuCqRYChUlvcKFTVoHOw0KOHIffg4zSIsLuvrG5FxP5Ng+vzwZSbrSG6vEEeyvIL9M6fDMhNIRLZ5WPCPIc2Af54Iw/t1InHsjFeniFxZLqpuWD43A== Received: from BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:2::9) by PN0PR01MB7672.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11; Tue, 10 Jan 2023 08:57:28 +0000 Received: from BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM ([fe80::f2f0:34b5:eb58:bb5a]) by BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM ([fe80::f2f0:34b5:eb58:bb5a%6]) with mapi id 15.20.6002.010; Tue, 10 Jan 2023 08:57:28 +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" , LKML , "linux-iio@vger.kernel.org" CC: "orlandoch.dev@gmail.com" , "ronald@innovation.ch" Subject: [PATCH v2] HID: Recognize sensors with application collections too. Thread-Topic: [PATCH v2] HID: Recognize sensors with application collections too. Thread-Index: AQHZJNGQHGy5pxaqk0SG23+WPMWSag== Date: Tue, 10 Jan 2023 08:57:27 +0000 Message-ID: References: <8DA00FF4-DB08-4CEC-A5B4-47A71DC09C13@live.com> <01D620E2-18CA-40F6-A330-454CBC20C542@live.com> In-Reply-To: <01D620E2-18CA-40F6-A330-454CBC20C542@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: [WeZSo3tYEJvTUKOztUz6yf0QA9WnC7MiCNF8inqwknGZnGTodRx0I9r3ydfJQU69] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BM1PR01MB0931:EE_|PN0PR01MB7672:EE_ x-ms-office365-filtering-correlation-id: e50cf2a9-faf7-41b8-2906-08daf2e8b33a x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TqRz5Ris94fW5yyFS0Wx7m4rZboQpi8E3Li9eK5jWXtsk4vwMe1q9mjuU7Z8kZpq1vcWGx01FowYPJXsR7KlMyZ5hEg+6MHTuDLHi5JZPFlPTcUVomiwqunEQInEyHvD+4ZN8N4/6c3KQq9lN8v4IMkv6RLD6yFghWg8OGT9lrCrvf8GfwZsnV4wMvVmTt3QBnNXkzy6WWibtUG93Z4KSRCN+WvA0ctYfGb7mV1JllcLttXBGmwthK056J4dTEARYAJUe8pwbt8U+jWLMFt52d0SGvBewmL0lMnXfR/r36wnzdHdDgTvaBAJrNBgtHY2DbTwdi/EHJydv2m2MZwX7KkjDyeRcaaL0ztLWJEOaLxwbd/urKz45XeytbBox6TGXBFjk+Xk5eIejNNswdJMj5HvkjHhhJwd0osU4+hc8RrC9dbKe5cUsysM99dP2RvuS8wnRe34E6eWE6BPC9GXMfAo40y+rvx5KecFTwFUrdB84Mc5bGG9tp2HMxY9MkjpHL2trI1wn3BkWSviKqL8ZoWj3eOXosf4Sx8fkDpnAMqrQgOCkIascXRAXBXTv1XUNXjzXqATT7jao2zWA3d+fvw8P/+TJ9DQaiii1lbWAho= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?2CScJzGVLVD3T0qM9LlvglKs33uU?= =?utf-8?q?es0Q0hiwJM/O/sIdMZPWW60wRP9v4khjiYrxQL6ApjlXgj3CKLiLP5G3Hq2V3zl3y?= =?utf-8?q?P0nMyex1l9PH7p2CJ3SJj5krE6riL3OgMHwIueZ7s2peZGB6FPW3VWeStMpvguD2W?= =?utf-8?q?AxKcMps0ZGWTMThjgSzn/7ccDB6r7b2SRxJz8wYrphx6wSrOo9x1Hslo0MO6TQuU9?= =?utf-8?q?tAcUGOpuJsxrHcvr2QK057v/4fmkAaYLQhRbWeXGubqlN87rA76XGqlRn4bcvXYhQ?= =?utf-8?q?wq2pvcpqL1/Lb3mibFeIWgTn7E1pntmEiOI38dDN9XIlaQuUoz0JPtc15jpLR9yPj?= =?utf-8?q?2xuYVpoNmizkmAw8kpy9rtTb9k37z6ACaVeMdJHVNt/rnl4eEvLTpJzMiBbiwdWt+?= =?utf-8?q?QZ6zJIqncU56FlQW2nj2qUrrQ1Ln+q8dxhU4GAFyJm73sBTjlXYc1h27/DKTLuWTK?= =?utf-8?q?fhBr496rXofh598bRsPEw8nW7XOV0DZNgFND3zUacGvMTaJ0Ab+eKgHssHfZJtNLr?= =?utf-8?q?baqbxLPSScqJb9gHkxXkk2a6ChaL5Z3fx6KLjJBfmO8DMN+vNDSCXgALFJd0phEcv?= =?utf-8?q?ZRa99JLN97mALk+AlvG0RLzvgaMfs8sJPal4yTeE1nsqZp94msRM1ezgu1oXnhdSg?= =?utf-8?q?C0r2i5GVWtywUhz5nZZ+jUc7SEO5GthmLvjt9KIQEEZo4iKh3SjBEonXJfDOTNFOg?= =?utf-8?q?IafErF/Ep+Y0ditHreZBMb2niHMEw5VyaG5reTdLMl5aNEPp7xc5GqiYDEGArZLDL?= =?utf-8?q?4xN3mKJRejsc/XvmgthbhkhjEgX3fAhgdV+q8uoJ3VX8nRMDbG5/6w2PX25vT/skM?= =?utf-8?q?Wl2bM7MMka5yIkvPiXOOlXj8PQrvVrmegEelN0GaIr22aFVFWj2fE1Ccc7q1Ooy8h?= =?utf-8?q?Z8aKutGygTKynoO6a0YgQpnOLra7VIvo5sJxC2iC1f+4gpSvOeavFUthO8vMH2qrV?= =?utf-8?q?4JxbX4D1xBkDLo3lqm4IToHbHLjLb6tip3D9X1chOpvan4O6ZvPJqB0RFXHVQjfnx?= =?utf-8?q?5HEBUChCDr2+HicDQuToFWioEVW/M+116Rrg+SWcwqDUQRVcy8iXlfXhrLyLOPKRd?= =?utf-8?q?ox4Hi4p56LvPwVmfv7ZeKs0vteySVnoizgLkU6BsyKznUVfkdlFJ4TpyfjoVRRZyg?= =?utf-8?q?nwILgs4zyqni0FgS0YL5C+VNqqTIr17fp7vlUo3yDZvPdVXAKKwMSRygn+jq4sjwz?= =?utf-8?q?YjUrYA69zol3+hZGB5YjoRgHdAjD+PaMvGALGeuhbmd8bcHkyw6QW6Mz0Z5qscdv6?= =?utf-8?q?VtLdE5vbNsQF0r1cnhYyPxL8go3AgIrADu9Yig=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: e50cf2a9-faf7-41b8-2906-08daf2e8b33a X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Jan 2023 08:57:27.8989 (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: PN0PR01MB7672 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?1754626029290099693?= 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 the T2 MacBook Pro's which define the ALS in a top-level application collection. Signed-off-by: Ronald Tschalär Signed-off-by: Aditya Garg — V2 :- Add missing signed-off-by 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) {