Commit | Line | Data |
---|---|---|
8eaf2b31 RA |
1 | /* |
2 | * Intel Skylake I2S Machine Driver with MAXIM98357A | |
3 | * and NAU88L25 | |
4 | * | |
5 | * Copyright (C) 2015, Intel Corporation. All rights reserved. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License version | |
9 | * 2 as published by the Free Software Foundation. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | */ | |
16 | ||
17 | #include <linux/module.h> | |
18 | #include <linux/platform_device.h> | |
19 | #include <sound/core.h> | |
20 | #include <sound/jack.h> | |
21 | #include <sound/pcm.h> | |
22 | #include <sound/pcm_params.h> | |
23 | #include <sound/soc.h> | |
b92826fa | 24 | #include <sound/soc-acpi.h> |
8eaf2b31 | 25 | #include "../../codecs/nau8825.h" |
0ab338ff | 26 | #include "../../codecs/hdac_hdmi.h" |
8eaf2b31 RA |
27 | |
28 | #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" | |
29 | #define SKL_MAXIM_CODEC_DAI "HiFi" | |
05282c77 | 30 | #define DMIC_CH(p) p->list[p->count-1] |
8eaf2b31 RA |
31 | |
32 | static struct snd_soc_jack skylake_headset; | |
33 | static struct snd_soc_card skylake_audio_card; | |
05282c77 | 34 | static const struct snd_pcm_hw_constraint_list *dmic_constraints; |
c541b2dd | 35 | static struct snd_soc_jack skylake_hdmi[3]; |
8eaf2b31 | 36 | |
0d425b4f SP |
37 | struct skl_hdmi_pcm { |
38 | struct list_head head; | |
39 | struct snd_soc_dai *codec_dai; | |
40 | int device; | |
41 | }; | |
42 | ||
43 | struct skl_nau8825_private { | |
44 | struct list_head hdmi_pcm_list; | |
45 | }; | |
46 | ||
0ab338ff SN |
47 | enum { |
48 | SKL_DPCM_AUDIO_PB = 0, | |
49 | SKL_DPCM_AUDIO_CP, | |
50 | SKL_DPCM_AUDIO_REF_CP, | |
51 | SKL_DPCM_AUDIO_DMIC_CP, | |
52 | SKL_DPCM_AUDIO_HDMI1_PB, | |
53 | SKL_DPCM_AUDIO_HDMI2_PB, | |
54 | SKL_DPCM_AUDIO_HDMI3_PB, | |
55 | }; | |
56 | ||
8eaf2b31 RA |
57 | static int platform_clock_control(struct snd_soc_dapm_widget *w, |
58 | struct snd_kcontrol *k, int event) | |
59 | { | |
60 | struct snd_soc_dapm_context *dapm = w->dapm; | |
61 | struct snd_soc_card *card = dapm->card; | |
62 | struct snd_soc_dai *codec_dai; | |
63 | int ret; | |
64 | ||
dfb6ec7a | 65 | codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI); |
8eaf2b31 RA |
66 | if (!codec_dai) { |
67 | dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); | |
68 | return -EIO; | |
69 | } | |
70 | ||
71 | if (SND_SOC_DAPM_EVENT_ON(event)) { | |
72 | ret = snd_soc_dai_set_sysclk(codec_dai, | |
73 | NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN); | |
74 | if (ret < 0) { | |
75 | dev_err(card->dev, "set sysclk err = %d\n", ret); | |
76 | return -EIO; | |
77 | } | |
78 | } else { | |
79 | ret = snd_soc_dai_set_sysclk(codec_dai, | |
80 | NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN); | |
81 | if (ret < 0) { | |
82 | dev_err(card->dev, "set sysclk err = %d\n", ret); | |
83 | return -EIO; | |
84 | } | |
85 | } | |
86 | ||
87 | return ret; | |
88 | } | |
89 | ||
90 | static const struct snd_kcontrol_new skylake_controls[] = { | |
91 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), | |
92 | SOC_DAPM_PIN_SWITCH("Headset Mic"), | |
93 | SOC_DAPM_PIN_SWITCH("Spk"), | |
94 | }; | |
95 | ||
96 | static const struct snd_soc_dapm_widget skylake_widgets[] = { | |
97 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | |
98 | SND_SOC_DAPM_MIC("Headset Mic", NULL), | |
99 | SND_SOC_DAPM_SPK("Spk", NULL), | |
100 | SND_SOC_DAPM_MIC("SoC DMIC", NULL), | |
b0aad231 JK |
101 | SND_SOC_DAPM_SPK("DP1", NULL), |
102 | SND_SOC_DAPM_SPK("DP2", NULL), | |
8eaf2b31 RA |
103 | SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, |
104 | platform_clock_control, SND_SOC_DAPM_PRE_PMU | | |
105 | SND_SOC_DAPM_POST_PMD), | |
106 | }; | |
107 | ||
108 | static const struct snd_soc_dapm_route skylake_map[] = { | |
109 | /* HP jack connectors - unknown if we have jack detection */ | |
110 | { "Headphone Jack", NULL, "HPOL" }, | |
111 | { "Headphone Jack", NULL, "HPOR" }, | |
112 | ||
113 | /* speaker */ | |
114 | { "Spk", NULL, "Speaker" }, | |
115 | ||
116 | /* other jacks */ | |
117 | { "MIC", NULL, "Headset Mic" }, | |
118 | { "DMic", NULL, "SoC DMIC" }, | |
119 | ||
8eaf2b31 RA |
120 | /* CODEC BE connections */ |
121 | { "HiFi Playback", NULL, "ssp0 Tx" }, | |
122 | { "ssp0 Tx", NULL, "codec0_out" }, | |
123 | ||
124 | { "Playback", NULL, "ssp1 Tx" }, | |
125 | { "ssp1 Tx", NULL, "codec1_out" }, | |
126 | ||
127 | { "codec0_in", NULL, "ssp1 Rx" }, | |
128 | { "ssp1 Rx", NULL, "Capture" }, | |
129 | ||
130 | /* DMIC */ | |
131 | { "dmic01_hifi", NULL, "DMIC01 Rx" }, | |
132 | { "DMIC01 Rx", NULL, "DMIC AIF" }, | |
0ab338ff SN |
133 | |
134 | { "hifi3", NULL, "iDisp3 Tx"}, | |
135 | { "iDisp3 Tx", NULL, "iDisp3_out"}, | |
136 | { "hifi2", NULL, "iDisp2 Tx"}, | |
137 | { "iDisp2 Tx", NULL, "iDisp2_out"}, | |
138 | { "hifi1", NULL, "iDisp1 Tx"}, | |
139 | { "iDisp1 Tx", NULL, "iDisp1_out"}, | |
140 | ||
8eaf2b31 RA |
141 | { "Headphone Jack", NULL, "Platform Clock" }, |
142 | { "Headset Mic", NULL, "Platform Clock" }, | |
143 | }; | |
144 | ||
145 | static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, | |
146 | struct snd_pcm_hw_params *params) | |
147 | { | |
148 | struct snd_interval *rate = hw_param_interval(params, | |
149 | SNDRV_PCM_HW_PARAM_RATE); | |
150 | struct snd_interval *channels = hw_param_interval(params, | |
151 | SNDRV_PCM_HW_PARAM_CHANNELS); | |
152 | struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); | |
153 | ||
154 | /* The ADSP will covert the FE rate to 48k, stereo */ | |
155 | rate->min = rate->max = 48000; | |
156 | channels->min = channels->max = 2; | |
157 | ||
158 | /* set SSP0 to 24 bit */ | |
159 | snd_mask_none(fmt); | |
b5453e8c | 160 | snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); |
8eaf2b31 RA |
161 | |
162 | return 0; | |
163 | } | |
164 | ||
165 | static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) | |
166 | { | |
167 | int ret; | |
45101122 | 168 | struct snd_soc_component *component = rtd->codec_dai->component; |
8eaf2b31 RA |
169 | |
170 | /* | |
171 | * Headset buttons map to the google Reference headset. | |
172 | * These can be configured by userspace. | |
173 | */ | |
174 | ret = snd_soc_card_jack_new(&skylake_audio_card, "Headset Jack", | |
175 | SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | | |
176 | SND_JACK_BTN_2 | SND_JACK_BTN_3, &skylake_headset, | |
177 | NULL, 0); | |
178 | if (ret) { | |
179 | dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret); | |
180 | return ret; | |
181 | } | |
182 | ||
45101122 | 183 | nau8825_enable_jack_detect(component, &skylake_headset); |
8eaf2b31 RA |
184 | |
185 | snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); | |
8eaf2b31 RA |
186 | |
187 | return ret; | |
188 | } | |
189 | ||
0ab338ff SN |
190 | static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) |
191 | { | |
0d425b4f | 192 | struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
0ab338ff | 193 | struct snd_soc_dai *dai = rtd->codec_dai; |
0d425b4f SP |
194 | struct skl_hdmi_pcm *pcm; |
195 | ||
196 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); | |
197 | if (!pcm) | |
198 | return -ENOMEM; | |
199 | ||
200 | pcm->device = SKL_DPCM_AUDIO_HDMI1_PB; | |
201 | pcm->codec_dai = dai; | |
0ab338ff | 202 | |
0d425b4f SP |
203 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
204 | ||
205 | return 0; | |
0ab338ff SN |
206 | } |
207 | ||
208 | static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) | |
209 | { | |
0d425b4f | 210 | struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
0ab338ff | 211 | struct snd_soc_dai *dai = rtd->codec_dai; |
0d425b4f SP |
212 | struct skl_hdmi_pcm *pcm; |
213 | ||
214 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); | |
215 | if (!pcm) | |
216 | return -ENOMEM; | |
0ab338ff | 217 | |
0d425b4f SP |
218 | pcm->device = SKL_DPCM_AUDIO_HDMI2_PB; |
219 | pcm->codec_dai = dai; | |
220 | ||
221 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); | |
222 | ||
223 | return 0; | |
0ab338ff SN |
224 | } |
225 | ||
226 | static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) | |
227 | { | |
0d425b4f | 228 | struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
0ab338ff | 229 | struct snd_soc_dai *dai = rtd->codec_dai; |
0d425b4f | 230 | struct skl_hdmi_pcm *pcm; |
0ab338ff | 231 | |
0d425b4f SP |
232 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
233 | if (!pcm) | |
234 | return -ENOMEM; | |
235 | ||
236 | pcm->device = SKL_DPCM_AUDIO_HDMI3_PB; | |
237 | pcm->codec_dai = dai; | |
238 | ||
239 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); | |
240 | ||
241 | return 0; | |
0ab338ff SN |
242 | } |
243 | ||
8eaf2b31 RA |
244 | static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd) |
245 | { | |
246 | struct snd_soc_dapm_context *dapm; | |
247 | struct snd_soc_component *component = rtd->cpu_dai->component; | |
248 | ||
249 | dapm = snd_soc_component_get_dapm(component); | |
250 | snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); | |
251 | ||
252 | return 0; | |
253 | } | |
254 | ||
617647ae | 255 | static const unsigned int rates[] = { |
8eaf2b31 RA |
256 | 48000, |
257 | }; | |
258 | ||
617647ae | 259 | static const struct snd_pcm_hw_constraint_list constraints_rates = { |
8eaf2b31 RA |
260 | .count = ARRAY_SIZE(rates), |
261 | .list = rates, | |
262 | .mask = 0, | |
263 | }; | |
264 | ||
617647ae | 265 | static const unsigned int channels[] = { |
8eaf2b31 RA |
266 | 2, |
267 | }; | |
268 | ||
617647ae | 269 | static const struct snd_pcm_hw_constraint_list constraints_channels = { |
8eaf2b31 RA |
270 | .count = ARRAY_SIZE(channels), |
271 | .list = channels, | |
272 | .mask = 0, | |
273 | }; | |
274 | ||
275 | static int skl_fe_startup(struct snd_pcm_substream *substream) | |
276 | { | |
277 | struct snd_pcm_runtime *runtime = substream->runtime; | |
278 | ||
279 | /* | |
280 | * On this platform for PCM device we support, | |
281 | * 48Khz | |
282 | * stereo | |
283 | * 16 bit audio | |
284 | */ | |
285 | ||
286 | runtime->hw.channels_max = 2; | |
287 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | |
288 | &constraints_channels); | |
289 | ||
290 | runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; | |
291 | snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); | |
292 | ||
293 | snd_pcm_hw_constraint_list(runtime, 0, | |
294 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); | |
295 | ||
296 | return 0; | |
297 | } | |
298 | ||
299 | static const struct snd_soc_ops skylake_nau8825_fe_ops = { | |
300 | .startup = skl_fe_startup, | |
301 | }; | |
302 | ||
303 | static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream, | |
304 | struct snd_pcm_hw_params *params) | |
305 | { | |
306 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
307 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | |
308 | int ret; | |
309 | ||
310 | ret = snd_soc_dai_set_sysclk(codec_dai, | |
311 | NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN); | |
312 | ||
313 | if (ret < 0) | |
314 | dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); | |
315 | ||
316 | return ret; | |
317 | } | |
318 | ||
9b6fdef6 | 319 | static const struct snd_soc_ops skylake_nau8825_ops = { |
8eaf2b31 RA |
320 | .hw_params = skylake_nau8825_hw_params, |
321 | }; | |
322 | ||
323 | static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, | |
324 | struct snd_pcm_hw_params *params) | |
325 | { | |
326 | struct snd_interval *channels = hw_param_interval(params, | |
327 | SNDRV_PCM_HW_PARAM_CHANNELS); | |
328 | ||
05282c77 | 329 | if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) |
8eaf2b31 RA |
330 | channels->min = channels->max = 2; |
331 | else | |
332 | channels->min = channels->max = 4; | |
333 | ||
334 | return 0; | |
335 | } | |
336 | ||
617647ae | 337 | static const unsigned int channels_dmic[] = { |
8eaf2b31 RA |
338 | 2, 4, |
339 | }; | |
340 | ||
617647ae | 341 | static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = { |
8eaf2b31 RA |
342 | .count = ARRAY_SIZE(channels_dmic), |
343 | .list = channels_dmic, | |
344 | .mask = 0, | |
345 | }; | |
346 | ||
05282c77 YZ |
347 | static const unsigned int dmic_2ch[] = { |
348 | 2, | |
349 | }; | |
350 | ||
351 | static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = { | |
352 | .count = ARRAY_SIZE(dmic_2ch), | |
353 | .list = dmic_2ch, | |
354 | .mask = 0, | |
355 | }; | |
356 | ||
8eaf2b31 RA |
357 | static int skylake_dmic_startup(struct snd_pcm_substream *substream) |
358 | { | |
359 | struct snd_pcm_runtime *runtime = substream->runtime; | |
360 | ||
05282c77 | 361 | runtime->hw.channels_max = DMIC_CH(dmic_constraints); |
8eaf2b31 | 362 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
05282c77 | 363 | dmic_constraints); |
8eaf2b31 RA |
364 | |
365 | return snd_pcm_hw_constraint_list(substream->runtime, 0, | |
366 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); | |
367 | } | |
368 | ||
9b6fdef6 | 369 | static const struct snd_soc_ops skylake_dmic_ops = { |
8eaf2b31 RA |
370 | .startup = skylake_dmic_startup, |
371 | }; | |
372 | ||
617647ae | 373 | static const unsigned int rates_16000[] = { |
8eaf2b31 RA |
374 | 16000, |
375 | }; | |
376 | ||
617647ae | 377 | static const struct snd_pcm_hw_constraint_list constraints_16000 = { |
8eaf2b31 RA |
378 | .count = ARRAY_SIZE(rates_16000), |
379 | .list = rates_16000, | |
380 | }; | |
381 | ||
d6c9f6af YZ |
382 | static const unsigned int ch_mono[] = { |
383 | 1, | |
384 | }; | |
385 | ||
386 | static const struct snd_pcm_hw_constraint_list constraints_refcap = { | |
387 | .count = ARRAY_SIZE(ch_mono), | |
388 | .list = ch_mono, | |
389 | }; | |
390 | ||
8eaf2b31 RA |
391 | static int skylake_refcap_startup(struct snd_pcm_substream *substream) |
392 | { | |
d6c9f6af YZ |
393 | substream->runtime->hw.channels_max = 1; |
394 | snd_pcm_hw_constraint_list(substream->runtime, 0, | |
395 | SNDRV_PCM_HW_PARAM_CHANNELS, | |
396 | &constraints_refcap); | |
397 | ||
8eaf2b31 RA |
398 | return snd_pcm_hw_constraint_list(substream->runtime, 0, |
399 | SNDRV_PCM_HW_PARAM_RATE, | |
400 | &constraints_16000); | |
401 | } | |
402 | ||
48bf41a2 | 403 | static const struct snd_soc_ops skylake_refcap_ops = { |
8eaf2b31 RA |
404 | .startup = skylake_refcap_startup, |
405 | }; | |
406 | ||
407 | /* skylake digital audio interface glue - connects codec <--> CPU */ | |
408 | static struct snd_soc_dai_link skylake_dais[] = { | |
409 | /* Front End DAI links */ | |
0ab338ff | 410 | [SKL_DPCM_AUDIO_PB] = { |
8eaf2b31 RA |
411 | .name = "Skl Audio Port", |
412 | .stream_name = "Audio", | |
413 | .cpu_dai_name = "System Pin", | |
414 | .platform_name = "0000:00:1f.3", | |
415 | .dynamic = 1, | |
416 | .codec_name = "snd-soc-dummy", | |
417 | .codec_dai_name = "snd-soc-dummy-dai", | |
418 | .nonatomic = 1, | |
419 | .init = skylake_nau8825_fe_init, | |
420 | .trigger = { | |
421 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | |
422 | .dpcm_playback = 1, | |
423 | .ops = &skylake_nau8825_fe_ops, | |
424 | }, | |
0ab338ff | 425 | [SKL_DPCM_AUDIO_CP] = { |
8eaf2b31 RA |
426 | .name = "Skl Audio Capture Port", |
427 | .stream_name = "Audio Record", | |
428 | .cpu_dai_name = "System Pin", | |
429 | .platform_name = "0000:00:1f.3", | |
430 | .dynamic = 1, | |
431 | .codec_name = "snd-soc-dummy", | |
432 | .codec_dai_name = "snd-soc-dummy-dai", | |
433 | .nonatomic = 1, | |
434 | .trigger = { | |
435 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | |
436 | .dpcm_capture = 1, | |
437 | .ops = &skylake_nau8825_fe_ops, | |
438 | }, | |
0ab338ff | 439 | [SKL_DPCM_AUDIO_REF_CP] = { |
8eaf2b31 RA |
440 | .name = "Skl Audio Reference cap", |
441 | .stream_name = "Wake on Voice", | |
442 | .cpu_dai_name = "Reference Pin", | |
443 | .codec_name = "snd-soc-dummy", | |
444 | .codec_dai_name = "snd-soc-dummy-dai", | |
445 | .platform_name = "0000:00:1f.3", | |
446 | .init = NULL, | |
447 | .dpcm_capture = 1, | |
8eaf2b31 RA |
448 | .nonatomic = 1, |
449 | .dynamic = 1, | |
48bf41a2 | 450 | .ops = &skylake_refcap_ops, |
8eaf2b31 | 451 | }, |
0ab338ff | 452 | [SKL_DPCM_AUDIO_DMIC_CP] = { |
8eaf2b31 RA |
453 | .name = "Skl Audio DMIC cap", |
454 | .stream_name = "dmiccap", | |
455 | .cpu_dai_name = "DMIC Pin", | |
456 | .codec_name = "snd-soc-dummy", | |
457 | .codec_dai_name = "snd-soc-dummy-dai", | |
458 | .platform_name = "0000:00:1f.3", | |
459 | .init = NULL, | |
460 | .dpcm_capture = 1, | |
461 | .nonatomic = 1, | |
462 | .dynamic = 1, | |
463 | .ops = &skylake_dmic_ops, | |
464 | }, | |
0ab338ff SN |
465 | [SKL_DPCM_AUDIO_HDMI1_PB] = { |
466 | .name = "Skl HDMI Port1", | |
467 | .stream_name = "Hdmi1", | |
468 | .cpu_dai_name = "HDMI1 Pin", | |
469 | .codec_name = "snd-soc-dummy", | |
470 | .codec_dai_name = "snd-soc-dummy-dai", | |
471 | .platform_name = "0000:00:1f.3", | |
472 | .dpcm_playback = 1, | |
473 | .init = NULL, | |
474 | .trigger = { | |
475 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | |
476 | .nonatomic = 1, | |
477 | .dynamic = 1, | |
478 | }, | |
479 | [SKL_DPCM_AUDIO_HDMI2_PB] = { | |
480 | .name = "Skl HDMI Port2", | |
481 | .stream_name = "Hdmi2", | |
482 | .cpu_dai_name = "HDMI2 Pin", | |
8eaf2b31 RA |
483 | .codec_name = "snd-soc-dummy", |
484 | .codec_dai_name = "snd-soc-dummy-dai", | |
485 | .platform_name = "0000:00:1f.3", | |
486 | .dpcm_playback = 1, | |
487 | .init = NULL, | |
0ab338ff SN |
488 | .trigger = { |
489 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | |
490 | .nonatomic = 1, | |
491 | .dynamic = 1, | |
492 | }, | |
493 | [SKL_DPCM_AUDIO_HDMI3_PB] = { | |
494 | .name = "Skl HDMI Port3", | |
495 | .stream_name = "Hdmi3", | |
496 | .cpu_dai_name = "HDMI3 Pin", | |
497 | .codec_name = "snd-soc-dummy", | |
498 | .codec_dai_name = "snd-soc-dummy-dai", | |
499 | .platform_name = "0000:00:1f.3", | |
500 | .trigger = { | |
501 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | |
502 | .dpcm_playback = 1, | |
503 | .init = NULL, | |
8eaf2b31 RA |
504 | .nonatomic = 1, |
505 | .dynamic = 1, | |
506 | }, | |
507 | ||
508 | /* Back End DAI links */ | |
509 | { | |
510 | /* SSP0 - Codec */ | |
511 | .name = "SSP0-Codec", | |
2f0ad491 | 512 | .id = 0, |
8eaf2b31 RA |
513 | .cpu_dai_name = "SSP0 Pin", |
514 | .platform_name = "0000:00:1f.3", | |
515 | .no_pcm = 1, | |
516 | .codec_name = "MX98357A:00", | |
517 | .codec_dai_name = SKL_MAXIM_CODEC_DAI, | |
518 | .dai_fmt = SND_SOC_DAIFMT_I2S | | |
519 | SND_SOC_DAIFMT_NB_NF | | |
520 | SND_SOC_DAIFMT_CBS_CFS, | |
521 | .ignore_pmdown_time = 1, | |
522 | .be_hw_params_fixup = skylake_ssp_fixup, | |
523 | .dpcm_playback = 1, | |
524 | }, | |
525 | { | |
526 | /* SSP1 - Codec */ | |
527 | .name = "SSP1-Codec", | |
2f0ad491 | 528 | .id = 1, |
8eaf2b31 RA |
529 | .cpu_dai_name = "SSP1 Pin", |
530 | .platform_name = "0000:00:1f.3", | |
531 | .no_pcm = 1, | |
532 | .codec_name = "i2c-10508825:00", | |
533 | .codec_dai_name = SKL_NUVOTON_CODEC_DAI, | |
534 | .init = skylake_nau8825_codec_init, | |
535 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | |
536 | SND_SOC_DAIFMT_CBS_CFS, | |
537 | .ignore_pmdown_time = 1, | |
538 | .be_hw_params_fixup = skylake_ssp_fixup, | |
539 | .ops = &skylake_nau8825_ops, | |
540 | .dpcm_playback = 1, | |
541 | .dpcm_capture = 1, | |
542 | }, | |
543 | { | |
544 | .name = "dmic01", | |
2f0ad491 | 545 | .id = 2, |
8eaf2b31 RA |
546 | .cpu_dai_name = "DMIC01 Pin", |
547 | .codec_name = "dmic-codec", | |
548 | .codec_dai_name = "dmic-hifi", | |
549 | .platform_name = "0000:00:1f.3", | |
550 | .be_hw_params_fixup = skylake_dmic_fixup, | |
551 | .ignore_suspend = 1, | |
552 | .dpcm_capture = 1, | |
553 | .no_pcm = 1, | |
554 | }, | |
555 | { | |
0ab338ff | 556 | .name = "iDisp1", |
2f0ad491 | 557 | .id = 3, |
0ab338ff | 558 | .cpu_dai_name = "iDisp1 Pin", |
8eaf2b31 RA |
559 | .codec_name = "ehdaudio0D2", |
560 | .codec_dai_name = "intel-hdmi-hifi1", | |
561 | .platform_name = "0000:00:1f.3", | |
562 | .dpcm_playback = 1, | |
0ab338ff SN |
563 | .init = skylake_hdmi1_init, |
564 | .no_pcm = 1, | |
565 | }, | |
566 | { | |
567 | .name = "iDisp2", | |
2f0ad491 | 568 | .id = 4, |
0ab338ff SN |
569 | .cpu_dai_name = "iDisp2 Pin", |
570 | .codec_name = "ehdaudio0D2", | |
571 | .codec_dai_name = "intel-hdmi-hifi2", | |
572 | .platform_name = "0000:00:1f.3", | |
573 | .init = skylake_hdmi2_init, | |
574 | .dpcm_playback = 1, | |
575 | .no_pcm = 1, | |
576 | }, | |
577 | { | |
578 | .name = "iDisp3", | |
2f0ad491 | 579 | .id = 5, |
0ab338ff SN |
580 | .cpu_dai_name = "iDisp3 Pin", |
581 | .codec_name = "ehdaudio0D2", | |
582 | .codec_dai_name = "intel-hdmi-hifi3", | |
583 | .platform_name = "0000:00:1f.3", | |
584 | .init = skylake_hdmi3_init, | |
585 | .dpcm_playback = 1, | |
8eaf2b31 RA |
586 | .no_pcm = 1, |
587 | }, | |
588 | }; | |
589 | ||
c541b2dd | 590 | #define NAME_SIZE 32 |
0d425b4f SP |
591 | static int skylake_card_late_probe(struct snd_soc_card *card) |
592 | { | |
593 | struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(card); | |
594 | struct skl_hdmi_pcm *pcm; | |
45101122 | 595 | struct snd_soc_component *component = NULL; |
c541b2dd JK |
596 | int err, i = 0; |
597 | char jack_name[NAME_SIZE]; | |
0d425b4f SP |
598 | |
599 | list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { | |
45101122 | 600 | component = pcm->codec_dai->component; |
c541b2dd JK |
601 | snprintf(jack_name, sizeof(jack_name), |
602 | "HDMI/DP, pcm=%d Jack", pcm->device); | |
603 | err = snd_soc_card_jack_new(card, jack_name, | |
604 | SND_JACK_AVOUT, | |
605 | &skylake_hdmi[i], | |
606 | NULL, 0); | |
607 | ||
608 | if (err) | |
609 | return err; | |
610 | ||
611 | err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, | |
612 | &skylake_hdmi[i]); | |
0d425b4f SP |
613 | if (err < 0) |
614 | return err; | |
c541b2dd JK |
615 | |
616 | i++; | |
0d425b4f SP |
617 | } |
618 | ||
45101122 | 619 | if (!component) |
565f13a9 JK |
620 | return -EINVAL; |
621 | ||
45101122 | 622 | return hdac_hdmi_jack_port_init(component, &card->dapm); |
0d425b4f SP |
623 | } |
624 | ||
8eaf2b31 RA |
625 | /* skylake audio machine driver for SPT + NAU88L25 */ |
626 | static struct snd_soc_card skylake_audio_card = { | |
627 | .name = "sklnau8825max", | |
628 | .owner = THIS_MODULE, | |
629 | .dai_link = skylake_dais, | |
630 | .num_links = ARRAY_SIZE(skylake_dais), | |
631 | .controls = skylake_controls, | |
632 | .num_controls = ARRAY_SIZE(skylake_controls), | |
633 | .dapm_widgets = skylake_widgets, | |
634 | .num_dapm_widgets = ARRAY_SIZE(skylake_widgets), | |
635 | .dapm_routes = skylake_map, | |
636 | .num_dapm_routes = ARRAY_SIZE(skylake_map), | |
637 | .fully_routed = true, | |
0d425b4f | 638 | .late_probe = skylake_card_late_probe, |
8eaf2b31 RA |
639 | }; |
640 | ||
641 | static int skylake_audio_probe(struct platform_device *pdev) | |
642 | { | |
0d425b4f | 643 | struct skl_nau8825_private *ctx; |
b92826fa | 644 | struct snd_soc_acpi_mach *mach; |
0d425b4f | 645 | |
3afce6a4 | 646 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); |
0d425b4f SP |
647 | if (!ctx) |
648 | return -ENOMEM; | |
649 | ||
650 | INIT_LIST_HEAD(&ctx->hdmi_pcm_list); | |
651 | ||
8eaf2b31 | 652 | skylake_audio_card.dev = &pdev->dev; |
0d425b4f | 653 | snd_soc_card_set_drvdata(&skylake_audio_card, ctx); |
8eaf2b31 | 654 | |
b92826fa PLB |
655 | mach = dev_get_drvdata(&pdev->dev); |
656 | if (mach) | |
657 | dmic_constraints = mach->mach_params.dmic_num == 2 ? | |
05282c77 YZ |
658 | &constraints_dmic_2ch : &constraints_dmic_channels; |
659 | ||
8eaf2b31 RA |
660 | return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card); |
661 | } | |
662 | ||
2ca972da VK |
663 | static const struct platform_device_id skl_board_ids[] = { |
664 | { .name = "skl_n88l25_m98357a" }, | |
665 | { .name = "kbl_n88l25_m98357a" }, | |
666 | { } | |
667 | }; | |
668 | ||
8eaf2b31 RA |
669 | static struct platform_driver skylake_audio = { |
670 | .probe = skylake_audio_probe, | |
671 | .driver = { | |
a2f5b8db | 672 | .name = "skl_n88l25_m98357a", |
8eaf2b31 RA |
673 | .pm = &snd_soc_pm_ops, |
674 | }, | |
2ca972da | 675 | .id_table = skl_board_ids, |
8eaf2b31 RA |
676 | }; |
677 | ||
678 | module_platform_driver(skylake_audio) | |
679 | ||
680 | /* Module information */ | |
681 | MODULE_DESCRIPTION("Audio Machine driver-NAU88L25 & MAX98357A in I2S mode"); | |
682 | MODULE_AUTHOR("Rohit Ainapure <rohit.m.ainapure@intel.com"); | |
683 | MODULE_LICENSE("GPL v2"); | |
a2f5b8db | 684 | MODULE_ALIAS("platform:skl_n88l25_m98357a"); |
2ca972da | 685 | MODULE_ALIAS("platform:kbl_n88l25_m98357a"); |