From 6d6f62c868a8ad9c451c22f9f20f08a6149f8487 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 31 Jan 2023 12:46:47 -0600 Subject: 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. Signed-off-by: Mario Limonciello Reviewed-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20230131184653.10216-2-mario.limonciello@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/yc/acp6x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc/amd/yc') diff --git a/sound/soc/amd/yc/acp6x.h b/sound/soc/amd/yc/acp6x.h index 74b596e6807a..846ca10e24d3 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 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 -- cgit v1.2.3 From 02ea45d10fab99040c87d0267656930accb91e3c Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 31 Jan 2023 12:46:48 -0600 Subject: ASoC: amd: yc: Add a module parameter to influence pdm_gain 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: Mario Limonciello Reviewed-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20230131184653.10216-3-mario.limonciello@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/yc/acp6x-pdm-dma.c | 8 +++++++- sound/soc/amd/yc/acp6x.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'sound/soc/amd/yc') diff --git a/sound/soc/amd/yc/acp6x-pdm-dma.c b/sound/soc/amd/yc/acp6x-pdm-dma.c index acecd6a4ec4b..294dd7fb43c9 100644 --- a/sound/soc/amd/yc/acp6x-pdm-dma.c +++ b/sound/soc/amd/yc/acp6x-pdm-dma.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -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); } diff --git a/sound/soc/amd/yc/acp6x.h b/sound/soc/amd/yc/acp6x.h index 846ca10e24d3..036207568c04 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 -- cgit v1.2.3