From patchwork Wed Dec 20 07:00:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 13499609 X-Patchwork-Delegate: jikos@jikos.cz Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2069.outbound.protection.outlook.com [40.107.96.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1DEA168C6 for ; Wed, 20 Dec 2023 07:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="XAt0ALyz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z7qjaF61umv3HBOP0fnRzfiRPdoTj+il+DkwkblMd7vseKRQcngNTaxCg3P/Hv4VpgTySoah0G9HXi+kPdweM8+CwzFDTLwJBegwzJb8WtSxkNrQ9ge2LpQqrU0dIb/yHzjfBbEt6i78seH79HdXpSkAyz2MM5uigXzbLeb4DJ9mpN8JCljj5ta95YlcRt9SgpXLggN6KokGqIlkemAtpIxDTYQD3kIBZ9zrkwmkqC6PEplBxQaCV/N0QY8OGeZzyUcq9QM400ggwz77yvnzMat0iUW5MAoeF2Lv7D/Za6rBmf6EgEB+zgMedJuZQocaFORK3T4pTU+vAjrXIfi41w== 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=eJqAHrkb3JXMmEz1ipqt5ZDFStxT42M3d0SUfwiHCkY=; b=jMAvIUjzZWu3cNWjG+uaBeNrMdGO36Pekutdy++6gA3pQ2pCNAukEO7CS+s+plJY6epun5bBYS52AlV6rQ4DsR5Lz2CzWUzF4Cnpf0xcnUlHs1Vp7Ql5ATc5CjZjQfETqHuOOsvy3btjZ6+vxuN0HJ/Azck7TbZpcN8giM4Db4X+4rZn/m+YeNXYrUhzOkHBEpv232eLrpOfl7htQ+F6BwC5UrK4OfuxOKl5GNitiHhIGeYlfOGvAh71YKi/mKHew+FgmmQy+GKDX6w/NI0R8JYnOSW+oo0qtPsLjt9QWA7aq6mLpB10gfMPwYQwNANd4D9jJuiLOPcVM0dUX3cIgw== 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 (0) 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=eJqAHrkb3JXMmEz1ipqt5ZDFStxT42M3d0SUfwiHCkY=; b=XAt0ALyzYcH4eaEF84dFRJAaAQPtYc9KVhmtfohy3tEEduBbvNFcgIbeRIqPiguEr7TTfVnFhCwmYRsNxDXUslY2xH1lf5efcd7j3w4FD1kTETH89pBiYMGzmnORYA59F+mekx1CdrQuEmzHzapdX5wjsz3Y3RjUBZZJiGMLomE= Received: from DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) by BN9PR12MB5225.namprd12.prod.outlook.com (2603:10b6:408:11e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Wed, 20 Dec 2023 07:01:14 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::d9) by DM6PR18CA0010.outlook.office365.com (2603:10b6:5:15b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38 via Frontend Transport; Wed, 20 Dec 2023 07:01:14 +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 DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Wed, 20 Dec 2023 07:01:14 +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.34; Wed, 20 Dec 2023 01:01:11 -0600 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH 1/3] HID: amd_sfh: rename float_to_int() to amd_sfh_float_to_int() Date: Wed, 20 Dec 2023 12:30:40 +0530 Message-ID: <20231220070042.610455-2-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231220070042.610455-1-Basavaraj.Natikar@amd.com> References: <20231220070042.610455-1-Basavaraj.Natikar@amd.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: DS1PEPF0001708E:EE_|BN9PR12MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 13307a9f-abc0-4321-b4a7-08dc012974e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: alvkfurs87TFo6ceaXdAYG5caXxCy/e/dKQ8uqQlfO+6pOAvb2f53l2PXKy+yC030KaQ3/Tji9QaCZJzZhnXilnQMs480tGhK3teP7Gx20po8UdQcb9voBpGJedCV4JW1uaeJQojsgvnDRqccaXcpI6INQ3Me1/9yvWsiz66hz3kT2XY14K6Iyb4PgvsQOxRt2aIPDeK1C6LAtMr7giut4FeBflR4nqguwhRFkbgSik0DFk/s2bjZzl+WaGdab0vaA7Cl7IyX8FqmdLVVhRtx91c1/2KDFAgLkllMDAGrM+ibshheh/GToep+3/FVt4ADWzQz1GTBbp5ic7MQAIt7+0kHJYheUBNid/d638peIu/iuSJC12YrAAt536HHjPwj5egbOPWElPki8zRtBO0bG9Gu6P+d5uw2z7C/0VzUBdy3tVz4zg5bi0iWH4awuuU0lpE2UvECHCS31xFlDA0kBiJ+d4sARgIi7mFzJZEPQYfdd6M08RLiE+lkOPQVk0lCbzQ9PO402Olgaa4SFCyu0q4iNPc7hwdO2eqKdLkXrwxGUwFPLu4F6ZdOf4i5OIxCjIkTxOsx1MGBZAG1nty9iHVnGZWB7ZIxArMMBb5iC92yh5bB8f8jmMgKC8fh6zXQNlxpV7MRexvSSNKIiLZlT+z6i2BU7rWhaDPB+pVupe1KHbwpuJPIm9xZmgkxZLeViXUYc806av1/P6zmTMaJIkbG4Vw6uAOJ6ymo1xXbRZLN0fASwO5ihEo5rDHR+OZNWH4HywQxTu4P+BzjOGt1Q== 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)(39860400002)(346002)(396003)(136003)(376002)(230922051799003)(1800799012)(82310400011)(186009)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(5660300002)(2906002)(40460700003)(41300700001)(81166007)(356005)(36756003)(110136005)(86362001)(82740400003)(966005)(26005)(426003)(66574015)(1076003)(2616005)(16526019)(478600001)(6666004)(336012)(47076005)(7696005)(36860700001)(83380400001)(8936002)(4326008)(8676002)(70206006)(70586007)(316002)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2023 07:01:14.5287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13307a9f-abc0-4321-b4a7-08dc012974e2 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5225 Current amd_sfh driver has float_to_int() to convert units from float to int. This is fine until this function gets called outside of the current scope of file. Add a prefix "amd_sfh" to float_to_int() so that function represents the driver name. This function will be called by multiple callers in the next patch. Link: https://lore.kernel.org/all/ad064333-48a4-4cfa-9428-69e8a7c44667@redhat.com/ Reviewed-by: Ilpo Järvinen Co-developed-by: Shyam Sundar S K Signed-off-by: Shyam Sundar S K Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c | 28 ++++++++++--------- .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) 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 8a037de08e92..33fbdde8aff0 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 @@ -132,7 +132,7 @@ static void get_common_inputs(struct common_input_property *common, int report_i common->event_type = HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM; } -static int float_to_int(u32 flt32_val) +int amd_sfh_float_to_int(u32 flt32_val) { int fraction, shift, mantissa, sign, exp, zeropre; @@ -201,9 +201,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, OFFSET_SENSOR_DATA_DEFAULT; memcpy_fromio(&accel_data, sensoraddr, sizeof(struct sfh_accel_data)); get_common_inputs(&acc_input.common_property, report_id); - acc_input.in_accel_x_value = float_to_int(accel_data.acceldata.x) / 100; - acc_input.in_accel_y_value = float_to_int(accel_data.acceldata.y) / 100; - acc_input.in_accel_z_value = float_to_int(accel_data.acceldata.z) / 100; + acc_input.in_accel_x_value = amd_sfh_float_to_int(accel_data.acceldata.x) / 100; + acc_input.in_accel_y_value = amd_sfh_float_to_int(accel_data.acceldata.y) / 100; + acc_input.in_accel_z_value = amd_sfh_float_to_int(accel_data.acceldata.z) / 100; memcpy(input_report, &acc_input, sizeof(acc_input)); report_size = sizeof(acc_input); break; @@ -212,9 +212,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, OFFSET_SENSOR_DATA_DEFAULT; memcpy_fromio(&gyro_data, sensoraddr, sizeof(struct sfh_gyro_data)); get_common_inputs(&gyro_input.common_property, report_id); - gyro_input.in_angel_x_value = float_to_int(gyro_data.gyrodata.x) / 1000; - gyro_input.in_angel_y_value = float_to_int(gyro_data.gyrodata.y) / 1000; - gyro_input.in_angel_z_value = float_to_int(gyro_data.gyrodata.z) / 1000; + gyro_input.in_angel_x_value = amd_sfh_float_to_int(gyro_data.gyrodata.x) / 1000; + gyro_input.in_angel_y_value = amd_sfh_float_to_int(gyro_data.gyrodata.y) / 1000; + gyro_input.in_angel_z_value = amd_sfh_float_to_int(gyro_data.gyrodata.z) / 1000; memcpy(input_report, &gyro_input, sizeof(gyro_input)); report_size = sizeof(gyro_input); break; @@ -223,9 +223,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, OFFSET_SENSOR_DATA_DEFAULT; memcpy_fromio(&mag_data, sensoraddr, sizeof(struct sfh_mag_data)); get_common_inputs(&magno_input.common_property, report_id); - magno_input.in_magno_x = float_to_int(mag_data.magdata.x) / 100; - magno_input.in_magno_y = float_to_int(mag_data.magdata.y) / 100; - magno_input.in_magno_z = float_to_int(mag_data.magdata.z) / 100; + magno_input.in_magno_x = amd_sfh_float_to_int(mag_data.magdata.x) / 100; + magno_input.in_magno_y = amd_sfh_float_to_int(mag_data.magdata.y) / 100; + magno_input.in_magno_z = amd_sfh_float_to_int(mag_data.magdata.z) / 100; magno_input.in_magno_accuracy = mag_data.accuracy / 100; memcpy(input_report, &magno_input, sizeof(magno_input)); report_size = sizeof(magno_input); @@ -235,13 +235,15 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, OFFSET_SENSOR_DATA_DEFAULT; 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); + als_input.illuminance_value = amd_sfh_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; - als_input.chromaticity_x_value = float_to_int(als_data.chromaticity_x); - als_input.chromaticity_y_value = float_to_int(als_data.chromaticity_y); + als_input.chromaticity_x_value = + amd_sfh_float_to_int(als_data.chromaticity_x); + als_input.chromaticity_y_value = + amd_sfh_float_to_int(als_data.chromaticity_y); } report_size = 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 656c3e95ef8c..75267b0fec70 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 @@ -166,4 +166,5 @@ struct hpd_status { void sfh_interface_init(struct amd_mp2_dev *mp2); void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops); +int amd_sfh_float_to_int(u32 flt32_val); #endif From patchwork Wed Dec 20 07:00:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 13499610 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 200F5168B3 for ; Wed, 20 Dec 2023 07:01:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="BH3c/CQA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dOA02wHacGqb8seQlaO2FyWaLUwsWZhYlE9wMM6sjv8o/ZBaA6U2b6cPPI5iN9hnFyVG5+yqIb0JECM/zLTfWxU9rGSuTmy1zmEr36ziXT5OBPfibH0jWL+RXkPAe547IIyt0WignRRGvT5opSaHYC8UV2jbnUkkJ+KEB5vO02QhbQYADeLTJ3wZdol9lECX807WtSIpYhpnVpqV2jHT2A8lG36FMFMafGqAGSUjNyzTuwKtPb3O1e5MCtvfi6QTP06YDVxl5A5rWsaTn3PAVjk7Q6d2s9/EgWC+MBM4ucY8AgXTwLKF4nL1KUvFg1wMBndlir75Q9N5dpx9t8+DbQ== 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=AOm92nCn/abwH1ffv4vVntBtcOq8/tmnVp/pzRIlO80=; b=Sdh8Bff3Wcrf/bQj3nleudYpXXVAi3U4dof1enMs9Gy7vACFBNERmWFOE3bo1/ZRxiLjm+KNITK7wTWZXs2SFxt9DftWCpRPu5p5g8qkmd9Ijv+UKLxLCxget9eUSooYHeQDZtCKseD8VLX2OjQ4G5OUm/dAA9aXsCxqBG+F939FfU64hOY1xrF+gpILEUP1GcwZErcP5ST0YCWW0fbYkoY2UCKpXHs+MLoE7wtRkZ5gnT/EiscxQijNb2kMtfl7DOwVC/9/ns0Im0+vD53wKpl6b+JzstL8Qx6xtiHa+f/NjurlNXD41s1d41W4H4HnywiW8FIBw0xu30MNWGVqRw== 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 (0) 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=AOm92nCn/abwH1ffv4vVntBtcOq8/tmnVp/pzRIlO80=; b=BH3c/CQAGXSI6EZos+XyVr4HeOGQjQHCt/V+DvPJlFAgfKVXhk3VhWXRkxn+pqWh9ZQpFP9q4+yuI26Z2wA41P0WzQyiJxshm90f+3JaUDK+OSTwJVk93QdsTsUxvM2aI9ACueSYFIZBDVxGfzGtylFq1yye5ivZE+WlbskiVy0= Received: from DM6PR18CA0031.namprd18.prod.outlook.com (2603:10b6:5:15b::44) by SJ0PR12MB5663.namprd12.prod.outlook.com (2603:10b6:a03:42a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Wed, 20 Dec 2023 07:01:18 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::7a) by DM6PR18CA0031.outlook.office365.com (2603:10b6:5:15b::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38 via Frontend Transport; Wed, 20 Dec 2023 07:01:18 +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 DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Wed, 20 Dec 2023 07:01:18 +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.34; Wed, 20 Dec 2023 01:01:14 -0600 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH 2/3] HID: amd_sfh: Add a new interface for exporting HPD data Date: Wed, 20 Dec 2023 12:30:41 +0530 Message-ID: <20231220070042.610455-3-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231220070042.610455-1-Basavaraj.Natikar@amd.com> References: <20231220070042.610455-1-Basavaraj.Natikar@amd.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: DS1PEPF0001708E:EE_|SJ0PR12MB5663:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fd1cabe-82e1-4c36-369c-08dc0129772d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i1+qTNyJ7xnfAXDdNvz1osNzkzEhUv3+IIuHUXIfDkJUK2CFc+xR32PGW3NY8KDPxKcoqUUrDqafpyhzGl1pRenoYrQX4KmEF1VIH0wHcSrTVlDoVGDtzoto+oRabH58FxXmHpN9EFimfRtdAWmkf2F8mAnIB8+OxUMfUpIoxdhBhL6itFkDZhdqqwkoXfaAjVjYxE3wTxI5f/NBxtbTeaWz7prdS0CpkAM2m/pnJeZLf6OThXu4S3MV7Ueh69Z2IgaHrgmASoUNLLmZkW4nLefeijqpNoV7vvidoUGCohgc55uDIAjlqxGsWqpHrPmJs1sLXfei797goO0VlwNeiHF7P119wZXc/ZwGavfhOGlFZuham6ttBWQTwu7UBk0M80/jPoTcz6I78/sqorqtXQsZum7Bizq6AAuMZtcZHg4XbLa37JuQvmbjEcXJTnbxHBmUVgXAoXct+1M2KgFz0d0L4JP0cwB6FwPmWfPcJ/IRef1e0c1sM08hqIQy5R5XrReh0je0nws096PfEZZSP5sTNbxwS2EYMTVc0nksxb5Uh7B2Xu5alWqq5NWegJs3uy2C5Kh0ZvYIqnDjrTW/+fP9sObBO7U4l6x8WtfGmJmY9K3BmGWlKllQmm1a9lft5lj6caRQsN0R5SxzT2diBx+leOd5KhLzQBzN86hG0UuXNbhsPIohgrN7h3ZeopzUcItDE7UD2qBA9bgfzeCho12rRJFaLKjJ2TD7X7rgVromtiCY3q1kJKY0B/pKlTDjqUSf6ZrmpyNXaY9nn6aKIg== 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)(136003)(396003)(376002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799012)(82310400011)(186009)(46966006)(36840700001)(40470700004)(36860700001)(2906002)(47076005)(41300700001)(86362001)(81166007)(36756003)(356005)(82740400003)(6666004)(316002)(478600001)(110136005)(7696005)(8936002)(8676002)(70586007)(70206006)(966005)(336012)(426003)(16526019)(1076003)(5660300002)(26005)(4326008)(83380400001)(2616005)(40480700001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2023 07:01:18.3569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fd1cabe-82e1-4c36-369c-08dc0129772d 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5663 AMDSFH has information about the User presence information via the Human Presence Detection (HPD) sensor which is part of the AMD sensor fusion hub. Add a new interface to export this information, where other drivers like PMF can use this information to enhance user experiences. Link: https://lore.kernel.org/all/ad064333-48a4-4cfa-9428-69e8a7c44667@redhat.com/ Co-developed-by: Shyam Sundar S K Signed-off-by: Shyam Sundar S K Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 5 ++ drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 14 ++++++ .../amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 37 +++++++++++++++ .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 1 + include/linux/amd-pmf-io.h | 46 +++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 include/linux/amd-pmf-io.h diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index 2643bb14fee2..cd57037bf217 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -37,6 +37,10 @@ struct amd_mp2_sensor_info { dma_addr_t dma_address; }; +struct sfh_dev_status { + bool is_hpd_present; +}; + struct amd_mp2_dev { struct pci_dev *pdev; struct amdtp_cl_data *cl_data; @@ -47,6 +51,7 @@ struct amd_mp2_dev { struct amd_input_data in_data; /* mp2 active control status */ u32 mp2_acs; + struct sfh_dev_status dev_en; }; struct amd_mp2_ops { diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c index e9c6413af24a..0351b0fd394a 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c @@ -73,6 +73,12 @@ static int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata) int i, status; for (i = 0; i < cl_data->num_hid_devices; i++) { + switch (cl_data->sensor_idx[i]) { + case HPD_IDX: + privdata->dev_en.is_hpd_present = false; + break; + } + if (cl_data->sensor_sts[i] == SENSOR_ENABLED) { privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]); status = amd_sfh_wait_for_response @@ -178,6 +184,11 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata) rc = amdtp_hid_probe(i, cl_data); if (rc) goto cleanup; + switch (cl_data->sensor_idx[i]) { + case HPD_IDX: + privdata->dev_en.is_hpd_present = true; + break; + } } dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n", cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), @@ -259,6 +270,7 @@ static void amd_mp2_pci_remove(void *privdata) { struct amd_mp2_dev *mp2 = privdata; + sfh_deinit_emp2(); amd_sfh_hid_client_deinit(privdata); mp2->mp2_ops->stop_all(mp2); pci_intx(mp2->pdev, false); @@ -311,12 +323,14 @@ int amd_sfh1_1_init(struct amd_mp2_dev *mp2) rc = amd_sfh_irq_init(mp2); if (rc) { + sfh_deinit_emp2(); dev_err(dev, "amd_sfh_irq_init failed\n"); return rc; } rc = amd_sfh1_1_hid_client_init(mp2); if (rc) { + sfh_deinit_emp2(); dev_err(dev, "amd_sfh1_1_hid_client_init failed\n"); return rc; } diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c index 4f81ef2d4f56..197b828fc6a0 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c @@ -7,11 +7,14 @@ * * Author: Basavaraj Natikar */ +#include #include #include #include "amd_sfh_interface.h" +static struct amd_mp2_dev *emp2; + static int amd_sfh_wait_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id) { struct sfh_cmd_response cmd_resp; @@ -73,7 +76,41 @@ static struct amd_mp2_ops amd_sfh_ops = { .response = amd_sfh_wait_response, }; +void sfh_deinit_emp2(void) +{ + emp2 = NULL; +} + void sfh_interface_init(struct amd_mp2_dev *mp2) { mp2->mp2_ops = &amd_sfh_ops; + emp2 = mp2; +} + +static int amd_sfh_hpd_info(u8 *user_present) +{ + struct hpd_status hpdstatus; + + if (!user_present) + return -EINVAL; + + if (!emp2 || !emp2->dev_en.is_hpd_present) + return -ENODEV; + + hpdstatus.val = readl(emp2->mmio + AMD_C2P_MSG(4)); + *user_present = hpdstatus.shpd.presence; + + return 0; +} + +int amd_get_sfh_info(struct amd_sfh_info *sfh_info, enum sfh_message_type op) +{ + if (sfh_info) { + switch (op) { + case MT_HPD: + return amd_sfh_hpd_info(&sfh_info->user_present); + } + } + return -EINVAL; } +EXPORT_SYMBOL_GPL(amd_get_sfh_info); 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 75267b0fec70..2c211d28764d 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 @@ -165,6 +165,7 @@ struct hpd_status { }; void sfh_interface_init(struct amd_mp2_dev *mp2); +void sfh_deinit_emp2(void); void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops); int amd_sfh_float_to_int(u32 flt32_val); #endif diff --git a/include/linux/amd-pmf-io.h b/include/linux/amd-pmf-io.h new file mode 100644 index 000000000000..5b6d29d36922 --- /dev/null +++ b/include/linux/amd-pmf-io.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AMD Platform Management Framework Interface + * + * Copyright (c) 2023, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Authors: Shyam Sundar S K + * Basavaraj Natikar + */ + +#ifndef AMD_PMF_IO_H +#define AMD_PMF_IO_H + +#include + +/** + * enum sfh_message_type - Query the SFH message type + * @MT_HPD: Message ID to know the Human presence info from MP2 FW + */ +enum sfh_message_type { + MT_HPD, +}; + +/** + * enum sfh_hpd_info - Query the Human presence information + * @SFH_NOT_DETECTED: Check the HPD connection information from MP2 FW + * @SFH_USER_PRESENT: Check if the user is present from HPD sensor + * @SFH_USER_AWAY: Check if the user is away from HPD sensor + */ +enum sfh_hpd_info { + SFH_NOT_DETECTED, + SFH_USER_PRESENT, + SFH_USER_AWAY, +}; + +/** + * struct amd_sfh_info - get HPD sensor info from MP2 FW + * @user_present: Populates the user presence information + */ +struct amd_sfh_info { + u8 user_present; +}; + +int amd_get_sfh_info(struct amd_sfh_info *sfh_info, enum sfh_message_type op); +#endif From patchwork Wed Dec 20 07:00:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 13499611 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2079.outbound.protection.outlook.com [40.107.212.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD6A4168B2 for ; Wed, 20 Dec 2023 07:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MaO92EFV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JMY4EzrN6pj/88WYHDu9SiMIS7GMm4ysjvySPIsSCnlkJVd6bjQXpAhS2tsIt/UVWP0TMIWvML+NvHqPYPf9GS5AebwqP/xRvDBAeUCpfw7B85HP4uFksxgfBTrNzxzNs3r+8njhGco92wZroyAJrjQz9ffgrKsbaQkzNb4XB6N7NfTzEeWLTpl3yXPmvHVu/7zxIwKydBF3qy4wrwO53IVtiJeHr5YOjw9wH5aweTOMgNnYgIXH6qM3tRVfPcfWvl3z7fkpHrPx1pNPuN5aa1iXItiixI5qzJvRNybLU+3hrjUHFXzn6gCodnsbIKr377Em0ExPb8N+kC/uiboXbA== 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=6a6ZvfwRVMBN8Ha0Th5F3YWrncskSi5ZOyP6GrQglKU=; b=f4k3/K5j8U5IEXi2l75FhUo/9zE7xUXSig6KqewyxAuRSfOMBXlZyj33Kafa/79LNRe1zbMaSMmTwN3F8Ev/YTI+YJkts6LnXHLAB0wCOuscSWGDqZRcS7rmciVGc1BD6QrfvZapSihuzG5BhDOEBFx3YzfK7x8ge8ROl3Ppf8Anpt5Vyg+F1U3sREbymeb/t5s/bOT8ryCCa2gqnFwtBSC6ZlJJHzjoG5JUKpDdxZqkMrpXCGZ+lMyLkYah0UCvywSXieCj8o+OfdWpLvKJqmxL5mNYFIYPCbarTtBltLmNiR5QalxPFQhGtX5NUlhL7NrhEekmeVvT3lUC2Nl2/g== 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 (0) 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=6a6ZvfwRVMBN8Ha0Th5F3YWrncskSi5ZOyP6GrQglKU=; b=MaO92EFVDDl1RQvxNyDLaWbGkKY+mrge45us4HFn+VPpDRRxSC2IVlXCk5oWPrqcC0G2BrMCI7RGwuzWISXtgOiGSzvFso8wBJMOc/J+66ZYoVjWnLZXXogwTMcunPhD4ZhqVwZFv1QwhFDJLumGQSmFgWgd/P1P3ymwSfJ1d8U= Received: from DM6PR03CA0075.namprd03.prod.outlook.com (2603:10b6:5:333::8) by DM4PR12MB7504.namprd12.prod.outlook.com (2603:10b6:8:110::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Wed, 20 Dec 2023 07:01:29 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:333:cafe::5b) by DM6PR03CA0075.outlook.office365.com (2603:10b6:5:333::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18 via Frontend Transport; Wed, 20 Dec 2023 07:01: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 DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Wed, 20 Dec 2023 07:01: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.34; Wed, 20 Dec 2023 01:01:17 -0600 From: Basavaraj Natikar To: , , , , , , CC: Basavaraj Natikar Subject: [PATCH 3/3] HID: amd_sfh: Add a new interface for exporting ALS data Date: Wed, 20 Dec 2023 12:30:42 +0530 Message-ID: <20231220070042.610455-4-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231220070042.610455-1-Basavaraj.Natikar@amd.com> References: <20231220070042.610455-1-Basavaraj.Natikar@amd.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: DS1PEPF0001708F:EE_|DM4PR12MB7504:EE_ X-MS-Office365-Filtering-Correlation-Id: fcebb26e-7863-4e39-0405-08dc01297d74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lk9sCzdO41YP5k9h8JbhPKb/jtHdigz3sk2C9ucJ5vjHVRmggO1giM9JzSvh2pADKDdCTv1NLl+ylCQIaEww4ubWk+I2IUMc80wuIZ9py+PfKUZnIUVzIPTWv7/yiHKplJiprwt9v01NPP2OOydqwwkSbe+FLZSjeJ1tFLYKYYbAvkpGhcUlKMVSsVdNLif+MIzqo32d0CTREWOSNSpBjYDS0dLifLJb1CnMxHAngF7tb7lXpWz6W6R3mByiCkGLUBv2ETt7kzAEX9zBtObTs0uoZggID2GDq8XtF8X52vP4ImEMOdavTOAvszWgxi/UWD8q9qKHuXE+VjLd2usLhilUX4ZA5dD47NghzFJ6MH6Z4TFAqydzZWbGt2r9dr4cd2QdkQ637O3o72p5TEbmGO3R3wfNEO8BLLDoMNPICuB1xHU5mA03kBq3k5q9CFqinpehNSspslzQmHNXd6KoBrSm5vufF9vuMWl2H7AhHLMcbucF2aeegEymSjmFcSk6SqGClMvyptW9BMjvuC982BZIgxG2L8Buoo6/BK+yh6rMKjFOWwR4WtppHrXGQCSPmZHOBn3wb912jT6bw+MFHNGesK35z9dRXim9mRs1dQXc60kmjq5FRlMgBNwpQ7PJIMfE1UxnPpeejOFKkJ/KYi2jzXj3/C4+sHvCOdX/Zidnq5KZuQuxrY8tDd42MyYt960zree2gTq9QpU/sL0H+i78MVtI5Va+kON58p/FgkLQ1/0QsKY1WP8Szly9WP4BDiD0QoYvfTD5X85vtalg5Q== 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)(39860400002)(346002)(136003)(396003)(376002)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(82310400011)(46966006)(36840700001)(40470700004)(36756003)(47076005)(36860700001)(4326008)(8936002)(8676002)(81166007)(40480700001)(2906002)(5660300002)(1076003)(478600001)(966005)(70586007)(110136005)(2616005)(70206006)(316002)(26005)(336012)(426003)(83380400001)(16526019)(6666004)(41300700001)(40460700003)(86362001)(7696005)(356005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2023 07:01:28.8872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fcebb26e-7863-4e39-0405-08dc01297d74 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7504 AMDSFH has information about the Ambient light via the Ambient Light Sensor (ALS) which is part of the AMD sensor fusion hub. Add a new interface to export this information, where other drivers like PMF can use this information to enhance user experiences. Link: https://lore.kernel.org/all/ad064333-48a4-4cfa-9428-69e8a7c44667@redhat.com/ Reviewed-by: Mario Limonciello Co-developed-by: Shyam Sundar S K Signed-off-by: Shyam Sundar S K Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 1 + drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 6 +++++ .../amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 22 +++++++++++++++++++ include/linux/amd-pmf-io.h | 4 ++++ 4 files changed, 33 insertions(+) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index cd57037bf217..a1950bc6e6ce 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -39,6 +39,7 @@ struct amd_mp2_sensor_info { struct sfh_dev_status { bool is_hpd_present; + bool is_als_present; }; struct amd_mp2_dev { diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c index 0351b0fd394a..9dbe6f4cb294 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c @@ -77,6 +77,9 @@ static int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata) case HPD_IDX: privdata->dev_en.is_hpd_present = false; break; + case ALS_IDX: + privdata->dev_en.is_als_present = false; + break; } if (cl_data->sensor_sts[i] == SENSOR_ENABLED) { @@ -188,6 +191,9 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata) case HPD_IDX: privdata->dev_en.is_hpd_present = true; break; + case ALS_IDX: + privdata->dev_en.is_als_present = true; + break; } } dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n", diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c index 197b828fc6a0..ae36312bc236 100644 --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c @@ -103,12 +103,34 @@ static int amd_sfh_hpd_info(u8 *user_present) return 0; } +static int amd_sfh_als_info(u32 *ambient_light) +{ + struct sfh_als_data als_data; + void __iomem *sensoraddr; + + if (!ambient_light) + return -EINVAL; + + if (!emp2 || !emp2->dev_en.is_als_present) + return -ENODEV; + + sensoraddr = emp2->vsbase + + (ALS_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) + + OFFSET_SENSOR_DATA_DEFAULT; + memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data)); + *ambient_light = amd_sfh_float_to_int(als_data.lux); + + return 0; +} + int amd_get_sfh_info(struct amd_sfh_info *sfh_info, enum sfh_message_type op) { if (sfh_info) { switch (op) { case MT_HPD: return amd_sfh_hpd_info(&sfh_info->user_present); + case MT_ALS: + return amd_sfh_als_info(&sfh_info->ambient_light); } } return -EINVAL; diff --git a/include/linux/amd-pmf-io.h b/include/linux/amd-pmf-io.h index 5b6d29d36922..b4f818205216 100644 --- a/include/linux/amd-pmf-io.h +++ b/include/linux/amd-pmf-io.h @@ -17,9 +17,11 @@ /** * enum sfh_message_type - Query the SFH message type * @MT_HPD: Message ID to know the Human presence info from MP2 FW + * @MT_ALS: Message ID to know the Ambient light info from MP2 FW */ enum sfh_message_type { MT_HPD, + MT_ALS, }; /** @@ -36,9 +38,11 @@ enum sfh_hpd_info { /** * struct amd_sfh_info - get HPD sensor info from MP2 FW + * @ambient_light: Populates the ambient light information * @user_present: Populates the user presence information */ struct amd_sfh_info { + u32 ambient_light; u8 user_present; };