From: Lucas Tanure <lucas.tanure@collabora.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
Lucas Tanure <lucas.tanure@collabora.com>,
kernel@collabora.com
Subject: [PATCH 7/9] ASoC: amd: vangogh: Move nau8821 and CPU side code up for future platform
Date: Thu, 16 Feb 2023 10:32:58 +0000 [thread overview]
Message-ID: <20230216103300.360016-8-lucas.tanure@collabora.com> (raw)
In-Reply-To: <20230216103300.360016-1-lucas.tanure@collabora.com>
Move nau8821 and CPU side code up in the source so future platforms can
be added.
Signed-off-by: Lucas Tanure <lucas.tanure@collabora.com>
---
sound/soc/amd/vangogh/acp5x-mach.c | 93 +++++++++++++++---------------
1 file changed, 47 insertions(+), 46 deletions(-)
diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c
index 7072352389ab..2072151957a6 100644
--- a/sound/soc/amd/vangogh/acp5x-mach.c
+++ b/sound/soc/amd/vangogh/acp5x-mach.c
@@ -30,6 +30,11 @@
static unsigned long acp5x_machine_id;
static struct snd_soc_jack vg_headset;
+SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("acp5x_i2s_dma.0")));
+SND_SOC_DAILINK_DEF(acp5x_i2s, DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.0")));
+SND_SOC_DAILINK_DEF(acp5x_bt, DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.1")));
+SND_SOC_DAILINK_DEF(nau8821, DAILINK_COMP_ARRAY(COMP_CODEC("i2c-NVTN2020:00", "nau8821-hifi")));
+
static struct snd_soc_jack_pin acp5x_nau8821_jack_pins[] = {
{
.pin = "Headphone",
@@ -134,6 +139,48 @@ static int acp5x_nau8821_hw_params(struct snd_pcm_substream *sub, struct snd_pcm
return ret;
}
+static int platform_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event)
+{
+ struct snd_soc_dapm_context *dapm = w->dapm;
+ struct snd_soc_card *card = dapm->card;
+ struct snd_soc_dai *dai;
+ int ret = 0;
+
+ dai = snd_soc_card_get_codec_dai(card, ACP5X_NUVOTON_CODEC_DAI);
+ if (!dai) {
+ dev_err(card->dev, "Codec dai not found\n");
+ return -EIO;
+ }
+
+ if (SND_SOC_DAPM_EVENT_OFF(event)) {
+ ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN);
+ if (ret < 0) {
+ dev_err(card->dev, "set sysclk err = %d\n", ret);
+ return -EIO;
+ }
+ } else {
+ ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN);
+ if (ret < 0)
+ dev_err(dai->dev, "can't set BLK clock %d\n", ret);
+ ret = snd_soc_dai_set_pll(dai, 0, 0, ACP5X_NUVOTON_BCLK, ACP5X_NAU8821_FREQ_OUT);
+ if (ret < 0)
+ dev_err(dai->dev, "can't set FLL: %d\n", ret);
+ }
+
+ return ret;
+}
+
+static const struct snd_kcontrol_new acp5x_8821_controls[] = {
+ SOC_DAPM_PIN_SWITCH("Headphone"),
+ SOC_DAPM_PIN_SWITCH("Headset Mic"),
+ SOC_DAPM_PIN_SWITCH("Int Mic"),
+};
+
+static const struct snd_soc_ops acp5x_8821_ops = {
+ .startup = acp5x_8821_startup,
+ .hw_params = acp5x_nau8821_hw_params,
+};
+
static int acp5x_cs35l41_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
@@ -183,11 +230,6 @@ static int acp5x_cs35l41_hw_params(struct snd_pcm_substream *sub, struct snd_pcm
return 0;
}
-static const struct snd_soc_ops acp5x_8821_ops = {
- .startup = acp5x_8821_startup,
- .hw_params = acp5x_nau8821_hw_params,
-};
-
static const struct snd_soc_ops acp5x_cs35l41_play_ops = {
.startup = acp5x_cs35l41_startup,
.hw_params = acp5x_cs35l41_hw_params,
@@ -204,10 +246,6 @@ static struct snd_soc_codec_conf cs35l41_conf[] = {
},
};
-SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("acp5x_i2s_dma.0")));
-SND_SOC_DAILINK_DEF(acp5x_i2s, DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.0")));
-SND_SOC_DAILINK_DEF(acp5x_bt, DAILINK_COMP_ARRAY(COMP_CPU("acp5x_i2s_playcap.1")));
-SND_SOC_DAILINK_DEF(nau8821, DAILINK_COMP_ARRAY(COMP_CODEC("i2c-NVTN2020:00", "nau8821-hifi")));
SND_SOC_DAILINK_DEF(cs35l41, DAILINK_COMP_ARRAY(COMP_CODEC("spi-VLV1776:00", "cs35l41-pcm"),
COMP_CODEC("spi-VLV1776:01", "cs35l41-pcm")));
@@ -233,43 +271,6 @@ static struct snd_soc_dai_link acp5x_dai[] = {
},
};
-static int platform_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event)
-{
- struct snd_soc_dapm_context *dapm = w->dapm;
- struct snd_soc_card *card = dapm->card;
- struct snd_soc_dai *dai;
- int ret = 0;
-
- dai = snd_soc_card_get_codec_dai(card, ACP5X_NUVOTON_CODEC_DAI);
- if (!dai) {
- dev_err(card->dev, "Codec dai not found\n");
- return -EIO;
- }
-
- if (SND_SOC_DAPM_EVENT_OFF(event)) {
- ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN);
- if (ret < 0) {
- dev_err(card->dev, "set sysclk err = %d\n", ret);
- return -EIO;
- }
- } else {
- ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN);
- if (ret < 0)
- dev_err(dai->dev, "can't set BLK clock %d\n", ret);
- ret = snd_soc_dai_set_pll(dai, 0, 0, ACP5X_NUVOTON_BCLK, ACP5X_NAU8821_FREQ_OUT);
- if (ret < 0)
- dev_err(dai->dev, "can't set FLL: %d\n", ret);
- }
-
- return ret;
-}
-
-static const struct snd_kcontrol_new acp5x_8821_controls[] = {
- SOC_DAPM_PIN_SWITCH("Headphone"),
- SOC_DAPM_PIN_SWITCH("Headset Mic"),
- SOC_DAPM_PIN_SWITCH("Int Mic"),
-};
-
static const struct snd_soc_dapm_widget acp5x_8821_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
--
2.39.2
next prev parent reply other threads:[~2023-02-16 10:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 10:32 [PATCH 0/9] Refactor Vangogh acp5x machine driver Lucas Tanure
2023-02-16 10:32 ` [PATCH 1/9] ASoC: amd: vangogh: Remove unnecessary init function Lucas Tanure
2023-02-16 10:32 ` [PATCH 2/9] ASoC: amd: vangogh: Update code indentation Lucas Tanure
2023-02-16 15:15 ` Mark Brown
2023-02-16 10:32 ` [PATCH 3/9] ASoC: amd: vangogh: use sizeof of variable instead of struct type Lucas Tanure
2023-02-16 10:32 ` [PATCH 4/9] ASoC: amd: vangogh: remove unnecessarily included headers Lucas Tanure
2023-02-16 10:32 ` [PATCH 5/9] ASoC: amd: vangogh: use for_each_rtd_components instead of for Lucas Tanure
2023-02-16 10:32 ` [PATCH 6/9] ASoC: amd: vangogh: Check Bit Clock rate before snd_soc_dai_set_pll Lucas Tanure
2023-02-16 10:32 ` Lucas Tanure [this message]
2023-02-16 10:32 ` [PATCH 8/9] ASoC: amd: vangogh: Centralize strings definition Lucas Tanure
2023-02-16 15:37 ` Mark Brown
2023-02-16 10:33 ` [PATCH 9/9] ASoC: amd: vangogh: Include cs35l41 in structs names Lucas Tanure
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=20230216103300.360016-8-lucas.tanure@collabora.com \
--to=lucas.tanure@collabora.com \
--cc=Vijendar.Mukunda@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=kernel@collabora.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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®