Fix default DMIC gain on AMD PDM drivers
Subsystems (3)
v3 cover Fix default DMIC gain on AMD PDM drivers
It's been reported that a number of laptops have a low volume level from the digital microphone compared to Windows.
AMD offers a register that can adjust the gain for PDM which is not configured at maximum gain by default.
To fix this change the default for all 3 drivers to raise the gain but also offer a module parameter. The module parameter can be used for debugging if the gain is too high on a given laptop.
This is intentionally split into multiple patches for default and parameter so that if the default really does behave better universally we can bring it back to stable too later.
v2->v3:
* Use clamp and clear properly
Mario Limonciello (6):
ASoC: amd: yc: Adjust the gain for PDM DMIC
ASoC: amd: yc: Add a module parameter to influence pdm_gain
ASoC: amd: renoir: Adjust the gain for PDM DMIC
ASoC: amd: renoir: Add a module parameter to influence pdm_gain
ASoC: amd: ps: Adjust the gain for PDM DMIC
ASoC: amd: ps: Add a module parameter to influence pdm_gain
sound/soc/amd/ps/acp63.h | 2 +- sound/soc/amd/ps/ps-pdm-dma.c | 8 +++++++- sound/soc/amd/renoir/acp3x-pdm-dma.c | 8 +++++++- sound/soc/amd/renoir/rn_acp3x.h | 2 +- sound/soc/amd/yc/acp6x-pdm-dma.c | 8 +++++++- sound/soc/amd/yc/acp6x.h | 2 +- 6 files changed, 24 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/6 ASoC: amd: yc: Adjust the gain for PDM DMIC
A number of users for Lenovo Rembrandt based laptops are reporting that the microphone is too quiet relative to Windows with a dual boot.
Increase the PDM gain to overcome this problem.
--- sound/soc/amd/yc/acp6x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/yc/acp6x.h +1 -1
@@ -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 0x10 +#define ACP_WOV_MISC_CTRL_MASK 0x18#define ACP_PDM_ENABLE 1#define ACP_PDM_DISABLE 0#define ACP_PDM_DMA_EN_STATUS 2
Signature · 1 line
2.34.1
Mark Brown
maintainerRe: [PATCH v3 1/6] ASoC: amd: yc: Adjust the gain for PDM DMIC
Quoted 3 lines · Mario Limonciello
A number of users for Lenovo Rembrandt based laptops are reporting that the microphone is too quiet relative to Windows with a dual boot.
If you're sending a cover letter for a series you should send it to the maintainers as well, not just the patches.
Re: [PATCH v3 1/6] ASoC: amd: yc: Adjust the gain for PDM DMIC
Quoted 7 lines · Mark Brown
Quoted 3 lines · Mario Limonciello
A number of users for Lenovo Rembrandt based laptops are reporting that the microphone is too quiet relative to Windows with a dual boot.
If you're sending a cover letter for a series you should send it to the maintainers as well, not just the patches.
My apologies. My scripts to get maintainers to send to sometimes fail on cover letters and I didn't do a manual fix up.
Would you like me to resend the series?
Mark Brown
maintainerRe: [PATCH v3 1/6] ASoC: amd: yc: Adjust the gain for PDM DMIC
Quoted 1 line · Mario Limonciello
Would you like me to resend the series?
No, it's fine.
PATCH v3 2/6 ASoC: amd: yc: Add a module parameter to influence pdm_gain
In reply to Mario LimoncielloIn 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.
---v2->v3:
* Use clamp() and clear bits appropriatelyv1->v2:
* Add a guard for values > 3 to overflow the FIELD_PREP
* Clear ACP_WOV_GAIN_CONTROL before setting it
--- sound/soc/amd/yc/acp6x-pdm-dma.c | 8 +++++++- sound/soc/amd/yc/acp6x.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-)
sound/soc/amd/yc/acp6x-pdm-dma.c +7 -1
@@ -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,8 @@ 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 &= ~ACP_WOV_GAIN_CONTROL ; + pdm_ctrl |=FIELD_PREP (ACP_WOV_GAIN_CONTROL ,clamp (pdm_gain,0 ,3 ));acp6x_writel (pdm_ctrl, acp_base +ACP_WOV_MISC_CTRL ); }
sound/soc/amd/yc/acp6x.h +1 -1
@@ -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
Signature · 1 line
2.34.1
PATCH v3 3/6 ASoC: amd: renoir: Adjust the gain for PDM DMIC
In reply to Mario LimoncielloA similar issue that was reported on Rembrandt based laptops with low DMIC volume is also being reported for Barcelo based laptops that use renoir acp3x.
Increase the PDM gain to overcome this problem.
--- sound/soc/amd/renoir/rn_acp3x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/renoir/rn_acp3x.h +1 -1
@@ -34,7 +34,7 @@#define ACP_ERROR_STAT 29#define PDM_DECIMATION_FACTOR 0x2#define ACP_PDM_CLK_FREQ_MASK 0x07 -#define ACP_WOV_MISC_CTRL_MASK 0x10 +#define ACP_WOV_MISC_CTRL_MASK 0x18#define ACP_PDM_ENABLE 0x01#define ACP_PDM_DISABLE 0x00#define ACP_PDM_DMA_EN_STATUS 0x02
Signature · 1 line
2.34.1
PATCH v3 4/6 ASoC: amd: renoir: Add a module parameter to influence pdm_gain
In reply to Mario LimoncielloIn 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.
---v2->v3:
* Use clamp() and clear bits appropriatelyv1->v2:
* Add a guard for values > 3 to overflow the FIELD_PREP
* Clear ACP_WOV_GAIN_CONTROL before setting it
--- sound/soc/amd/renoir/acp3x-pdm-dma.c | 8 +++++++- sound/soc/amd/renoir/rn_acp3x.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-)
sound/soc/amd/renoir/acp3x-pdm-dma.c +7 -1
@@ -6,6 +6,7 @@#include <linux/platform_device.h> #include <linux/module.h> +#include <linux/bitfield.h> #include <linux/err.h> #include <linux/io.h> #include <linux/pm_runtime.h>
@@ -17,6 +18,10 @@#define DRV_NAME "acp_rn_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 acp_pdm_hardware_capture = { .info =SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -80,7 +85,8 @@ static void enable_pdm_clock(void __iomem *acp_base)rn_writel (pdm_clk_enable, acp_base +ACP_WOV_CLK_CTRL ); pdm_ctrl =rn_readl (acp_base +ACP_WOV_MISC_CTRL ); - pdm_ctrl |=ACP_WOV_MISC_CTRL_MASK ; + pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL ; + pdm_ctrl |=FIELD_PREP (ACP_WOV_GAIN_CONTROL ,clamp (pdm_gain,0 ,3 ));rn_writel (pdm_ctrl, acp_base +ACP_WOV_MISC_CTRL ); }
sound/soc/amd/renoir/rn_acp3x.h +1 -1
@@ -34,7 +34,7 @@#define ACP_ERROR_STAT 29#define PDM_DECIMATION_FACTOR 0x2#define ACP_PDM_CLK_FREQ_MASK 0x07 -#define ACP_WOV_MISC_CTRL_MASK 0x18 +#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3)#define ACP_PDM_ENABLE 0x01#define ACP_PDM_DISABLE 0x00#define ACP_PDM_DMA_EN_STATUS 0x02
Signature · 1 line
2.34.1
PATCH v3 5/6 ASoC: amd: ps: Adjust the gain for PDM DMIC
In reply to Mario LimoncielloNo issues have been reported yet for DMIC audio level on ps platforms, but as problems were found both on YC (Rembrandt) and Renoir based designs it's very likely they happen on ps too.
Increase the PDM gain to solve this problem.
--- sound/soc/amd/ps/acp63.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/ps/acp63.h +1 -1
@@ -30,7 +30,7 @@#define ACP_ERROR_STAT 29#define PDM_DECIMATION_FACTOR 2#define ACP_PDM_CLK_FREQ_MASK 7 -#define ACP_WOV_MISC_CTRL_MASK 0x10 +#define ACP_WOV_MISC_CTRL_MASK 0x18#define ACP_PDM_ENABLE 1#define ACP_PDM_DISABLE 0#define ACP_PDM_DMA_EN_STATUS 2
Signature · 1 line
2.34.1
PATCH v3 6/6 ASoC: amd: ps: Add a module parameter to influence pdm_gain
In reply to Mario LimoncielloIn 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.
---v2->v3:
* Use clamp() and clear bits appropriatelyv1->v2:
* Add a guard for values > 3 to overflow the FIELD_PREP
* Clear ACP_WOV_GAIN_CONTROL before setting it
--- sound/soc/amd/ps/acp63.h | 2 +- sound/soc/amd/ps/ps-pdm-dma.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-)
sound/soc/amd/ps/acp63.h +1 -1
@@ -30,7 +30,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
sound/soc/amd/ps/ps-pdm-dma.c +7 -1
@@ -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_ps_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 acp63_pdm_hardware_capture = { .info =SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -55,7 +60,8 @@ static void acp63_enable_pdm_clock(void __iomem *acp_base)acp63_writel (pdm_clk_enable, acp_base +ACP_WOV_CLK_CTRL ); pdm_ctrl =acp63_readl (acp_base +ACP_WOV_MISC_CTRL ); - pdm_ctrl |=ACP_WOV_MISC_CTRL_MASK ; + pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL ; + pdm_ctrl |=FIELD_PREP (ACP_WOV_GAIN_CONTROL ,clamp (pdm_gain,0 ,3 ));acp63_writel (pdm_ctrl, acp_base +ACP_WOV_MISC_CTRL ); }
Signature · 1 line
2.34.1
Quoted 17 lines · Mario Limonciello
It's been reported that a number of laptops have a low volume level from the digital microphone compared to Windows.
AMD offers a register that can adjust the gain for PDM which is not configured at maximum gain by default.
To fix this change the default for all 3 drivers to raise the gain but also offer a module parameter. The module parameter can be used for debugging if the gain is too high on a given laptop.
This is intentionally split into multiple patches for default and parameter so that if the default really does behave better universally we can bring it back to stable too later.
v2->v3:
* Use clamp and clear properly
Quoted 7 lines
Mario Limonciello (6):
ASoC: amd: yc: Adjust the gain for PDM DMIC
ASoC: amd: yc: Add a module parameter to influencepdm_gain
ASoC: amd: renoir: Adjust the gain for PDM DMIC
ASoC: amd: renoir: Add a module parameter to influencepdm_gain
ASoC: amd: ps: Adjust the gain for PDM DMIC
ASoC: amd: ps: Add a module parameter to influencepdm_gain
For all patches:
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Mark Brown
maintainerQuoted 11 lines · Mario Limonciello
It's been reported that a number of laptops have a low volume level from the digital microphone compared to Windows.
AMD offers a register that can adjust the gain for PDM which is not configured at maximum gain by default.
To fix this change the default for all 3 drivers to raise the gain but also offer a module parameter. The module parameter can be used for debugging if the gain is too high on a given laptop.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/6] ASoC: amd: yc: Adjust the gain for PDM DMIC
commit: 6d6f62c868a8ad9c451c22f9f20f08a6149f8487
[2/6] ASoC: amd: yc: Add a module parameter to influence pdm_gain
commit: 02ea45d10fab99040c87d0267656930accb91e3c
[3/6] ASoC: amd: renoir: Adjust the gain for PDM DMIC
commit: 47dc601a067d9a79989310c8a1f93ea390ae9ead
[4/6] ASoC: amd: renoir: Add a module parameter to influence pdm_gain
commit: b7d8d4ec80ee380a82d6748c1d4e9fd89ce6e595
[5/6] ASoC: amd: ps: Adjust the gain for PDM DMIC
commit: 99ecc7889bee68fdf377f328c21ad0f953f8b05e
[6/6] ASoC: amd: ps: Add a module parameter to influence pdm_gain
commit: 5579a966229c3365d0e2c91e9a96fc40e293dffaAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark