From patchwork Tue Jan 10 08:55:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 41367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2633988wrt; Tue, 10 Jan 2023 01:00:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXv13tVGJP7VIAV2PaFZkTiJ/1ZdhVRlST3YFCjjTuPMcK7q/SnYxCWymYqu7lHGhmNZtl2/ X-Received: by 2002:a05:6a00:3217:b0:581:7430:aba with SMTP id bm23-20020a056a00321700b0058174300abamr43530822pfb.10.1673341222921; Tue, 10 Jan 2023 01:00:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673341222; cv=pass; d=google.com; s=arc-20160816; b=a5macQjFuVg/z3hln/YSfWlP6HcrALoBREal3zOG9HHPQb2EY210wN4ojNTlUv5qtd P276dwr1YZWKBr16g4LuRYf9f3LsJmKqvOn3i90thtA6VDmWSwllriSgZsoZw/g2a2h9 7jj/yDZLdpBv+St4HdM9EJkZmXSJPNgTYbLG8XoHlpUv9jEJdAWVcnoohlklCaCYb9up C8p/WQ6Ev8tbQLmD9RWLMvHHZ/NuGyDo7n2hDaSEgJcVzn7RkNXrtSSEvA5Y9uoVjp15 Y1XmuvcECMhM+QsTT4ttO2MVQVPInHSgaVVO/uimwWPh+vNev25g0efEFRVco7T0IjxF herQ== 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=7OHsp8+dUn3iWBtan4/qA4fKHgByblGmY6nrAFCMBL8=; b=0qQudagBuMH9qUU963zXogO7Rhj9ad07P651R2A6c404+XOsHBpK24o7afICJ4h9/5 2/WOItU8f9rYtjDcEJarKlRxZ9NDOBaTw0Kss13CrjL/Th1rKva43cYXwgn/vMw80Exx 5iQ+zTCfkFWy5Sp5Wix7wnlANjQEj8tgs5P5qBDe5YxvCKCTacldn+iXmJRaHqG0X2Nw x3pycad0VbZGvWp87FXcaq4/8WGwrPlKv6Cb8d57XUvqQSjjljg6n5X5FB9e9+Q95t9V bJ9d4x0CsO3R1/j4CR+RyZ3qYRSTcSOoSwRl0UIsdL113jX4Nb8IQDgAFQubq3UpuRBh eD2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=q8He3W9u; 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 u20-20020a056a00099400b00576a51119c0si12512471pfg.179.2023.01.10.01.00.06; Tue, 10 Jan 2023 01:00:22 -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=q8He3W9u; 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 S238062AbjAJJAD (ORCPT + 99 others); Tue, 10 Jan 2023 04:00:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238247AbjAJI6u (ORCPT ); Tue, 10 Jan 2023 03:58:50 -0500 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2023.outbound.protection.outlook.com [40.92.103.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9244E77AC4; Tue, 10 Jan 2023 00:55:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pstq+EfPdCBsc8k+hxKksvp9CosqKGVnKuYZVXgrMU1pg+owQVXyYGgzMLEOg1emLGS1vJOQUEwi/eA6ynlekFOY/dtOtQbbkOlF83O9D08g7PHEKLWg4oLL4Cp406yimtISyfEK0Pfl1WTehpr23EsX8IIMdj8neQdshIDG60fZity9KGW1Rx2mrm+oBVJ/3I63PZRwI66WfMAYOnwmXv3VffDwH92tLrYOoIsi5rqAAqCHhTAjZaI5wD6BWE5nnw+GIL+CQCr52Kv1jbOgZ4uXo14OmZlD48a6ApZnmWhOLzBirNhdBsGix8Lh7rvG4VSCRdE4rSCceMX0afWtPg== 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=7OHsp8+dUn3iWBtan4/qA4fKHgByblGmY6nrAFCMBL8=; b=kXyRq0kCjRegrZzcF5SrklEiTtvS45gon7cx5dLkxAFFNIJy8yDBJTq8eisK2UYHl2i6D0+8tTY9UljRpIojuJBDq8ZDpV+uDPWG9C3YAZWHdkFd0OWwbQvcPAlWnM60wx+WVQ0KXV2CywuaxTFRVqJ0/F7VfcNmWpTn1D6MjXZ6Cw2kiWTpb7xecKbtE0WOUHAaHMyznfd2FvCzhSRj87KVUiu9V79PK6RKszSlF4wTV4rSM1pQCuTiZSeqe/5iuu3MS7V9EciVw28gvWPkqVOvuHSIPOVKv5rrb1snK9mJ2f4Ban6FZ5EsgHNF0JNDPAXmOiRjbV1xqJxlWlRV/A== 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=7OHsp8+dUn3iWBtan4/qA4fKHgByblGmY6nrAFCMBL8=; b=q8He3W9uKQMVCFrdhTJfroBHHaoAA/cC2q07QPQNERiHPFptb1axu95A8Flknk4i1WF2gZTajqlM586FkCilrs+v0iIqjQ2UAlr36RF3tMocMMhPC29ybT9Ia7eb9a2fOCkfLHCevj8wsdOglOMqGQuDKH1A4wUITvraSPaLU3U9OsVMfBTv8hx518lo3OIYE/ZlQ0SCXBJI+aJbzrcXxuJK9q1UVoD7MATg7OUfRMn1r20cOEiqNkPbT7zPGMFeLS5z1Mx87iRbdMpObSDKS8u81HwoECcQwymfgmWVqa0Xq0JedhJIvxpiNpP6HqHM+CrZuZ2UQkZhVkoWNs8W4Q== 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:55:00 +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:55:00 +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 RESEND] HID: Recognize sensors with application collections too. Thread-Topic: [PATCH RESEND] HID: Recognize sensors with application collections too. Thread-Index: AQHZJNE4jRay16Fg0UGqrwt+OFsMig== Date: Tue, 10 Jan 2023 08:55:00 +0000 Message-ID: <01D620E2-18CA-40F6-A330-454CBC20C542@live.com> References: <8DA00FF4-DB08-4CEC-A5B4-47A71DC09C13@live.com> In-Reply-To: <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: [qgF/Qaro3TCCID9lJqATRFf586hRQBbVUuCI0tKoeQk8cI3rrba7gQLCP9euHN2d] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BM1PR01MB0931:EE_|PN0PR01MB7672:EE_ x-ms-office365-filtering-correlation-id: c9432737-6bf7-466e-3898-08daf2e85b54 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7BPjj6eKQVBqnVDG8WLKVn6c/GtrSoTXzjYDHFHtHOF2agGKFsiMK0gyUQuZ1ZyvnSQUbsjQp5DhWPSbGGp+7nrC2SjwRw01kfMww+nEo4bw+e9zzYWNUhBlztq+8iQbOqBoew36P63qnCcW+F2gcsueIIQAPlPGNWTAw96KT9PvWErB8xwkuq2xFDdovKEetSaprSYKD/5faP68iz8krWHNQqCh6C56wsJMTpuvpRgK3ji9/2ASBoYJK1DUqn4TnDNVHrGkT8IejGX5CqvC5OAjDvyYraWuKF02fMa54bsRG0qSWm6/BhWQ+MGghD8BMZnk3nbq8bC3j1CfWi24t5X/feSGcPLpfYvxlFwTI1VAmxaF9rhLjIoTAuE+Au6jf38SLNUUAEiFUSxoPkAs1w1G75EB3ptFS2XCs1MfN2haMRfsgnQePRy7e3CYOpIES7RUwgB1TgM7Ypbu37K5JmCmDFuPlzSieyUUfXTelxcOr8UN1k62/588NLB0hthW61LZXRCwrAb83AngR8gzABVtqNB1G7624wwVQ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0PxOdQV?= =?utf-8?q?T5FJlE9yPQVSMYiXT81GmP7MpzlgBKdF4shGDLczTjtdMjB97k+K4qrytyfjryHSl?= =?utf-8?q?F2LMFahh4NRtdhRD9d4YTBOX9NWsCKJnN8Me4KdfsY+apn4NcbkLk8W05Ymd+GVgO?= =?utf-8?q?toGE3Cukc9Q2bhiRHed4Dw2sZJuM5F+DAi/pIjv1ZFHcSlg9S1yYhtGZuOtbgaM4z?= =?utf-8?q?oFRBz+btAJtvtqEBjI1xR5pl5x81H/Njnlkij+78uU/Ig9SKFMW4/AwUcmA5COfpS?= =?utf-8?q?rMo6WXqBUqF6xheormDl/YCuwzabM2QQn+5v4JlHXAW4JxutgNNmg3aQuq3ZjmnaL?= =?utf-8?q?gF5lyD6NHtq49JSD9kKQt7stAfb5CkejHoyHwkAE5YI9fek5NKeGmjgh5DOaCcrt9?= =?utf-8?q?tuIgstyhP64iODpe8DYw5wMO3aCVSwCU61PxXO17fIr6s0ZX1L+IBMgRtMCGH7wi1?= =?utf-8?q?DqPHfxZlV7iSFGQVv8BFfeNT8Yf/297948TPVy4xwhNI+93FmDIPOyfmjfGqRjxCW?= =?utf-8?q?bqbK4x0UZtMlNwIg0xT97hkPgZoPOWt3oDyVgg=3D=3D?= Content-ID: <39C99373EFDCD44EB46F6EA33E3877AF@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: c9432737-6bf7-466e-3898-08daf2e85b54 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Jan 2023 08:55:00.4770 (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?1754625446107817713?= 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 --- 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) {