Skip to content

Commit 3a807f3

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: Enable operating mode
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 <[email protected]> Co-developed-by: Akshata MukundShetty <[email protected]> Signed-off-by: Akshata MukundShetty <[email protected]> Signed-off-by: Basavaraj Natikar <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 8a20830 commit 3a807f3

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ static const char *get_sensor_name(int idx)
146146
return "gyroscope";
147147
case mag_idx:
148148
return "magnetometer";
149+
case op_idx:
150+
return "operating-mode";
149151
case als_idx:
150152
case ACS_IDX: /* ambient color sensor */
151153
return "ALS";
@@ -243,6 +245,20 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
243245
rc = -ENOMEM;
244246
goto cleanup;
245247
}
248+
249+
if (cl_data->sensor_idx[i] == op_idx) {
250+
info.period = AMD_SFH_IDLE_LOOP;
251+
info.sensor_idx = cl_data->sensor_idx[i];
252+
info.dma_address = cl_data->sensor_dma_addr[i];
253+
mp2_ops->start(privdata, info);
254+
cl_data->sensor_sts[i] = amd_sfh_wait_for_response(privdata,
255+
cl_data->sensor_idx[i],
256+
SENSOR_ENABLED);
257+
if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
258+
cl_data->is_any_sensor_enabled = true;
259+
continue;
260+
}
261+
246262
cl_data->sensor_sts[i] = SENSOR_DISABLED;
247263
cl_data->sensor_requested_cnt[i] = 0;
248264
cl_data->cur_hid_dev = i;
@@ -303,6 +319,13 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
303319

304320
for (i = 0; i < cl_data->num_hid_devices; i++) {
305321
cl_data->cur_hid_dev = i;
322+
if (cl_data->sensor_idx[i] == op_idx) {
323+
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
324+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
325+
cl_data->sensor_sts[i]);
326+
continue;
327+
}
328+
306329
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
307330
rc = amdtp_hid_probe(i, cl_data);
308331
if (rc)

drivers/hid/amd-sfh-hid/amd_sfh_hid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef AMDSFH_HID_H
1212
#define AMDSFH_HID_H
1313

14-
#define MAX_HID_DEVICES 6
14+
#define MAX_HID_DEVICES 7
1515
#define AMD_SFH_HID_VENDOR 0x1022
1616
#define AMD_SFH_HID_PRODUCT 0x0001
1717

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define ACEL_EN BIT(0)
3030
#define GYRO_EN BIT(1)
3131
#define MAGNO_EN BIT(2)
32+
#define OP_EN BIT(15)
3233
#define HPD_EN BIT(16)
3334
#define ALS_EN BIT(19)
3435
#define ACS_EN BIT(22)
@@ -232,6 +233,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
232233
if (MAGNO_EN & activestatus)
233234
sensor_id[num_of_sensors++] = mag_idx;
234235

236+
if (OP_EN & activestatus)
237+
sensor_id[num_of_sensors++] = op_idx;
238+
235239
if (ALS_EN & activestatus)
236240
sensor_id[num_of_sensors++] = als_idx;
237241

drivers/hid/amd-sfh-hid/amd_sfh_pcie.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ enum sensor_idx {
7979
accel_idx = 0,
8080
gyro_idx = 1,
8181
mag_idx = 2,
82+
op_idx = 15,
8283
als_idx = 19
8384
};
8485

0 commit comments

Comments
 (0)