2 * Intel Kabylake I2S Machine Driver with MAXIM98927
5 * Copyright (C) 2017, Intel Corporation. All rights reserved.
8 * Intel Skylake I2S Machine driver
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License version
12 * 2 as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #include <linux/module.h>
21 #include <linux/platform_device.h>
22 #include <sound/core.h>
23 #include <sound/jack.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/soc.h>
27 #include "../../codecs/rt5663.h"
28 #include "../../codecs/hdac_hdmi.h"
29 #include "../skylake/skl.h"
31 #define KBL_REALTEK_CODEC_DAI "rt5663-aif"
32 #define KBL_MAXIM_CODEC_DAI "max98927-aif1"
33 #define DMIC_CH(p) p->list[p->count-1]
34 #define MAXIM_DEV0_NAME "i2c-MX98927:00"
35 #define MAXIM_DEV1_NAME "i2c-MX98927:01"
37 static struct snd_soc_card *kabylake_audio_card;
38 static const struct snd_pcm_hw_constraint_list *dmic_constraints;
39 static struct snd_soc_jack skylake_hdmi[3];
42 struct list_head head;
43 struct snd_soc_dai *codec_dai;
47 struct kbl_rt5663_private {
48 struct snd_soc_jack kabylake_headset;
49 struct list_head hdmi_pcm_list;
53 KBL_DPCM_AUDIO_PB = 0,
56 KBL_DPCM_AUDIO_ECHO_REF_CP,
57 KBL_DPCM_AUDIO_REF_CP,
58 KBL_DPCM_AUDIO_DMIC_CP,
59 KBL_DPCM_AUDIO_HDMI1_PB,
60 KBL_DPCM_AUDIO_HDMI2_PB,
61 KBL_DPCM_AUDIO_HDMI3_PB,
64 static const struct snd_kcontrol_new kabylake_controls[] = {
65 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
66 SOC_DAPM_PIN_SWITCH("Headset Mic"),
67 SOC_DAPM_PIN_SWITCH("Left Spk"),
68 SOC_DAPM_PIN_SWITCH("Right Spk"),
71 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
72 SND_SOC_DAPM_HP("Headphone Jack", NULL),
73 SND_SOC_DAPM_MIC("Headset Mic", NULL),
74 SND_SOC_DAPM_SPK("Left Spk", NULL),
75 SND_SOC_DAPM_SPK("Right Spk", NULL),
76 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
77 SND_SOC_DAPM_SPK("DP", NULL),
78 SND_SOC_DAPM_SPK("HDMI", NULL),
82 static const struct snd_soc_dapm_route kabylake_map[] = {
83 /* HP jack connectors - unknown if we have jack detection */
84 { "Headphone Jack", NULL, "HPOL" },
85 { "Headphone Jack", NULL, "HPOR" },
88 { "Left Spk", NULL, "Left BE_OUT" },
89 { "Right Spk", NULL, "Right BE_OUT" },
92 { "IN1P", NULL, "Headset Mic" },
93 { "IN1N", NULL, "Headset Mic" },
94 { "DMic", NULL, "SoC DMIC" },
96 { "HDMI", NULL, "hif5 Output" },
97 { "DP", NULL, "hif6 Output" },
99 /* CODEC BE connections */
100 { "Left HiFi Playback", NULL, "ssp0 Tx" },
101 { "Right HiFi Playback", NULL, "ssp0 Tx" },
102 { "ssp0 Tx", NULL, "spk_out" },
104 { "AIF Playback", NULL, "ssp1 Tx" },
105 { "ssp1 Tx", NULL, "hs_out" },
107 { "hs_in", NULL, "ssp1 Rx" },
108 { "ssp1 Rx", NULL, "AIF Capture" },
111 { "dmic01_hifi", NULL, "DMIC01 Rx" },
112 { "DMIC01 Rx", NULL, "DMIC AIF" },
114 { "hifi3", NULL, "iDisp3 Tx"},
115 { "iDisp3 Tx", NULL, "iDisp3_out"},
116 { "hifi2", NULL, "iDisp2 Tx"},
117 { "iDisp2 Tx", NULL, "iDisp2_out"},
118 { "hifi1", NULL, "iDisp1 Tx"},
119 { "iDisp1 Tx", NULL, "iDisp1_out"},
123 KBL_DPCM_AUDIO_5663_PB = 0,
124 KBL_DPCM_AUDIO_5663_CP,
125 KBL_DPCM_AUDIO_5663_HDMI1_PB,
126 KBL_DPCM_AUDIO_5663_HDMI2_PB,
129 static const struct snd_kcontrol_new kabylake_5663_controls[] = {
130 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
131 SOC_DAPM_PIN_SWITCH("Headset Mic"),
134 static const struct snd_soc_dapm_widget kabylake_5663_widgets[] = {
135 SND_SOC_DAPM_HP("Headphone Jack", NULL),
136 SND_SOC_DAPM_MIC("Headset Mic", NULL),
137 SND_SOC_DAPM_SPK("DP", NULL),
138 SND_SOC_DAPM_SPK("HDMI", NULL),
141 static const struct snd_soc_dapm_route kabylake_5663_map[] = {
142 { "Headphone Jack", NULL, "HPOL" },
143 { "Headphone Jack", NULL, "HPOR" },
146 { "IN1P", NULL, "Headset Mic" },
147 { "IN1N", NULL, "Headset Mic" },
149 { "HDMI", NULL, "hif5 Output" },
150 { "DP", NULL, "hif6 Output" },
152 /* CODEC BE connections */
153 { "AIF Playback", NULL, "ssp1 Tx" },
154 { "ssp1 Tx", NULL, "codec1_out" },
156 { "codec0_in", NULL, "ssp1 Rx" },
157 { "ssp1 Rx", NULL, "AIF Capture" },
159 { "hifi2", NULL, "iDisp2 Tx"},
160 { "iDisp2 Tx", NULL, "iDisp2_out"},
161 { "hifi1", NULL, "iDisp1 Tx"},
162 { "iDisp1 Tx", NULL, "iDisp1_out"},
165 static struct snd_soc_codec_conf max98927_codec_conf[] = {
167 .dev_name = MAXIM_DEV0_NAME,
168 .name_prefix = "Right",
171 .dev_name = MAXIM_DEV1_NAME,
172 .name_prefix = "Left",
176 static struct snd_soc_dai_link_component max98927_codec_components[] = {
178 .name = MAXIM_DEV0_NAME,
179 .dai_name = KBL_MAXIM_CODEC_DAI,
182 .name = MAXIM_DEV1_NAME,
183 .dai_name = KBL_MAXIM_CODEC_DAI,
187 static int kabylake_rt5663_fe_init(struct snd_soc_pcm_runtime *rtd)
190 struct snd_soc_dapm_context *dapm;
191 struct snd_soc_component *component = rtd->cpu_dai->component;
193 dapm = snd_soc_component_get_dapm(component);
194 ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
196 dev_err(rtd->dev, "Ref Cap ignore suspend failed %d\n", ret);
203 static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
206 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
207 struct snd_soc_codec *codec = rtd->codec;
210 * Headset buttons map to the google Reference headset.
211 * These can be configured by userspace.
213 ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
214 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
215 SND_JACK_BTN_2 | SND_JACK_BTN_3, &ctx->kabylake_headset,
218 dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
221 rt5663_set_jack_detect(codec, &ctx->kabylake_headset);
225 static int kabylake_rt5663_max98927_codec_init(struct snd_soc_pcm_runtime *rtd)
229 ret = kabylake_rt5663_codec_init(rtd);
233 ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
235 dev_err(rtd->dev, "SoC DMIC ignore suspend failed %d\n", ret);
242 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
244 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
245 struct snd_soc_dai *dai = rtd->codec_dai;
246 struct kbl_hdmi_pcm *pcm;
248 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
252 pcm->device = device;
253 pcm->codec_dai = dai;
255 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
260 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
262 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
265 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
267 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
270 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
272 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
275 static int kabylake_5663_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
277 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI1_PB);
280 static int kabylake_5663_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
282 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI2_PB);
285 static unsigned int rates[] = {
289 static const struct snd_pcm_hw_constraint_list constraints_rates = {
290 .count = ARRAY_SIZE(rates),
295 static unsigned int channels[] = {
299 static const struct snd_pcm_hw_constraint_list constraints_channels = {
300 .count = ARRAY_SIZE(channels),
305 static int kbl_fe_startup(struct snd_pcm_substream *substream)
307 struct snd_pcm_runtime *runtime = substream->runtime;
310 * On this platform for PCM device we support,
316 runtime->hw.channels_max = 2;
317 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
318 &constraints_channels);
320 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
321 snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
323 snd_pcm_hw_constraint_list(runtime, 0,
324 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
329 static const struct snd_soc_ops kabylake_rt5663_fe_ops = {
330 .startup = kbl_fe_startup,
333 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
334 struct snd_pcm_hw_params *params)
336 struct snd_interval *rate = hw_param_interval(params,
337 SNDRV_PCM_HW_PARAM_RATE);
338 struct snd_interval *channels = hw_param_interval(params,
339 SNDRV_PCM_HW_PARAM_CHANNELS);
340 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
342 /* The ADSP will convert the FE rate to 48k, stereo */
343 rate->min = rate->max = 48000;
344 channels->min = channels->max = 2;
345 /* set SSP1 to 24 bit */
347 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
352 static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
353 struct snd_pcm_hw_params *params)
355 struct snd_soc_pcm_runtime *rtd = substream->private_data;
356 struct snd_soc_dai *codec_dai = rtd->codec_dai;
359 /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */
360 rt5663_sel_asrc_clk_src(codec_dai->codec,
361 RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER,
362 RT5663_CLK_SEL_I2S1_ASRC);
364 ret = snd_soc_dai_set_sysclk(codec_dai,
365 RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN);
367 dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
372 static struct snd_soc_ops kabylake_rt5663_ops = {
373 .hw_params = kabylake_rt5663_hw_params,
376 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
377 struct snd_pcm_hw_params *params)
379 struct snd_interval *channels = hw_param_interval(params,
380 SNDRV_PCM_HW_PARAM_CHANNELS);
382 if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
383 channels->min = channels->max = 2;
385 channels->min = channels->max = 4;
390 static unsigned int channels_dmic[] = {
394 static struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
395 .count = ARRAY_SIZE(channels_dmic),
396 .list = channels_dmic,
400 static const unsigned int dmic_2ch[] = {
404 static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
405 .count = ARRAY_SIZE(dmic_2ch),
410 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
412 struct snd_pcm_runtime *runtime = substream->runtime;
414 runtime->hw.channels_max = DMIC_CH(dmic_constraints);
415 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
418 return snd_pcm_hw_constraint_list(substream->runtime, 0,
419 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
422 static struct snd_soc_ops kabylake_dmic_ops = {
423 .startup = kabylake_dmic_startup,
426 static unsigned int rates_16000[] = {
430 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
431 .count = ARRAY_SIZE(rates_16000),
435 static const unsigned int ch_mono[] = {
439 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
440 .count = ARRAY_SIZE(ch_mono),
444 static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
446 substream->runtime->hw.channels_max = 1;
447 snd_pcm_hw_constraint_list(substream->runtime, 0,
448 SNDRV_PCM_HW_PARAM_CHANNELS,
449 &constraints_refcap);
451 return snd_pcm_hw_constraint_list(substream->runtime, 0,
452 SNDRV_PCM_HW_PARAM_RATE,
456 static struct snd_soc_ops skylaye_refcap_ops = {
457 .startup = kabylake_refcap_startup,
460 /* kabylake digital audio interface glue - connects codec <--> CPU */
461 static struct snd_soc_dai_link kabylake_dais[] = {
462 /* Front End DAI links */
463 [KBL_DPCM_AUDIO_PB] = {
464 .name = "Kbl Audio Port",
465 .stream_name = "Audio",
466 .cpu_dai_name = "System Pin",
467 .platform_name = "0000:00:1f.3",
469 .codec_name = "snd-soc-dummy",
470 .codec_dai_name = "snd-soc-dummy-dai",
472 .init = kabylake_rt5663_fe_init,
474 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
476 .ops = &kabylake_rt5663_fe_ops,
478 [KBL_DPCM_AUDIO_CP] = {
479 .name = "Kbl Audio Capture Port",
480 .stream_name = "Audio Record",
481 .cpu_dai_name = "System Pin",
482 .platform_name = "0000:00:1f.3",
484 .codec_name = "snd-soc-dummy",
485 .codec_dai_name = "snd-soc-dummy-dai",
488 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
490 .ops = &kabylake_rt5663_fe_ops,
492 [KBL_DPCM_AUDIO_HS_PB] = {
493 .name = "Kbl Audio Headset Playback",
494 .stream_name = "Headset Audio",
495 .cpu_dai_name = "System Pin2",
496 .codec_name = "snd-soc-dummy",
497 .codec_dai_name = "snd-soc-dummy-dai",
498 .platform_name = "0000:00:1f.3",
503 [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
504 .name = "Kbl Audio Echo Reference cap",
505 .stream_name = "Echoreference Capture",
506 .cpu_dai_name = "Echoref Pin",
507 .codec_name = "snd-soc-dummy",
508 .codec_dai_name = "snd-soc-dummy-dai",
509 .platform_name = "0000:00:1f.3",
514 [KBL_DPCM_AUDIO_REF_CP] = {
515 .name = "Kbl Audio Reference cap",
516 .stream_name = "Wake on Voice",
517 .cpu_dai_name = "Reference Pin",
518 .codec_name = "snd-soc-dummy",
519 .codec_dai_name = "snd-soc-dummy-dai",
520 .platform_name = "0000:00:1f.3",
525 .ops = &skylaye_refcap_ops,
527 [KBL_DPCM_AUDIO_DMIC_CP] = {
528 .name = "Kbl Audio DMIC cap",
529 .stream_name = "dmiccap",
530 .cpu_dai_name = "DMIC Pin",
531 .codec_name = "snd-soc-dummy",
532 .codec_dai_name = "snd-soc-dummy-dai",
533 .platform_name = "0000:00:1f.3",
538 .ops = &kabylake_dmic_ops,
540 [KBL_DPCM_AUDIO_HDMI1_PB] = {
541 .name = "Kbl HDMI Port1",
542 .stream_name = "Hdmi1",
543 .cpu_dai_name = "HDMI1 Pin",
544 .codec_name = "snd-soc-dummy",
545 .codec_dai_name = "snd-soc-dummy-dai",
546 .platform_name = "0000:00:1f.3",
550 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
554 [KBL_DPCM_AUDIO_HDMI2_PB] = {
555 .name = "Kbl HDMI Port2",
556 .stream_name = "Hdmi2",
557 .cpu_dai_name = "HDMI2 Pin",
558 .codec_name = "snd-soc-dummy",
559 .codec_dai_name = "snd-soc-dummy-dai",
560 .platform_name = "0000:00:1f.3",
564 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
568 [KBL_DPCM_AUDIO_HDMI3_PB] = {
569 .name = "Kbl HDMI Port3",
570 .stream_name = "Hdmi3",
571 .cpu_dai_name = "HDMI3 Pin",
572 .codec_name = "snd-soc-dummy",
573 .codec_dai_name = "snd-soc-dummy-dai",
574 .platform_name = "0000:00:1f.3",
576 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
583 /* Back End DAI links */
586 .name = "SSP0-Codec",
588 .cpu_dai_name = "SSP0 Pin",
589 .platform_name = "0000:00:1f.3",
591 .codecs = max98927_codec_components,
592 .num_codecs = ARRAY_SIZE(max98927_codec_components),
593 .dai_fmt = SND_SOC_DAIFMT_I2S |
594 SND_SOC_DAIFMT_NB_NF |
595 SND_SOC_DAIFMT_CBS_CFS,
596 .ignore_pmdown_time = 1,
597 .be_hw_params_fixup = kabylake_ssp_fixup,
602 .name = "SSP1-Codec",
604 .cpu_dai_name = "SSP1 Pin",
605 .platform_name = "0000:00:1f.3",
607 .codec_name = "i2c-10EC5663:00",
608 .codec_dai_name = KBL_REALTEK_CODEC_DAI,
609 .init = kabylake_rt5663_max98927_codec_init,
610 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
611 SND_SOC_DAIFMT_CBS_CFS,
612 .ignore_pmdown_time = 1,
613 .be_hw_params_fixup = kabylake_ssp_fixup,
614 .ops = &kabylake_rt5663_ops,
621 .cpu_dai_name = "DMIC01 Pin",
622 .codec_name = "dmic-codec",
623 .codec_dai_name = "dmic-hifi",
624 .platform_name = "0000:00:1f.3",
625 .be_hw_params_fixup = kabylake_dmic_fixup,
633 .cpu_dai_name = "iDisp1 Pin",
634 .codec_name = "ehdaudio0D2",
635 .codec_dai_name = "intel-hdmi-hifi1",
636 .platform_name = "0000:00:1f.3",
638 .init = kabylake_hdmi1_init,
644 .cpu_dai_name = "iDisp2 Pin",
645 .codec_name = "ehdaudio0D2",
646 .codec_dai_name = "intel-hdmi-hifi2",
647 .platform_name = "0000:00:1f.3",
648 .init = kabylake_hdmi2_init,
655 .cpu_dai_name = "iDisp3 Pin",
656 .codec_name = "ehdaudio0D2",
657 .codec_dai_name = "intel-hdmi-hifi3",
658 .platform_name = "0000:00:1f.3",
659 .init = kabylake_hdmi3_init,
665 static struct snd_soc_dai_link kabylake_5663_dais[] = {
666 /* Front End DAI links */
667 [KBL_DPCM_AUDIO_5663_PB] = {
668 .name = "Kbl Audio Port",
669 .stream_name = "Audio",
670 .cpu_dai_name = "System Pin",
671 .platform_name = "0000:00:1f.3",
673 .codec_name = "snd-soc-dummy",
674 .codec_dai_name = "snd-soc-dummy-dai",
677 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
679 .ops = &kabylake_rt5663_fe_ops,
681 [KBL_DPCM_AUDIO_5663_CP] = {
682 .name = "Kbl Audio Capture Port",
683 .stream_name = "Audio Record",
684 .cpu_dai_name = "System Pin",
685 .platform_name = "0000:00:1f.3",
687 .codec_name = "snd-soc-dummy",
688 .codec_dai_name = "snd-soc-dummy-dai",
691 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
693 .ops = &kabylake_rt5663_fe_ops,
695 [KBL_DPCM_AUDIO_5663_HDMI1_PB] = {
696 .name = "Kbl HDMI Port1",
697 .stream_name = "Hdmi1",
698 .cpu_dai_name = "HDMI1 Pin",
699 .codec_name = "snd-soc-dummy",
700 .codec_dai_name = "snd-soc-dummy-dai",
701 .platform_name = "0000:00:1f.3",
705 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
709 [KBL_DPCM_AUDIO_5663_HDMI2_PB] = {
710 .name = "Kbl HDMI Port2",
711 .stream_name = "Hdmi2",
712 .cpu_dai_name = "HDMI2 Pin",
713 .codec_name = "snd-soc-dummy",
714 .codec_dai_name = "snd-soc-dummy-dai",
715 .platform_name = "0000:00:1f.3",
719 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
724 /* Back End DAI links */
727 .name = "SSP1-Codec",
729 .cpu_dai_name = "SSP1 Pin",
730 .platform_name = "0000:00:1f.3",
732 .codec_name = "i2c-10EC5663:00",
733 .codec_dai_name = KBL_REALTEK_CODEC_DAI,
734 .init = kabylake_rt5663_codec_init,
735 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
736 SND_SOC_DAIFMT_CBS_CFS,
737 .ignore_pmdown_time = 1,
738 .be_hw_params_fixup = kabylake_ssp_fixup,
739 .ops = &kabylake_rt5663_ops,
746 .cpu_dai_name = "iDisp1 Pin",
747 .codec_name = "ehdaudio0D2",
748 .codec_dai_name = "intel-hdmi-hifi1",
749 .platform_name = "0000:00:1f.3",
751 .init = kabylake_5663_hdmi1_init,
757 .cpu_dai_name = "iDisp2 Pin",
758 .codec_name = "ehdaudio0D2",
759 .codec_dai_name = "intel-hdmi-hifi2",
760 .platform_name = "0000:00:1f.3",
761 .init = kabylake_5663_hdmi2_init,
768 static int kabylake_card_late_probe(struct snd_soc_card *card)
770 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card);
771 struct kbl_hdmi_pcm *pcm;
773 char jack_name[NAME_SIZE];
775 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
776 snprintf(jack_name, sizeof(jack_name),
777 "HDMI/DP, pcm=%d Jack", pcm->device);
778 err = snd_soc_card_jack_new(card, jack_name,
779 SND_JACK_AVOUT, &skylake_hdmi[i],
785 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
796 /* kabylake audio machine driver for SPT + RT5663 */
797 static struct snd_soc_card kabylake_audio_card_rt5663_m98927 = {
798 .name = "kblrt5663max",
799 .owner = THIS_MODULE,
800 .dai_link = kabylake_dais,
801 .num_links = ARRAY_SIZE(kabylake_dais),
802 .controls = kabylake_controls,
803 .num_controls = ARRAY_SIZE(kabylake_controls),
804 .dapm_widgets = kabylake_widgets,
805 .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
806 .dapm_routes = kabylake_map,
807 .num_dapm_routes = ARRAY_SIZE(kabylake_map),
808 .codec_conf = max98927_codec_conf,
809 .num_configs = ARRAY_SIZE(max98927_codec_conf),
810 .fully_routed = true,
811 .late_probe = kabylake_card_late_probe,
814 /* kabylake audio machine driver for RT5663 */
815 static struct snd_soc_card kabylake_audio_card_rt5663 = {
817 .owner = THIS_MODULE,
818 .dai_link = kabylake_5663_dais,
819 .num_links = ARRAY_SIZE(kabylake_5663_dais),
820 .controls = kabylake_5663_controls,
821 .num_controls = ARRAY_SIZE(kabylake_5663_controls),
822 .dapm_widgets = kabylake_5663_widgets,
823 .num_dapm_widgets = ARRAY_SIZE(kabylake_5663_widgets),
824 .dapm_routes = kabylake_5663_map,
825 .num_dapm_routes = ARRAY_SIZE(kabylake_5663_map),
826 .fully_routed = true,
827 .late_probe = kabylake_card_late_probe,
830 static int kabylake_audio_probe(struct platform_device *pdev)
832 struct kbl_rt5663_private *ctx;
833 struct skl_machine_pdata *pdata;
835 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
839 INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
841 kabylake_audio_card =
842 (struct snd_soc_card *)pdev->id_entry->driver_data;
844 kabylake_audio_card->dev = &pdev->dev;
845 snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
847 pdata = dev_get_drvdata(&pdev->dev);
849 dmic_constraints = pdata->dmic_num == 2 ?
850 &constraints_dmic_2ch : &constraints_dmic_channels;
852 return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
855 static const struct platform_device_id kbl_board_ids[] = {
857 .name = "kbl_rt5663",
858 .driver_data = (kernel_ulong_t)&kabylake_audio_card_rt5663,
861 .name = "kbl_rt5663_m98927",
863 (kernel_ulong_t)&kabylake_audio_card_rt5663_m98927,
868 static struct platform_driver kabylake_audio = {
869 .probe = kabylake_audio_probe,
871 .name = "kbl_rt5663_m98927",
872 .pm = &snd_soc_pm_ops,
874 .id_table = kbl_board_ids,
877 module_platform_driver(kabylake_audio)
879 /* Module information */
880 MODULE_DESCRIPTION("Audio Machine driver-RT5663 & MAX98927 in I2S mode");
881 MODULE_AUTHOR("Naveen M <naveen.m@intel.com>");
882 MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
883 MODULE_LICENSE("GPL v2");
884 MODULE_ALIAS("platform:kbl_rt5663");
885 MODULE_ALIAS("platform:kbl_rt5663_m98927");