* [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter
@ 2025-07-28 9:42 Venkata Prasad Potturu
2025-07-28 10:52 ` Greg KH
2025-07-28 10:52 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Venkata Prasad Potturu @ 2025-07-28 9:42 UTC (permalink / raw)
To: broonie, alsa-devel
Cc: Vijendar.Mukunda, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
syed.sabakareem, Venkata Prasad Potturu, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Mario Limonciello, Peter Zijlstra,
Greg KH,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
Adjust pdm dimc gain value using module param.
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.
This parameter should be removed in the future:
* If it's determined that the parameter is not needed, just hardcode
the correct value as before
* If users do end up using it to debug and report different values
we should introduce a config knob that can have policy set by ucm.
Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
---
sound/soc/amd/acp/acp-legacy-common.c | 3 ++-
sound/soc/amd/acp/acp-pdm.c | 3 ++-
sound/soc/amd/acp/amd.h | 6 +++++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/amd/acp/acp-legacy-common.c b/sound/soc/amd/acp/acp-legacy-common.c
index 57982d057c3a..dd804fb95790 100644
--- a/sound/soc/amd/acp/acp-legacy-common.c
+++ b/sound/soc/amd/acp/acp-legacy-common.c
@@ -173,7 +173,8 @@ static void set_acp_pdm_clk(struct snd_pcm_substream *substream,
/* Enable default ACP PDM clk */
writel(PDM_CLK_FREQ_MASK, chip->base + ACP_WOV_CLK_CTRL);
pdm_ctrl = readl(chip->base + ACP_WOV_MISC_CTRL);
- pdm_ctrl |= PDM_MISC_CTRL_MASK;
+ pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL;
+ pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
writel(pdm_ctrl, chip->base + ACP_WOV_MISC_CTRL);
set_acp_pdm_ring_buffer(substream, dai);
}
diff --git a/sound/soc/amd/acp/acp-pdm.c b/sound/soc/amd/acp/acp-pdm.c
index 1bfc34c2aa53..ffb622a7a69a 100644
--- a/sound/soc/amd/acp/acp-pdm.c
+++ b/sound/soc/amd/acp/acp-pdm.c
@@ -38,7 +38,8 @@ static int acp_dmic_prepare(struct snd_pcm_substream *substream,
/* Enable default DMIC clk */
writel(PDM_CLK_FREQ_MASK, chip->base + ACP_WOV_CLK_CTRL);
dmic_ctrl = readl(chip->base + ACP_WOV_MISC_CTRL);
- dmic_ctrl |= PDM_MISC_CTRL_MASK;
+ dmic_ctrl &= ~ACP_WOV_GAIN_CONTROL;
+ dmic_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
writel(dmic_ctrl, chip->base + ACP_WOV_MISC_CTRL);
period_bytes = frames_to_bytes(substream->runtime,
diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h
index cb8d97122f95..f2567e06ccd3 100644
--- a/sound/soc/amd/acp/amd.h
+++ b/sound/soc/amd/acp/amd.h
@@ -130,7 +130,7 @@
#define PDM_DMA_INTR_MASK 0x10000
#define PDM_DEC_64 0x2
#define PDM_CLK_FREQ_MASK 0x07
-#define PDM_MISC_CTRL_MASK 0x10
+#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3)
#define PDM_ENABLE 0x01
#define PDM_DISABLE 0x00
#define DMA_EN_MASK 0x02
@@ -138,6 +138,10 @@
#define PDM_TIMEOUT 1000
#define ACP_REGION2_OFFSET 0x02000000
+static int pdm_gain = 3;
+module_param(pdm_gain, int, 0644);
+MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)");
+
struct acp_chip_info {
char *name; /* Platform name */
struct resource *res;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter
2025-07-28 9:42 [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter Venkata Prasad Potturu
@ 2025-07-28 10:52 ` Greg KH
2025-07-29 6:04 ` Mario Limonciello
2025-07-28 10:52 ` Greg KH
1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2025-07-28 10:52 UTC (permalink / raw)
To: Venkata Prasad Potturu
Cc: broonie, alsa-devel, Vijendar.Mukunda, Basavaraj.Hiregoudar,
Sunil-kumar.Dommati, syed.sabakareem, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Mario Limonciello, Peter Zijlstra,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
On Mon, Jul 28, 2025 at 03:12:27PM +0530, Venkata Prasad Potturu wrote:
> Adjust pdm dimc gain value using module param.
> 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.
>
> This parameter should be removed in the future:
> * If it's determined that the parameter is not needed, just hardcode
> the correct value as before
> * If users do end up using it to debug and report different values
> we should introduce a config knob that can have policy set by ucm.
>
> Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
> ---
> sound/soc/amd/acp/acp-legacy-common.c | 3 ++-
> sound/soc/amd/acp/acp-pdm.c | 3 ++-
> sound/soc/amd/acp/amd.h | 6 +++++-
> 3 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/amd/acp/acp-legacy-common.c b/sound/soc/amd/acp/acp-legacy-common.c
> index 57982d057c3a..dd804fb95790 100644
> --- a/sound/soc/amd/acp/acp-legacy-common.c
> +++ b/sound/soc/amd/acp/acp-legacy-common.c
> @@ -173,7 +173,8 @@ static void set_acp_pdm_clk(struct snd_pcm_substream *substream,
> /* Enable default ACP PDM clk */
> writel(PDM_CLK_FREQ_MASK, chip->base + ACP_WOV_CLK_CTRL);
> pdm_ctrl = readl(chip->base + ACP_WOV_MISC_CTRL);
> - pdm_ctrl |= PDM_MISC_CTRL_MASK;
> + pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL;
> + pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
> writel(pdm_ctrl, chip->base + ACP_WOV_MISC_CTRL);
> set_acp_pdm_ring_buffer(substream, dai);
> }
> diff --git a/sound/soc/amd/acp/acp-pdm.c b/sound/soc/amd/acp/acp-pdm.c
> index 1bfc34c2aa53..ffb622a7a69a 100644
> --- a/sound/soc/amd/acp/acp-pdm.c
> +++ b/sound/soc/amd/acp/acp-pdm.c
> @@ -38,7 +38,8 @@ static int acp_dmic_prepare(struct snd_pcm_substream *substream,
> /* Enable default DMIC clk */
> writel(PDM_CLK_FREQ_MASK, chip->base + ACP_WOV_CLK_CTRL);
> dmic_ctrl = readl(chip->base + ACP_WOV_MISC_CTRL);
> - dmic_ctrl |= PDM_MISC_CTRL_MASK;
> + dmic_ctrl &= ~ACP_WOV_GAIN_CONTROL;
> + dmic_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
> writel(dmic_ctrl, chip->base + ACP_WOV_MISC_CTRL);
>
> period_bytes = frames_to_bytes(substream->runtime,
> diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h
> index cb8d97122f95..f2567e06ccd3 100644
> --- a/sound/soc/amd/acp/amd.h
> +++ b/sound/soc/amd/acp/amd.h
> @@ -130,7 +130,7 @@
> #define PDM_DMA_INTR_MASK 0x10000
> #define PDM_DEC_64 0x2
> #define PDM_CLK_FREQ_MASK 0x07
> -#define PDM_MISC_CTRL_MASK 0x10
> +#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3)
> #define PDM_ENABLE 0x01
> #define PDM_DISABLE 0x00
> #define DMA_EN_MASK 0x02
> @@ -138,6 +138,10 @@
> #define PDM_TIMEOUT 1000
> #define ACP_REGION2_OFFSET 0x02000000
>
> +static int pdm_gain = 3;
> +module_param(pdm_gain, int, 0644);
> +MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)");
This is not the 1990's, please do not add new module parameters, it will
not work for modern systems and is a horrible thing to attempt to
support over time :(
Please do this properly, with a per-device setting.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter
2025-07-28 10:52 ` Greg KH
@ 2025-07-29 6:04 ` Mario Limonciello
2025-07-29 10:36 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Mario Limonciello @ 2025-07-29 6:04 UTC (permalink / raw)
To: Greg KH, Venkata Prasad Potturu
Cc: broonie, alsa-devel, Vijendar.Mukunda, Basavaraj.Hiregoudar,
Sunil-kumar.Dommati, syed.sabakareem, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Peter Zijlstra,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
On 7/28/2025 4:22 PM, Greg KH wrote:
> On Mon, Jul 28, 2025 at 03:12:27PM +0530, Venkata Prasad Potturu wrote:
>> Adjust pdm dimc gain value using module param.
>> 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.
>>
>> This parameter should be removed in the future:
>> * If it's determined that the parameter is not needed, just hardcode
>> the correct value as before
>> * If users do end up using it to debug and report different values
>> we should introduce a config knob that can have policy set by ucm.
>>
>> Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
>> ---
>> sound/soc/amd/acp/acp-legacy-common.c | 3 ++-
>> sound/soc/amd/acp/acp-pdm.c | 3 ++-
>> sound/soc/amd/acp/amd.h | 6 +++++-
>> 3 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/sound/soc/amd/acp/acp-legacy-common.c b/sound/soc/amd/acp/acp-legacy-common.c
>> index 57982d057c3a..dd804fb95790 100644
>> --- a/sound/soc/amd/acp/acp-legacy-common.c
>> +++ b/sound/soc/amd/acp/acp-legacy-common.c
>> @@ -173,7 +173,8 @@ static void set_acp_pdm_clk(struct snd_pcm_substream *substream,
>> /* Enable default ACP PDM clk */
>> writel(PDM_CLK_FREQ_MASK, chip->base + ACP_WOV_CLK_CTRL);
>> pdm_ctrl = readl(chip->base + ACP_WOV_MISC_CTRL);
>> - pdm_ctrl |= PDM_MISC_CTRL_MASK;
>> + pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL;
>> + pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
>> writel(pdm_ctrl, chip->base + ACP_WOV_MISC_CTRL);
>> set_acp_pdm_ring_buffer(substream, dai);
>> }
>> diff --git a/sound/soc/amd/acp/acp-pdm.c b/sound/soc/amd/acp/acp-pdm.c
>> index 1bfc34c2aa53..ffb622a7a69a 100644
>> --- a/sound/soc/amd/acp/acp-pdm.c
>> +++ b/sound/soc/amd/acp/acp-pdm.c
>> @@ -38,7 +38,8 @@ static int acp_dmic_prepare(struct snd_pcm_substream *substream,
>> /* Enable default DMIC clk */
>> writel(PDM_CLK_FREQ_MASK, chip->base + ACP_WOV_CLK_CTRL);
>> dmic_ctrl = readl(chip->base + ACP_WOV_MISC_CTRL);
>> - dmic_ctrl |= PDM_MISC_CTRL_MASK;
>> + dmic_ctrl &= ~ACP_WOV_GAIN_CONTROL;
>> + dmic_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
>> writel(dmic_ctrl, chip->base + ACP_WOV_MISC_CTRL);
>>
>> period_bytes = frames_to_bytes(substream->runtime,
>> diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h
>> index cb8d97122f95..f2567e06ccd3 100644
>> --- a/sound/soc/amd/acp/amd.h
>> +++ b/sound/soc/amd/acp/amd.h
>> @@ -130,7 +130,7 @@
>> #define PDM_DMA_INTR_MASK 0x10000
>> #define PDM_DEC_64 0x2
>> #define PDM_CLK_FREQ_MASK 0x07
>> -#define PDM_MISC_CTRL_MASK 0x10
>> +#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3)
>> #define PDM_ENABLE 0x01
>> #define PDM_DISABLE 0x00
>> #define DMA_EN_MASK 0x02
>> @@ -138,6 +138,10 @@
>> #define PDM_TIMEOUT 1000
>> #define ACP_REGION2_OFFSET 0x02000000
>>
>> +static int pdm_gain = 3;
>> +module_param(pdm_gain, int, 0644);
>> +MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)");
>
> This is not the 1990's, please do not add new module parameters, it will
> not work for modern systems and is a horrible thing to attempt to
> support over time :(
>
> Please do this properly, with a per-device setting.
>
> thanks,
>
> greg k-h
As the main purpose for this parameter is for being able to tune whether
the property is correct, how about adding a debugfs file instead?
AFAICT it should just be a single register write, so debugfs to read
current value and write the debugging value seems pretty straightforward.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter
2025-07-29 6:04 ` Mario Limonciello
@ 2025-07-29 10:36 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-07-29 10:36 UTC (permalink / raw)
To: Mario Limonciello
Cc: Greg KH, Venkata Prasad Potturu, alsa-devel, Vijendar.Mukunda,
Basavaraj.Hiregoudar, Sunil-kumar.Dommati, syed.sabakareem,
Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Peter Zijlstra,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
[-- Attachment #1: Type: text/plain, Size: 767 bytes --]
On Tue, Jul 29, 2025 at 11:34:59AM +0530, Mario Limonciello wrote:
> On 7/28/2025 4:22 PM, Greg KH wrote:
> > On Mon, Jul 28, 2025 at 03:12:27PM +0530, Venkata Prasad Potturu wrote:
> > > * If users do end up using it to debug and report different values
> > > we should introduce a config knob that can have policy set by ucm.
> > Please do this properly, with a per-device setting.
> As the main purpose for this parameter is for being able to tune whether the
> property is correct, how about adding a debugfs file instead?
> AFAICT it should just be a single register write, so debugfs to read current
> value and write the debugging value seems pretty straightforward.
Or you could just go direct to making it user tunable like a normal gain
control?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter
2025-07-28 9:42 [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter Venkata Prasad Potturu
2025-07-28 10:52 ` Greg KH
@ 2025-07-28 10:52 ` Greg KH
1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-07-28 10:52 UTC (permalink / raw)
To: Venkata Prasad Potturu
Cc: broonie, alsa-devel, Vijendar.Mukunda, Basavaraj.Hiregoudar,
Sunil-kumar.Dommati, syed.sabakareem, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Mario Limonciello, Peter Zijlstra,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
On Mon, Jul 28, 2025 at 03:12:27PM +0530, Venkata Prasad Potturu wrote:
> Adjust pdm dimc gain value using module param.
> 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.
>
> This parameter should be removed in the future:
> * If it's determined that the parameter is not needed, just hardcode
> the correct value as before
> * If users do end up using it to debug and report different values
> we should introduce a config knob that can have policy set by ucm.
Note, you can not break a user/kernel api like this once you introduce
it, so be VERY careful (yet another reason for it to NOT be a module
parameter...)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-29 10:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-28 9:42 [PATCH] ASoC: amd: acp: Adjust pdm dmic gain using module parameter Venkata Prasad Potturu
2025-07-28 10:52 ` Greg KH
2025-07-29 6:04 ` Mario Limonciello
2025-07-29 10:36 ` Mark Brown
2025-07-28 10:52 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox