From patchwork Tue Sep 19 08:10:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 724521 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 EEE19CD54A8 for ; Tue, 19 Sep 2023 08:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbjISILg (ORCPT ); Tue, 19 Sep 2023 04:11:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230404AbjISILd (ORCPT ); Tue, 19 Sep 2023 04:11:33 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2078.outbound.protection.outlook.com [40.107.94.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2129D18D; Tue, 19 Sep 2023 01:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lq/A83rcvLCvjCjoKnuSze+rZH+tfe9ZP4rRWCK6kGOQJvLagIRSLPqYq8IykuLK5Qi59DThb5q0QwODrtkdbpdLGzeMOD5l/I1BqOHuK0Tx9HYXPJBBk0O9T8AljIP+gztGPYhFz7sxGjOp3whnFPPnN+LtagrmCcz5nhXwPlIqjcciDiJKQtiyhRCtN8jkM/L1yY6qKQDcXOKRmSfz4PoTOOBGTbXAFiTqjRQJ0UbEQ6OwNO/rtNkoM9SDR/qlYdhonILFOBVyeLgnNvUc2qK5VdJHwH0VoAaBSk+jFrtEflXCQsdSOl3R67WZbSZozUh7A+9YZ43O717dHzhtAg== 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=9DG4gCSDnInNq1X5cgRxW9hJa63Lj0CGrBitDCFBamA=; b=jndP5Dh3wg3iK8ja3sbevo34Qptff/e7qPpgX0SMv1LlAjSKaK7siNrj39gKyphT4XQciz8VHOu9OJwOA4d2YzWXurO9u12M0Tx9LyhGxjNUmMPQTjqX2CZ4RHrSTjQOTc3bjGjIyvv2XfU2EXYwgYyHvVGUcn9xT8RMzt/B/CxhR8acp6AFpnLa+NNKYONaPlTWmu36tYD+VWicnNFNR9EhEe6z3YYome0Jfn7jDcoeDTV23d+8LZUcRiX89T4vycP/TiFLezKyJikWdjXRMqE+dUO7Gb0ZpsNug/MU3eeppMD9SzrYRcjfDbJhFcdaNEeIOQBeOkoCEC+ZvbCyjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9DG4gCSDnInNq1X5cgRxW9hJa63Lj0CGrBitDCFBamA=; b=vf4tP6pjtDC7eWrBSDMvGCbopuNAtezUyT9PK5PgC+VtoOI3Aa5zE8yx5o+RCETopX40oL5EqMGl/oukr6XzHmnIgY8ZJfO1DO7A0pa2CcVgxuHaV1krRWTB68CfSETPX8XF7numPniWlkReDu+JUmtn/a8Y0QdMC1cCTn8K85M= Received: from MW4PR04CA0148.namprd04.prod.outlook.com (2603:10b6:303:84::33) by PH0PR12MB7929.namprd12.prod.outlook.com (2603:10b6:510:284::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Tue, 19 Sep 2023 08:11:24 +0000 Received: from MWH0EPF000989E7.namprd02.prod.outlook.com (2603:10b6:303:84:cafe::c4) by MW4PR04CA0148.outlook.office365.com (2603:10b6:303:84::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Tue, 19 Sep 2023 08:11:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E7.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.20 via Frontend Transport; Tue, 19 Sep 2023 08:11:23 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 19 Sep 2023 03:11:20 -0500 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes Date: Tue, 19 Sep 2023 13:40:46 +0530 Message-ID: <20230919081054.2050714-2-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> References: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E7:EE_|PH0PR12MB7929:EE_ X-MS-Office365-Filtering-Correlation-Id: 2674ec1e-15f4-4a1c-3a3b-08dbb8e803e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nenf/s68h2krOG3/g0AZC6BcPzGVOmlKcP+RrYBiBd+hlEcKtjiPiJL0PRpfn5GlZXqMsQi0Kz4iOJ9CMfpsnYCby7xTtRlspGTNWzBf8cgo0n0RaxhEDbCidNFiJr7Yqq7yEUyk9NMkfnNqiQia06qeKmDp1IivQZ/Jjy2CAQJ+jtskEYESJ9DxAZnhdRTHJAFAF2YaGyAZhRIFEvt0bJF1YYXBLhNGkCYyQqqLa/vBZqspwSmqMc8jhzvJo0Q4JT9QbMGyTSy6zy5NiJN170A2Zt8cBA6BuG8ZwvQFJtFxaxmg1aHlcTt5d/18Kujz2Q3sWmzkaDJMgyVumTk+RhG60bSn92ay5E+cWjMxjOFMV3xh4YNfsCWXH75pjkZHaDCsTNL2ctsvWRlJNyMONE4ifj5zZ9SX68AHpdDDgbOiWFbeAOusgef+/CJdawr+QJYTEUhECCrDRl0QEVoX/WJCNG5y38jerMCqMwrQNjSxg6KiiOgxeOzpmKqXSjwH2Tg8gHIMb3zFubFAuuz6XJc3DLR9+qbx31wpz+oZSnuWt8WRJFjmZqjynS8vfJb662DQYnjiJl7f2AZTOAW9lqrwz++cK2fL4sEqFeqnjHxAl5Z2lgpDlfyrhyo++4tT+Dqx+CDqWiuokcgGUO47K28EeVYxug/AaH6GOXyWMMg4XX40bJqG0kB+nEV1qH4WUMTM2nkxULlG5t+7xKCRqfPt2EQHd1cZzOfQRi22crbtRpz5CNTsj+0IOoFt9TlG7lVNVCXgG6pwyKr3N4N+MQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199024)(186009)(82310400011)(1800799009)(46966006)(36840700001)(40470700004)(40480700001)(5660300002)(7696005)(86362001)(316002)(41300700001)(70206006)(70586007)(110136005)(6666004)(478600001)(8936002)(8676002)(16526019)(2616005)(356005)(81166007)(26005)(82740400003)(2906002)(36860700001)(36756003)(336012)(426003)(47076005)(40460700003)(1076003)(83380400001)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 08:11:23.8772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2674ec1e-15f4-4a1c-3a3b-08dbb8e803e5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7929 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Sensor hub attributes can be extended to support more channels. Repeat the reading for the two existing channels and store them separately. It still operates in the same manner as before where there was just one entry. So in order to support more sensor hub attributes for ALS use channel index to get specific sensor hub attributes. Signed-off-by: Basavaraj Natikar Acked-by: Srinivas Pandruvada --- drivers/iio/light/hid-sensor-als.c | 38 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index eb1aedad7edc..efb1f8862b28 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -24,7 +24,7 @@ enum { struct als_state { struct hid_sensor_hub_callbacks callbacks; struct hid_sensor_common common_attributes; - struct hid_sensor_hub_attribute_info als_illum; + struct hid_sensor_hub_attribute_info als[CHANNEL_SCAN_INDEX_MAX]; struct { u32 illum[CHANNEL_SCAN_INDEX_MAX]; u64 timestamp __aligned(8); @@ -99,8 +99,8 @@ static int als_read_raw(struct iio_dev *indio_dev, switch (chan->scan_index) { case CHANNEL_SCAN_INDEX_INTENSITY: case CHANNEL_SCAN_INDEX_ILLUM: - report_id = als_state->als_illum.report_id; - min = als_state->als_illum.logical_minimum; + report_id = als_state->als[chan->scan_index].report_id; + min = als_state->als[chan->scan_index].logical_minimum; address = HID_USAGE_SENSOR_LIGHT_ILLUM; break; default: @@ -242,22 +242,24 @@ static int als_parse_report(struct platform_device *pdev, struct als_state *st) { int ret; + int i; + + for (i = 0; i <= CHANNEL_SCAN_INDEX_ILLUM; ++i) { + ret = sensor_hub_input_get_attribute_info(hsdev, + HID_INPUT_REPORT, + usage_id, + HID_USAGE_SENSOR_LIGHT_ILLUM, + &st->als[i]); + if (ret < 0) + return ret; + als_adjust_channel_bit_mask(channels, i, st->als[i].size); + + dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index, + st->als[i].report_id); + } - ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT, - usage_id, - HID_USAGE_SENSOR_LIGHT_ILLUM, - &st->als_illum); - if (ret < 0) - return ret; - als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_INTENSITY, - st->als_illum.size); - als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_ILLUM, - st->als_illum.size); - - dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index, - st->als_illum.report_id); - - st->scale_precision = hid_sensor_format_scale(usage_id, &st->als_illum, + st->scale_precision = hid_sensor_format_scale(usage_id, + &st->als[CHANNEL_SCAN_INDEX_INTENSITY], &st->scale_pre_decml, &st->scale_post_decml); return ret; From patchwork Tue Sep 19 08:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 724520 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 DD4D6CD54A4 for ; Tue, 19 Sep 2023 08:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbjISILn (ORCPT ); Tue, 19 Sep 2023 04:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230376AbjISILi (ORCPT ); Tue, 19 Sep 2023 04:11:38 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2748412F; Tue, 19 Sep 2023 01:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AYZzdvUaiYb1Bv/eoegpxU+3bjv8PbECSqOagvyRLuJvSCA50GTgY6f+mOz8aieeu2eZ1B57xiXGgHuJjfgvK5RKM8ZVnlE44vsuWpJgB7PqJdrpFsKuVBD13/MbWK3FiDgkk4YMobPv+cG96DkNJBrQyREw4pABT5OhZazVqPoY+ptKRVhWhH8XuYL32TVDyWTfa8HOerLIR388VagSHnF7Sh3x1rboCdq9CuO0xVVvscVX8yRHs0kT2klb+GrOmuTwZKhDz8fAPzw3smbZ507W1zXiCW4jUBksgZ171+y0wnPu+VEAESypaIVLuqDWlxYrMZPAByhnZce5PWn0xA== 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=c0+iO/szdrPTOM8xx79lFjdVBbP/nOVbTPGqV5IBkEA=; b=JO5Eu1Z+Sb3mtzNfX8HLAGsakzJ4UB63LgrhMJFfm2Z661VJKGuqh0ckL5XZUwERz8DZ7FA+cQcC7oDN5fbhdRQte9sXrsfsWDz0M+ZAMIRSjDv8zGBJJrt0S/mVIuvgIbwOXu3qGWYu1UauwtUKWmp/DuiUfQPAOWjjtPY258TC8n9ZPm3ybqeOtEp6E9gzwlahoMsi/faZfy3kmJ3ZN1DuD5ndkdKpbHMo46jWndfgeuPfU3ZybZrj3SU8+dro1ZgDQzczdbswwujKUx+ABR/HkO/cpJQYwJUSTg684DKAdUKJds1pywEVitTcFBeuHhT0j77AefSWbvALYzLYOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c0+iO/szdrPTOM8xx79lFjdVBbP/nOVbTPGqV5IBkEA=; b=kFWfXnsKRNzaxUc7aEQLVut3MGmEs3YdWlroAFTa9l7xyJZ6/JWd+Py74I3GAF/UpFnuC3njS2h7EyOH6uGjQF+kRczL9G3wZNs5x+aqYyr4ewCThjbjJwdKGG3bI1G8qdH3oZMkpqrh8S2cBHCR/oUPY5AM0z5MC0GvqjnUK58= Received: from MW4PR04CA0156.namprd04.prod.outlook.com (2603:10b6:303:85::11) by SA3PR12MB8439.namprd12.prod.outlook.com (2603:10b6:806:2f7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Tue, 19 Sep 2023 08:11:29 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:303:85:cafe::b6) by MW4PR04CA0156.outlook.office365.com (2603:10b6:303:85::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Tue, 19 Sep 2023 08:11:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.20 via Frontend Transport; Tue, 19 Sep 2023 08:11:28 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 19 Sep 2023 03:11:26 -0500 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH v2 3/9] iio: hid-sensor-als: Add light color temperature support Date: Tue, 19 Sep 2023 13:40:48 +0530 Message-ID: <20230919081054.2050714-4-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> References: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EA:EE_|SA3PR12MB8439:EE_ X-MS-Office365-Filtering-Correlation-Id: ebb32687-005c-47a6-5b4c-08dbb8e806f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: itQZSu/AyruKdcnqcGmaiutOPx54VAgsEDqWo98+LuK761DPNXxeHuT2Al9sQjlIu0jra0sBj17hRE7TG3B+RCqdYDIGRrSpbt2DaiTT7JTuCIQJIgonQa2v9aP2a2Rh4oG90xxoRgJy+56Zhz4ckMmLiCnIoJGCVZam5Dx3G6gYso0yKbel2xZp2MkBqUjqCJVsE0eDnLgSB0yLSLUWKRQQxL2ICwqWLx3rhq5ZzSMrX3/QocyT7lniEfsK6CiEyMvq7OUgJZjzfxdc54zqG/4SG5aOU1quARs4tcw1ZhflLrM6jVu60Ab/PYecE/cJn2E8MRYca6/azDCvYg+TdVYs1b+ayICMzGMQAx7qz9y62lta+Zq4KkkllbvE4jmBRBmBgtPjk1ldIRiPeEk/G4Y/zDXyJffpTHCtbF0OGHxQE2juBF1+d6iTGzqB1S2Jcn6QZ8nUx5Z/2OnUJPq59FXkDGuqGr2SJiDrzRYh14DE8RWI/a9Q3Vrvt54n0Ctfl3+8bEtIe1h3XbYhx6pCHvW3NcZ9XiIzWR0tZEePmMNFFGfeEx2eOrjQlA50i8k2NSvCiK/kgO6eEH5oxelkFqIxxXNC+C0zthBsxEnDL1LboBS6BG5GqeJjf4+spb6OI91g+fSYq1WhO5gjKUnDFAfZd0++kRu+9fnXQQ5/hE/MdlJKewWKKQTGut6evGDhpCd1o3goMiW3FoswlBQefF0acbCanq5TpFyf59RlwkzGr8QLfbnclFAY2E60ujw2HLgHiRyEHJxC+77BLsze2Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(346002)(396003)(39860400002)(136003)(82310400011)(1800799009)(186009)(451199024)(46966006)(40470700004)(36840700001)(26005)(5660300002)(16526019)(1076003)(8676002)(8936002)(4326008)(82740400003)(40460700003)(2616005)(2906002)(86362001)(36756003)(81166007)(356005)(47076005)(36860700001)(83380400001)(426003)(336012)(40480700001)(7696005)(70586007)(70206006)(110136005)(6666004)(478600001)(41300700001)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 08:11:28.9888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebb32687-005c-47a6-5b4c-08dbb8e806f8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8439 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org In most cases, ambient color sensors also support light color temperature. As a result, add support of light color temperature. Signed-off-by: Basavaraj Natikar Acked-by: Srinivas Pandruvada --- drivers/iio/light/hid-sensor-als.c | 37 ++++++++++++++++++++++++++++-- include/linux/hid-sensor-ids.h | 1 + 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index efb1f8862b28..16a3f1941c27 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -14,8 +14,9 @@ #include "../common/hid-sensors/hid-sensor-trigger.h" enum { - CHANNEL_SCAN_INDEX_INTENSITY = 0, - CHANNEL_SCAN_INDEX_ILLUM = 1, + CHANNEL_SCAN_INDEX_INTENSITY, + CHANNEL_SCAN_INDEX_ILLUM, + CHANNEL_SCAN_INDEX_COLOR_TEMP, CHANNEL_SCAN_INDEX_MAX }; @@ -65,6 +66,16 @@ static const struct iio_chan_spec als_channels[] = { BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), .scan_index = CHANNEL_SCAN_INDEX_ILLUM, }, + { + .type = IIO_COLORTEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_HYSTERESIS) | + BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), + .scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP, + }, IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP) }; @@ -103,6 +114,11 @@ static int als_read_raw(struct iio_dev *indio_dev, min = als_state->als[chan->scan_index].logical_minimum; address = HID_USAGE_SENSOR_LIGHT_ILLUM; break; + case CHANNEL_SCAN_INDEX_COLOR_TEMP: + report_id = als_state->als[chan->scan_index].report_id; + min = als_state->als[chan->scan_index].logical_minimum; + address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE; + break; default: report_id = -1; break; @@ -223,6 +239,10 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev, als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data; ret = 0; break; + case HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE: + als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data; + ret = 0; + break; case HID_USAGE_SENSOR_TIME_TIMESTAMP: als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes, *(s64 *)raw_data); @@ -258,6 +278,19 @@ static int als_parse_report(struct platform_device *pdev, st->als[i].report_id); } + ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT, + usage_id, + HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE, + &st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]); + if (ret < 0) + return ret; + als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP, + st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size); + + dev_dbg(&pdev->dev, "als %x:%x\n", + st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index, + st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id); + st->scale_precision = hid_sensor_format_scale(usage_id, &st->als[CHANNEL_SCAN_INDEX_INTENSITY], &st->scale_pre_decml, &st->scale_post_decml); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index 13b1e65fbdcc..8af4fb3e0254 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -21,6 +21,7 @@ #define HID_USAGE_SENSOR_ALS 0x200041 #define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0 #define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1 +#define HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE 0x2004d2 /* PROX (200011) */ #define HID_USAGE_SENSOR_PROX 0x200011 From patchwork Tue Sep 19 08:10:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 724519 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 1A86DCD54AE for ; Tue, 19 Sep 2023 08:11:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbjISILw (ORCPT ); Tue, 19 Sep 2023 04:11:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbjISILt (ORCPT ); Tue, 19 Sep 2023 04:11:49 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2069.outbound.protection.outlook.com [40.107.237.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D53CA12C; Tue, 19 Sep 2023 01:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cm8RK2xGTyMrF+raG6lUo5GvkVl5uRea4zGdoZcPtMxnYFaqx/ArdtuwMG0wK8ddXOVyBLP5fpVJ5SNAl9sktlF4+xeFQOBfIWs+aqMWItGAtLSzZR/FxFNuU/tSFCjUBy9f4ZSXYKwAmgYuuXQW6M3PMbsD3P5XZvLKnGKkycOzw/A+Dfh2gdAxqeuDO6rXhz+ai6k4m6qE751Fz2dSHjdmAOwhDwiKHxxTBg1fZbmUKAnViR4NwH3A/nv3q2msWnjCf8DkL8IPPGXMkYqFJfDmbFXO+djGkaCydBqvHi/EdEGiWEKSj3CK62rZrKxLmpxStKCdKkzf4Ke2yknryQ== 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=XYFbC19+qb+hmfTtsZu+eKfqubRxtg4a/ctf2q6CvkQ=; b=WURDObCa0nlQ5kMqyY92x3ENBJuhBj7kPvToEE189bz9gsnmPRGvzRVnct3hXJoBY8YyaUcwJB/9w8maU9lLABueBYBh8F1DhnXYyIlLxJhfhbhjHdPosqSJYj+AtlAQ8A63w6Y5KsSDTi8eSvRBrkb2PMAOes8Xun5+M8L4ytQTdwossSq//q4AcOgq1tFO70MbTw3H4S0lpnObJvTzXJAOjv6PpH/8EeB6EB06UNFbEbBVSh654wMRSADUI7FphgQlV+/tUWx9qhzAucjFGEmZwo/qWrzrenjguURU2aaQlDmG7huLG5n5SbP7TUXyDp/QWA3W3BGJ3Zm4pfmAXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XYFbC19+qb+hmfTtsZu+eKfqubRxtg4a/ctf2q6CvkQ=; b=0XSxtJzyceGLFiIbugwQhWb8FO0yXUlxjIfiSymP4QTNoUHzM/HF5spAFObGGyaHNeD4zMddxu+z+KatsW9oWDI9YAjKGL6zodkFodc17A5ZxbbuMJKKjlazLet1neIPwqyu2UWU2eWe6wvfcXt54fuV1ClBnKqQK5z6Ei4eTzc= Received: from MW4PR03CA0038.namprd03.prod.outlook.com (2603:10b6:303:8e::13) by BL3PR12MB6593.namprd12.prod.outlook.com (2603:10b6:208:38c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Tue, 19 Sep 2023 08:11:35 +0000 Received: from MWH0EPF000989E6.namprd02.prod.outlook.com (2603:10b6:303:8e:cafe::58) by MW4PR03CA0038.outlook.office365.com (2603:10b6:303:8e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Tue, 19 Sep 2023 08:11:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E6.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Tue, 19 Sep 2023 08:11:34 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 19 Sep 2023 03:11:31 -0500 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH v2 5/9] HID: amd_sfh: Add support for SFH1.1 light color temperature Date: Tue, 19 Sep 2023 13:40:50 +0530 Message-ID: <20230919081054.2050714-6-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> References: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E6:EE_|BL3PR12MB6593:EE_ X-MS-Office365-Filtering-Correlation-Id: 846f533c-273f-4f8f-5cbd-08dbb8e80a81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VYf8i37kOK7br0+PrLtDyo1+A+dHU92DG9gH7/92LNLW1ubNW0YiGSxzEoFBVLLOZQBA6B7qNtodQkL2wkXiDsapcXcFGM+gVN+gSxOgOezNfmL/oQ0NNBj6pbc5V97YwjKzYtYqZCPl/BGYhFc9v0MmQF5OF0WtkdGD2T4oURJe/Qs8tXlGXI5P+OFTdq8u4pE8VTfAuMxf7mE3ckRRNAhkdUAsUtGMYOr0hLK5VdHZ+x6n6u4JdJLG+WuqRhOuBqdYw3gQqARiZ1/oI44SyIPN+FQrHsBSCU5kY7jiMJyuSn24KLf1GXJKlx+tvWW+Bpi516vIiNveAzXiQx0lUB0RzT4IO7IYsFT5bZP5zPleHblFPEYLkkGZrHMxwf/oolmNO6hnffcW8S3Vj5fd7Hv4bcQgk6sLKwlgmOWXgSKreHNwZQJzERSrtTJBBsHMm9Schu5aSNgZukCRYGxvrKx89YOY5961n3x71nMsNLwDMpd6eC/cmFWr0JG+QbmE1FgGUmptX9ekduroAT24J545YLrNNpW99VJ7VXKzkBOg6AVGEiw6h6p2UoW+RVhX5ajj32DKp/K5TPeSRQL8XHtaduwLLOT9EX0JO/xClyOTkZ/dj8ZdpvqE8QZ00c69+XY5dj9PRN3qaGfScoLdBo/cCJK6nUzc3OD/1yXx+eJWYPJKwFubvC5i+sksLPngu7XP/zzJGribmXZGYnKnPtptHrsITTSpL7W/BkMOG8j9bvUMm23b3RXGrwa+S9qK4wlKjNUTEx2IOPKpBBgFPg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(39860400002)(376002)(396003)(136003)(82310400011)(1800799009)(186009)(451199024)(46966006)(36840700001)(40470700004)(110136005)(336012)(7696005)(6666004)(47076005)(478600001)(2616005)(16526019)(70586007)(356005)(2906002)(426003)(1076003)(70206006)(316002)(8676002)(4326008)(8936002)(86362001)(5660300002)(41300700001)(36756003)(82740400003)(81166007)(36860700001)(26005)(40480700001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 08:11:34.9824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 846f533c-273f-4f8f-5cbd-08dbb8e80a81 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6593 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org In most cases, ambient color sensors also support light color temperature. As a result, add support of light color temperature for SFH1.1. Signed-off-by: Basavaraj Natikar Acked-by: Jiri Kosina --- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c | 6 ++++++ drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c index 06bdcf072d10..f100aaafa167 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c @@ -188,6 +188,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, struct sfh_mag_data mag_data; struct sfh_als_data als_data; struct hpd_status hpdstatus; + struct sfh_base_info binfo; void __iomem *sensoraddr; u8 report_size = 0; @@ -235,6 +236,11 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data)); get_common_inputs(&als_input.common_property, report_id); als_input.illuminance_value = float_to_int(als_data.lux); + + memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info)); + if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) + als_input.light_color_temp = als_data.light_color_temp; + report_size = sizeof(als_input); memcpy(input_report, &als_input, sizeof(als_input)); break; diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h index 9d31d5b510eb..6f6f5db150c3 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h @@ -88,6 +88,16 @@ struct sfh_sensor_list { }; }; +struct sfh_sensor_prop { + union { + u32 sprop; + struct { + u32 elist : 16; + u32 feat : 16; + } sf; + }; +}; + struct sfh_base_info { union { u32 sfh_base[24]; @@ -95,6 +105,8 @@ struct sfh_base_info { struct sfh_platform_info plat_info; struct sfh_firmware_info fw_info; struct sfh_sensor_list s_list; + u32 rsvd; + struct sfh_sensor_prop s_prop[16]; } sbase; }; }; @@ -134,6 +146,7 @@ struct sfh_mag_data { struct sfh_als_data { struct sfh_common_data commondata; u32 lux; + u32 light_color_temp; }; struct hpd_status { From patchwork Tue Sep 19 08:10:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 724518 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 A870ECD54A9 for ; Tue, 19 Sep 2023 08:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbjISIME (ORCPT ); Tue, 19 Sep 2023 04:12:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231282AbjISILw (ORCPT ); Tue, 19 Sep 2023 04:11:52 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2079.outbound.protection.outlook.com [40.107.237.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BC8A12F; Tue, 19 Sep 2023 01:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oHHnS2cfsJTN1Um8Q0OUZ74VY1GerowZSbg2+FPVw0veh9woZKtqX0CXOMW+TpNjGINnXndAnf1A/gxQ91E7CML8Xo47wRUEzxrSP3qCoOsMnUkB7HMu3BHxeAomiTA26fNbbJG/3BWX/Xd2xlGi9NY/VeTv1nxahYLBVOYzI75+/pvq7BASPKihSjgh3vGmPKFj599rrc608t7UAYNpfWqUvcR339vwfhqiXOhRRGtEWm5K6w+5Bh6EtnwNxrgE96QnnUS2DxxFYNf09pLuk+IEXwQEi3jVVdNNA4lza9CibuJFAD7UtfKbm428KF32DlNaE4nWFRUanKUcxl3L0A== 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=G/T/GD34c7wjZ4oKhiB7EyqZT6/B6WlMHqs7N1WAK9s=; b=dAhNRAhcJ6puTFT51DJhI0xM9lm15UuITgJ3U/55VMQJnTvBL+Lg1aTxzjzE0CCv58Pi7R5DJvQnMASk/mkuDywe5d0qz5D0TjbxoNmpbL/Q1Ws67GLBzWv7aPTqcyVWoKihnkwYLynsYR1t5IwwVrjqT/qiBxjctxTMY33A7B2DB4NOxB+/Ao3hQgegk2SBBgrygh5mrk/dwd/YM/2GWWAMO9TSGIvWz7jYHG+3Ug/TjxdxyTUdbIlNOduWFFZbvC5C5VGMooYDPr6Q3Abhk3xzWBj9ZxEe2V551yLWMkw8FTFr7Hu1yWXKwpPboSXfGQDW4OUhcxd/iRQiSTZr4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G/T/GD34c7wjZ4oKhiB7EyqZT6/B6WlMHqs7N1WAK9s=; b=jfJQRuAALqOWswnQB1zHGTajGFUa0Db7Yzl69ySBLFjnkXzMAchOkLYccV7VBwfXYeIGAto/q+ddBhCrdlMXMHZLD7JX1PKR2/PvPhInTqd0+xkAOYPYj966duMVMP+AqNWn+L6wgCUlrWd+IMMVMs1ana9oXuvGndVL4wDdsz8= Received: from MW4PR03CA0042.namprd03.prod.outlook.com (2603:10b6:303:8e::17) by IA0PR12MB8713.namprd12.prod.outlook.com (2603:10b6:208:48e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.24; Tue, 19 Sep 2023 08:11:41 +0000 Received: from MWH0EPF000989E6.namprd02.prod.outlook.com (2603:10b6:303:8e:cafe::7f) by MW4PR03CA0042.outlook.office365.com (2603:10b6:303:8e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28 via Frontend Transport; Tue, 19 Sep 2023 08:11:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E6.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Tue, 19 Sep 2023 08:11:40 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 19 Sep 2023 03:11:37 -0500 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH v2 7/9] iio: hid-sensor-als: Add light chromaticity support Date: Tue, 19 Sep 2023 13:40:52 +0530 Message-ID: <20230919081054.2050714-8-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> References: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E6:EE_|IA0PR12MB8713:EE_ X-MS-Office365-Filtering-Correlation-Id: 7675cbf1-2d4f-4e1d-e4a1-08dbb8e80e14 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yC7r3u5nqLLvyzhuhDvtF6gd4eGt+B5/F7PTDOTHFTgUbGavjzj3GJsgEVV/VEHefnZm/RsZnLGeyLNsROChWw7UmhBVWGDWWhm1/TRCh8TlAgvBTyDXKA85/ThY9IOEMJMU2FthV+4jpzDRzRPsVHRyJhdCyQqnBV0ay1+Bn+VtKgsrbkpCoEZ0hUwHjoGYRqGgObBBCGlTSwZf3z6by2fwlo7MTAH7LPnkVALRu6RP2hl7TkLY4PdFFnV5WvfBym3eEgXqGIy5d5hDcTShAK8Dqf5zjkx5+QOOYUMvOXOl7Om6ihZNG3mFQ514PcsVfuOjynHwWOj+fXVOWTV7vhXv+UFRHmcXBLepoBdxqI2KbJJHQlNSkpd4e8PittugIIYh7utWiim+uUa3i/2FsFoevm/5vZXWsU8nrZBM3R93nznHMKAa55Cok7UvOJr+6gyjlopwy7XjD707+PcO/afofeUA82gq4Vs3aWC/CpTGGv0/XfGAV4CENnv4QBNVHbxw3LFbNrfWGakZE5D6MHwXFuXwYpeffHs22OGCBHSs3pYmzhOyO+wKq5wjJG0QbCsDHiv203JHwqI8lqBob3awbrCy6nZIWFmRgQ3Yymw+EkdwGMNkvYUxlqAFETpW9HhEmw7M8pan5SGZ1gKrJY4MyElaXFoRUnv4Bap/Xm9tGo81/M2Dx9N29Fu+Q7IwDKZyd6Tiw7Nbk6HEDQEFgHdr+qqT5zRuxcjDxvc9ugQ31VAWjMs7nui0tHwYx3wF8ucpV/3rFQ7nZfrVX6Nagg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(39860400002)(346002)(376002)(82310400011)(1800799009)(186009)(451199024)(40470700004)(36840700001)(46966006)(356005)(26005)(81166007)(16526019)(82740400003)(2616005)(8936002)(8676002)(4326008)(1076003)(40460700003)(47076005)(36860700001)(2906002)(426003)(36756003)(336012)(5660300002)(40480700001)(86362001)(7696005)(478600001)(6666004)(316002)(70206006)(70586007)(110136005)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 08:11:40.9824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7675cbf1-2d4f-4e1d-e4a1-08dbb8e80e14 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8713 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org In most cases, ambient color sensors also support the x and y light colors, which represent the coordinates on the CIE 1931 chromaticity diagram. Thus, add light chromaticity x and y. Signed-off-by: Basavaraj Natikar Acked-by: Srinivas Pandruvada --- drivers/iio/light/hid-sensor-als.c | 63 ++++++++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 3 ++ 2 files changed, 66 insertions(+) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 16a3f1941c27..c9d114ff080a 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -17,6 +17,8 @@ enum { CHANNEL_SCAN_INDEX_INTENSITY, CHANNEL_SCAN_INDEX_ILLUM, CHANNEL_SCAN_INDEX_COLOR_TEMP, + CHANNEL_SCAN_INDEX_CHROMATICITY_X, + CHANNEL_SCAN_INDEX_CHROMATICITY_Y, CHANNEL_SCAN_INDEX_MAX }; @@ -76,6 +78,30 @@ static const struct iio_chan_spec als_channels[] = { BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), .scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP, }, + { + .type = IIO_CHROMATICITY, + .modified = 1, + .channel2 = IIO_MOD_X, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_HYSTERESIS) | + BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), + .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X, + }, + { + .type = IIO_CHROMATICITY, + .modified = 1, + .channel2 = IIO_MOD_Y, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_HYSTERESIS) | + BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), + .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_Y, + }, IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP) }; @@ -119,6 +145,16 @@ static int als_read_raw(struct iio_dev *indio_dev, min = als_state->als[chan->scan_index].logical_minimum; address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE; break; + case CHANNEL_SCAN_INDEX_CHROMATICITY_X: + report_id = als_state->als[chan->scan_index].report_id; + min = als_state->als[chan->scan_index].logical_minimum; + address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X; + break; + case CHANNEL_SCAN_INDEX_CHROMATICITY_Y: + report_id = als_state->als[chan->scan_index].report_id; + min = als_state->als[chan->scan_index].logical_minimum; + address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y; + break; default: report_id = -1; break; @@ -243,6 +279,14 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev, als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data; ret = 0; break; + case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X: + als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_X] = sample_data; + ret = 0; + break; + case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y: + als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_Y] = sample_data; + ret = 0; + break; case HID_USAGE_SENSOR_TIME_TIMESTAMP: als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes, *(s64 *)raw_data); @@ -291,6 +335,25 @@ static int als_parse_report(struct platform_device *pdev, st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index, st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id); + for (i = 0; i < 2; i++) { + int next_scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X + i; + + ret = sensor_hub_input_get_attribute_info(hsdev, + HID_INPUT_REPORT, usage_id, + HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X + i, + &st->als[next_scan_index]); + if (ret < 0) + return ret; + + als_adjust_channel_bit_mask(channels, + CHANNEL_SCAN_INDEX_CHROMATICITY_X + i, + st->als[next_scan_index].size); + + dev_dbg(&pdev->dev, "als %x:%x\n", + st->als[next_scan_index].index, + st->als[next_scan_index].report_id); + } + st->scale_precision = hid_sensor_format_scale(usage_id, &st->als[CHANNEL_SCAN_INDEX_INTENSITY], &st->scale_pre_decml, &st->scale_post_decml); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index 8af4fb3e0254..6730ee900ee1 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -22,6 +22,9 @@ #define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0 #define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1 #define HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE 0x2004d2 +#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY 0x2004d3 +#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X 0x2004d4 +#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y 0x2004d5 /* PROX (200011) */ #define HID_USAGE_SENSOR_PROX 0x200011 From patchwork Tue Sep 19 08:10:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 724517 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 D1908CD54A7 for ; Tue, 19 Sep 2023 08:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbjISIMI (ORCPT ); Tue, 19 Sep 2023 04:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbjISIMC (ORCPT ); Tue, 19 Sep 2023 04:12:02 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE9A4197; Tue, 19 Sep 2023 01:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ehU/6wETGHNHtJ2nd84PXweGTbXEpXYW38Nun85TU8NG/LWv8Lq1i2zta3ahc/+fYDDMLCqQYF3HoVWcqBU7laNCvRMleSZx0iPuuHbzTfiqwfTLFKTm7qBJ1Fbnu6kRhFhex1UXcWFnEuH473mbPf9fTvadMKlxVKEJUnN/pS8LWJx/gTO+y7m0zrXqroicmxcdU1/Mb6pqZin6YMvTvGfzMnqv53oHerF8VBsrDPavKdwlnSxYAHDT0b/bXwfK8LpbBykPNZqowrnF5tYFk906sQPiVS2Lof9wzQBy9vIIb7mUFv3sLy2bTI8sTrKokMjGLzoVmWMXsXqNk6JjqQ== 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=BRttNnP96aTPXTUOo6HAVcO1CoeD7W1mXfqZ/tJJmZU=; b=HfpDXpW79wYDU7LoLoTp+hcredY9MQzgWkWG+QIUcGWc0zhj60XslFozbVssukvGL4AyBj/G3ijJkXbQyihgoP2WbTK7Xv/5u7zLfyFbdAhbAuIwcTqihzilUPe0sWT3RlUi3kixKkGSKxY6VfnzRb5g/OIXPgOCX9DXlv6meE9qguYlCGb8ldDIINsH47fIzxPbuzwFGHVU57mUm86GM9vb67LHGyhRpkp++eUellLIIKz6Obq0/Nj59d8Yz1LqgPacr8o3/+JS6AF0ryihREgCwFdk7MKZ1IFUvHoap2TG68KBEPHY7ORX/Wb4zhGNVfrdeIL46edYgeHsOCujfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BRttNnP96aTPXTUOo6HAVcO1CoeD7W1mXfqZ/tJJmZU=; b=UjCrodRmUoQFN/LDbeMM84Jt7dKCrbA/mXBiRPBpGDRqTD4wH5OaFaLv6CKLr4BlSyUWA9qj2cy9omjs83aFPfRq3lSa9WZG0YhJfK13CZmRkqlEWLzBnFPGklcqnLyVauH1pPYl9bkqQn7OAtA5MByRHa01l/Fll5W9ilIczpw= Received: from MW4PR04CA0062.namprd04.prod.outlook.com (2603:10b6:303:6b::7) by MN2PR12MB4046.namprd12.prod.outlook.com (2603:10b6:208:1da::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.34; Tue, 19 Sep 2023 08:11:48 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:303:6b:cafe::c0) by MW4PR04CA0062.outlook.office365.com (2603:10b6:303:6b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Tue, 19 Sep 2023 08:11:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Tue, 19 Sep 2023 08:11:47 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 19 Sep 2023 03:11:44 -0500 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH v2 9/9] HID: amd_sfh: Add light chromaticity for SFH1.1 Date: Tue, 19 Sep 2023 13:40:54 +0530 Message-ID: <20230919081054.2050714-10-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> References: <20230919081054.2050714-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EC:EE_|MN2PR12MB4046:EE_ X-MS-Office365-Filtering-Correlation-Id: ee221716-0782-4b78-397f-08dbb8e811f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nLA5dWu7yMjcGNYl0aKJ4izDVz7JBTJ6SH2o26b75irPAespa+0wYsc3dZgRq6JghCMgxpB+Inr85Hnf96kIK3l9BlvnVQDyyOkeRHMxCmRIauqlKIy0U8Vu45rv2PkoYjQTcte/rGQ/xULQw8dUuO8NoXL8oBBig2iG56u20t7nK/QooQNXBpoIPR66e0BcN88Yx0EwitASJVGuI3wufiLim3zje262wcenBDbrxD8iO1js6VTFnRT95fmd5ivG3HtDpwuI+QNv8C0iyEvxZ6FGCDhTAQ2kWol9hxTrk9Yf8WdweI7FLvHqTCUwjpGxxvME3fAwfqhlIMhre1DewV75u20LOTKM306GB4i4T6pxRfrGw6X65XkKZQEduhRUQiiNuk6ddHJeCjcyFADRlXMabmfHYK1wK/JxmEkdwcIEi5K123OJKkAa+8MC5fQqBqjClrFw66SVxXkADQwWAq8RXy3cHtbIUW/RM7PlglBhhBFChpEaxbRsflqpjvfP3drO+OEscEpIqk5MaTTqBnxMPDriWzVTRT0PAXNisZ+gE+n5awFkPHxOvZao8EX78VgpC1iAvQcsuvJKwBYsc9Xrx6PPFGwUJjziCuVZwLd0CWRjTwlfMQqy+brFD4H2FhRlbRbjCaCppfNonsOF7Mpdx4PjADCCixgU0rHbDG10ZxFGR3MP4UICqDn4gm/5h2PJt1zSgfFWDXzhH6rRHEfNmHh0FsBkja0/aBIFw3cmHqtrPIcflqBBkvdKmSqNOrgP4xAnOwiHa2Bzx3B6lg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199024)(82310400011)(1800799009)(186009)(46966006)(36840700001)(40470700004)(2906002)(40460700003)(83380400001)(1076003)(36756003)(86362001)(7696005)(6666004)(478600001)(2616005)(426003)(336012)(16526019)(26005)(40480700001)(8936002)(8676002)(4326008)(36860700001)(41300700001)(47076005)(5660300002)(316002)(356005)(81166007)(110136005)(70206006)(70586007)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 08:11:47.4832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee221716-0782-4b78-397f-08dbb8e811f7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4046 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org In most cases, ambient color sensors also support the x and y light colors, which represent the coordinates on the CIE 1931 chromaticity diagram. Thus, add light chromaticity x and y for SFH1.1. Signed-off-by: Basavaraj Natikar Acked-by: Jiri Kosina --- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c | 5 ++++- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c index f100aaafa167..8a037de08e92 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c @@ -238,8 +238,11 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, als_input.illuminance_value = float_to_int(als_data.lux); memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info)); - if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) + if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) { als_input.light_color_temp = als_data.light_color_temp; + als_input.chromaticity_x_value = float_to_int(als_data.chromaticity_x); + als_input.chromaticity_y_value = float_to_int(als_data.chromaticity_y); + } report_size = sizeof(als_input); memcpy(input_report, &als_input, sizeof(als_input)); diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h index 6f6f5db150c3..656c3e95ef8c 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h @@ -147,6 +147,8 @@ struct sfh_als_data { struct sfh_common_data commondata; u32 lux; u32 light_color_temp; + u32 chromaticity_x; + u32 chromaticity_y; }; struct hpd_status {