Skip to content

Commit 61a8ccd

Browse files
author
Herton R. Krzesinski
committed
Merge: ALSA: AMD - adjust the gain for PDM microphones
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2049 The PDM microphone input may be too low. Those patches increase the gain to maximum by default for AMD drivers. Signed-off-by: Jaroslav Kysela <jkysela@redhat.com> Bugzilla: https://bugzilla.redhat.com/2169760 Approved-by: Torez Smith <torez@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: John W. Linville <linville@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents c86af66 + 94dc177 commit 61a8ccd

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

sound/soc/amd/ps/acp63.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define ACP_ERROR_STAT 29
3131
#define PDM_DECIMATION_FACTOR 2
3232
#define ACP_PDM_CLK_FREQ_MASK 7
33-
#define ACP_WOV_MISC_CTRL_MASK 0x10
33+
#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3)
3434
#define ACP_PDM_ENABLE 1
3535
#define ACP_PDM_DISABLE 0
3636
#define ACP_PDM_DMA_EN_STATUS 2

sound/soc/amd/ps/ps-pdm-dma.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/platform_device.h>
99
#include <linux/module.h>
10+
#include <linux/bitfield.h>
1011
#include <linux/err.h>
1112
#include <linux/io.h>
1213
#include <sound/pcm_params.h>
@@ -18,6 +19,10 @@
1819

1920
#define DRV_NAME "acp_ps_pdm_dma"
2021

22+
static int pdm_gain = 3;
23+
module_param(pdm_gain, int, 0644);
24+
MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)");
25+
2126
static const struct snd_pcm_hardware acp63_pdm_hardware_capture = {
2227
.info = SNDRV_PCM_INFO_INTERLEAVED |
2328
SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -55,7 +60,8 @@ static void acp63_enable_pdm_clock(void __iomem *acp_base)
5560

5661
acp63_writel(pdm_clk_enable, acp_base + ACP_WOV_CLK_CTRL);
5762
pdm_ctrl = acp63_readl(acp_base + ACP_WOV_MISC_CTRL);
58-
pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK;
63+
pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL;
64+
pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
5965
acp63_writel(pdm_ctrl, acp_base + ACP_WOV_MISC_CTRL);
6066
}
6167

sound/soc/amd/renoir/acp3x-pdm-dma.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/platform_device.h>
88
#include <linux/module.h>
9+
#include <linux/bitfield.h>
910
#include <linux/err.h>
1011
#include <linux/io.h>
1112
#include <linux/pm_runtime.h>
@@ -17,6 +18,10 @@
1718

1819
#define DRV_NAME "acp_rn_pdm_dma"
1920

21+
static int pdm_gain = 3;
22+
module_param(pdm_gain, int, 0644);
23+
MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)");
24+
2025
static const struct snd_pcm_hardware acp_pdm_hardware_capture = {
2126
.info = SNDRV_PCM_INFO_INTERLEAVED |
2227
SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -80,7 +85,8 @@ static void enable_pdm_clock(void __iomem *acp_base)
8085

8186
rn_writel(pdm_clk_enable, acp_base + ACP_WOV_CLK_CTRL);
8287
pdm_ctrl = rn_readl(acp_base + ACP_WOV_MISC_CTRL);
83-
pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK;
88+
pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL;
89+
pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
8490
rn_writel(pdm_ctrl, acp_base + ACP_WOV_MISC_CTRL);
8591
}
8692

sound/soc/amd/renoir/rn_acp3x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define ACP_ERROR_STAT 29
3535
#define PDM_DECIMATION_FACTOR 0x2
3636
#define ACP_PDM_CLK_FREQ_MASK 0x07
37-
#define ACP_WOV_MISC_CTRL_MASK 0x10
37+
#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3)
3838
#define ACP_PDM_ENABLE 0x01
3939
#define ACP_PDM_DISABLE 0x00
4040
#define ACP_PDM_DMA_EN_STATUS 0x02

sound/soc/amd/yc/acp6x-pdm-dma.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/platform_device.h>
99
#include <linux/module.h>
10+
#include <linux/bitfield.h>
1011
#include <linux/err.h>
1112
#include <linux/io.h>
1213
#include <sound/pcm_params.h>
@@ -18,6 +19,10 @@
1819

1920
#define DRV_NAME "acp_yc_pdm_dma"
2021

22+
static int pdm_gain = 3;
23+
module_param(pdm_gain, int, 0644);
24+
MODULE_PARM_DESC(pdm_gain, "Gain control (0-3)");
25+
2126
static const struct snd_pcm_hardware acp6x_pdm_hardware_capture = {
2227
.info = SNDRV_PCM_INFO_INTERLEAVED |
2328
SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -55,7 +60,8 @@ static void acp6x_enable_pdm_clock(void __iomem *acp_base)
5560

5661
acp6x_writel(pdm_clk_enable, acp_base + ACP_WOV_CLK_CTRL);
5762
pdm_ctrl = acp6x_readl(acp_base + ACP_WOV_MISC_CTRL);
58-
pdm_ctrl |= ACP_WOV_MISC_CTRL_MASK;
63+
pdm_ctrl &= ~ACP_WOV_GAIN_CONTROL;
64+
pdm_ctrl |= FIELD_PREP(ACP_WOV_GAIN_CONTROL, clamp(pdm_gain, 0, 3));
5965
acp6x_writel(pdm_ctrl, acp_base + ACP_WOV_MISC_CTRL);
6066
}
6167

sound/soc/amd/yc/acp6x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define ACP_ERROR_STAT 29
3232
#define PDM_DECIMATION_FACTOR 2
3333
#define ACP_PDM_CLK_FREQ_MASK 7
34-
#define ACP_WOV_MISC_CTRL_MASK 0x10
34+
#define ACP_WOV_GAIN_CONTROL GENMASK(4, 3)
3535
#define ACP_PDM_ENABLE 1
3636
#define ACP_PDM_DISABLE 0
3737
#define ACP_PDM_DMA_EN_STATUS 2

0 commit comments

Comments
 (0)