1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright(c) 2023 Intel Corporation. All rights reserved.
6 #include "hda_dsp_common.h"
7 #include "sof_board_helpers.h"
12 static int hdmi_init(struct snd_soc_pcm_runtime *rtd)
14 struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
15 struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
17 ctx->hdmi.hdmi_comp = dai->component;
22 int sof_intel_board_card_late_probe(struct snd_soc_card *card)
24 struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);
29 if (!ctx->hdmi.idisp_codec)
32 if (!ctx->hdmi.hdmi_comp)
35 return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp);
37 EXPORT_SYMBOL_NS(sof_intel_board_card_late_probe, SND_SOC_INTEL_SOF_BOARD_HELPERS);
42 static const struct snd_soc_dapm_widget dmic_widgets[] = {
43 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
46 static const struct snd_soc_dapm_route dmic_routes[] = {
47 {"DMic", NULL, "SoC DMIC"},
50 static int dmic_init(struct snd_soc_pcm_runtime *rtd)
52 struct snd_soc_card *card = rtd->card;
55 ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
56 ARRAY_SIZE(dmic_widgets));
58 dev_err(rtd->dev, "fail to add dmic widgets, ret %d\n", ret);
62 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_routes,
63 ARRAY_SIZE(dmic_routes));
65 dev_err(rtd->dev, "fail to add dmic routes, ret %d\n", ret);
75 static struct snd_soc_dai_link_component dmic_component[] = {
78 .dai_name = "dmic-hifi",
82 static struct snd_soc_dai_link_component platform_component[] = {
84 /* name might be overridden during probe */
85 .name = "0000:00:1f.3"
89 int sof_intel_board_set_dmic_link(struct device *dev,
90 struct snd_soc_dai_link *link, int be_id,
91 enum sof_dmic_be_type be_type)
93 struct snd_soc_dai_link_component *cpus;
96 cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
103 dev_dbg(dev, "link %d: dmic01\n", be_id);
105 link->name = "dmic01";
106 cpus->dai_name = "DMIC01 Pin";
109 dev_dbg(dev, "link %d: dmic16k\n", be_id);
111 link->name = "dmic16k";
112 cpus->dai_name = "DMIC16k Pin";
115 dev_err(dev, "invalid be type %d\n", be_type);
123 link->codecs = dmic_component;
124 link->num_codecs = ARRAY_SIZE(dmic_component);
127 link->platforms = platform_component;
128 link->num_platforms = ARRAY_SIZE(platform_component);
131 if (be_type == SOF_DMIC_01)
132 link->init = dmic_init;
133 link->ignore_suspend = 1;
135 link->dpcm_capture = 1;
139 EXPORT_SYMBOL_NS(sof_intel_board_set_dmic_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
141 int sof_intel_board_set_intel_hdmi_link(struct device *dev,
142 struct snd_soc_dai_link *link, int be_id,
143 int hdmi_id, bool idisp_codec)
145 struct snd_soc_dai_link_component *cpus, *codecs;
147 dev_dbg(dev, "link %d: intel hdmi, hdmi id %d, idisp codec %d\n",
148 be_id, hdmi_id, idisp_codec);
151 link->name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", hdmi_id);
156 cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
161 cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d Pin", hdmi_id);
170 codecs = devm_kzalloc(dev,
171 sizeof(struct snd_soc_dai_link_component),
176 codecs->name = "ehdaudio0D2";
177 codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL,
178 "intel-hdmi-hifi%d", hdmi_id);
179 if (!codecs->dai_name)
182 link->codecs = codecs;
184 link->codecs = &snd_soc_dummy_dlc;
186 link->num_codecs = 1;
189 link->platforms = platform_component;
190 link->num_platforms = ARRAY_SIZE(platform_component);
193 link->init = (hdmi_id == 1) ? hdmi_init : NULL;
195 link->dpcm_playback = 1;
199 EXPORT_SYMBOL_NS(sof_intel_board_set_intel_hdmi_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
201 MODULE_DESCRIPTION("ASoC Intel SOF Machine Driver Board Helpers");
202 MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
203 MODULE_LICENSE("GPL");
204 MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);