mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Jaroslav Kysela <jkysela@redhat.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>,
	Mario Limonciello <mario.limonciello@amd.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	<alsa-devel@alsa-project.org>
Subject: [PATCH v3 2/6] ASoC: amd: yc: Add a module parameter to influence pdm_gain
Date: Tue, 31 Jan 2023 12:46:48 -0600	[thread overview]
Message-ID: <20230131184653.10216-3-mario.limonciello@amd.com> (raw)
In-Reply-To: <20230131184653.10216-1-mario.limonciello@amd.com>

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 <mario.limonciello@amd.com>
---
v2->v3:
 * Use clamp() and clear bits appropriately
v1->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(-)

diff --git a/sound/soc/amd/yc/acp6x-pdm-dma.c b/sound/soc/amd/yc/acp6x-pdm-dma.c
index acecd6a4ec4b1..294dd7fb43c9b 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,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 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
-- 
2.34.1


  parent reply	other threads:[~2023-01-31 18:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31 18:46 [PATCH v3 0/6] Fix default DMIC gain on AMD PDM drivers Mario Limonciello
2023-01-31 18:46 ` [PATCH v3 1/6] ASoC: amd: yc: Adjust the gain for PDM DMIC Mario Limonciello
2023-02-02 11:42   ` Mark Brown
2023-02-02 13:38     ` Mario Limonciello
2023-02-02 13:42       ` Mark Brown
2023-01-31 18:46 ` Mario Limonciello [this message]
2023-01-31 18:46 ` [PATCH v3 3/6] ASoC: amd: renoir: " Mario Limonciello
2023-01-31 18:46 ` [PATCH v3 4/6] ASoC: amd: renoir: Add a module parameter to influence pdm_gain Mario Limonciello
2023-01-31 18:46 ` [PATCH v3 5/6] ASoC: amd: ps: Adjust the gain for PDM DMIC Mario Limonciello
2023-01-31 18:46 ` [PATCH v3 6/6] ASoC: amd: ps: Add a module parameter to influence pdm_gain Mario Limonciello
2023-01-31 18:51 ` [PATCH v3 0/6] Fix default DMIC gain on AMD PDM drivers Jaroslav Kysela
2023-02-02 15:37 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230131184653.10216-3-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Renjith.Pananchikkal@amd.com \
    --cc=Syed.SabaKareem@amd.com \
    --cc=Vijendar.Mukunda@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jkysela@redhat.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpearson@lenovo.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®