Message ID | 20241217151627.757477-3-Shyam-sundar.S-k@amd.com |
---|---|
State | New |
Headers | show |
Series | Add new capabilities to PMF Smart PC | expand |
On Tue, 17 Dec 2024, Shyam Sundar S K wrote: > The AMD SFH driver includes APIs to export SRA sensor data. This data is > utilized by the AMD PMF driver to transmit SRA data to the PMF TA, > enabling the AMD PMF driver to implement the output actions specified by > the PMF TA. > > Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> > Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> > Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> > --- > drivers/platform/x86/amd/pmf/pmf.h | 18 ++++++++++- > drivers/platform/x86/amd/pmf/spc.c | 51 ++++++++++++++++++++++++++++++ > 2 files changed, 68 insertions(+), 1 deletion(-) Hans, can I please get your Acked-by: for these bits so that I could take the whole lot via hid.git? Thanks,
On Thu, 9 Jan 2025, Jiri Kosina wrote: > On Tue, 17 Dec 2024, Shyam Sundar S K wrote: > > > The AMD SFH driver includes APIs to export SRA sensor data. This data is > > utilized by the AMD PMF driver to transmit SRA data to the PMF TA, > > enabling the AMD PMF driver to implement the output actions specified by > > the PMF TA. > > > > Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> > > Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> > > Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> > > --- > > drivers/platform/x86/amd/pmf/pmf.h | 18 ++++++++++- > > drivers/platform/x86/amd/pmf/spc.c | 51 ++++++++++++++++++++++++++++++ > > 2 files changed, 68 insertions(+), 1 deletion(-) > > Hans, can I please get your Acked-by: for these bits so that I could take > the whole lot via hid.git? Hi Jiri, I already merged those to pdx86 repo (the changes are only in my review-ilpo-next staging branch currently waiting for LKP's build check). There will be conflict with other amd/pmf changes made in this cycle if you route this patch through your tree. So either I take both or you make an immutable branch out of the first patch, which way you want? I figured as the amd-sfh-hid maintainer is among the submitters that counts some form ack (and amd-sfh-hid seems really low volume to begin with) but perhaps you'd have wanted me to wait yours as well?
On Thu, 9 Jan 2025, Ilpo Järvinen wrote: > > > The AMD SFH driver includes APIs to export SRA sensor data. This data is > > > utilized by the AMD PMF driver to transmit SRA data to the PMF TA, > > > enabling the AMD PMF driver to implement the output actions specified by > > > the PMF TA. > > > > > > Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> > > > Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> > > > Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> > > > --- > > > drivers/platform/x86/amd/pmf/pmf.h | 18 ++++++++++- > > > drivers/platform/x86/amd/pmf/spc.c | 51 ++++++++++++++++++++++++++++++ > > > 2 files changed, 68 insertions(+), 1 deletion(-) > > > > Hans, can I please get your Acked-by: for these bits so that I could take > > the whole lot via hid.git? > > Hi Jiri, > > I already merged those to pdx86 repo (the changes are only in my > review-ilpo-next staging branch currently waiting for LKP's build check). > There will be conflict with other amd/pmf changes made in this cycle if > you route this patch through your tree. So either I take both or you make > an immutable branch out of the first patch, which way you want? > > I figured as the amd-sfh-hid maintainer is among the submitters that > counts some form ack (and amd-sfh-hid seems really low volume to begin > with) but perhaps you'd have wanted me to wait yours as well? Feel free to take both through your tree, thanks. Acked-by: Jiri Kosina <jkosina@suse.com>
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 255c5ad2300e..492a64958fcf 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -628,6 +628,20 @@ enum apmf_preq_smartpc { NOTIFY_CUSTOM_BIOS_INPUT2, }; +enum platform_type { + PTYPE_UNKNOWN = 0, + LID_CLOSE, + CLAMSHELL, + FLAT, + TENT, + STAND, + TABLET, + BOOK, + PRESENTATION, + PULL_FWD, + PTYPE_INVALID = 0Xf, +}; + /* Command ids for TA communication */ enum ta_pmf_command { TA_PMF_COMMAND_POLICY_BUILDER_INITIALIZE, @@ -680,7 +694,9 @@ struct ta_pmf_condition_info { u32 device_state; u32 socket_power; u32 skin_temperature; - u32 rsvd3[5]; + u32 rsvd3[2]; + u32 platform_type; + u32 rsvd3_1[2]; u32 ambient_light; u32 length; u32 avg_c0residency; diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c index 05bed8206365..f34f3130c330 100644 --- a/drivers/platform/x86/amd/pmf/spc.c +++ b/drivers/platform/x86/amd/pmf/spc.c @@ -16,6 +16,46 @@ #include "pmf.h" #ifdef CONFIG_AMD_PMF_DEBUG +static const char *platform_type_as_str(u16 platform_type) +{ + switch (platform_type) { + case CLAMSHELL: + return "CLAMSHELL"; + case FLAT: + return "FLAT"; + case TENT: + return "TENT"; + case STAND: + return "STAND"; + case TABLET: + return "TABLET"; + case BOOK: + return "BOOK"; + case PRESENTATION: + return "PRESENTATION"; + case PULL_FWD: + return "PULL_FWD"; + default: + return "UNKNOWN"; + } +} + +static const char *laptop_placement_as_str(u16 device_state) +{ + switch (device_state) { + case ON_TABLE: + return "ON_TABLE"; + case ON_LAP_MOTION: + return "ON_LAP_MOTION"; + case IN_BAG: + return "IN_BAG"; + case OUT_OF_BAG: + return "OUT_OF_BAG"; + default: + return "UNKNOWN"; + } +} + static const char *ta_slider_as_str(unsigned int state) { switch (state) { @@ -47,6 +87,9 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table * dev_dbg(dev->dev, "LID State: %s\n", in->ev_info.lid_state ? "close" : "open"); dev_dbg(dev->dev, "User Presence: %s\n", in->ev_info.user_present ? "Present" : "Away"); dev_dbg(dev->dev, "Ambient Light: %d\n", in->ev_info.ambient_light); + dev_dbg(dev->dev, "Platform type: %s\n", platform_type_as_str(in->ev_info.platform_type)); + dev_dbg(dev->dev, "Laptop placement: %s\n", + laptop_placement_as_str(in->ev_info.device_state)); dev_dbg(dev->dev, "Custom BIOS input1: %u\n", in->ev_info.bios_input1); dev_dbg(dev->dev, "Custom BIOS input2: %u\n", in->ev_info.bios_input2); dev_dbg(dev->dev, "==== TA inputs END ====\n"); @@ -213,6 +256,14 @@ static void amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact } else { dev_dbg(dev->dev, "HPD is not enabled/detected\n"); } + + /* Get SRA (Secondary Accelerometer) data */ + if (!amd_get_sfh_info(&sfh_info, MT_SRA)) { + in->ev_info.platform_type = sfh_info.platform_type; + in->ev_info.device_state = sfh_info.laptop_placement; + } else { + dev_dbg(dev->dev, "SRA is not enabled/detected\n"); + } } void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)