Skip to content

Commit 91aaea5

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: Add illuminance mask to limit ALS max value
ALS illuminance value present only in first 15 bits from SFH firmware for V2 platforms. Hence added a mask of 15 bit to limit ALS max illuminance values to get correct illuminance value. Fixes: 0aad9c9 ("HID: amd_sfh: Extend ALS support for newer AMD platform") Signed-off-by: Basavaraj Natikar <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent a7072c0 commit 91aaea5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define HID_USAGE_SENSOR_STATE_READY_ENUM 0x02
2828
#define HID_USAGE_SENSOR_STATE_INITIALIZING_ENUM 0x05
2929
#define HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM 0x04
30+
#define ILLUMINANCE_MASK GENMASK(14, 0)
3031

3132
int get_report_descriptor(int sensor_idx, u8 *rep_desc)
3233
{
@@ -246,7 +247,8 @@ u8 get_input_report(u8 current_index, int sensor_idx, int report_id, struct amd_
246247
get_common_inputs(&als_input.common_property, report_id);
247248
/* For ALS ,V2 Platforms uses C2P_MSG5 register instead of DRAM access method */
248249
if (supported_input == V2_STATUS)
249-
als_input.illuminance_value = (int)readl(privdata->mmio + AMD_C2P_MSG(5));
250+
als_input.illuminance_value =
251+
readl(privdata->mmio + AMD_C2P_MSG(5)) & ILLUMINANCE_MASK;
250252
else
251253
als_input.illuminance_value =
252254
(int)sensor_virt_addr[0] / AMD_SFH_FW_MULTIPLIER;

0 commit comments

Comments
 (0)