* [PATCH v2] HID: amd_sfh: Enable operating mode
@ 2025-06-23 8:54 Basavaraj Natikar
2025-06-23 14:59 ` Limonciello, Mario
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Basavaraj Natikar @ 2025-06-23 8:54 UTC (permalink / raw)
To: jikos, bentiss
Cc: Mario.Limonciello, linux-input, Basavaraj Natikar, Eric Naim,
Akshata MukundShetty
Add changes to enable operating modes in the driver to allow the FW to
activate and retrieve data from relevant sensors. This enables the FW to
take necessary actions based on the operating modes.
Tested-by: Eric Naim <dnaim@cachyos.org>
Co-developed-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
Signed-off-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
v2:
* Increased missing device count.
---
drivers/hid/amd-sfh-hid/amd_sfh_client.c | 23 +++++++++++++++++++++++
drivers/hid/amd-sfh-hid/amd_sfh_hid.h | 2 +-
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++++
drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 +
4 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
index 3438d392920f..0f2cbae39b2b 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
@@ -146,6 +146,8 @@ static const char *get_sensor_name(int idx)
return "gyroscope";
case mag_idx:
return "magnetometer";
+ case op_idx:
+ return "operating-mode";
case als_idx:
case ACS_IDX: /* ambient color sensor */
return "ALS";
@@ -243,6 +245,20 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
rc = -ENOMEM;
goto cleanup;
}
+
+ if (cl_data->sensor_idx[i] == op_idx) {
+ info.period = AMD_SFH_IDLE_LOOP;
+ info.sensor_idx = cl_data->sensor_idx[i];
+ info.dma_address = cl_data->sensor_dma_addr[i];
+ mp2_ops->start(privdata, info);
+ cl_data->sensor_sts[i] = amd_sfh_wait_for_response(privdata,
+ cl_data->sensor_idx[i],
+ SENSOR_ENABLED);
+ if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
+ cl_data->is_any_sensor_enabled = true;
+ continue;
+ }
+
cl_data->sensor_sts[i] = SENSOR_DISABLED;
cl_data->sensor_requested_cnt[i] = 0;
cl_data->cur_hid_dev = i;
@@ -303,6 +319,13 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
for (i = 0; i < cl_data->num_hid_devices; i++) {
cl_data->cur_hid_dev = i;
+ if (cl_data->sensor_idx[i] == op_idx) {
+ dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
+ cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
+ cl_data->sensor_sts[i]);
+ continue;
+ }
+
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
rc = amdtp_hid_probe(i, cl_data);
if (rc)
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
index 1c91be8daedd..7452b0302953 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
@@ -11,7 +11,7 @@
#ifndef AMDSFH_HID_H
#define AMDSFH_HID_H
-#define MAX_HID_DEVICES 6
+#define MAX_HID_DEVICES 7
#define AMD_SFH_HID_VENDOR 0x1022
#define AMD_SFH_HID_PRODUCT 0x0001
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index 1c1fd63330c9..2983af969579 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -29,6 +29,7 @@
#define ACEL_EN BIT(0)
#define GYRO_EN BIT(1)
#define MAGNO_EN BIT(2)
+#define OP_EN BIT(15)
#define HPD_EN BIT(16)
#define ALS_EN BIT(19)
#define ACS_EN BIT(22)
@@ -232,6 +233,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
if (MAGNO_EN & activestatus)
sensor_id[num_of_sensors++] = mag_idx;
+ if (OP_EN & activestatus)
+ sensor_id[num_of_sensors++] = op_idx;
+
if (ALS_EN & activestatus)
sensor_id[num_of_sensors++] = als_idx;
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
index 05e400a4a83e..2eb61f4e8434 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
@@ -79,6 +79,7 @@ enum sensor_idx {
accel_idx = 0,
gyro_idx = 1,
mag_idx = 2,
+ op_idx = 15,
als_idx = 19
};
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] HID: amd_sfh: Enable operating mode
2025-06-23 8:54 [PATCH v2] HID: amd_sfh: Enable operating mode Basavaraj Natikar
@ 2025-06-23 14:59 ` Limonciello, Mario
2025-07-03 7:36 ` Jiri Kosina
2025-08-07 12:42 ` butmonkeh
2 siblings, 0 replies; 4+ messages in thread
From: Limonciello, Mario @ 2025-06-23 14:59 UTC (permalink / raw)
To: Natikar, Basavaraj, jikos@kernel.org, bentiss@kernel.org
Cc: linux-input@vger.kernel.org, Eric Naim, MukundShetty, Akshata
On 6/23/25 3:54 AM, Natikar, Basavaraj wrote:
> Add changes to enable operating modes in the driver to allow the FW to
> activate and retrieve data from relevant sensors. This enables the FW to
> take necessary actions based on the operating modes.
>
> Tested-by: Eric Naim <dnaim@cachyos.org>
> Co-developed-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
> Signed-off-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v2:
> * Increased missing device count.
> ---
> drivers/hid/amd-sfh-hid/amd_sfh_client.c | 23 +++++++++++++++++++++++
> drivers/hid/amd-sfh-hid/amd_sfh_hid.h | 2 +-
> drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++++
> drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 +
> 4 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
> index 3438d392920f..0f2cbae39b2b 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
> @@ -146,6 +146,8 @@ static const char *get_sensor_name(int idx)
> return "gyroscope";
> case mag_idx:
> return "magnetometer";
> + case op_idx:
> + return "operating-mode";
> case als_idx:
> case ACS_IDX: /* ambient color sensor */
> return "ALS";
> @@ -243,6 +245,20 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
> rc = -ENOMEM;
> goto cleanup;
> }
> +
> + if (cl_data->sensor_idx[i] == op_idx) {
> + info.period = AMD_SFH_IDLE_LOOP;
> + info.sensor_idx = cl_data->sensor_idx[i];
> + info.dma_address = cl_data->sensor_dma_addr[i];
> + mp2_ops->start(privdata, info);
> + cl_data->sensor_sts[i] = amd_sfh_wait_for_response(privdata,
> + cl_data->sensor_idx[i],
> + SENSOR_ENABLED);
> + if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
> + cl_data->is_any_sensor_enabled = true;
> + continue;
> + }
> +
> cl_data->sensor_sts[i] = SENSOR_DISABLED;
> cl_data->sensor_requested_cnt[i] = 0;
> cl_data->cur_hid_dev = i;
> @@ -303,6 +319,13 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
>
> for (i = 0; i < cl_data->num_hid_devices; i++) {
> cl_data->cur_hid_dev = i;
> + if (cl_data->sensor_idx[i] == op_idx) {
> + dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
> + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
> + cl_data->sensor_sts[i]);
> + continue;
> + }
> +
> if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
> rc = amdtp_hid_probe(i, cl_data);
> if (rc)
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
> index 1c91be8daedd..7452b0302953 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
> @@ -11,7 +11,7 @@
> #ifndef AMDSFH_HID_H
> #define AMDSFH_HID_H
>
> -#define MAX_HID_DEVICES 6
> +#define MAX_HID_DEVICES 7
> #define AMD_SFH_HID_VENDOR 0x1022
> #define AMD_SFH_HID_PRODUCT 0x0001
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
> index 1c1fd63330c9..2983af969579 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
> @@ -29,6 +29,7 @@
> #define ACEL_EN BIT(0)
> #define GYRO_EN BIT(1)
> #define MAGNO_EN BIT(2)
> +#define OP_EN BIT(15)
> #define HPD_EN BIT(16)
> #define ALS_EN BIT(19)
> #define ACS_EN BIT(22)
> @@ -232,6 +233,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
> if (MAGNO_EN & activestatus)
> sensor_id[num_of_sensors++] = mag_idx;
>
> + if (OP_EN & activestatus)
> + sensor_id[num_of_sensors++] = op_idx;
> +
> if (ALS_EN & activestatus)
> sensor_id[num_of_sensors++] = als_idx;
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
> index 05e400a4a83e..2eb61f4e8434 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
> @@ -79,6 +79,7 @@ enum sensor_idx {
> accel_idx = 0,
> gyro_idx = 1,
> mag_idx = 2,
> + op_idx = 15,
> als_idx = 19
> };
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] HID: amd_sfh: Enable operating mode
2025-06-23 8:54 [PATCH v2] HID: amd_sfh: Enable operating mode Basavaraj Natikar
2025-06-23 14:59 ` Limonciello, Mario
@ 2025-07-03 7:36 ` Jiri Kosina
2025-08-07 12:42 ` butmonkeh
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2025-07-03 7:36 UTC (permalink / raw)
To: Basavaraj Natikar
Cc: bentiss, Mario.Limonciello, linux-input, Eric Naim,
Akshata MukundShetty
On Mon, 23 Jun 2025, Basavaraj Natikar wrote:
> Add changes to enable operating modes in the driver to allow the FW to
> activate and retrieve data from relevant sensors. This enables the FW to
> take necessary actions based on the operating modes.
>
> Tested-by: Eric Naim <dnaim@cachyos.org>
> Co-developed-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
> Signed-off-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Applied to hid.git#for-6.17/amd-sfh. Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] HID: amd_sfh: Enable operating mode
2025-06-23 8:54 [PATCH v2] HID: amd_sfh: Enable operating mode Basavaraj Natikar
2025-06-23 14:59 ` Limonciello, Mario
2025-07-03 7:36 ` Jiri Kosina
@ 2025-08-07 12:42 ` butmonkeh
2 siblings, 0 replies; 4+ messages in thread
From: butmonkeh @ 2025-08-07 12:42 UTC (permalink / raw)
To: jikos, bentiss, Basavaraj Natikar
Cc: Mario.Limonciello, linux-input, Basavaraj Natikar, Eric Naim,
Akshata MukundShetty
On Monday, 23 June 2025 09:54:53 British Summer Time Basavaraj Natikar wrote:
> Add changes to enable operating modes in the driver to allow the FW to
> activate and retrieve data from relevant sensors. This enables the FW to
> take necessary actions based on the operating modes.
>
> Tested-by: Eric Naim <dnaim@cachyos.org>
> Co-developed-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
> Signed-off-by: Akshata MukundShetty <akshata.mukundshetty@amd.com>
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> ---
> v2:
> * Increased missing device count.
> ---
> drivers/hid/amd-sfh-hid/amd_sfh_client.c | 23 +++++++++++++++++++++++
> drivers/hid/amd-sfh-hid/amd_sfh_hid.h | 2 +-
> drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++++
> drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 +
> 4 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c
> b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index 3438d392920f..0f2cbae39b2b
> 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
> @@ -146,6 +146,8 @@ static const char *get_sensor_name(int idx)
> return "gyroscope";
> case mag_idx:
> return "magnetometer";
> + case op_idx:
> + return "operating-mode";
> case als_idx:
> case ACS_IDX: /* ambient color sensor */
> return "ALS";
> @@ -243,6 +245,20 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev
> *privdata) rc = -ENOMEM;
> goto cleanup;
> }
> +
> + if (cl_data->sensor_idx[i] == op_idx) {
> + info.period = AMD_SFH_IDLE_LOOP;
> + info.sensor_idx = cl_data->sensor_idx[i];
> + info.dma_address = cl_data->sensor_dma_addr[i];
> + mp2_ops->start(privdata, info);
> + cl_data->sensor_sts[i] =
amd_sfh_wait_for_response(privdata,
> +
cl_data->sensor_idx[i],
> +
SENSOR_ENABLED);
> + if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
> + cl_data->is_any_sensor_enabled = true;
> + continue;
> + }
> +
> cl_data->sensor_sts[i] = SENSOR_DISABLED;
> cl_data->sensor_requested_cnt[i] = 0;
> cl_data->cur_hid_dev = i;
> @@ -303,6 +319,13 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev
> *privdata)
>
> for (i = 0; i < cl_data->num_hid_devices; i++) {
> cl_data->cur_hid_dev = i;
> + if (cl_data->sensor_idx[i] == op_idx) {
> + dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
> + cl_data->sensor_idx[i],
get_sensor_name(cl_data->sensor_idx[i]),
> + cl_data->sensor_sts[i]);
> + continue;
> + }
> +
> if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
> rc = amdtp_hid_probe(i, cl_data);
> if (rc)
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
> b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h index 1c91be8daedd..7452b0302953
> 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h
> @@ -11,7 +11,7 @@
> #ifndef AMDSFH_HID_H
> #define AMDSFH_HID_H
>
> -#define MAX_HID_DEVICES 6
> +#define MAX_HID_DEVICES 7
> #define AMD_SFH_HID_VENDOR 0x1022
> #define AMD_SFH_HID_PRODUCT 0x0001
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
> b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 1c1fd63330c9..2983af969579
> 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
> @@ -29,6 +29,7 @@
> #define ACEL_EN BIT(0)
> #define GYRO_EN BIT(1)
> #define MAGNO_EN BIT(2)
> +#define OP_EN BIT(15)
> #define HPD_EN BIT(16)
> #define ALS_EN BIT(19)
> #define ACS_EN BIT(22)
> @@ -232,6 +233,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata,
> u8 *sensor_id) if (MAGNO_EN & activestatus)
> sensor_id[num_of_sensors++] = mag_idx;
>
> + if (OP_EN & activestatus)
> + sensor_id[num_of_sensors++] = op_idx;
> +
> if (ALS_EN & activestatus)
> sensor_id[num_of_sensors++] = als_idx;
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
> b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 05e400a4a83e..2eb61f4e8434
> 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
> @@ -79,6 +79,7 @@ enum sensor_idx {
> accel_idx = 0,
> gyro_idx = 1,
> mag_idx = 2,
> + op_idx = 15,
> als_idx = 19
> };
Tested-by: Marc H (butmonkeh@gmail.com) Asus ROG Flow X13 (GV301) - working
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-07 12:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 8:54 [PATCH v2] HID: amd_sfh: Enable operating mode Basavaraj Natikar
2025-06-23 14:59 ` Limonciello, Mario
2025-07-03 7:36 ` Jiri Kosina
2025-08-07 12:42 ` butmonkeh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).