Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>
Signed-off-by: Jiri Kosina <jkosina@suse.com>

authored by

Basavaraj Natikar and committed by
Jiri Kosina
3a807f3f 8a20830f

+29 -1
+23
drivers/hid/amd-sfh-hid/amd_sfh_client.c
··· 146 146 return "gyroscope"; 147 147 case mag_idx: 148 148 return "magnetometer"; 149 + case op_idx: 150 + return "operating-mode"; 149 151 case als_idx: 150 152 case ACS_IDX: /* ambient color sensor */ 151 153 return "ALS"; ··· 245 243 rc = -ENOMEM; 246 244 goto cleanup; 247 245 } 246 + 247 + if (cl_data->sensor_idx[i] == op_idx) { 248 + info.period = AMD_SFH_IDLE_LOOP; 249 + info.sensor_idx = cl_data->sensor_idx[i]; 250 + info.dma_address = cl_data->sensor_dma_addr[i]; 251 + mp2_ops->start(privdata, info); 252 + cl_data->sensor_sts[i] = amd_sfh_wait_for_response(privdata, 253 + cl_data->sensor_idx[i], 254 + SENSOR_ENABLED); 255 + if (cl_data->sensor_sts[i] == SENSOR_ENABLED) 256 + cl_data->is_any_sensor_enabled = true; 257 + continue; 258 + } 259 + 248 260 cl_data->sensor_sts[i] = SENSOR_DISABLED; 249 261 cl_data->sensor_requested_cnt[i] = 0; 250 262 cl_data->cur_hid_dev = i; ··· 319 303 320 304 for (i = 0; i < cl_data->num_hid_devices; i++) { 321 305 cl_data->cur_hid_dev = i; 306 + if (cl_data->sensor_idx[i] == op_idx) { 307 + dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n", 308 + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), 309 + cl_data->sensor_sts[i]); 310 + continue; 311 + } 312 + 322 313 if (cl_data->sensor_sts[i] == SENSOR_ENABLED) { 323 314 rc = amdtp_hid_probe(i, cl_data); 324 315 if (rc)
+1 -1
drivers/hid/amd-sfh-hid/amd_sfh_hid.h
··· 11 11 #ifndef AMDSFH_HID_H 12 12 #define AMDSFH_HID_H 13 13 14 - #define MAX_HID_DEVICES 6 14 + #define MAX_HID_DEVICES 7 15 15 #define AMD_SFH_HID_VENDOR 0x1022 16 16 #define AMD_SFH_HID_PRODUCT 0x0001 17 17
+4
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
··· 29 29 #define ACEL_EN BIT(0) 30 30 #define GYRO_EN BIT(1) 31 31 #define MAGNO_EN BIT(2) 32 + #define OP_EN BIT(15) 32 33 #define HPD_EN BIT(16) 33 34 #define ALS_EN BIT(19) 34 35 #define ACS_EN BIT(22) ··· 232 231 233 232 if (MAGNO_EN & activestatus) 234 233 sensor_id[num_of_sensors++] = mag_idx; 234 + 235 + if (OP_EN & activestatus) 236 + sensor_id[num_of_sensors++] = op_idx; 235 237 236 238 if (ALS_EN & activestatus) 237 239 sensor_id[num_of_sensors++] = als_idx;
+1
drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
··· 79 79 accel_idx = 0, 80 80 gyro_idx = 1, 81 81 mag_idx = 2, 82 + op_idx = 15, 82 83 als_idx = 19 83 84 }; 84 85