Skip to content

Commit 7829642

Browse files
Shyam Sundar S Kij-intel
authored andcommitted
platform/x86/amd/pmf: Fix to Update HPD Data When ALS is Disabled
If the Ambient Light Sensor (ALS) is disabled, the current code in the PMF driver does not query for Human Presence Detection (HPD) data in amd_pmf_get_sensor_info(). As a result, stale HPD data is used by PMF-TA to evaluate policy conditions, leading to unexpected behavior in the policy output actions. To resolve this issue, modify the PMF driver to query HPD data independently of ALS. Since user_present is a boolean, modify the current code to return true if the user is present and false if the user is away or if the sensor is not detected, and report this status to the PMF TA firmware accordingly. With this change, amd_pmf_get_sensor_info() now returns void instead of int. Fixes: cedecdb ("platform/x86/amd/pmf: Get ambient light information from AMD SFH driver") Co-developed-by: Patil Rajesh Reddy <[email protected]> Signed-off-by: Patil Rajesh Reddy <[email protected]> Signed-off-by: Shyam Sundar S K <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 3114f77 commit 7829642

File tree

1 file changed

+11
-21
lines changed
  • drivers/platform/x86/amd/pmf

1 file changed

+11
-21
lines changed

drivers/platform/x86/amd/pmf/spc.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,36 +150,26 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_
150150
return 0;
151151
}
152152

153-
static int amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
153+
static void amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
154154
{
155155
struct amd_sfh_info sfh_info;
156-
int ret;
156+
157+
/* Get the latest information from SFH */
158+
in->ev_info.user_present = false;
157159

158160
/* Get ALS data */
159-
ret = amd_get_sfh_info(&sfh_info, MT_ALS);
160-
if (!ret)
161+
if (!amd_get_sfh_info(&sfh_info, MT_ALS))
161162
in->ev_info.ambient_light = sfh_info.ambient_light;
162163
else
163-
return ret;
164+
dev_dbg(dev->dev, "ALS is not enabled/detected\n");
164165

165166
/* get HPD data */
166-
ret = amd_get_sfh_info(&sfh_info, MT_HPD);
167-
if (ret)
168-
return ret;
169-
170-
switch (sfh_info.user_present) {
171-
case SFH_NOT_DETECTED:
172-
in->ev_info.user_present = 0xff; /* assume no sensors connected */
173-
break;
174-
case SFH_USER_PRESENT:
175-
in->ev_info.user_present = 1;
176-
break;
177-
case SFH_USER_AWAY:
178-
in->ev_info.user_present = 0;
179-
break;
167+
if (!amd_get_sfh_info(&sfh_info, MT_HPD)) {
168+
if (sfh_info.user_present == SFH_USER_PRESENT)
169+
in->ev_info.user_present = true;
170+
} else {
171+
dev_dbg(dev->dev, "HPD is not enabled/detected\n");
180172
}
181-
182-
return 0;
183173
}
184174

185175
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)

0 commit comments

Comments
 (0)