WIP FPC-III support
[linux/fpc-iii.git] / sound / soc / intel / boards / skl_hda_dsp_common.c
blob07bfb2e64b3b03119180f8b41e3bb803096121f8
1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright(c) 2015-18 Intel Corporation.
4 /*
5 * Common functions used in different Intel machine drivers
6 */
7 #include <linux/module.h>
8 #include <linux/platform_device.h>
9 #include <sound/core.h>
10 #include <sound/jack.h>
11 #include <sound/pcm.h>
12 #include <sound/pcm_params.h>
13 #include <sound/soc.h>
14 #include "../../codecs/hdac_hdmi.h"
15 #include "skl_hda_dsp_common.h"
17 #include <sound/hda_codec.h>
18 #include "../../codecs/hdac_hda.h"
20 #define NAME_SIZE 32
22 int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
24 struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
25 struct skl_hda_hdmi_pcm *pcm;
26 char dai_name[NAME_SIZE];
28 pcm = devm_kzalloc(card->dev, sizeof(*pcm), GFP_KERNEL);
29 if (!pcm)
30 return -ENOMEM;
32 snprintf(dai_name, sizeof(dai_name), "intel-hdmi-hifi%d",
33 ctx->dai_index);
34 pcm->codec_dai = snd_soc_card_get_codec_dai(card, dai_name);
35 if (!pcm->codec_dai)
36 return -EINVAL;
38 pcm->device = device;
39 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
41 return 0;
44 SND_SOC_DAILINK_DEF(idisp1_cpu,
45 DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
46 SND_SOC_DAILINK_DEF(idisp1_codec,
47 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
49 SND_SOC_DAILINK_DEF(idisp2_cpu,
50 DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
51 SND_SOC_DAILINK_DEF(idisp2_codec,
52 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
54 SND_SOC_DAILINK_DEF(idisp3_cpu,
55 DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
56 SND_SOC_DAILINK_DEF(idisp3_codec,
57 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
59 SND_SOC_DAILINK_DEF(analog_cpu,
60 DAILINK_COMP_ARRAY(COMP_CPU("Analog CPU DAI")));
61 SND_SOC_DAILINK_DEF(analog_codec,
62 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D0", "Analog Codec DAI")));
64 SND_SOC_DAILINK_DEF(digital_cpu,
65 DAILINK_COMP_ARRAY(COMP_CPU("Digital CPU DAI")));
66 SND_SOC_DAILINK_DEF(digital_codec,
67 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D0", "Digital Codec DAI")));
69 SND_SOC_DAILINK_DEF(dmic_pin,
70 DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
72 SND_SOC_DAILINK_DEF(dmic_codec,
73 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
75 SND_SOC_DAILINK_DEF(dmic16k,
76 DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));
78 SND_SOC_DAILINK_DEF(platform,
79 DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
81 /* skl_hda_digital audio interface glue - connects codec <--> CPU */
82 struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
83 /* Back End DAI links */
85 .name = "iDisp1",
86 .id = 1,
87 .dpcm_playback = 1,
88 .no_pcm = 1,
89 SND_SOC_DAILINK_REG(idisp1_cpu, idisp1_codec, platform),
92 .name = "iDisp2",
93 .id = 2,
94 .dpcm_playback = 1,
95 .no_pcm = 1,
96 SND_SOC_DAILINK_REG(idisp2_cpu, idisp2_codec, platform),
99 .name = "iDisp3",
100 .id = 3,
101 .dpcm_playback = 1,
102 .no_pcm = 1,
103 SND_SOC_DAILINK_REG(idisp3_cpu, idisp3_codec, platform),
106 .name = "Analog Playback and Capture",
107 .id = 4,
108 .dpcm_playback = 1,
109 .dpcm_capture = 1,
110 .no_pcm = 1,
111 SND_SOC_DAILINK_REG(analog_cpu, analog_codec, platform),
114 .name = "Digital Playback and Capture",
115 .id = 5,
116 .dpcm_playback = 1,
117 .dpcm_capture = 1,
118 .no_pcm = 1,
119 SND_SOC_DAILINK_REG(digital_cpu, digital_codec, platform),
122 .name = "dmic01",
123 .id = 6,
124 .dpcm_capture = 1,
125 .no_pcm = 1,
126 SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
129 .name = "dmic16k",
130 .id = 7,
131 .dpcm_capture = 1,
132 .no_pcm = 1,
133 SND_SOC_DAILINK_REG(dmic16k, dmic_codec, platform),
137 int skl_hda_hdmi_jack_init(struct snd_soc_card *card)
139 struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
140 struct snd_soc_component *component = NULL;
141 struct skl_hda_hdmi_pcm *pcm;
142 char jack_name[NAME_SIZE];
143 int err;
145 if (ctx->common_hdmi_codec_drv)
146 return skl_hda_hdmi_build_controls(card);
148 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
149 component = pcm->codec_dai->component;
150 snprintf(jack_name, sizeof(jack_name),
151 "HDMI/DP, pcm=%d Jack", pcm->device);
152 err = snd_soc_card_jack_new(card, jack_name,
153 SND_JACK_AVOUT, &pcm->hdmi_jack,
154 NULL, 0);
156 if (err)
157 return err;
159 err = snd_jack_add_new_kctl(pcm->hdmi_jack.jack,
160 jack_name, SND_JACK_AVOUT);
161 if (err)
162 dev_warn(component->dev, "failed creating Jack kctl\n");
164 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
165 &pcm->hdmi_jack);
166 if (err < 0)
167 return err;
170 if (!component)
171 return -EINVAL;
173 return hdac_hdmi_jack_port_init(component, &card->dapm);