Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 // Copyright(c) 2017-18 Intel Corporation.
0003 
0004 /*
0005  * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs
0006  *
0007  * Modified from:
0008  *   Intel Kabylake I2S Machine driver supporting MAXIM98927 and
0009  *   RT5663 codecs
0010  */
0011 
0012 #include <linux/input.h>
0013 #include <linux/module.h>
0014 #include <linux/platform_device.h>
0015 #include <sound/core.h>
0016 #include <sound/jack.h>
0017 #include <sound/pcm.h>
0018 #include <sound/pcm_params.h>
0019 #include <sound/soc.h>
0020 #include "../../codecs/da7219.h"
0021 #include "../../codecs/hdac_hdmi.h"
0022 #include "../../codecs/da7219-aad.h"
0023 
0024 #define KBL_DIALOG_CODEC_DAI "da7219-hifi"
0025 #define KBL_MAXIM_CODEC_DAI "HiFi"
0026 #define MAXIM_DEV0_NAME "MX98357A:00"
0027 #define DUAL_CHANNEL 2
0028 #define QUAD_CHANNEL 4
0029 
0030 static struct snd_soc_card *kabylake_audio_card;
0031 static struct snd_soc_jack skylake_hdmi[3];
0032 
0033 struct kbl_hdmi_pcm {
0034     struct list_head head;
0035     struct snd_soc_dai *codec_dai;
0036     int device;
0037 };
0038 
0039 struct kbl_codec_private {
0040     struct snd_soc_jack kabylake_headset;
0041     struct list_head hdmi_pcm_list;
0042 };
0043 
0044 enum {
0045     KBL_DPCM_AUDIO_PB = 0,
0046     KBL_DPCM_AUDIO_CP,
0047     KBL_DPCM_AUDIO_REF_CP,
0048     KBL_DPCM_AUDIO_DMIC_CP,
0049     KBL_DPCM_AUDIO_HDMI1_PB,
0050     KBL_DPCM_AUDIO_HDMI2_PB,
0051     KBL_DPCM_AUDIO_HDMI3_PB,
0052 };
0053 
0054 static int platform_clock_control(struct snd_soc_dapm_widget *w,
0055                     struct snd_kcontrol *k, int  event)
0056 {
0057     struct snd_soc_dapm_context *dapm = w->dapm;
0058     struct snd_soc_card *card = dapm->card;
0059     struct snd_soc_dai *codec_dai;
0060     int ret = 0;
0061 
0062     codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI);
0063     if (!codec_dai) {
0064         dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
0065         return -EIO;
0066     }
0067 
0068     if (SND_SOC_DAPM_EVENT_OFF(event)) {
0069         ret = snd_soc_dai_set_pll(codec_dai, 0,
0070                      DA7219_SYSCLK_MCLK, 0, 0);
0071         if (ret)
0072             dev_err(card->dev, "failed to stop PLL: %d\n", ret);
0073     } else if (SND_SOC_DAPM_EVENT_ON(event)) {
0074         ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM,
0075                      0, DA7219_PLL_FREQ_OUT_98304);
0076         if (ret)
0077             dev_err(card->dev, "failed to start PLL: %d\n", ret);
0078     }
0079 
0080     return ret;
0081 }
0082 
0083 static const struct snd_kcontrol_new kabylake_controls[] = {
0084     SOC_DAPM_PIN_SWITCH("Headphone Jack"),
0085     SOC_DAPM_PIN_SWITCH("Headset Mic"),
0086     SOC_DAPM_PIN_SWITCH("Spk"),
0087 };
0088 
0089 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
0090     SND_SOC_DAPM_HP("Headphone Jack", NULL),
0091     SND_SOC_DAPM_MIC("Headset Mic", NULL),
0092     SND_SOC_DAPM_SPK("Spk", NULL),
0093     SND_SOC_DAPM_MIC("SoC DMIC", NULL),
0094     SND_SOC_DAPM_SPK("HDMI1", NULL),
0095     SND_SOC_DAPM_SPK("HDMI2", NULL),
0096     SND_SOC_DAPM_SPK("HDMI3", NULL),
0097     SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
0098             platform_clock_control, SND_SOC_DAPM_PRE_PMU |
0099             SND_SOC_DAPM_POST_PMD),
0100 };
0101 
0102 static struct snd_soc_jack_pin jack_pins[] = {
0103     {
0104         .pin    = "Headphone Jack",
0105         .mask   = SND_JACK_HEADPHONE,
0106     },
0107     {
0108         .pin    = "Headset Mic",
0109         .mask   = SND_JACK_MICROPHONE,
0110     },
0111 };
0112 
0113 static const struct snd_soc_dapm_route kabylake_map[] = {
0114     { "Headphone Jack", NULL, "HPL" },
0115     { "Headphone Jack", NULL, "HPR" },
0116 
0117     /* speaker */
0118     { "Spk", NULL, "Speaker" },
0119 
0120     /* other jacks */
0121     { "MIC", NULL, "Headset Mic" },
0122     { "DMic", NULL, "SoC DMIC" },
0123 
0124     {"HDMI1", NULL, "hif5-0 Output"},
0125     {"HDMI2", NULL, "hif6-0 Output"},
0126     {"HDMI3", NULL, "hif7-0 Output"},
0127 
0128     /* CODEC BE connections */
0129     { "HiFi Playback", NULL, "ssp0 Tx" },
0130     { "ssp0 Tx", NULL, "codec0_out" },
0131 
0132     { "Playback", NULL, "ssp1 Tx" },
0133     { "ssp1 Tx", NULL, "codec1_out" },
0134 
0135     { "codec0_in", NULL, "ssp1 Rx" },
0136     { "ssp1 Rx", NULL, "Capture" },
0137 
0138     /* DMIC */
0139     { "dmic01_hifi", NULL, "DMIC01 Rx" },
0140     { "DMIC01 Rx", NULL, "DMIC AIF" },
0141 
0142     { "hifi1", NULL, "iDisp1 Tx" },
0143     { "iDisp1 Tx", NULL, "iDisp1_out" },
0144     { "hifi2", NULL, "iDisp2 Tx" },
0145     { "iDisp2 Tx", NULL, "iDisp2_out" },
0146     { "hifi3", NULL, "iDisp3 Tx"},
0147     { "iDisp3 Tx", NULL, "iDisp3_out"},
0148 
0149     { "Headphone Jack", NULL, "Platform Clock" },
0150     { "Headset Mic", NULL, "Platform Clock" },
0151 };
0152 
0153 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
0154             struct snd_pcm_hw_params *params)
0155 {
0156     struct snd_interval *rate = hw_param_interval(params,
0157             SNDRV_PCM_HW_PARAM_RATE);
0158     struct snd_interval *chan = hw_param_interval(params,
0159             SNDRV_PCM_HW_PARAM_CHANNELS);
0160     struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
0161 
0162     /* The ADSP will convert the FE rate to 48k, stereo */
0163     rate->min = rate->max = 48000;
0164     chan->min = chan->max = DUAL_CHANNEL;
0165 
0166     /* set SSP to 24 bit */
0167     snd_mask_none(fmt);
0168     snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
0169 
0170     return 0;
0171 }
0172 
0173 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
0174 {
0175     struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
0176     struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
0177     struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
0178     struct snd_soc_jack *jack;
0179     int ret;
0180 
0181     /* Configure sysclk for codec */
0182     ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000,
0183                         SND_SOC_CLOCK_IN);
0184     if (ret) {
0185         dev_err(rtd->dev, "can't set codec sysclk configuration\n");
0186         return ret;
0187     }
0188 
0189     /*
0190      * Headset buttons map to the google Reference headset.
0191      * These can be configured by userspace.
0192      */
0193     ret = snd_soc_card_jack_new_pins(kabylake_audio_card, "Headset Jack",
0194                      SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
0195                      SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
0196                      &ctx->kabylake_headset,
0197                      jack_pins,
0198                      ARRAY_SIZE(jack_pins));
0199     if (ret) {
0200         dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
0201         return ret;
0202     }
0203 
0204     jack = &ctx->kabylake_headset;
0205 
0206     snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
0207     snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
0208     snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
0209     snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
0210     da7219_aad_jack_det(component, &ctx->kabylake_headset);
0211 
0212     ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
0213     if (ret)
0214         dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
0215 
0216     return ret;
0217 }
0218 
0219 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
0220 {
0221     struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
0222     struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
0223     struct kbl_hdmi_pcm *pcm;
0224 
0225     pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
0226     if (!pcm)
0227         return -ENOMEM;
0228 
0229     pcm->device = device;
0230     pcm->codec_dai = dai;
0231 
0232     list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
0233 
0234     return 0;
0235 }
0236 
0237 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
0238 {
0239     return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
0240 }
0241 
0242 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
0243 {
0244     return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
0245 }
0246 
0247 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
0248 {
0249     return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
0250 }
0251 
0252 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
0253 {
0254     struct snd_soc_dapm_context *dapm;
0255     struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
0256 
0257     dapm = snd_soc_component_get_dapm(component);
0258     snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
0259 
0260     return 0;
0261 }
0262 
0263 static const unsigned int rates[] = {
0264     48000,
0265 };
0266 
0267 static const struct snd_pcm_hw_constraint_list constraints_rates = {
0268     .count = ARRAY_SIZE(rates),
0269     .list  = rates,
0270     .mask = 0,
0271 };
0272 
0273 static const unsigned int channels[] = {
0274     DUAL_CHANNEL,
0275 };
0276 
0277 static const struct snd_pcm_hw_constraint_list constraints_channels = {
0278     .count = ARRAY_SIZE(channels),
0279     .list = channels,
0280     .mask = 0,
0281 };
0282 
0283 static unsigned int channels_quad[] = {
0284     QUAD_CHANNEL,
0285 };
0286 
0287 static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
0288     .count = ARRAY_SIZE(channels_quad),
0289     .list = channels_quad,
0290     .mask = 0,
0291 };
0292 
0293 static int kbl_fe_startup(struct snd_pcm_substream *substream)
0294 {
0295     struct snd_pcm_runtime *runtime = substream->runtime;
0296 
0297     /*
0298      * On this platform for PCM device we support,
0299      * 48Khz
0300      * stereo
0301      * 16 bit audio
0302      */
0303 
0304     runtime->hw.channels_max = DUAL_CHANNEL;
0305     snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
0306                        &constraints_channels);
0307 
0308     runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
0309     snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
0310 
0311     snd_pcm_hw_constraint_list(runtime, 0,
0312                 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
0313 
0314     return 0;
0315 }
0316 
0317 static const struct snd_soc_ops kabylake_da7219_fe_ops = {
0318     .startup = kbl_fe_startup,
0319 };
0320 
0321 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
0322         struct snd_pcm_hw_params *params)
0323 {
0324     struct snd_interval *chan = hw_param_interval(params,
0325                 SNDRV_PCM_HW_PARAM_CHANNELS);
0326 
0327     /*
0328      * set BE channel constraint as user FE channels
0329      */
0330 
0331     if (params_channels(params) == 2)
0332         chan->min = chan->max = 2;
0333     else
0334         chan->min = chan->max = 4;
0335 
0336     return 0;
0337 }
0338 
0339 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
0340 {
0341     struct snd_pcm_runtime *runtime = substream->runtime;
0342 
0343     runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
0344     snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
0345             &constraints_channels_quad);
0346 
0347     return snd_pcm_hw_constraint_list(substream->runtime, 0,
0348             SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
0349 }
0350 
0351 static struct snd_soc_ops kabylake_dmic_ops = {
0352     .startup = kabylake_dmic_startup,
0353 };
0354 
0355 static unsigned int rates_16000[] = {
0356         16000,
0357 };
0358 
0359 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
0360         .count = ARRAY_SIZE(rates_16000),
0361         .list  = rates_16000,
0362 };
0363 
0364 static const unsigned int ch_mono[] = {
0365     1,
0366 };
0367 
0368 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
0369     .count = ARRAY_SIZE(ch_mono),
0370     .list  = ch_mono,
0371 };
0372 
0373 static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
0374 {
0375     substream->runtime->hw.channels_max = 1;
0376     snd_pcm_hw_constraint_list(substream->runtime, 0,
0377                     SNDRV_PCM_HW_PARAM_CHANNELS,
0378                     &constraints_refcap);
0379 
0380     return snd_pcm_hw_constraint_list(substream->runtime, 0,
0381                     SNDRV_PCM_HW_PARAM_RATE,
0382                     &constraints_16000);
0383 }
0384 
0385 static struct snd_soc_ops skylake_refcap_ops = {
0386     .startup = kabylake_refcap_startup,
0387 };
0388 
0389 SND_SOC_DAILINK_DEF(dummy,
0390     DAILINK_COMP_ARRAY(COMP_DUMMY()));
0391 
0392 SND_SOC_DAILINK_DEF(system,
0393     DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
0394 
0395 SND_SOC_DAILINK_DEF(reference,
0396     DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
0397 
0398 SND_SOC_DAILINK_DEF(dmic,
0399     DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
0400 
0401 SND_SOC_DAILINK_DEF(hdmi1,
0402     DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
0403 
0404 SND_SOC_DAILINK_DEF(hdmi2,
0405     DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
0406 
0407 SND_SOC_DAILINK_DEF(hdmi3,
0408     DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
0409 
0410 SND_SOC_DAILINK_DEF(ssp0_pin,
0411     DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
0412 SND_SOC_DAILINK_DEF(ssp0_codec,
0413     DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME,
0414                       KBL_MAXIM_CODEC_DAI)));
0415 
0416 SND_SOC_DAILINK_DEF(ssp1_pin,
0417     DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
0418 SND_SOC_DAILINK_DEF(ssp1_codec,
0419     DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
0420                       KBL_DIALOG_CODEC_DAI)));
0421 
0422 SND_SOC_DAILINK_DEF(dmic_pin,
0423     DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
0424 SND_SOC_DAILINK_DEF(dmic_codec,
0425     DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
0426 
0427 SND_SOC_DAILINK_DEF(idisp1_pin,
0428     DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
0429 SND_SOC_DAILINK_DEF(idisp1_codec,
0430     DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
0431                       "intel-hdmi-hifi1")));
0432 
0433 SND_SOC_DAILINK_DEF(idisp2_pin,
0434     DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
0435 SND_SOC_DAILINK_DEF(idisp2_codec,
0436     DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
0437 
0438 SND_SOC_DAILINK_DEF(idisp3_pin,
0439     DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
0440 SND_SOC_DAILINK_DEF(idisp3_codec,
0441     DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
0442 
0443 SND_SOC_DAILINK_DEF(platform,
0444     DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
0445 
0446 /* kabylake digital audio interface glue - connects codec <--> CPU */
0447 static struct snd_soc_dai_link kabylake_dais[] = {
0448     /* Front End DAI links */
0449     [KBL_DPCM_AUDIO_PB] = {
0450         .name = "Kbl Audio Port",
0451         .stream_name = "Audio",
0452         .dynamic = 1,
0453         .nonatomic = 1,
0454         .init = kabylake_da7219_fe_init,
0455         .trigger = {
0456             SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
0457         .dpcm_playback = 1,
0458         .ops = &kabylake_da7219_fe_ops,
0459         SND_SOC_DAILINK_REG(system, dummy, platform),
0460     },
0461     [KBL_DPCM_AUDIO_CP] = {
0462         .name = "Kbl Audio Capture Port",
0463         .stream_name = "Audio Record",
0464         .dynamic = 1,
0465         .nonatomic = 1,
0466         .trigger = {
0467             SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
0468         .dpcm_capture = 1,
0469         .ops = &kabylake_da7219_fe_ops,
0470         SND_SOC_DAILINK_REG(system, dummy, platform),
0471     },
0472     [KBL_DPCM_AUDIO_REF_CP] = {
0473         .name = "Kbl Audio Reference cap",
0474         .stream_name = "Wake on Voice",
0475         .init = NULL,
0476         .dpcm_capture = 1,
0477         .nonatomic = 1,
0478         .dynamic = 1,
0479         .ops = &skylake_refcap_ops,
0480         SND_SOC_DAILINK_REG(reference, dummy, platform),
0481     },
0482     [KBL_DPCM_AUDIO_DMIC_CP] = {
0483         .name = "Kbl Audio DMIC cap",
0484         .stream_name = "dmiccap",
0485         .init = NULL,
0486         .dpcm_capture = 1,
0487         .nonatomic = 1,
0488         .dynamic = 1,
0489         .ops = &kabylake_dmic_ops,
0490         SND_SOC_DAILINK_REG(dmic, dummy, platform),
0491     },
0492     [KBL_DPCM_AUDIO_HDMI1_PB] = {
0493         .name = "Kbl HDMI Port1",
0494         .stream_name = "Hdmi1",
0495         .dpcm_playback = 1,
0496         .init = NULL,
0497         .trigger = {
0498             SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
0499         .nonatomic = 1,
0500         .dynamic = 1,
0501         SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
0502     },
0503     [KBL_DPCM_AUDIO_HDMI2_PB] = {
0504         .name = "Kbl HDMI Port2",
0505         .stream_name = "Hdmi2",
0506         .dpcm_playback = 1,
0507         .init = NULL,
0508         .trigger = {
0509             SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
0510         .nonatomic = 1,
0511         .dynamic = 1,
0512         SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
0513     },
0514     [KBL_DPCM_AUDIO_HDMI3_PB] = {
0515         .name = "Kbl HDMI Port3",
0516         .stream_name = "Hdmi3",
0517         .trigger = {
0518             SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
0519         .dpcm_playback = 1,
0520         .init = NULL,
0521         .nonatomic = 1,
0522         .dynamic = 1,
0523         SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
0524     },
0525 
0526     /* Back End DAI links */
0527     {
0528         /* SSP0 - Codec */
0529         .name = "SSP0-Codec",
0530         .id = 0,
0531         .no_pcm = 1,
0532         .dai_fmt = SND_SOC_DAIFMT_I2S |
0533             SND_SOC_DAIFMT_NB_NF |
0534             SND_SOC_DAIFMT_CBC_CFC,
0535         .ignore_pmdown_time = 1,
0536         .be_hw_params_fixup = kabylake_ssp_fixup,
0537         .dpcm_playback = 1,
0538         SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
0539     },
0540     {
0541         /* SSP1 - Codec */
0542         .name = "SSP1-Codec",
0543         .id = 1,
0544         .no_pcm = 1,
0545         .init = kabylake_da7219_codec_init,
0546         .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
0547             SND_SOC_DAIFMT_CBC_CFC,
0548         .ignore_pmdown_time = 1,
0549         .be_hw_params_fixup = kabylake_ssp_fixup,
0550         .dpcm_playback = 1,
0551         .dpcm_capture = 1,
0552         SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
0553     },
0554     {
0555         .name = "dmic01",
0556         .id = 2,
0557         .be_hw_params_fixup = kabylake_dmic_fixup,
0558         .ignore_suspend = 1,
0559         .dpcm_capture = 1,
0560         .no_pcm = 1,
0561         SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
0562     },
0563     {
0564         .name = "iDisp1",
0565         .id = 3,
0566         .dpcm_playback = 1,
0567         .init = kabylake_hdmi1_init,
0568         .no_pcm = 1,
0569         SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
0570     },
0571     {
0572         .name = "iDisp2",
0573         .id = 4,
0574         .init = kabylake_hdmi2_init,
0575         .dpcm_playback = 1,
0576         .no_pcm = 1,
0577         SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
0578     },
0579     {
0580         .name = "iDisp3",
0581         .id = 5,
0582         .init = kabylake_hdmi3_init,
0583         .dpcm_playback = 1,
0584         .no_pcm = 1,
0585         SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
0586     },
0587 };
0588 
0589 #define NAME_SIZE   32
0590 static int kabylake_card_late_probe(struct snd_soc_card *card)
0591 {
0592     struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
0593     struct kbl_hdmi_pcm *pcm;
0594     struct snd_soc_component *component = NULL;
0595     int err, i = 0;
0596     char jack_name[NAME_SIZE];
0597 
0598     list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
0599         component = pcm->codec_dai->component;
0600         snprintf(jack_name, sizeof(jack_name),
0601             "HDMI/DP, pcm=%d Jack", pcm->device);
0602         err = snd_soc_card_jack_new(card, jack_name,
0603                     SND_JACK_AVOUT, &skylake_hdmi[i]);
0604 
0605         if (err)
0606             return err;
0607 
0608         err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
0609                 &skylake_hdmi[i]);
0610         if (err < 0)
0611             return err;
0612 
0613         i++;
0614 
0615     }
0616 
0617     if (!component)
0618         return -EINVAL;
0619 
0620     return hdac_hdmi_jack_port_init(component, &card->dapm);
0621 }
0622 
0623 /* kabylake audio machine driver for SPT + DA7219 */
0624 static struct snd_soc_card kabylake_audio_card_da7219_m98357a = {
0625     .name = "kblda7219max",
0626     .owner = THIS_MODULE,
0627     .dai_link = kabylake_dais,
0628     .num_links = ARRAY_SIZE(kabylake_dais),
0629     .controls = kabylake_controls,
0630     .num_controls = ARRAY_SIZE(kabylake_controls),
0631     .dapm_widgets = kabylake_widgets,
0632     .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
0633     .dapm_routes = kabylake_map,
0634     .num_dapm_routes = ARRAY_SIZE(kabylake_map),
0635     .fully_routed = true,
0636     .late_probe = kabylake_card_late_probe,
0637 };
0638 
0639 static int kabylake_audio_probe(struct platform_device *pdev)
0640 {
0641     struct kbl_codec_private *ctx;
0642 
0643     ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
0644     if (!ctx)
0645         return -ENOMEM;
0646 
0647     INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
0648 
0649     kabylake_audio_card =
0650         (struct snd_soc_card *)pdev->id_entry->driver_data;
0651 
0652     kabylake_audio_card->dev = &pdev->dev;
0653     snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
0654     return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
0655 }
0656 
0657 static const struct platform_device_id kbl_board_ids[] = {
0658     {
0659         .name = "kbl_da7219_mx98357a",
0660         .driver_data =
0661             (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a,
0662     },
0663     { }
0664 };
0665 MODULE_DEVICE_TABLE(platform, kbl_board_ids);
0666 
0667 static struct platform_driver kabylake_audio = {
0668     .probe = kabylake_audio_probe,
0669     .driver = {
0670         .name = "kbl_da7219_max98357a",
0671         .pm = &snd_soc_pm_ops,
0672     },
0673     .id_table = kbl_board_ids,
0674 };
0675 
0676 module_platform_driver(kabylake_audio)
0677 
0678 /* Module information */
0679 MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode");
0680 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
0681 MODULE_LICENSE("GPL v2");