Message ID | 20230127160134.2658-3-mario.limonciello@amd.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Fix default DMIC gain on AMD PDM drivers | expand |
On 27. 01. 23 17:01, Mario Limonciello wrote: > In case of regressions for any users that the new pdm_gain value is > too high and for additional debugging, introduce a module parameter > that would let them configure it. > > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > --- > sound/soc/amd/yc/acp6x-pdm-dma.c | 7 ++++++- > sound/soc/amd/yc/acp6x.h | 2 +- > 2 files changed, 7 insertions(+), 2 deletions(-) ... > pdm_ctrl = acp6x_readl(acp_base + ACP_WOV_MISC_CTRL); > - pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK; > + pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, pdm_gain); The bits should be zeroed (AND - &) before OR to make sure that the correct value is written to the register. More related patches are affected. > acp6x_writel(pdm_ctrl, acp_base + ACP_WOV_MISC_CTRL); Jaroslav
[AMD Official Use Only - General] > -----Original Message----- > From: Jaroslav Kysela <perex@perex.cz> > Sent: Friday, January 27, 2023 10:23 > To: Limonciello, Mario <Mario.Limonciello@amd.com>; Mukunda, Vijendar > <Vijendar.Mukunda@amd.com>; Saba Kareem, Syed > <Syed.SabaKareem@amd.com>; linux-kernel@vger.kernel.org > Cc: Pananchikkal, Renjith <Renjith.Pananchikkal@amd.com>; Mark Pearson > <mpearson@lenovo.com>; Liam Girdwood <lgirdwood@gmail.com>; Mark > Brown <broonie@kernel.org>; Takashi Iwai <tiwai@suse.com>; alsa- > devel@alsa-project.org > Subject: Re: [PATCH 2/6] ASoC: amd: yc: Add a module parameter to > influence pdm_gain > > On 27. 01. 23 17:01, Mario Limonciello wrote: > > In case of regressions for any users that the new pdm_gain value is > > too high and for additional debugging, introduce a module parameter > > that would let them configure it. > > > > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > > --- > > sound/soc/amd/yc/acp6x-pdm-dma.c | 7 ++++++- > > sound/soc/amd/yc/acp6x.h | 2 +- > > 2 files changed, 7 insertions(+), 2 deletions(-) > > ... > > > pdm_ctrl = acp6x_readl(acp_base + ACP_WOV_MISC_CTRL); > > - pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK; > > + pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, pdm_gain); > > The bits should be zeroed (AND - &) before OR to make sure that the correct > value is written to the register. More related patches are affected. I had consider this, but the hardware default at reset is 0x0. Do you think it's still necessary for posterity?
On 27. 01. 23 17:25, Limonciello, Mario wrote: > [AMD Official Use Only - General] > > > >> -----Original Message----- >> From: Jaroslav Kysela <perex@perex.cz> >> Sent: Friday, January 27, 2023 10:23 >> To: Limonciello, Mario <Mario.Limonciello@amd.com>; Mukunda, Vijendar >> <Vijendar.Mukunda@amd.com>; Saba Kareem, Syed >> <Syed.SabaKareem@amd.com>; linux-kernel@vger.kernel.org >> Cc: Pananchikkal, Renjith <Renjith.Pananchikkal@amd.com>; Mark Pearson >> <mpearson@lenovo.com>; Liam Girdwood <lgirdwood@gmail.com>; Mark >> Brown <broonie@kernel.org>; Takashi Iwai <tiwai@suse.com>; alsa- >> devel@alsa-project.org >> Subject: Re: [PATCH 2/6] ASoC: amd: yc: Add a module parameter to >> influence pdm_gain >> >> On 27. 01. 23 17:01, Mario Limonciello wrote: >>> In case of regressions for any users that the new pdm_gain value is >>> too high and for additional debugging, introduce a module parameter >>> that would let them configure it. >>> >>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> >>> --- >>> sound/soc/amd/yc/acp6x-pdm-dma.c | 7 ++++++- >>> sound/soc/amd/yc/acp6x.h | 2 +- >>> 2 files changed, 7 insertions(+), 2 deletions(-) >> >> ... >> >>> pdm_ctrl = acp6x_readl(acp_base + ACP_WOV_MISC_CTRL); >>> - pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK; >>> + pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, pdm_gain); >> >> The bits should be zeroed (AND - &) before OR to make sure that the correct >> value is written to the register. More related patches are affected. > > I had consider this, but the hardware default at reset is 0x0. Do you think it's > still necessary for posterity? You're using 0644 permissions for the module parameter, so the value can be changed by root using sysfs anytime (between SNDRV_PCM_TRIGGER calls). Jaroslav
On Fri, Jan 27, 2023 at 05:41:44PM +0100, Jaroslav Kysela wrote: > On 27. 01. 23 17:25, Limonciello, Mario wrote: > > > > pdm_ctrl = acp6x_readl(acp_base + ACP_WOV_MISC_CTRL); > > > > - pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK; > > > > + pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, pdm_gain); > > > The bits should be zeroed (AND - &) before OR to make sure that the correct > > > value is written to the register. More related patches are affected. > > I had consider this, but the hardware default at reset is 0x0. Do you think it's > > still necessary for posterity? > You're using 0644 permissions for the module parameter, so the value can be > changed by root using sysfs anytime (between SNDRV_PCM_TRIGGER calls). Plus even if the value were never changed it just saves anyone having to wonder if this has been taken care of, and means that if there's any future hardware using this driver that uses a different default (or a stale value in the hardware somehow) then things will just work.
diff --git a/sound/soc/amd/yc/acp6x-pdm-dma.c b/sound/soc/amd/yc/acp6x-pdm-dma.c index acecd6a4ec4b1..3d6a765c5011c 100644 --- a/sound/soc/amd/yc/acp6x-pdm-dma.c +++ b/sound/soc/amd/yc/acp6x-pdm-dma.c @@ -7,6 +7,7 @@ #include <linux/platform_device.h> #include <linux/module.h> +#include <linux/bitfield.h> #include <linux/err.h> #include <linux/io.h> #include <sound/pcm_params.h> @@ -18,6 +19,10 @@ #define DRV_NAME "acp_yc_pdm_dma" +static int pdm_gain = 3; +module_param(pdm_gain, int, 0644); +MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)"); + static const struct snd_pcm_hardware acp6x_pdm_hardware_capture = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -55,7 +60,7 @@ static void acp6x_enable_pdm_clock(void __iomem *acp_base) acp6x_writel(pdm_clk_enable, acp_base + ACP_WOV_CLK_CTRL); pdm_ctrl = acp6x_readl(acp_base + ACP_WOV_MISC_CTRL); - pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK; + pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, pdm_gain); acp6x_writel(pdm_ctrl, acp_base + ACP_WOV_MISC_CTRL); } diff --git a/sound/soc/amd/yc/acp6x.h b/sound/soc/amd/yc/acp6x.h index 846ca10e24d3f..036207568c048 100644 --- a/sound/soc/amd/yc/acp6x.h +++ b/sound/soc/amd/yc/acp6x.h @@ -31,7 +31,7 @@ #define ACP_ERROR_STAT 29 #define PDM_DECIMATION_FACTOR 2 #define ACP_PDM_CLK_FREQ_MASK 7 -#define ACP_WOV_MISC_CTRL_MASK 0x18 +#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3) #define ACP_PDM_ENABLE 1 #define ACP_PDM_DISABLE 0 #define ACP_PDM_DMA_EN_STATUS 2
In case of regressions for any users that the new pdm_gain value is too high and for additional debugging, introduce a module parameter that would let them configure it. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> --- sound/soc/amd/yc/acp6x-pdm-dma.c | 7 ++++++- sound/soc/amd/yc/acp6x.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)