Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9725171rwl; Wed, 11 Jan 2023 09:09:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwGVmR4e0Q1pejieI5cnH09znzQX8BW/bGJ95Dis5Ojxdrpe1mY67fcM9AsskMDuOXf/Ka X-Received: by 2002:a05:6402:2146:b0:46c:7035:2f6d with SMTP id bq6-20020a056402214600b0046c70352f6dmr65043920edb.38.1673456978003; Wed, 11 Jan 2023 09:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673456977; cv=none; d=google.com; s=arc-20160816; b=XoSib9sv6bxaFcVume8XsxDRfXfP7TTI08/lcW7kygs2mHf3788Q+iMs3Ls7z3EHAN W37G2nSds/AwVnlVv1GJfUurhnV4S848YezluGvdRAWWrYAtX3NbEnP/95ehZOch1hd4 V5+8Dy/ykag6EO53rbUZCYrB+qWOdTvbIGE+hqPUab3V97aUVXKPnJdbmYhUah1CWT0J z7PiHJRM5JwgBnVmuViAvgkJ0v2ULya7yPky+wzOKw0lSkiKL6d5adns21vztaWsZ35j 8ifhLExL2vjAkrDO+V4DmoeMg0RTV/VKObaD6LS107hS0y2JowtB5Yo50mISgNscHwIC aHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=VhoLyPRRnCJpqrqw6ERRhnzk05VuYU9JiRPDhYJ+h5g=; b=BBBacBA9WC0eb+oKkaGBXUqeDT9kBBwFP+5AEsHVd2NR60LWKK8V6Z86JQ0CBG5fca NMDYkqfJ2pIfNM3xypw4ihg/xvC47ESfo3TuRTSAf7koWR0RgZnu929je+YDdsQ5rwKi pqTVajY5M82Rpd86UlbmddhOIvv2WObGp2f7Yv2ckRXJF7jDPqpn9IBmbv1mJTMlSxNR DwikH3D8gi9QGwjDJrr/wOxYNajT++zget9ghRSl8PRg0t0b1avl5ZW0I1l+7YWOAPBD sYmTo+vlqsC/pqcFChlwMM3R3GBIRhWLG+DWm9VutJoRHTeq/eJRZJMinsXScxHM4VTW vgyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P3OU5mV+; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a056402428200b004885f068e3bsi15068457edc.138.2023.01.11.09.09.24; Wed, 11 Jan 2023 09:09:37 -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=@intel.com header.s=Intel header.b=P3OU5mV+; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234390AbjAKQ7h (ORCPT + 53 others); Wed, 11 Jan 2023 11:59:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235405AbjAKQ7S (ORCPT ); Wed, 11 Jan 2023 11:59:18 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79AAE1D9; Wed, 11 Jan 2023 08:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673456357; x=1704992357; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=XmWC3XI33pAhrNwTO3pTEmkiACbcf3LnIHheDFqokkE=; b=P3OU5mV+xXoLpwRrFF76da8/UzlrChX77c3/4uzU6KfSjoughgOUHR8X kr0Khdh981k4EOyaDA3xJ9Xz2kbJ5ibeC3mcKYGaql1yb+Yt8t6KIQWnt Iej0RHUMHLIJJlSW0LTxZWJSedMifZFjN9UXpfUnsD4xBb+bUsAKw7QVa 5qNvnjfA8HkGEvm50Cc372kK//p+6irPD4SUYfECmlj7LZBhdhe3HgwMP Pot01bEWjEPsGzsMOPQN3aXWYhu1RFkzBAPKRL0G3mMiHOj9KkwoWZ1Bm k1FwZclX//boldl8adiPb4onDNSZO0dHDPBUpwTisy7Ik6Ye0CqNrZ9E8 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="311290796" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="311290796" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2023 08:59:16 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="765227402" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="765227402" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2023 08:59:15 -0800 Message-ID: Subject: Re: [PATCH v3] HID: Recognize sensors with application collections From: srinivas pandruvada To: Aditya Garg , Jiri Kosina , "jkosina@suse.cz" , "benjamin.tissoires@redhat.com" , "jic23@kernel.org" , "linux-input@vger.kernel.org" , LKML , "linux-iio@vger.kernel.org" Cc: "orlandoch.dev@gmail.com" , "ronald@innovation.ch" Date: Wed, 11 Jan 2023 08:59:15 -0800 In-Reply-To: <9E66CF6F-99A0-4CC5-9FA0-3A9DCFCA0388@live.com> References: <8DA00FF4-DB08-4CEC-A5B4-47A71DC09C13@live.com> <01D620E2-18CA-40F6-A330-454CBC20C542@live.com> <9E66CF6F-99A0-4CC5-9FA0-3A9DCFCA0388@live.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 On Wed, 2023-01-11 at 10:07 +0000, Aditya Garg wrote: > 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 Since there are some hid core change, Jiri needs to check. If Jiri is fine with hid core changes: Acked-by: Srinivas Pandruvada > --- > 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) { > -- > 2.34.1 >