1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel Broxton-P I2S Machine Driver
5 * Copyright (C) 2016, Intel Corporation. All rights reserved.
8 * Intel Skylake I2S Machine driver
11 #include <linux/input.h>
12 #include <linux/module.h>
13 #include <linux/platform_device.h>
14 #include <sound/core.h>
15 #include <sound/jack.h>
16 #include <sound/pcm.h>
17 #include <sound/pcm_params.h>
18 #include <sound/soc.h>
19 #include <sound/soc-acpi.h>
20 #include "../../codecs/hdac_hdmi.h"
21 #include "../../codecs/da7219.h"
22 #include "../common/soc-intel-quirks.h"
23 #include "hda_dsp_common.h"
25 #define BXT_DIALOG_CODEC_DAI "da7219-hifi"
26 #define BXT_MAXIM_CODEC_DAI "HiFi"
27 #define MAX98390_DEV0_NAME "i2c-MX98390:00"
28 #define MAX98390_DEV1_NAME "i2c-MX98390:01"
29 #define DUAL_CHANNEL 2
30 #define QUAD_CHANNEL 4
32 #define SPKAMP_MAX98357A 1
33 #define SPKAMP_MAX98390 2
35 static struct snd_soc_jack broxton_headset;
36 static struct snd_soc_jack broxton_hdmi[3];
39 struct list_head head;
40 struct snd_soc_dai *codec_dai;
44 struct bxt_card_private {
45 struct list_head hdmi_pcm_list;
46 bool common_hdmi_codec_drv;
51 BXT_DPCM_AUDIO_PB = 0,
54 BXT_DPCM_AUDIO_REF_CP,
55 BXT_DPCM_AUDIO_DMIC_CP,
56 BXT_DPCM_AUDIO_HDMI1_PB,
57 BXT_DPCM_AUDIO_HDMI2_PB,
58 BXT_DPCM_AUDIO_HDMI3_PB,
61 static int platform_clock_control(struct snd_soc_dapm_widget *w,
62 struct snd_kcontrol *k, int event)
65 struct snd_soc_dapm_context *dapm = w->dapm;
66 struct snd_soc_card *card = dapm->card;
67 struct snd_soc_dai *codec_dai;
69 codec_dai = snd_soc_card_get_codec_dai(card, BXT_DIALOG_CODEC_DAI);
71 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
75 if (SND_SOC_DAPM_EVENT_OFF(event)) {
76 ret = snd_soc_dai_set_pll(codec_dai, 0,
77 DA7219_SYSCLK_MCLK, 0, 0);
79 dev_err(card->dev, "failed to stop PLL: %d\n", ret);
80 } else if(SND_SOC_DAPM_EVENT_ON(event)) {
81 ret = snd_soc_dai_set_pll(codec_dai, 0,
82 DA7219_SYSCLK_PLL_SRM, 0, DA7219_PLL_FREQ_OUT_98304);
84 dev_err(card->dev, "failed to start PLL: %d\n", ret);
90 static const struct snd_kcontrol_new broxton_controls[] = {
91 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
92 SOC_DAPM_PIN_SWITCH("Headset Mic"),
93 SOC_DAPM_PIN_SWITCH("Line Out"),
96 static const struct snd_kcontrol_new max98357a_controls[] = {
97 SOC_DAPM_PIN_SWITCH("Spk"),
100 static const struct snd_kcontrol_new max98390_controls[] = {
101 SOC_DAPM_PIN_SWITCH("Left Spk"),
102 SOC_DAPM_PIN_SWITCH("Right Spk"),
105 static const struct snd_soc_dapm_widget broxton_widgets[] = {
106 SND_SOC_DAPM_HP("Headphone Jack", NULL),
107 SND_SOC_DAPM_MIC("Headset Mic", NULL),
108 SND_SOC_DAPM_LINE("Line Out", NULL),
109 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
110 SND_SOC_DAPM_SPK("HDMI1", NULL),
111 SND_SOC_DAPM_SPK("HDMI2", NULL),
112 SND_SOC_DAPM_SPK("HDMI3", NULL),
113 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
114 platform_clock_control, SND_SOC_DAPM_POST_PMD|SND_SOC_DAPM_PRE_PMU),
117 static const struct snd_soc_dapm_widget max98357a_widgets[] = {
118 SND_SOC_DAPM_SPK("Spk", NULL),
121 static const struct snd_soc_dapm_widget max98390_widgets[] = {
122 SND_SOC_DAPM_SPK("Left Spk", NULL),
123 SND_SOC_DAPM_SPK("Right Spk", NULL),
126 static const struct snd_soc_dapm_route audio_map[] = {
127 /* HP jack connectors - unknown if we have jack detection */
128 {"Headphone Jack", NULL, "HPL"},
129 {"Headphone Jack", NULL, "HPR"},
132 {"MIC", NULL, "Headset Mic"},
135 {"DMic", NULL, "SoC DMIC"},
137 /* CODEC BE connections */
138 {"HDMI1", NULL, "hif5-0 Output"},
139 {"HDMI2", NULL, "hif6-0 Output"},
140 {"HDMI2", NULL, "hif7-0 Output"},
142 {"hifi3", NULL, "iDisp3 Tx"},
143 {"iDisp3 Tx", NULL, "iDisp3_out"},
144 {"hifi2", NULL, "iDisp2 Tx"},
145 {"iDisp2 Tx", NULL, "iDisp2_out"},
146 {"hifi1", NULL, "iDisp1 Tx"},
147 {"iDisp1 Tx", NULL, "iDisp1_out"},
150 {"dmic01_hifi", NULL, "DMIC01 Rx"},
151 {"DMIC01 Rx", NULL, "DMIC AIF"},
153 { "Headphone Jack", NULL, "Platform Clock" },
154 { "Headset Mic", NULL, "Platform Clock" },
155 { "Line Out", NULL, "Platform Clock" },
158 static const struct snd_soc_dapm_route max98357a_routes[] = {
160 {"Spk", NULL, "Speaker"},
163 static const struct snd_soc_dapm_route max98390_routes[] = {
165 {"Left Spk", NULL, "Left BE_OUT"},
166 {"Right Spk", NULL, "Right BE_OUT"},
169 static const struct snd_soc_dapm_route broxton_map[] = {
170 {"HiFi Playback", NULL, "ssp5 Tx"},
171 {"ssp5 Tx", NULL, "codec0_out"},
173 {"Playback", NULL, "ssp1 Tx"},
174 {"ssp1 Tx", NULL, "codec1_out"},
176 {"codec0_in", NULL, "ssp1 Rx"},
177 {"ssp1 Rx", NULL, "Capture"},
180 static const struct snd_soc_dapm_route gemini_map[] = {
181 {"HiFi Playback", NULL, "ssp1 Tx"},
182 {"ssp1 Tx", NULL, "codec0_out"},
184 {"Playback", NULL, "ssp2 Tx"},
185 {"ssp2 Tx", NULL, "codec1_out"},
187 {"codec0_in", NULL, "ssp2 Rx"},
188 {"ssp2 Rx", NULL, "Capture"},
191 static struct snd_soc_jack_pin jack_pins[] = {
193 .pin = "Headphone Jack",
194 .mask = SND_JACK_HEADPHONE,
197 .pin = "Headset Mic",
198 .mask = SND_JACK_MICROPHONE,
202 .mask = SND_JACK_LINEOUT,
206 static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
207 struct snd_pcm_hw_params *params)
209 struct snd_interval *rate = hw_param_interval(params,
210 SNDRV_PCM_HW_PARAM_RATE);
211 struct snd_interval *chan = hw_param_interval(params,
212 SNDRV_PCM_HW_PARAM_CHANNELS);
213 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
215 /* The ADSP will convert the FE rate to 48k, stereo */
216 rate->min = rate->max = 48000;
217 chan->min = chan->max = DUAL_CHANNEL;
219 /* set SSP to 24 bit */
221 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
226 static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
229 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
230 struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
233 /* Configure sysclk for codec */
234 if (soc_intel_is_cml())
239 ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, clk_freq,
243 dev_err(rtd->dev, "can't set codec sysclk configuration\n");
248 * Headset buttons map to the google Reference headset.
249 * These can be configured by userspace.
251 ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
252 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
253 SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
256 ARRAY_SIZE(jack_pins));
258 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
262 snd_jack_set_key(broxton_headset.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
263 snd_jack_set_key(broxton_headset.jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
264 snd_jack_set_key(broxton_headset.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
265 snd_jack_set_key(broxton_headset.jack, SND_JACK_BTN_3,
268 snd_soc_component_set_jack(component, &broxton_headset, NULL);
270 snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
275 static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
277 struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
278 struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
279 struct bxt_hdmi_pcm *pcm;
281 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
285 pcm->device = BXT_DPCM_AUDIO_HDMI1_PB + dai->id;
286 pcm->codec_dai = dai;
288 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
293 static int broxton_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
295 struct snd_soc_dapm_context *dapm;
296 struct snd_soc_component *component = snd_soc_rtd_to_cpu(rtd, 0)->component;
298 dapm = snd_soc_component_get_dapm(component);
299 snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
304 static const unsigned int rates[] = {
308 static const struct snd_pcm_hw_constraint_list constraints_rates = {
309 .count = ARRAY_SIZE(rates),
314 static const unsigned int channels[] = {
318 static const struct snd_pcm_hw_constraint_list constraints_channels = {
319 .count = ARRAY_SIZE(channels),
324 static const unsigned int channels_quad[] = {
328 static const struct snd_pcm_hw_constraint_list constraints_channels_quad = {
329 .count = ARRAY_SIZE(channels_quad),
330 .list = channels_quad,
334 static int bxt_fe_startup(struct snd_pcm_substream *substream)
336 struct snd_pcm_runtime *runtime = substream->runtime;
339 * On this platform for PCM device we support,
345 runtime->hw.channels_max = DUAL_CHANNEL;
346 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
347 &constraints_channels);
349 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
350 snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
352 snd_pcm_hw_constraint_list(runtime, 0,
353 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
358 static const struct snd_soc_ops broxton_da7219_fe_ops = {
359 .startup = bxt_fe_startup,
362 static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
363 struct snd_pcm_hw_params *params)
365 struct snd_interval *chan = hw_param_interval(params,
366 SNDRV_PCM_HW_PARAM_CHANNELS);
367 if (params_channels(params) == 2)
368 chan->min = chan->max = 2;
370 chan->min = chan->max = 4;
375 static int broxton_dmic_startup(struct snd_pcm_substream *substream)
377 struct snd_pcm_runtime *runtime = substream->runtime;
379 runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
380 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
381 &constraints_channels_quad);
383 return snd_pcm_hw_constraint_list(substream->runtime, 0,
384 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
387 static const struct snd_soc_ops broxton_dmic_ops = {
388 .startup = broxton_dmic_startup,
391 static const unsigned int rates_16000[] = {
395 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
396 .count = ARRAY_SIZE(rates_16000),
400 static const unsigned int ch_mono[] = {
404 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
405 .count = ARRAY_SIZE(ch_mono),
409 static int broxton_refcap_startup(struct snd_pcm_substream *substream)
411 substream->runtime->hw.channels_max = 1;
412 snd_pcm_hw_constraint_list(substream->runtime, 0,
413 SNDRV_PCM_HW_PARAM_CHANNELS,
414 &constraints_refcap);
416 return snd_pcm_hw_constraint_list(substream->runtime, 0,
417 SNDRV_PCM_HW_PARAM_RATE,
421 static const struct snd_soc_ops broxton_refcap_ops = {
422 .startup = broxton_refcap_startup,
425 /* broxton digital audio interface glue - connects codec <--> CPU */
426 SND_SOC_DAILINK_DEF(dummy,
427 DAILINK_COMP_ARRAY(COMP_DUMMY()));
429 SND_SOC_DAILINK_DEF(system,
430 DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
432 SND_SOC_DAILINK_DEF(system2,
433 DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
435 SND_SOC_DAILINK_DEF(reference,
436 DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
438 SND_SOC_DAILINK_DEF(dmic,
439 DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
441 SND_SOC_DAILINK_DEF(hdmi1,
442 DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
444 SND_SOC_DAILINK_DEF(hdmi2,
445 DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
447 SND_SOC_DAILINK_DEF(hdmi3,
448 DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
451 SND_SOC_DAILINK_DEF(ssp5_pin,
452 DAILINK_COMP_ARRAY(COMP_CPU("SSP5 Pin")));
453 SND_SOC_DAILINK_DEF(ssp5_codec,
454 DAILINK_COMP_ARRAY(COMP_CODEC("MX98357A:00",
455 BXT_MAXIM_CODEC_DAI)));
456 SND_SOC_DAILINK_DEF(max98390_codec,
458 /* Left */ COMP_CODEC(MAX98390_DEV0_NAME, "max98390-aif1"),
459 /* Right */ COMP_CODEC(MAX98390_DEV1_NAME, "max98390-aif1")));
461 SND_SOC_DAILINK_DEF(ssp1_pin,
462 DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
463 SND_SOC_DAILINK_DEF(ssp1_codec,
464 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
465 BXT_DIALOG_CODEC_DAI)));
467 SND_SOC_DAILINK_DEF(dmic_pin,
468 DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
470 SND_SOC_DAILINK_DEF(dmic16k_pin,
471 DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));
473 SND_SOC_DAILINK_DEF(dmic_codec,
474 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
476 SND_SOC_DAILINK_DEF(idisp1_pin,
477 DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
478 SND_SOC_DAILINK_DEF(idisp1_codec,
479 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
481 SND_SOC_DAILINK_DEF(idisp2_pin,
482 DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
483 SND_SOC_DAILINK_DEF(idisp2_codec,
484 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
485 "intel-hdmi-hifi2")));
487 SND_SOC_DAILINK_DEF(idisp3_pin,
488 DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
489 SND_SOC_DAILINK_DEF(idisp3_codec,
490 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
491 "intel-hdmi-hifi3")));
493 SND_SOC_DAILINK_DEF(platform,
494 DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0")));
496 static struct snd_soc_dai_link broxton_dais[] = {
497 /* Front End DAI links */
498 [BXT_DPCM_AUDIO_PB] =
500 .name = "Bxt Audio Port",
501 .stream_name = "Audio",
504 .init = broxton_da7219_fe_init,
506 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
508 .ops = &broxton_da7219_fe_ops,
509 SND_SOC_DAILINK_REG(system, dummy, platform),
511 [BXT_DPCM_AUDIO_CP] =
513 .name = "Bxt Audio Capture Port",
514 .stream_name = "Audio Record",
518 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
520 .ops = &broxton_da7219_fe_ops,
521 SND_SOC_DAILINK_REG(system, dummy, platform),
523 [BXT_DPCM_AUDIO_HS_PB] = {
524 .name = "Bxt Audio Headset Playback",
525 .stream_name = "Headset Playback",
529 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
531 .ops = &broxton_da7219_fe_ops,
532 SND_SOC_DAILINK_REG(system2, dummy, platform),
534 [BXT_DPCM_AUDIO_REF_CP] =
536 .name = "Bxt Audio Reference cap",
537 .stream_name = "Refcap",
542 .ops = &broxton_refcap_ops,
543 SND_SOC_DAILINK_REG(reference, dummy, platform),
545 [BXT_DPCM_AUDIO_DMIC_CP] =
547 .name = "Bxt Audio DMIC cap",
548 .stream_name = "dmiccap",
553 .ops = &broxton_dmic_ops,
554 SND_SOC_DAILINK_REG(dmic, dummy, platform),
556 [BXT_DPCM_AUDIO_HDMI1_PB] =
558 .name = "Bxt HDMI Port1",
559 .stream_name = "Hdmi1",
564 SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
566 [BXT_DPCM_AUDIO_HDMI2_PB] =
568 .name = "Bxt HDMI Port2",
569 .stream_name = "Hdmi2",
574 SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
576 [BXT_DPCM_AUDIO_HDMI3_PB] =
578 .name = "Bxt HDMI Port3",
579 .stream_name = "Hdmi3",
584 SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
586 /* Back End DAI links */
589 .name = "SSP5-Codec",
592 .dai_fmt = SND_SOC_DAIFMT_I2S |
593 SND_SOC_DAIFMT_NB_NF |
594 SND_SOC_DAIFMT_CBC_CFC,
595 .ignore_pmdown_time = 1,
596 .be_hw_params_fixup = broxton_ssp_fixup,
598 SND_SOC_DAILINK_REG(ssp5_pin, ssp5_codec, platform),
602 .name = "SSP1-Codec",
605 .init = broxton_da7219_codec_init,
606 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
607 SND_SOC_DAIFMT_CBC_CFC,
608 .ignore_pmdown_time = 1,
609 .be_hw_params_fixup = broxton_ssp_fixup,
612 SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
618 .be_hw_params_fixup = broxton_dmic_fixup,
621 SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
626 .init = broxton_hdmi_init,
629 SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
634 .init = broxton_hdmi_init,
637 SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
642 .init = broxton_hdmi_init,
645 SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
650 .be_hw_params_fixup = broxton_dmic_fixup,
653 SND_SOC_DAILINK_REG(dmic16k_pin, dmic_codec, platform),
657 static struct snd_soc_codec_conf max98390_codec_confs[] = {
659 .dlc = COMP_CODEC_CONF(MAX98390_DEV0_NAME),
660 .name_prefix = "Left",
663 .dlc = COMP_CODEC_CONF(MAX98390_DEV1_NAME),
664 .name_prefix = "Right",
669 static int bxt_card_late_probe(struct snd_soc_card *card)
671 struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card);
672 struct bxt_hdmi_pcm *pcm;
673 struct snd_soc_component *component = NULL;
674 const struct snd_kcontrol_new *controls;
675 const struct snd_soc_dapm_widget *widgets;
676 const struct snd_soc_dapm_route *routes;
677 int num_controls, num_widgets, num_routes, err, i = 0;
678 char jack_name[NAME_SIZE];
680 switch (ctx->spkamp) {
681 case SPKAMP_MAX98357A:
682 controls = max98357a_controls;
683 num_controls = ARRAY_SIZE(max98357a_controls);
684 widgets = max98357a_widgets;
685 num_widgets = ARRAY_SIZE(max98357a_widgets);
686 routes = max98357a_routes;
687 num_routes = ARRAY_SIZE(max98357a_routes);
689 case SPKAMP_MAX98390:
690 controls = max98390_controls;
691 num_controls = ARRAY_SIZE(max98390_controls);
692 widgets = max98390_widgets;
693 num_widgets = ARRAY_SIZE(max98390_widgets);
694 routes = max98390_routes;
695 num_routes = ARRAY_SIZE(max98390_routes);
698 dev_err(card->dev, "Invalid speaker amplifier %d\n", ctx->spkamp);
702 err = snd_soc_dapm_new_controls(&card->dapm, widgets, num_widgets);
704 dev_err(card->dev, "Fail to new widgets\n");
708 err = snd_soc_add_card_controls(card, controls, num_controls);
710 dev_err(card->dev, "Fail to add controls\n");
714 err = snd_soc_dapm_add_routes(&card->dapm, routes, num_routes);
716 dev_err(card->dev, "Fail to add routes\n");
720 if (soc_intel_is_glk())
721 snd_soc_dapm_add_routes(&card->dapm, gemini_map,
722 ARRAY_SIZE(gemini_map));
724 snd_soc_dapm_add_routes(&card->dapm, broxton_map,
725 ARRAY_SIZE(broxton_map));
727 if (list_empty(&ctx->hdmi_pcm_list))
730 if (ctx->common_hdmi_codec_drv) {
731 pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
733 component = pcm->codec_dai->component;
734 return hda_dsp_hdmi_build_controls(card, component);
737 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
738 component = pcm->codec_dai->component;
739 snprintf(jack_name, sizeof(jack_name),
740 "HDMI/DP, pcm=%d Jack", pcm->device);
741 err = snd_soc_card_jack_new(card, jack_name,
742 SND_JACK_AVOUT, &broxton_hdmi[i]);
747 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
755 return hdac_hdmi_jack_port_init(component, &card->dapm);
758 /* broxton audio machine driver for SPT + da7219 */
759 static struct snd_soc_card broxton_audio_card = {
760 .name = "bxtda7219max",
761 .owner = THIS_MODULE,
762 .dai_link = broxton_dais,
763 .num_links = ARRAY_SIZE(broxton_dais),
764 .controls = broxton_controls,
765 .num_controls = ARRAY_SIZE(broxton_controls),
766 .dapm_widgets = broxton_widgets,
767 .num_dapm_widgets = ARRAY_SIZE(broxton_widgets),
768 .dapm_routes = audio_map,
769 .num_dapm_routes = ARRAY_SIZE(audio_map),
770 .fully_routed = true,
771 .late_probe = bxt_card_late_probe,
774 static int broxton_audio_probe(struct platform_device *pdev)
776 struct bxt_card_private *ctx;
777 struct snd_soc_acpi_mach *mach;
778 const char *platform_name;
781 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
785 INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
787 if (acpi_dev_present("MX98390", NULL, -1))
788 ctx->spkamp = SPKAMP_MAX98390;
790 ctx->spkamp = SPKAMP_MAX98357A;
792 broxton_audio_card.dev = &pdev->dev;
793 snd_soc_card_set_drvdata(&broxton_audio_card, ctx);
794 if (soc_intel_is_glk()) {
797 broxton_audio_card.name = "glkda7219max";
798 /* Fixup the SSP entries for geminilake */
799 for (i = 0; i < ARRAY_SIZE(broxton_dais); i++) {
800 /* MAXIM_CODEC is connected to SSP1. */
801 if (!strcmp(broxton_dais[i].codecs->dai_name,
802 BXT_MAXIM_CODEC_DAI)) {
803 broxton_dais[i].name = "SSP1-Codec";
804 broxton_dais[i].cpus->dai_name = "SSP1 Pin";
806 /* DIALOG_CODE is connected to SSP2 */
807 else if (!strcmp(broxton_dais[i].codecs->dai_name,
808 BXT_DIALOG_CODEC_DAI)) {
809 broxton_dais[i].name = "SSP2-Codec";
810 broxton_dais[i].cpus->dai_name = "SSP2 Pin";
813 } else if (soc_intel_is_cml()) {
816 if (ctx->spkamp == SPKAMP_MAX98390) {
817 broxton_audio_card.name = "cml_max98390_da7219";
819 broxton_audio_card.codec_conf = max98390_codec_confs;
820 broxton_audio_card.num_configs = ARRAY_SIZE(max98390_codec_confs);
822 broxton_audio_card.name = "cmlda7219max";
824 for (i = 0; i < ARRAY_SIZE(broxton_dais); i++) {
825 /* MAXIM_CODEC is connected to SSP1. */
826 if (!strcmp(broxton_dais[i].codecs->dai_name,
827 BXT_MAXIM_CODEC_DAI)) {
828 broxton_dais[i].name = "SSP1-Codec";
829 broxton_dais[i].cpus->dai_name = "SSP1 Pin";
831 if (ctx->spkamp == SPKAMP_MAX98390) {
832 broxton_dais[i].codecs = max98390_codec;
833 broxton_dais[i].num_codecs = ARRAY_SIZE(max98390_codec);
834 broxton_dais[i].dpcm_capture = 1;
837 /* DIALOG_CODEC is connected to SSP0 */
838 else if (!strcmp(broxton_dais[i].codecs->dai_name,
839 BXT_DIALOG_CODEC_DAI)) {
840 broxton_dais[i].name = "SSP0-Codec";
841 broxton_dais[i].cpus->dai_name = "SSP0 Pin";
846 /* override platform name, if required */
847 mach = pdev->dev.platform_data;
848 platform_name = mach->mach_params.platform;
850 ret = snd_soc_fixup_dai_links_platform_name(&broxton_audio_card,
855 ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
857 return devm_snd_soc_register_card(&pdev->dev, &broxton_audio_card);
860 static const struct platform_device_id bxt_board_ids[] = {
861 { .name = "bxt_da7219_mx98357a" },
862 { .name = "glk_da7219_mx98357a" },
863 { .name = "cml_da7219_mx98357a" },
866 MODULE_DEVICE_TABLE(platform, bxt_board_ids);
868 static struct platform_driver broxton_audio = {
869 .probe = broxton_audio_probe,
871 .name = "bxt_da7219_max98357a",
872 .pm = &snd_soc_pm_ops,
874 .id_table = bxt_board_ids,
876 module_platform_driver(broxton_audio)
878 /* Module information */
879 MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode");
880 MODULE_AUTHOR("Sathyanarayana Nujella <sathyanarayana.nujella@intel.com>");
881 MODULE_AUTHOR("Rohit Ainapure <rohit.m.ainapure@intel.com>");
882 MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
883 MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>");
884 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
885 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
886 MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
887 MODULE_LICENSE("GPL v2");
888 MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);