Commit c9314526 authored by Brent Lu's avatar Brent Lu Committed by Mark Brown

ASoC: Intel: sof_cs42l42: use common module for HDMI link

Use intel_board module for Intel HDMI DAI link initialization.
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarBrent Lu <brent.lu@intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20231012190826.142619-21-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7368ae92
...@@ -517,6 +517,7 @@ config SND_SOC_INTEL_SOF_CS42L42_MACH ...@@ -517,6 +517,7 @@ config SND_SOC_INTEL_SOF_CS42L42_MACH
select SND_SOC_MAX98357A select SND_SOC_MAX98357A
select SND_SOC_DMIC select SND_SOC_DMIC
select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_HDA_DSP_COMMON
select SND_SOC_INTEL_SOF_BOARD_HELPERS
select SND_SOC_INTEL_SOF_MAXIM_COMMON select SND_SOC_INTEL_SOF_MAXIM_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON select SND_SOC_INTEL_SOF_SSP_COMMON
help help
......
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <dt-bindings/sound/cs42l42.h> #include <dt-bindings/sound/cs42l42.h>
#include "../common/soc-intel-quirks.h" #include "../common/soc-intel-quirks.h"
#include "hda_dsp_common.h" #include "sof_board_helpers.h"
#include "sof_hdmi_common.h"
#include "sof_maxim_common.h" #include "sof_maxim_common.h"
#include "sof_ssp_common.h" #include "sof_ssp_common.h"
...@@ -68,23 +67,6 @@ static struct snd_soc_jack_pin jack_pins[] = { ...@@ -68,23 +67,6 @@ static struct snd_soc_jack_pin jack_pins[] = {
/* Default: SSP2 */ /* Default: SSP2 */
static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2); static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2);
struct sof_card_private {
struct snd_soc_jack headset_jack;
struct sof_hdmi_private hdmi;
enum sof_ssp_codec codec_type;
enum sof_ssp_codec amp_type;
};
static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
{
struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
ctx->hdmi.hdmi_comp = dai->component;
return 0;
}
static int sof_cs42l42_init(struct snd_soc_pcm_runtime *rtd) static int sof_cs42l42_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
...@@ -165,15 +147,7 @@ static struct snd_soc_dai_link_component platform_component[] = { ...@@ -165,15 +147,7 @@ static struct snd_soc_dai_link_component platform_component[] = {
static int sof_card_late_probe(struct snd_soc_card *card) static int sof_card_late_probe(struct snd_soc_card *card)
{ {
struct sof_card_private *ctx = snd_soc_card_get_drvdata(card); return sof_intel_board_card_late_probe(card);
if (!ctx->hdmi.idisp_codec)
return 0;
if (!ctx->hdmi.hdmi_comp)
return -EINVAL;
return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp);
} }
static const struct snd_kcontrol_new sof_controls[] = { static const struct snd_kcontrol_new sof_controls[] = {
...@@ -389,65 +363,6 @@ static int create_dmic_dai_links(struct device *dev, ...@@ -389,65 +363,6 @@ static int create_dmic_dai_links(struct device *dev,
return 0; return 0;
} }
static int create_hdmi_dai_links(struct device *dev,
struct snd_soc_dai_link *links,
struct snd_soc_dai_link_component *cpus,
int *id, int hdmi_num)
{
struct snd_soc_dai_link_component *idisp_components;
int i;
/* HDMI */
if (hdmi_num <= 0)
return 0;
idisp_components = devm_kcalloc(dev,
hdmi_num,
sizeof(struct snd_soc_dai_link_component), GFP_KERNEL);
if (!idisp_components)
goto devm_err;
for (i = 1; i <= hdmi_num; i++) {
links[*id].name = devm_kasprintf(dev, GFP_KERNEL,
"iDisp%d", i);
if (!links[*id].name)
goto devm_err;
links[*id].id = *id;
links[*id].cpus = &cpus[*id];
links[*id].num_cpus = 1;
links[*id].cpus->dai_name = devm_kasprintf(dev,
GFP_KERNEL,
"iDisp%d Pin",
i);
if (!links[*id].cpus->dai_name)
goto devm_err;
idisp_components[i - 1].name = "ehdaudio0D2";
idisp_components[i - 1].dai_name = devm_kasprintf(dev,
GFP_KERNEL,
"intel-hdmi-hifi%d",
i);
if (!idisp_components[i - 1].dai_name)
goto devm_err;
links[*id].codecs = &idisp_components[i - 1];
links[*id].num_codecs = 1;
links[*id].platforms = platform_component;
links[*id].num_platforms = ARRAY_SIZE(platform_component);
links[*id].init = (i == 1) ? sof_hdmi_init : NULL;
links[*id].dpcm_playback = 1;
links[*id].no_pcm = 1;
(*id)++;
}
return 0;
devm_err:
return -ENOMEM;
}
static int create_bt_offload_dai_links(struct device *dev, static int create_bt_offload_dai_links(struct device *dev,
struct snd_soc_dai_link *links, struct snd_soc_dai_link *links,
struct snd_soc_dai_link_component *cpus, struct snd_soc_dai_link_component *cpus,
...@@ -491,11 +406,14 @@ static int create_bt_offload_dai_links(struct device *dev, ...@@ -491,11 +406,14 @@ static int create_bt_offload_dai_links(struct device *dev,
static struct snd_soc_dai_link * static struct snd_soc_dai_link *
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int ssp_codec, int ssp_amp, int ssp_bt, int ssp_codec, int ssp_amp, int ssp_bt,
int dmic_be_num, int hdmi_num) int dmic_be_num, int hdmi_num, bool idisp_codec)
{ {
struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *cpus;
struct snd_soc_dai_link *links; struct snd_soc_dai_link *links;
int ret, id = 0, link_seq; int ret;
int id = 0;
int link_seq;
int i;
links = devm_kcalloc(dev, sof_audio_card_cs42l42.num_links, links = devm_kcalloc(dev, sof_audio_card_cs42l42.num_links,
sizeof(struct snd_soc_dai_link), GFP_KERNEL); sizeof(struct snd_soc_dai_link), GFP_KERNEL);
...@@ -536,12 +454,19 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -536,12 +454,19 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
} }
break; break;
case LINK_HDMI: case LINK_HDMI:
ret = create_hdmi_dai_links(dev, links, cpus, &id, hdmi_num); for (i = 1; i <= hdmi_num; i++) {
if (ret < 0) { ret = sof_intel_board_set_intel_hdmi_link(dev,
dev_err(dev, "fail to create hdmi dai links, ret %d\n", &links[id],
id, i,
idisp_codec);
if (ret) {
dev_err(dev, "fail to create hdmi link, ret %d\n",
ret); ret);
goto devm_err; goto devm_err;
} }
id++;
}
break; break;
case LINK_BT: case LINK_BT:
ret = create_bt_offload_dai_links(dev, links, cpus, &id, ssp_bt); ret = create_bt_offload_dai_links(dev, links, cpus, &id, ssp_bt);
...@@ -571,7 +496,7 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -571,7 +496,7 @@ static int sof_audio_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
struct snd_soc_dai_link *dai_links; struct snd_soc_dai_link *dai_links;
struct sof_card_private *ctx; struct sof_card_private *ctx;
int dmic_be_num, hdmi_num; int dmic_be_num;
int ret, ssp_bt, ssp_amp, ssp_codec; int ret, ssp_bt, ssp_amp, ssp_codec;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
...@@ -586,14 +511,14 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -586,14 +511,14 @@ static int sof_audio_probe(struct platform_device *pdev)
if (soc_intel_is_glk()) { if (soc_intel_is_glk()) {
dmic_be_num = 1; dmic_be_num = 1;
hdmi_num = 3; ctx->hdmi_num = 3;
} else { } else {
dmic_be_num = 2; dmic_be_num = 2;
hdmi_num = (sof_cs42l42_quirk & SOF_CS42L42_NUM_HDMIDEV_MASK) >> ctx->hdmi_num = (sof_cs42l42_quirk & SOF_CS42L42_NUM_HDMIDEV_MASK) >>
SOF_CS42L42_NUM_HDMIDEV_SHIFT; SOF_CS42L42_NUM_HDMIDEV_SHIFT;
/* default number of HDMI DAI's */ /* default number of HDMI DAI's */
if (!hdmi_num) if (!ctx->hdmi_num)
hdmi_num = 3; ctx->hdmi_num = 3;
} }
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK) if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
...@@ -610,7 +535,7 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -610,7 +535,7 @@ static int sof_audio_probe(struct platform_device *pdev)
ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK; ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK;
/* compute number of dai links */ /* compute number of dai links */
sof_audio_card_cs42l42.num_links = 1 + dmic_be_num + hdmi_num; sof_audio_card_cs42l42.num_links = 1 + dmic_be_num + ctx->hdmi_num;
if (ctx->amp_type != CODEC_NONE) if (ctx->amp_type != CODEC_NONE)
sof_audio_card_cs42l42.num_links++; sof_audio_card_cs42l42.num_links++;
...@@ -619,7 +544,8 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -619,7 +544,8 @@ static int sof_audio_probe(struct platform_device *pdev)
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type,
ssp_codec, ssp_amp, ssp_bt, ssp_codec, ssp_amp, ssp_bt,
dmic_be_num, hdmi_num); dmic_be_num, ctx->hdmi_num,
ctx->hdmi.idisp_codec);
if (!dai_links) if (!dai_links)
return -ENOMEM; return -ENOMEM;
...@@ -679,6 +605,6 @@ module_platform_driver(sof_audio) ...@@ -679,6 +605,6 @@ module_platform_driver(sof_audio)
MODULE_DESCRIPTION("SOF Audio Machine driver for CS42L42"); MODULE_DESCRIPTION("SOF Audio Machine driver for CS42L42");
MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment