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