Skip to content

Commit

Permalink
ASoC: Intel: sof_nau8825: use common module
Browse files Browse the repository at this point in the history
Use nuvoton-common module to support nau8318 and realtek-common module
to support rt1019p.

Signed-off-by: Brent Lu <[email protected]>
  • Loading branch information
brentlu committed Aug 31, 2023
1 parent 0fd8247 commit 72d9a10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 61 deletions.
1 change: 1 addition & 0 deletions sound/soc/intel/boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ config SND_SOC_INTEL_SOF_NAU8825_MACH
select SND_SOC_HDAC_HDMI
select SND_SOC_INTEL_HDA_DSP_COMMON
select SND_SOC_INTEL_SOF_MAXIM_COMMON
select SND_SOC_INTEL_SOF_NUVOTON_COMMON
select SND_SOC_INTEL_SOF_REALTEK_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON
help
Expand Down
65 changes: 4 additions & 61 deletions sound/soc/intel/boards/sof_nau8825.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "hda_dsp_common.h"
#include "sof_realtek_common.h"
#include "sof_maxim_common.h"
#include "sof_nuvoton_common.h"
#include "sof_ssp_common.h"

#define NAME_SIZE 32
Expand Down Expand Up @@ -213,21 +214,13 @@ static const struct snd_kcontrol_new sof_controls[] = {
SOC_DAPM_PIN_SWITCH("Right Spk"),
};

static const struct snd_kcontrol_new speaker_controls[] = {
SOC_DAPM_PIN_SWITCH("Spk"),
};

static const struct snd_soc_dapm_widget sof_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};

static const struct snd_soc_dapm_widget speaker_widgets[] = {
SND_SOC_DAPM_SPK("Spk", NULL),
};

static const struct snd_soc_dapm_widget dmic_widgets[] = {
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
};
Expand All @@ -241,44 +234,11 @@ static const struct snd_soc_dapm_route sof_map[] = {
{ "MIC", NULL, "Headset Mic" },
};

static const struct snd_soc_dapm_route speaker_map[] = {
/* speaker */
{ "Spk", NULL, "Speaker" },
};

static const struct snd_soc_dapm_route dmic_map[] = {
/* digital mics */
{"DMic", NULL, "SoC DMIC"},
};

static int speaker_codec_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
int ret;

ret = snd_soc_dapm_new_controls(&card->dapm, speaker_widgets,
ARRAY_SIZE(speaker_widgets));
if (ret) {
dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret);
/* Don't need to add routes if widget addition failed */
return ret;
}

ret = snd_soc_add_card_controls(card, speaker_controls,
ARRAY_SIZE(speaker_controls));
if (ret) {
dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
return ret;
}

ret = snd_soc_dapm_add_routes(&card->dapm, speaker_map,
ARRAY_SIZE(speaker_map));

if (ret)
dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret);
return ret;
}

static int dmic_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
Expand Down Expand Up @@ -329,20 +289,6 @@ static struct snd_soc_dai_link_component dmic_component[] = {
}
};

static struct snd_soc_dai_link_component rt1019p_component[] = {
{
.name = "RTL1019:00",
.dai_name = "HiFi",
}
};

static struct snd_soc_dai_link_component nau8318_components[] = {
{
.name = "NVTN2012:00",
.dai_name = "nau8315-hifi",
}
};

static struct snd_soc_dai_link *
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int ssp_codec, int ssp_amp, int dmic_be_num,
Expand Down Expand Up @@ -478,17 +424,13 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
links[id].ops = &max_98373_ops;
break;
case CODEC_NAU8318:
links[id].codecs = nau8318_components;
links[id].num_codecs = ARRAY_SIZE(nau8318_components);
links[id].init = speaker_codec_init;
nau8318_set_dai_link(&links[id]);
break;
case CODEC_RT1015P:
sof_rt1015p_dai_link(&links[id]);
break;
case CODEC_RT1019P:
links[id].codecs = rt1019p_component;
links[id].num_codecs = ARRAY_SIZE(rt1019p_component);
links[id].init = speaker_codec_init;
sof_rt1019p_dai_link(&links[id]);
break;
default:
dev_err(dev, "invalid amp type %d\n", amp_type);
Expand Down Expand Up @@ -715,5 +657,6 @@ MODULE_AUTHOR("Brent Lu <[email protected]>");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_NUVOTON_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);

0 comments on commit 72d9a10

Please sign in to comment.