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