1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright(c) 2018 Intel Corporation.
5 * Intel Kabylake I2S Machine Driver with MAX98927, MAX98373 & DA7219 Codecs
8 * Intel Kabylake I2S Machine driver supporting MAX98927 and
12 #include <linux/input.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <sound/core.h>
16 #include <sound/jack.h>
17 #include <sound/pcm.h>
18 #include <sound/pcm_params.h>
19 #include <sound/soc.h>
20 #include "../../codecs/da7219.h"
21 #include "../../codecs/hdac_hdmi.h"
22 #include "../../codecs/da7219-aad.h"
24 #define KBL_DIALOG_CODEC_DAI "da7219-hifi"
25 #define MAX98927_CODEC_DAI "max98927-aif1"
26 #define MAX98927_DEV0_NAME "i2c-MX98927:00"
27 #define MAX98927_DEV1_NAME "i2c-MX98927:01"
29 #define MAX98373_CODEC_DAI "max98373-aif1"
30 #define MAX98373_DEV0_NAME "i2c-MX98373:00"
31 #define MAX98373_DEV1_NAME "i2c-MX98373:01"
34 #define DUAL_CHANNEL 2
35 #define QUAD_CHANNEL 4
38 static struct snd_soc_card
*kabylake_audio_card
;
39 static struct snd_soc_jack kabylake_hdmi
[3];
42 struct list_head head
;
43 struct snd_soc_dai
*codec_dai
;
47 struct kbl_codec_private
{
48 struct snd_soc_jack kabylake_headset
;
49 struct list_head hdmi_pcm_list
;
53 KBL_DPCM_AUDIO_PB
= 0,
54 KBL_DPCM_AUDIO_ECHO_REF_CP
,
55 KBL_DPCM_AUDIO_REF_CP
,
56 KBL_DPCM_AUDIO_DMIC_CP
,
57 KBL_DPCM_AUDIO_HDMI1_PB
,
58 KBL_DPCM_AUDIO_HDMI2_PB
,
59 KBL_DPCM_AUDIO_HDMI3_PB
,
64 static int platform_clock_control(struct snd_soc_dapm_widget
*w
,
65 struct snd_kcontrol
*k
, int event
)
67 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
68 struct snd_soc_card
*card
= dapm
->card
;
69 struct snd_soc_dai
*codec_dai
;
72 codec_dai
= snd_soc_card_get_codec_dai(card
, KBL_DIALOG_CODEC_DAI
);
74 dev_err(card
->dev
, "Codec dai not found; Unable to set/unset codec pll\n");
78 /* Configure sysclk for codec */
79 ret
= snd_soc_dai_set_sysclk(codec_dai
, DA7219_CLKSRC_MCLK
, 24576000,
82 dev_err(card
->dev
, "can't set codec sysclk configuration\n");
86 if (SND_SOC_DAPM_EVENT_OFF(event
)) {
87 ret
= snd_soc_dai_set_pll(codec_dai
, 0,
88 DA7219_SYSCLK_MCLK
, 0, 0);
90 dev_err(card
->dev
, "failed to stop PLL: %d\n", ret
);
91 } else if (SND_SOC_DAPM_EVENT_ON(event
)) {
92 ret
= snd_soc_dai_set_pll(codec_dai
, 0, DA7219_SYSCLK_PLL_SRM
,
93 0, DA7219_PLL_FREQ_OUT_98304
);
95 dev_err(card
->dev
, "failed to start PLL: %d\n", ret
);
101 static const struct snd_kcontrol_new kabylake_controls
[] = {
102 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
103 SOC_DAPM_PIN_SWITCH("Headset Mic"),
104 SOC_DAPM_PIN_SWITCH("Left Spk"),
105 SOC_DAPM_PIN_SWITCH("Right Spk"),
108 static const struct snd_soc_dapm_widget kabylake_widgets
[] = {
109 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
110 SND_SOC_DAPM_MIC("Headset Mic", NULL
),
111 SND_SOC_DAPM_SPK("Left Spk", NULL
),
112 SND_SOC_DAPM_SPK("Right Spk", NULL
),
113 SND_SOC_DAPM_MIC("SoC DMIC", NULL
),
114 SND_SOC_DAPM_SPK("DP", NULL
),
115 SND_SOC_DAPM_SPK("HDMI", NULL
),
116 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM
, 0, 0,
117 platform_clock_control
, SND_SOC_DAPM_PRE_PMU
|
118 SND_SOC_DAPM_POST_PMD
),
121 static const struct snd_soc_dapm_route kabylake_map
[] = {
123 { "Left Spk", NULL
, "Left BE_OUT" },
124 { "Right Spk", NULL
, "Right BE_OUT" },
127 { "DMic", NULL
, "SoC DMIC" },
129 { "HDMI", NULL
, "hif5 Output" },
130 { "DP", NULL
, "hif6 Output" },
132 /* CODEC BE connections */
133 { "Left HiFi Playback", NULL
, "ssp0 Tx" },
134 { "Right HiFi Playback", NULL
, "ssp0 Tx" },
135 { "ssp0 Tx", NULL
, "spk_out" },
137 /* IV feedback path */
138 { "codec0_fb_in", NULL
, "ssp0 Rx"},
139 { "ssp0 Rx", NULL
, "Left HiFi Capture" },
140 { "ssp0 Rx", NULL
, "Right HiFi Capture" },
142 /* AEC capture path */
143 { "echo_ref_out", NULL
, "ssp0 Rx" },
146 { "dmic01_hifi", NULL
, "DMIC01 Rx" },
147 { "DMIC01 Rx", NULL
, "DMIC AIF" },
149 { "hifi1", NULL
, "iDisp1 Tx" },
150 { "iDisp1 Tx", NULL
, "iDisp1_out" },
151 { "hifi2", NULL
, "iDisp2 Tx" },
152 { "iDisp2 Tx", NULL
, "iDisp2_out" },
153 { "hifi3", NULL
, "iDisp3 Tx"},
154 { "iDisp3 Tx", NULL
, "iDisp3_out"},
157 static const struct snd_soc_dapm_route kabylake_ssp1_map
[] = {
158 { "Headphone Jack", NULL
, "HPL" },
159 { "Headphone Jack", NULL
, "HPR" },
162 { "MIC", NULL
, "Headset Mic" },
164 /* CODEC BE connections */
165 { "Playback", NULL
, "ssp1 Tx" },
166 { "ssp1 Tx", NULL
, "codec1_out" },
168 { "hs_in", NULL
, "ssp1 Rx" },
169 { "ssp1 Rx", NULL
, "Capture" },
171 { "Headphone Jack", NULL
, "Platform Clock" },
172 { "Headset Mic", NULL
, "Platform Clock" },
175 static int kabylake_ssp0_hw_params(struct snd_pcm_substream
*substream
,
176 struct snd_pcm_hw_params
*params
)
178 struct snd_soc_pcm_runtime
*runtime
= asoc_substream_to_rtd(substream
);
179 struct snd_soc_dai
*codec_dai
;
182 for_each_rtd_codec_dais(runtime
, j
, codec_dai
) {
184 if (!strcmp(codec_dai
->component
->name
, MAX98927_DEV0_NAME
)) {
185 ret
= snd_soc_dai_set_tdm_slot(codec_dai
, 0x30, 3, 8, 16);
187 dev_err(runtime
->dev
, "DEV0 TDM slot err:%d\n", ret
);
191 if (!strcmp(codec_dai
->component
->name
, MAX98927_DEV1_NAME
)) {
192 ret
= snd_soc_dai_set_tdm_slot(codec_dai
, 0xC0, 3, 8, 16);
194 dev_err(runtime
->dev
, "DEV1 TDM slot err:%d\n", ret
);
198 if (!strcmp(codec_dai
->component
->name
, MAX98373_DEV0_NAME
)) {
199 ret
= snd_soc_dai_set_tdm_slot(codec_dai
,
202 dev_err(runtime
->dev
,
203 "DEV0 TDM slot err:%d\n", ret
);
207 if (!strcmp(codec_dai
->component
->name
, MAX98373_DEV1_NAME
)) {
208 ret
= snd_soc_dai_set_tdm_slot(codec_dai
,
211 dev_err(runtime
->dev
,
212 "DEV0 TDM slot err:%d\n", ret
);
221 static int kabylake_ssp0_trigger(struct snd_pcm_substream
*substream
, int cmd
)
223 struct snd_soc_pcm_runtime
*rtd
= asoc_substream_to_rtd(substream
);
224 struct snd_soc_dai
*codec_dai
;
227 for_each_rtd_codec_dais(rtd
, j
, codec_dai
) {
228 const char *name
= codec_dai
->component
->name
;
229 struct snd_soc_component
*component
= codec_dai
->component
;
230 struct snd_soc_dapm_context
*dapm
=
231 snd_soc_component_get_dapm(component
);
234 if (strcmp(name
, MAX98927_DEV0_NAME
) &&
235 strcmp(name
, MAX98927_DEV1_NAME
) &&
236 strcmp(name
, MAX98373_DEV0_NAME
) &&
237 strcmp(name
, MAX98373_DEV1_NAME
))
240 snprintf(pin_name
, ARRAY_SIZE(pin_name
), "%s Spk",
241 codec_dai
->component
->name_prefix
);
244 case SNDRV_PCM_TRIGGER_START
:
245 case SNDRV_PCM_TRIGGER_RESUME
:
246 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
247 ret
= snd_soc_dapm_enable_pin(dapm
, pin_name
);
249 dev_err(rtd
->dev
, "failed to enable %s: %d\n",
253 snd_soc_dapm_sync(dapm
);
255 case SNDRV_PCM_TRIGGER_STOP
:
256 case SNDRV_PCM_TRIGGER_SUSPEND
:
257 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
258 ret
= snd_soc_dapm_disable_pin(dapm
, pin_name
);
260 dev_err(rtd
->dev
, "failed to disable %s: %d\n",
264 snd_soc_dapm_sync(dapm
);
272 static struct snd_soc_ops kabylake_ssp0_ops
= {
273 .hw_params
= kabylake_ssp0_hw_params
,
274 .trigger
= kabylake_ssp0_trigger
,
277 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime
*rtd
,
278 struct snd_pcm_hw_params
*params
)
280 struct snd_interval
*rate
= hw_param_interval(params
,
281 SNDRV_PCM_HW_PARAM_RATE
);
282 struct snd_interval
*chan
= hw_param_interval(params
,
283 SNDRV_PCM_HW_PARAM_CHANNELS
);
284 struct snd_mask
*fmt
= hw_param_mask(params
, SNDRV_PCM_HW_PARAM_FORMAT
);
285 struct snd_soc_dpcm
*dpcm
= container_of(
286 params
, struct snd_soc_dpcm
, hw_params
);
287 struct snd_soc_dai_link
*fe_dai_link
= dpcm
->fe
->dai_link
;
288 struct snd_soc_dai_link
*be_dai_link
= dpcm
->be
->dai_link
;
291 * Topology for kblda7219m98373 & kblmax98373 supports only S24_LE,
292 * where as kblda7219m98927 & kblmax98927 supports S16_LE by default.
293 * Skipping the port wise FE and BE configuration for kblda7219m98373 &
294 * kblmax98373 as the topology (FE & BE) supports S24_LE only.
297 if (!strcmp(rtd
->card
->name
, "kblda7219m98373") ||
298 !strcmp(rtd
->card
->name
, "kblmax98373")) {
299 /* The ADSP will convert the FE rate to 48k, stereo */
300 rate
->min
= rate
->max
= 48000;
301 chan
->min
= chan
->max
= DUAL_CHANNEL
;
303 /* set SSP to 24 bit */
305 snd_mask_set_format(fmt
, SNDRV_PCM_FORMAT_S24_LE
);
310 * The ADSP will convert the FE rate to 48k, stereo, 24 bit
312 if (!strcmp(fe_dai_link
->name
, "Kbl Audio Port") ||
313 !strcmp(fe_dai_link
->name
, "Kbl Audio Headset Playback") ||
314 !strcmp(fe_dai_link
->name
, "Kbl Audio Capture Port")) {
315 rate
->min
= rate
->max
= 48000;
316 chan
->min
= chan
->max
= 2;
318 snd_mask_set_format(fmt
, SNDRV_PCM_FORMAT_S24_LE
);
322 * The speaker on the SSP0 supports S16_LE and not S24_LE.
323 * thus changing the mask here
325 if (!strcmp(be_dai_link
->name
, "SSP0-Codec"))
326 snd_mask_set_format(fmt
, SNDRV_PCM_FORMAT_S16_LE
);
331 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime
*rtd
)
333 struct kbl_codec_private
*ctx
= snd_soc_card_get_drvdata(rtd
->card
);
334 struct snd_soc_component
*component
= asoc_rtd_to_codec(rtd
, 0)->component
;
335 struct snd_soc_jack
*jack
;
336 struct snd_soc_card
*card
= rtd
->card
;
340 ret
= snd_soc_dapm_add_routes(&card
->dapm
,
342 ARRAY_SIZE(kabylake_ssp1_map
));
348 * Headset buttons map to the google Reference headset.
349 * These can be configured by userspace.
351 ret
= snd_soc_card_jack_new(kabylake_audio_card
, "Headset Jack",
352 SND_JACK_HEADSET
| SND_JACK_BTN_0
| SND_JACK_BTN_1
|
353 SND_JACK_BTN_2
| SND_JACK_BTN_3
| SND_JACK_LINEOUT
,
354 &ctx
->kabylake_headset
, NULL
, 0);
356 dev_err(rtd
->dev
, "Headset Jack creation failed: %d\n", ret
);
360 jack
= &ctx
->kabylake_headset
;
361 snd_jack_set_key(jack
->jack
, SND_JACK_BTN_0
, KEY_PLAYPAUSE
);
362 snd_jack_set_key(jack
->jack
, SND_JACK_BTN_1
, KEY_VOLUMEUP
);
363 snd_jack_set_key(jack
->jack
, SND_JACK_BTN_2
, KEY_VOLUMEDOWN
);
364 snd_jack_set_key(jack
->jack
, SND_JACK_BTN_3
, KEY_VOICECOMMAND
);
366 da7219_aad_jack_det(component
, &ctx
->kabylake_headset
);
371 static int kabylake_dmic_init(struct snd_soc_pcm_runtime
*rtd
)
374 ret
= snd_soc_dapm_ignore_suspend(&rtd
->card
->dapm
, "SoC DMIC");
376 dev_err(rtd
->dev
, "SoC DMIC - Ignore suspend failed %d\n", ret
);
381 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime
*rtd
, int device
)
383 struct kbl_codec_private
*ctx
= snd_soc_card_get_drvdata(rtd
->card
);
384 struct snd_soc_dai
*dai
= asoc_rtd_to_codec(rtd
, 0);
385 struct kbl_hdmi_pcm
*pcm
;
387 pcm
= devm_kzalloc(rtd
->card
->dev
, sizeof(*pcm
), GFP_KERNEL
);
391 pcm
->device
= device
;
392 pcm
->codec_dai
= dai
;
394 list_add_tail(&pcm
->head
, &ctx
->hdmi_pcm_list
);
399 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime
*rtd
)
401 return kabylake_hdmi_init(rtd
, KBL_DPCM_AUDIO_HDMI1_PB
);
404 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime
*rtd
)
406 return kabylake_hdmi_init(rtd
, KBL_DPCM_AUDIO_HDMI2_PB
);
409 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime
*rtd
)
411 return kabylake_hdmi_init(rtd
, KBL_DPCM_AUDIO_HDMI3_PB
);
414 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime
*rtd
)
416 struct snd_soc_dapm_context
*dapm
;
417 struct snd_soc_component
*component
= asoc_rtd_to_cpu(rtd
, 0)->component
;
419 dapm
= snd_soc_component_get_dapm(component
);
420 snd_soc_dapm_ignore_suspend(dapm
, "Reference Capture");
425 static const unsigned int rates
[] = {
429 static const struct snd_pcm_hw_constraint_list constraints_rates
= {
430 .count
= ARRAY_SIZE(rates
),
435 static const unsigned int channels
[] = {
439 static const struct snd_pcm_hw_constraint_list constraints_channels
= {
440 .count
= ARRAY_SIZE(channels
),
445 static unsigned int channels_quad
[] = {
449 static struct snd_pcm_hw_constraint_list constraints_channels_quad
= {
450 .count
= ARRAY_SIZE(channels_quad
),
451 .list
= channels_quad
,
455 static int kbl_fe_startup(struct snd_pcm_substream
*substream
)
457 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
458 struct snd_soc_pcm_runtime
*soc_rt
= asoc_substream_to_rtd(substream
);
461 * On this platform for PCM device we support,
466 runtime
->hw
.channels_max
= DUAL_CHANNEL
;
467 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_CHANNELS
,
468 &constraints_channels
);
470 * Setup S24_LE (32 bit container and 24 bit valid data) for
471 * kblda7219m98373 & kblmax98373. For kblda7219m98927 &
472 * kblmax98927 keeping it as 16/16 due to topology FW dependency.
474 if (!strcmp(soc_rt
->card
->name
, "kblda7219m98373") ||
475 !strcmp(soc_rt
->card
->name
, "kblmax98373")) {
476 runtime
->hw
.formats
= SNDRV_PCM_FMTBIT_S24_LE
;
477 snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
480 runtime
->hw
.formats
= SNDRV_PCM_FMTBIT_S16_LE
;
481 snd_pcm_hw_constraint_msbits(runtime
, 0, 16, 16);
484 snd_pcm_hw_constraint_list(runtime
, 0,
485 SNDRV_PCM_HW_PARAM_RATE
, &constraints_rates
);
490 static const struct snd_soc_ops kabylake_da7219_fe_ops
= {
491 .startup
= kbl_fe_startup
,
494 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime
*rtd
,
495 struct snd_pcm_hw_params
*params
)
497 struct snd_interval
*chan
= hw_param_interval(params
,
498 SNDRV_PCM_HW_PARAM_CHANNELS
);
501 * set BE channel constraint as user FE channels
504 if (params_channels(params
) == 2)
505 chan
->min
= chan
->max
= 2;
507 chan
->min
= chan
->max
= 4;
512 static int kabylake_dmic_startup(struct snd_pcm_substream
*substream
)
514 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
515 struct snd_soc_pcm_runtime
*soc_rt
= asoc_substream_to_rtd(substream
);
517 runtime
->hw
.channels_min
= runtime
->hw
.channels_max
= QUAD_CHANNEL
;
518 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_CHANNELS
,
519 &constraints_channels_quad
);
522 * Topology for kblda7219m98373 & kblmax98373 supports only S24_LE.
523 * The DMIC also configured for S24_LE. Forcing the DMIC format to
524 * S24_LE due to the topology FW dependency.
526 if (!strcmp(soc_rt
->card
->name
, "kblda7219m98373") ||
527 !strcmp(soc_rt
->card
->name
, "kblmax98373")) {
528 runtime
->hw
.formats
= SNDRV_PCM_FMTBIT_S24_LE
;
529 snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
532 return snd_pcm_hw_constraint_list(substream
->runtime
, 0,
533 SNDRV_PCM_HW_PARAM_RATE
, &constraints_rates
);
536 static struct snd_soc_ops kabylake_dmic_ops
= {
537 .startup
= kabylake_dmic_startup
,
540 static const unsigned int rates_16000
[] = {
544 static const struct snd_pcm_hw_constraint_list constraints_16000
= {
545 .count
= ARRAY_SIZE(rates_16000
),
549 static const unsigned int ch_mono
[] = {
552 static const struct snd_pcm_hw_constraint_list constraints_refcap
= {
553 .count
= ARRAY_SIZE(ch_mono
),
557 static int kabylake_refcap_startup(struct snd_pcm_substream
*substream
)
559 substream
->runtime
->hw
.channels_max
= 1;
560 snd_pcm_hw_constraint_list(substream
->runtime
, 0,
561 SNDRV_PCM_HW_PARAM_CHANNELS
,
562 &constraints_refcap
);
564 return snd_pcm_hw_constraint_list(substream
->runtime
, 0,
565 SNDRV_PCM_HW_PARAM_RATE
,
570 static struct snd_soc_ops skylake_refcap_ops
= {
571 .startup
= kabylake_refcap_startup
,
574 static struct snd_soc_codec_conf max98927_codec_conf
[] = {
577 .dlc
= COMP_CODEC_CONF(MAX98927_DEV0_NAME
),
578 .name_prefix
= "Right",
582 .dlc
= COMP_CODEC_CONF(MAX98927_DEV1_NAME
),
583 .name_prefix
= "Left",
587 static struct snd_soc_codec_conf max98373_codec_conf
[] = {
590 .dlc
= COMP_CODEC_CONF(MAX98373_DEV0_NAME
),
591 .name_prefix
= "Right",
595 .dlc
= COMP_CODEC_CONF(MAX98373_DEV1_NAME
),
596 .name_prefix
= "Left",
600 static struct snd_soc_dai_link_component max98373_ssp0_codec_components
[] = {
602 .name
= MAX98373_DEV0_NAME
,
603 .dai_name
= MAX98373_CODEC_DAI
,
607 .name
= MAX98373_DEV1_NAME
,
608 .dai_name
= MAX98373_CODEC_DAI
,
613 SND_SOC_DAILINK_DEF(dummy
,
614 DAILINK_COMP_ARRAY(COMP_DUMMY()));
616 SND_SOC_DAILINK_DEF(system
,
617 DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
619 SND_SOC_DAILINK_DEF(echoref
,
620 DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin")));
622 SND_SOC_DAILINK_DEF(reference
,
623 DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
625 SND_SOC_DAILINK_DEF(dmic
,
626 DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
628 SND_SOC_DAILINK_DEF(hdmi1
,
629 DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
631 SND_SOC_DAILINK_DEF(hdmi2
,
632 DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
634 SND_SOC_DAILINK_DEF(hdmi3
,
635 DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
637 SND_SOC_DAILINK_DEF(system2
,
638 DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
640 SND_SOC_DAILINK_DEF(ssp0_pin
,
641 DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
642 SND_SOC_DAILINK_DEF(ssp0_codec
,
644 /* Left */ COMP_CODEC(MAX98927_DEV0_NAME
, MAX98927_CODEC_DAI
),
645 /* For Right */ COMP_CODEC(MAX98927_DEV1_NAME
, MAX98927_CODEC_DAI
)));
647 SND_SOC_DAILINK_DEF(ssp1_pin
,
648 DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
649 SND_SOC_DAILINK_DEF(ssp1_codec
,
650 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
651 KBL_DIALOG_CODEC_DAI
)));
653 SND_SOC_DAILINK_DEF(dmic_pin
,
654 DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
655 SND_SOC_DAILINK_DEF(dmic_codec
,
656 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
658 SND_SOC_DAILINK_DEF(idisp1_pin
,
659 DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
660 SND_SOC_DAILINK_DEF(idisp1_codec
,
661 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
663 SND_SOC_DAILINK_DEF(idisp2_pin
,
664 DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
665 SND_SOC_DAILINK_DEF(idisp2_codec
,
666 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
668 SND_SOC_DAILINK_DEF(idisp3_pin
,
669 DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
670 SND_SOC_DAILINK_DEF(idisp3_codec
,
671 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
673 SND_SOC_DAILINK_DEF(platform
,
674 DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
676 /* kabylake digital audio interface glue - connects codec <--> CPU */
677 static struct snd_soc_dai_link kabylake_dais
[] = {
678 /* Front End DAI links */
679 [KBL_DPCM_AUDIO_PB
] = {
680 .name
= "Kbl Audio Port",
681 .stream_name
= "Audio",
684 .init
= kabylake_da7219_fe_init
,
686 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
688 .ops
= &kabylake_da7219_fe_ops
,
689 SND_SOC_DAILINK_REG(system
, dummy
, platform
),
691 [KBL_DPCM_AUDIO_ECHO_REF_CP
] = {
692 .name
= "Kbl Audio Echo Reference cap",
693 .stream_name
= "Echoreference Capture",
697 SND_SOC_DAILINK_REG(echoref
, dummy
, platform
),
699 [KBL_DPCM_AUDIO_REF_CP
] = {
700 .name
= "Kbl Audio Reference cap",
701 .stream_name
= "Wake on Voice",
706 .ops
= &skylake_refcap_ops
,
707 SND_SOC_DAILINK_REG(reference
, dummy
, platform
),
709 [KBL_DPCM_AUDIO_DMIC_CP
] = {
710 .name
= "Kbl Audio DMIC cap",
711 .stream_name
= "dmiccap",
716 .ops
= &kabylake_dmic_ops
,
717 SND_SOC_DAILINK_REG(dmic
, dummy
, platform
),
719 [KBL_DPCM_AUDIO_HDMI1_PB
] = {
720 .name
= "Kbl HDMI Port1",
721 .stream_name
= "Hdmi1",
725 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
728 SND_SOC_DAILINK_REG(hdmi1
, dummy
, platform
),
730 [KBL_DPCM_AUDIO_HDMI2_PB
] = {
731 .name
= "Kbl HDMI Port2",
732 .stream_name
= "Hdmi2",
736 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
739 SND_SOC_DAILINK_REG(hdmi2
, dummy
, platform
),
741 [KBL_DPCM_AUDIO_HDMI3_PB
] = {
742 .name
= "Kbl HDMI Port3",
743 .stream_name
= "Hdmi3",
745 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
750 SND_SOC_DAILINK_REG(hdmi3
, dummy
, platform
),
752 [KBL_DPCM_AUDIO_HS_PB
] = {
753 .name
= "Kbl Audio Headset Playback",
754 .stream_name
= "Headset Audio",
758 .init
= kabylake_da7219_fe_init
,
760 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
761 .ops
= &kabylake_da7219_fe_ops
,
762 SND_SOC_DAILINK_REG(system2
, dummy
, platform
),
764 [KBL_DPCM_AUDIO_CP
] = {
765 .name
= "Kbl Audio Capture Port",
766 .stream_name
= "Audio Record",
770 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
772 .ops
= &kabylake_da7219_fe_ops
,
773 SND_SOC_DAILINK_REG(system
, dummy
, platform
),
776 /* Back End DAI links */
779 .name
= "SSP0-Codec",
782 .dai_fmt
= SND_SOC_DAIFMT_DSP_B
|
783 SND_SOC_DAIFMT_NB_NF
|
784 SND_SOC_DAIFMT_CBS_CFS
,
787 .ignore_pmdown_time
= 1,
788 .be_hw_params_fixup
= kabylake_ssp_fixup
,
789 .ops
= &kabylake_ssp0_ops
,
790 SND_SOC_DAILINK_REG(ssp0_pin
, ssp0_codec
, platform
),
794 .name
= "SSP1-Codec",
797 .init
= kabylake_da7219_codec_init
,
798 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
799 SND_SOC_DAIFMT_CBS_CFS
,
800 .ignore_pmdown_time
= 1,
801 .be_hw_params_fixup
= kabylake_ssp_fixup
,
804 SND_SOC_DAILINK_REG(ssp1_pin
, ssp1_codec
, platform
),
809 .init
= kabylake_dmic_init
,
810 .be_hw_params_fixup
= kabylake_dmic_fixup
,
814 SND_SOC_DAILINK_REG(dmic_pin
, dmic_codec
, platform
),
820 .init
= kabylake_hdmi1_init
,
822 SND_SOC_DAILINK_REG(idisp1_pin
, idisp1_codec
, platform
),
827 .init
= kabylake_hdmi2_init
,
830 SND_SOC_DAILINK_REG(idisp2_pin
, idisp2_codec
, platform
),
835 .init
= kabylake_hdmi3_init
,
838 SND_SOC_DAILINK_REG(idisp3_pin
, idisp3_codec
, platform
),
842 /* kabylake digital audio interface glue - connects codec <--> CPU */
843 static struct snd_soc_dai_link kabylake_max98_927_373_dais
[] = {
844 /* Front End DAI links */
845 [KBL_DPCM_AUDIO_PB
] = {
846 .name
= "Kbl Audio Port",
847 .stream_name
= "Audio",
850 .init
= kabylake_da7219_fe_init
,
852 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
854 .ops
= &kabylake_da7219_fe_ops
,
855 SND_SOC_DAILINK_REG(system
, dummy
, platform
),
857 [KBL_DPCM_AUDIO_ECHO_REF_CP
] = {
858 .name
= "Kbl Audio Echo Reference cap",
859 .stream_name
= "Echoreference Capture",
863 SND_SOC_DAILINK_REG(echoref
, dummy
, platform
),
865 [KBL_DPCM_AUDIO_REF_CP
] = {
866 .name
= "Kbl Audio Reference cap",
867 .stream_name
= "Wake on Voice",
872 .ops
= &skylake_refcap_ops
,
873 SND_SOC_DAILINK_REG(reference
, dummy
, platform
),
875 [KBL_DPCM_AUDIO_DMIC_CP
] = {
876 .name
= "Kbl Audio DMIC cap",
877 .stream_name
= "dmiccap",
882 .ops
= &kabylake_dmic_ops
,
883 SND_SOC_DAILINK_REG(dmic
, dummy
, platform
),
885 [KBL_DPCM_AUDIO_HDMI1_PB
] = {
886 .name
= "Kbl HDMI Port1",
887 .stream_name
= "Hdmi1",
891 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
894 SND_SOC_DAILINK_REG(hdmi1
, dummy
, platform
),
896 [KBL_DPCM_AUDIO_HDMI2_PB
] = {
897 .name
= "Kbl HDMI Port2",
898 .stream_name
= "Hdmi2",
902 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
905 SND_SOC_DAILINK_REG(hdmi2
, dummy
, platform
),
907 [KBL_DPCM_AUDIO_HDMI3_PB
] = {
908 .name
= "Kbl HDMI Port3",
909 .stream_name
= "Hdmi3",
911 SND_SOC_DPCM_TRIGGER_POST
, SND_SOC_DPCM_TRIGGER_POST
},
916 SND_SOC_DAILINK_REG(hdmi3
, dummy
, platform
),
919 /* Back End DAI links */
922 .name
= "SSP0-Codec",
925 .dai_fmt
= SND_SOC_DAIFMT_DSP_B
|
926 SND_SOC_DAIFMT_NB_NF
|
927 SND_SOC_DAIFMT_CBS_CFS
,
930 .ignore_pmdown_time
= 1,
931 .be_hw_params_fixup
= kabylake_ssp_fixup
,
932 .ops
= &kabylake_ssp0_ops
,
933 SND_SOC_DAILINK_REG(ssp0_pin
, ssp0_codec
),
938 .init
= kabylake_dmic_init
,
939 .be_hw_params_fixup
= kabylake_dmic_fixup
,
943 SND_SOC_DAILINK_REG(dmic_pin
, dmic_codec
, platform
),
949 .init
= kabylake_hdmi1_init
,
951 SND_SOC_DAILINK_REG(idisp1_pin
, idisp1_codec
, platform
),
956 .init
= kabylake_hdmi2_init
,
959 SND_SOC_DAILINK_REG(idisp2_pin
, idisp2_codec
, platform
),
964 .init
= kabylake_hdmi3_init
,
967 SND_SOC_DAILINK_REG(idisp3_pin
, idisp3_codec
, platform
),
971 static int kabylake_card_late_probe(struct snd_soc_card
*card
)
973 struct kbl_codec_private
*ctx
= snd_soc_card_get_drvdata(card
);
974 struct kbl_hdmi_pcm
*pcm
;
975 struct snd_soc_dapm_context
*dapm
= &card
->dapm
;
976 struct snd_soc_component
*component
= NULL
;
978 char jack_name
[NAME_SIZE
];
980 list_for_each_entry(pcm
, &ctx
->hdmi_pcm_list
, head
) {
981 component
= pcm
->codec_dai
->component
;
982 snprintf(jack_name
, sizeof(jack_name
),
983 "HDMI/DP, pcm=%d Jack", pcm
->device
);
984 err
= snd_soc_card_jack_new(card
, jack_name
,
985 SND_JACK_AVOUT
, &kabylake_hdmi
[i
],
991 err
= hdac_hdmi_jack_init(pcm
->codec_dai
, pcm
->device
,
1003 err
= hdac_hdmi_jack_port_init(component
, &card
->dapm
);
1008 err
= snd_soc_dapm_disable_pin(dapm
, "Left Spk");
1010 dev_err(card
->dev
, "failed to disable Left Spk: %d\n", err
);
1014 err
= snd_soc_dapm_disable_pin(dapm
, "Right Spk");
1016 dev_err(card
->dev
, "failed to disable Right Spk: %d\n", err
);
1020 return snd_soc_dapm_sync(dapm
);
1023 /* kabylake audio machine driver for SPT + DA7219 */
1024 static struct snd_soc_card kbl_audio_card_da7219_m98927
= {
1025 .name
= "kblda7219m98927",
1026 .owner
= THIS_MODULE
,
1027 .dai_link
= kabylake_dais
,
1028 .num_links
= ARRAY_SIZE(kabylake_dais
),
1029 .controls
= kabylake_controls
,
1030 .num_controls
= ARRAY_SIZE(kabylake_controls
),
1031 .dapm_widgets
= kabylake_widgets
,
1032 .num_dapm_widgets
= ARRAY_SIZE(kabylake_widgets
),
1033 .dapm_routes
= kabylake_map
,
1034 .num_dapm_routes
= ARRAY_SIZE(kabylake_map
),
1035 .codec_conf
= max98927_codec_conf
,
1036 .num_configs
= ARRAY_SIZE(max98927_codec_conf
),
1037 .fully_routed
= true,
1038 .late_probe
= kabylake_card_late_probe
,
1041 /* kabylake audio machine driver for Maxim98927 */
1042 static struct snd_soc_card kbl_audio_card_max98927
= {
1043 .name
= "kblmax98927",
1044 .owner
= THIS_MODULE
,
1045 .dai_link
= kabylake_max98_927_373_dais
,
1046 .num_links
= ARRAY_SIZE(kabylake_max98_927_373_dais
),
1047 .controls
= kabylake_controls
,
1048 .num_controls
= ARRAY_SIZE(kabylake_controls
),
1049 .dapm_widgets
= kabylake_widgets
,
1050 .num_dapm_widgets
= ARRAY_SIZE(kabylake_widgets
),
1051 .dapm_routes
= kabylake_map
,
1052 .num_dapm_routes
= ARRAY_SIZE(kabylake_map
),
1053 .codec_conf
= max98927_codec_conf
,
1054 .num_configs
= ARRAY_SIZE(max98927_codec_conf
),
1055 .fully_routed
= true,
1056 .late_probe
= kabylake_card_late_probe
,
1059 static struct snd_soc_card kbl_audio_card_da7219_m98373
= {
1060 .name
= "kblda7219m98373",
1061 .owner
= THIS_MODULE
,
1062 .dai_link
= kabylake_dais
,
1063 .num_links
= ARRAY_SIZE(kabylake_dais
),
1064 .controls
= kabylake_controls
,
1065 .num_controls
= ARRAY_SIZE(kabylake_controls
),
1066 .dapm_widgets
= kabylake_widgets
,
1067 .num_dapm_widgets
= ARRAY_SIZE(kabylake_widgets
),
1068 .dapm_routes
= kabylake_map
,
1069 .num_dapm_routes
= ARRAY_SIZE(kabylake_map
),
1070 .codec_conf
= max98373_codec_conf
,
1071 .num_configs
= ARRAY_SIZE(max98373_codec_conf
),
1072 .fully_routed
= true,
1073 .late_probe
= kabylake_card_late_probe
,
1076 static struct snd_soc_card kbl_audio_card_max98373
= {
1077 .name
= "kblmax98373",
1078 .owner
= THIS_MODULE
,
1079 .dai_link
= kabylake_max98_927_373_dais
,
1080 .num_links
= ARRAY_SIZE(kabylake_max98_927_373_dais
),
1081 .controls
= kabylake_controls
,
1082 .num_controls
= ARRAY_SIZE(kabylake_controls
),
1083 .dapm_widgets
= kabylake_widgets
,
1084 .num_dapm_widgets
= ARRAY_SIZE(kabylake_widgets
),
1085 .dapm_routes
= kabylake_map
,
1086 .num_dapm_routes
= ARRAY_SIZE(kabylake_map
),
1087 .codec_conf
= max98373_codec_conf
,
1088 .num_configs
= ARRAY_SIZE(max98373_codec_conf
),
1089 .fully_routed
= true,
1090 .late_probe
= kabylake_card_late_probe
,
1093 static int kabylake_audio_probe(struct platform_device
*pdev
)
1095 struct kbl_codec_private
*ctx
;
1096 struct snd_soc_dai_link
*kbl_dai_link
;
1097 struct snd_soc_dai_link_component
**codecs
;
1100 ctx
= devm_kzalloc(&pdev
->dev
, sizeof(*ctx
), GFP_KERNEL
);
1104 INIT_LIST_HEAD(&ctx
->hdmi_pcm_list
);
1106 kabylake_audio_card
=
1107 (struct snd_soc_card
*)pdev
->id_entry
->driver_data
;
1109 kbl_dai_link
= kabylake_audio_card
->dai_link
;
1111 /* Update codecs for SSP0 with max98373 codec info */
1112 if (!strcmp(pdev
->name
, "kbl_da7219_max98373") ||
1113 (!strcmp(pdev
->name
, "kbl_max98373"))) {
1114 for (i
= 0; i
< kabylake_audio_card
->num_links
; ++i
) {
1115 if (strcmp(kbl_dai_link
[i
].name
, "SSP0-Codec"))
1118 codecs
= &(kbl_dai_link
[i
].codecs
);
1119 *codecs
= max98373_ssp0_codec_components
;
1120 kbl_dai_link
[i
].num_codecs
=
1121 ARRAY_SIZE(max98373_ssp0_codec_components
);
1125 kabylake_audio_card
->dev
= &pdev
->dev
;
1126 snd_soc_card_set_drvdata(kabylake_audio_card
, ctx
);
1128 return devm_snd_soc_register_card(&pdev
->dev
, kabylake_audio_card
);
1131 static const struct platform_device_id kbl_board_ids
[] = {
1133 .name
= "kbl_da7219_max98927",
1135 (kernel_ulong_t
)&kbl_audio_card_da7219_m98927
,
1138 .name
= "kbl_max98927",
1140 (kernel_ulong_t
)&kbl_audio_card_max98927
,
1143 .name
= "kbl_da7219_max98373",
1145 (kernel_ulong_t
)&kbl_audio_card_da7219_m98373
,
1148 .name
= "kbl_max98373",
1150 (kernel_ulong_t
)&kbl_audio_card_max98373
,
1155 static struct platform_driver kabylake_audio
= {
1156 .probe
= kabylake_audio_probe
,
1158 .name
= "kbl_da7219_max98_927_373",
1159 .pm
= &snd_soc_pm_ops
,
1161 .id_table
= kbl_board_ids
,
1164 module_platform_driver(kabylake_audio
)
1166 /* Module information */
1167 MODULE_DESCRIPTION("Audio KabyLake Machine driver for MAX98927/MAX98373 & DA7219");
1168 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
1169 MODULE_LICENSE("GPL v2");
1170 MODULE_ALIAS("platform:kbl_da7219_max98927");
1171 MODULE_ALIAS("platform:kbl_max98927");
1172 MODULE_ALIAS("platform:kbl_da7219_max98373");
1173 MODULE_ALIAS("platform:kbl_max98373");