Skip to content

Commit

Permalink
ASoC: intel: cnl_rt700: add rt1308 and rt711 support
Browse files Browse the repository at this point in the history
Add support for rt711 and rt1308. Use is_using_rt711 to config
if rt711 + rt1308 are using.

Signed-off-by: Bard Liao <bardliao@gmail.com>
  • Loading branch information
bardliao committed Aug 15, 2019
1 parent fc92a78 commit 4dce582
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 10 deletions.
3 changes: 3 additions & 0 deletions sound/soc/intel/boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ config SND_SOC_INTEL_SOUNDWIRE_RT700_MACH
depends on SOUNDWIRE && ACPI
select SND_SOC_RT700
select SND_SOC_RT700_SDW
select SND_SOC_RT711
select SND_SOC_RT711_SDW
select SND_SOC_RT1308_SDW
select SND_SOC_HDAC_HDMI if SND_SOC_SOF_HDA
help
This adds support for ASoC machine driver . This will create an alsa
Expand Down
124 changes: 114 additions & 10 deletions sound/soc/intel/boards/cnl_rt700.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include <sound/soc-acpi.h>
#include "../../codecs/hdac_hdmi.h"

static int is_rt711;
module_param_named(is_using_rt711, is_rt711, int, 0444);
MODULE_PARM_DESC(sof_debug, "Using rt711 test card");

struct cnl_rt700_mc_private {
struct list_head hdmi_pcm_list;
};
Expand Down Expand Up @@ -64,7 +68,6 @@ static int cnl_card_late_probe(struct snd_soc_card *card)
int err, i = 0;
char jack_name[NAME_SIZE];

pr_err("bard: %s\n", __func__);
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name),
Expand Down Expand Up @@ -98,21 +101,34 @@ static int cnl_card_late_probe(struct snd_soc_card *card)

static const struct snd_soc_dapm_widget cnl_rt700_widgets[] = {
SND_SOC_DAPM_HP("Headphones", NULL),
SND_SOC_DAPM_MIC("AMIC", NULL),
SND_SOC_DAPM_SPK("Speaker", NULL),
SND_SOC_DAPM_MIC("AMIC", NULL),
};

static const struct snd_soc_dapm_route cnl_rt700_map[] = {
/*Headphones*/
{ "Headphones", NULL, "HP" },
{ "Speaker", NULL, "SPK" },
{ "MIC2", NULL, "AMIC" },
};

static const struct snd_kcontrol_new cnl_rt700_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphones"),
SOC_DAPM_PIN_SWITCH("AMIC"),
SOC_DAPM_PIN_SWITCH("Speaker"),
SOC_DAPM_PIN_SWITCH("AMIC"),
};

static const struct snd_soc_dapm_route cnl_spk_rt700_map[] = {
{ "Speaker", NULL, "SPK" },
};

static const struct snd_soc_dapm_route cnl_spk_rt1308_map[] = {
{ "Speaker", NULL, "rt1308-1 SPOL" },
{ "Speaker", NULL, "rt1308-1 SPOR" },
{ "Speaker", NULL, "rt1308-2 SPOL" },
{ "Speaker", NULL, "rt1308-2 SPOR" },
};

static const struct snd_kcontrol_new cnl_rt1308_controls[] = {
};

static int cnl_rt700_codec_fixup(struct snd_soc_pcm_runtime *rtd,
Expand Down Expand Up @@ -143,11 +159,54 @@ static int cnl_rt700_codec_fixup(struct snd_soc_pcm_runtime *rtd,
return ret;
}

static int cnl_rt700_init(struct snd_soc_pcm_runtime *runtime)
{
struct snd_soc_card *card = runtime->card;
int ret;

ret = snd_soc_dapm_add_routes(&card->dapm, cnl_spk_rt700_map,
ARRAY_SIZE(cnl_spk_rt700_map));
if (ret)
dev_warn(card->dev, "add new routes failed %d\n", ret);

return ret;
}

static int cnl_rt1308_init(struct snd_soc_pcm_runtime *runtime)
{
struct snd_soc_card *card = runtime->card;
int ret;

ret = snd_soc_dapm_add_routes(&card->dapm, cnl_spk_rt1308_map,
ARRAY_SIZE(cnl_spk_rt1308_map));
if (ret)
dev_warn(card->dev, "add new routes failed %d\n", ret);

return ret;
}

SND_SOC_DAILINK_DEF(sdw0_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SDW0 Pin0")));
SND_SOC_DAILINK_DEF(sdw0_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("sdw:0:25d:700:0:0", "rt700-aif1")));

static struct snd_soc_dai_link_component rt711_component[] = {
{
.name = "sdw:0:25d:711:0:1",
.dai_name = "rt711-aif1",
}
};

SND_SOC_DAILINK_DEF(sdw1_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SDW1 Pin0")));
SND_SOC_DAILINK_DEF(sdw1_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("sdw:1:25d:1308:0:0", "rt1308-aif")));

SND_SOC_DAILINK_DEF(sdw2_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SDW2 Pin0")));
SND_SOC_DAILINK_DEF(sdw2_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("sdw:2:25d:1308:0:2", "rt1308-aif")));

SND_SOC_DAILINK_DEF(dmic_pin,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));

Expand Down Expand Up @@ -191,45 +250,77 @@ struct snd_soc_dai_link cnl_rt700_msic_dailink[] = {
},
{
.name = "dmic01",
.id = 1,
.id = 4,
.ignore_suspend = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
},
{
.name = "dmic16k",
.id = 2,
.id = 5,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic16k_pin, dmic_codec, platform),
},
#if IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)
{
.name = "iDisp1",
.id = 3,
.id = 6,
.init = cnl_hdmi_init,
.no_pcm = 1,
.dpcm_playback = 1,
SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
},
{
.name = "iDisp2",
.id = 4,
.id = 7,
.init = cnl_hdmi_init,
.no_pcm = 1,
.dpcm_playback = 1,
SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
},
{
.name = "iDisp3",
.id = 5,
.id = 8,
.init = cnl_hdmi_init,
.no_pcm = 1,
.dpcm_playback = 1,
SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
},
#endif
{
.name = "SDW1-Codec",
.id = 1,
.be_hw_params_fixup = cnl_rt700_codec_fixup,
.ignore_suspend = 1,
.no_pcm = 1,
.dpcm_playback = 1,
.nonatomic = true,
.init = cnl_rt1308_init,
SND_SOC_DAILINK_REG(sdw1_pin, sdw1_codec, platform),
},
{
.name = "SDW2-Codec",
.id = 2,
.be_hw_params_fixup = cnl_rt700_codec_fixup,
.ignore_suspend = 1,
.no_pcm = 1,
.dpcm_playback = 1,
.nonatomic = true,
SND_SOC_DAILINK_REG(sdw2_pin, sdw2_codec, platform),
},
};

static struct snd_soc_codec_conf rt1308_codec_conf[] = {
{
.dev_name = "sdw:1:25d:1308:0:0",
.name_prefix = "rt1308-1",
},
{
.dev_name = "sdw:2:25d:1308:0:2",
.name_prefix = "rt1308-2",
},
};

/* SoC card */
Expand Down Expand Up @@ -264,6 +355,19 @@ static int snd_cnl_rt700_mc_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
#endif

if (is_rt711) {
snd_soc_card_cnl_rt700.codec_conf = rt1308_codec_conf;
snd_soc_card_cnl_rt700.num_configs =
ARRAY_SIZE(rt1308_codec_conf);
cnl_rt700_msic_dailink[0].codecs = rt711_component;
cnl_rt700_msic_dailink[0].num_codecs =
ARRAY_SIZE(rt711_component);
} else {
cnl_rt700_msic_dailink[0].init = cnl_rt700_init;
snd_soc_card_cnl_rt700.num_links =
ARRAY_SIZE(cnl_rt700_msic_dailink) - 2;
}

card = &snd_soc_card_cnl_rt700;
card->dev = &pdev->dev;

Expand All @@ -282,7 +386,7 @@ static int snd_cnl_rt700_mc_probe(struct platform_device *pdev)
/* Register the card */
ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret) {
pr_err("snd_soc_register_card failed %d\n", ret);
dev_err(&pdev->dev, "snd_soc_register_card failed %d\n", ret);
return ret;
}
platform_set_drvdata(pdev, &snd_soc_card_cnl_rt700);
Expand Down

0 comments on commit 4dce582

Please sign in to comment.