Back to home page

OSCL-LXR

 
 

    


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