From patchwork Wed Jan 11 10:07:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 641509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A02DDC54EBE for ; Wed, 11 Jan 2023 10:12:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232185AbjAKKMA (ORCPT ); Wed, 11 Jan 2023 05:12:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233820AbjAKKLA (ORCPT ); Wed, 11 Jan 2023 05:11:00 -0500 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2098.outbound.protection.outlook.com [40.92.103.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E52A11C0E; Wed, 11 Jan 2023 02:07:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iVLyCJYnen+Z54lN8R/UqW87j8LBbcHiJYI0WV7ZdW+Lfm/YkrEACFRJKyrlHlOtyfQL+GY4GymloOoHfFAG8dAF6lX83upos61dHThIvKcRXTRV/0pj6emYOtquWD3w03TsP18ceyQ5F7QMYv6a2FkfokqctqA8eJzWOyy1eoCO10DTklgUc+WXrUevToh5rhpkn6HTdDqOpQ6LVNrePE61rna6pIyczUhgxcdtJoX/C7eSBPVzqdYlsiFFEyx7BH4oCJEZTQJdSiTAzc4jf8ck5Xmba2H9CmzCJShopBGpuvSxDm9lCceQDwHPmnZra+eCKJ3V9MY8eLFALsiPRg== 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=wPdutyTNJACletQHQTP1yBHh8lFOxwvU7rdYfe+bHj4=; b=W5JKAXettTd76Hb+vGkMJoQYQxzree7OfTJVrszs8vEvWadfvAr54o9TDAn54jWw5aGZgwHyGxZ6cqEauts1R7xfu/KnAwuNhpeGKEg1JoxpuG0DgTPfaxLqEOOUwQT9xoi3K+95AxH7QAJPjL4dMQMtoAIIDErX4nKDyqOR/9zTfuqFzMk3zZtSrs9At3GyPDggFYaHF+uni7LH86ITNQGcyXbB4Y8MnASFCLFxltz5+bjy+dBxV+PIYjW8GoyXMNHWLd6c7PSZSdNwy64+UNsRJJ1hyg3WmfLlsglsI6F4/rDD8n3n2595tWvMFH/QGrE1+G6TjCRbd90yjOOCZA== 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=wPdutyTNJACletQHQTP1yBHh8lFOxwvU7rdYfe+bHj4=; b=WuWiG+ATfmYRF3az4CUIOlSMwhJxcZY1uj0o3dfpEr9cJSGY6Dl3Ly5kMKaZn1mQ2Umo52ADQXXwjsxbKqc0meDTSxVUVaD98X+1cVA5fweT0Ve38g3NTv35opFecgIxqHcT+Mj4e41zUjjwWOxpvd1HBa7kPgbhWGTpqu75hAb4+az8+xA4LiY8v9lnu6xJucADxMCt7HoXXaJ9p6FMWTWrqd8hSJ9CmTWaole0vfQe7v1ItnZ27fAKrLhK4dDK+Lat9GZPzaUGLMJUSpm8YJTg0LI2pW07fJMEUWObcakZyiTpwV27uwIIL/LRxo3sTBYZF+VJFcvutQ3miDN5dw== Received: from BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:2::9) by MA0PR01MB6359.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:7f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Wed, 11 Jan 2023 10:07:36 +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.013; Wed, 11 Jan 2023 10:07:36 +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 v3] HID: Recognize sensors with application collections Thread-Topic: [PATCH v3] HID: Recognize sensors with application collections Thread-Index: AQHZJaSHSs9iTHSJpkmT7tm87pMIXg== Date: Wed, 11 Jan 2023 10:07:36 +0000 Message-ID: <9E66CF6F-99A0-4CC5-9FA0-3A9DCFCA0388@live.com> References: <8DA00FF4-DB08-4CEC-A5B4-47A71DC09C13@live.com> <01D620E2-18CA-40F6-A330-454CBC20C542@live.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [HX2B4FhKqfK1L+oHwPfYMEzPp3oXMZa7yZ81HyH2FRYXHEuJgRJ831Zv2510oATV] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BM1PR01MB0931:EE_|MA0PR01MB6359:EE_ x-ms-office365-filtering-correlation-id: ea75e6fe-dd48-4bf4-ba40-08daf3bbaa45 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 02yrKjJugzjWQ3GD8Gxm5w6TovvBQnKpe7rQ19obTRjzhTUVaphCF0Qoli4I4BhJpWRDn6S1l0CdeXUQgTfmaX5ysayxEM6aWkTiXelRjDmHkhhpt6TAP7hHBm4UxhpWajNAM5wAslq2SDevTScEWb+vKPwALoiwvsjrxjbLK4/WOySnmWxwYLfuyABkr6WpGq5sf6wCv5aShgnDM2CvzIRCXV8Ji6OUQUp9flpul1eYZmReKcPmpoyCJOPbs5Qe6KzvEn4mszQ8tEiBORSOQdX/taymqEHQrDxdOmbaqm4JNlq0HRb9cCsmURFwLP0v+jTeU/orTENY5VDWDc0lYyuvbM+PKoCgDHeE6XLx68QXjIYW/ADD7Qd9MWd2jtSjVnNcGyVkIZTad/JQ237ovhwZWS/VjvIwifdRHKx487c9xy8TkVzC52vq61OmHN1htrbyi+pqHSLUDhyW7cChOVRHLh3NQ6mCflXYS1D01fIbgWTqNq6j0CqKUD9WUi7QAUad0Z0SQk+BCf2XMxFxo7ioeHEaXQJMQehE0wzQmcKO5ek+vhOI+d7JIEDeqH0fID2k6wp5spkr2ymoy1djg3nZ1C45fx5t2mCDuNecJ6U= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?18gSLiGStOcAw/89wZFpZbJ1V2qV?= =?utf-8?q?+1QdTRCsGV5jjNxsiPBY6YifHak+6eObt7HbogMote4v3coawe8K8Z6FqsGMOg2H4?= =?utf-8?q?8qNBjxeYAw5v9fD0zeR9ftMQfg/P4+dPWqgyEfOzmqKIleQSI98W69jUISgPWYAq/?= =?utf-8?q?UDDwL7o8cRd7NYPgr6UAusJxdXCPZCi8Dg/5sIUyi6P5QWuBN9tViuw3N1rpyVx9e?= =?utf-8?q?8WMCtGz8x4+JhZJr58QZ+c45c4Jtiu8tZ4T9tN0+gwVsBtqX6t2Ad4vXgOSbNxyE6?= =?utf-8?q?SQzwQrcL2R03NkvQZK5KjbZakK84Z05sc/bnpea9xL+GcdOBOef4+5GSKLyAYG7ae?= =?utf-8?q?ped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VQhKqMAkquFuMush/O85EHzVO211eA8yOvjaUrahO3FQrDohe3v?= =?utf-8?q?wK1SY5PTCIFdlitMbcfmClUma/i6Qcwk6leY2w=3D=3D?= Content-ID: <181F55D8A09EE44D978B411E2F196849@INDPRD01.PROD.OUTLOOK.COM> 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: ea75e6fe-dd48-4bf4-ba40-08daf3bbaa45 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2023 10:07:36.7164 (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: MA0PR01MB6359 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 Pros 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 V3 :- Avoid using language extensions drivers/hid/hid-core.c | 3 ++- drivers/hid/hid-sensor-hub.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index bd47628da..8ff08e6c2 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 6abd3e2a9..83237b86c 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]->physical : + report->field[i]->application, report->field[i]->usage[0].collection_index, &hsdev, &priv); if (!callback) {