Commit 78296429 authored by Shyam Sundar S K's avatar Shyam Sundar S K Committed by Ilpo Järvinen

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: cedecdba ("platform/x86/amd/pmf: Get ambient light information from AMD SFH driver")
Co-developed-by: default avatarPatil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: default avatarPatil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Link: https://lore.kernel.org/r/20240730142316.3846259-1-Shyam-sundar.S-k@amd.comReviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 3114f77e
...@@ -150,36 +150,26 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_ ...@@ -150,36 +150,26 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_
return 0; return 0;
} }
static int amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) static void amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{ {
struct amd_sfh_info sfh_info; struct amd_sfh_info sfh_info;
int ret;
/* Get the latest information from SFH */
in->ev_info.user_present = false;
/* Get ALS data */ /* Get ALS data */
ret = amd_get_sfh_info(&sfh_info, MT_ALS); if (!amd_get_sfh_info(&sfh_info, MT_ALS))
if (!ret)
in->ev_info.ambient_light = sfh_info.ambient_light; in->ev_info.ambient_light = sfh_info.ambient_light;
else else
return ret; dev_dbg(dev->dev, "ALS is not enabled/detected\n");
/* get HPD data */ /* get HPD data */
ret = amd_get_sfh_info(&sfh_info, MT_HPD); if (!amd_get_sfh_info(&sfh_info, MT_HPD)) {
if (ret) if (sfh_info.user_present == SFH_USER_PRESENT)
return ret; in->ev_info.user_present = true;
} else {
switch (sfh_info.user_present) { dev_dbg(dev->dev, "HPD is not enabled/detected\n");
case SFH_NOT_DETECTED:
in->ev_info.user_present = 0xff; /* assume no sensors connected */
break;
case SFH_USER_PRESENT:
in->ev_info.user_present = 1;
break;
case SFH_USER_AWAY:
in->ev_info.user_present = 0;
break;
} }
return 0;
} }
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment