1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright(c) 2015-18 Intel Corporation.
5 * Common functions used in different Intel machine drivers
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"
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
);
32 snprintf(dai_name
, sizeof(dai_name
), "intel-hdmi-hifi%d",
34 pcm
->codec_dai
= snd_soc_card_get_codec_dai(card
, dai_name
);
39 list_add_tail(&pcm
->head
, &ctx
->hdmi_pcm_list
);
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 */
89 SND_SOC_DAILINK_REG(idisp1_cpu
, idisp1_codec
, platform
),
96 SND_SOC_DAILINK_REG(idisp2_cpu
, idisp2_codec
, platform
),
103 SND_SOC_DAILINK_REG(idisp3_cpu
, idisp3_codec
, platform
),
106 .name
= "Analog Playback and Capture",
111 SND_SOC_DAILINK_REG(analog_cpu
, analog_codec
, platform
),
114 .name
= "Digital Playback and Capture",
119 SND_SOC_DAILINK_REG(digital_cpu
, digital_codec
, platform
),
126 SND_SOC_DAILINK_REG(dmic_pin
, dmic_codec
, platform
),
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
];
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
,
159 err
= snd_jack_add_new_kctl(pcm
->hdmi_jack
.jack
,
160 jack_name
, SND_JACK_AVOUT
);
162 dev_warn(component
->dev
, "failed creating Jack kctl\n");
164 err
= hdac_hdmi_jack_init(pcm
->codec_dai
, pcm
->device
,
173 return hdac_hdmi_jack_port_init(component
, &card
->dapm
);