1 // SPDX-License-Identifier: GPL-2.0-only 2 // Copyright(c) 2017-18 Intel Corporation. 3 4 /* 5 * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs 6 * 7 * Modified from: 8 * Intel Kabylake I2S Machine driver supporting MAXIM98927 and 9 * RT5663 codecs 10 */ 11 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" 23 24 #define KBL_DIALOG_CODEC_DAI "da7219-hifi" 25 #define KBL_MAXIM_CODEC_DAI "HiFi" 26 #define MAXIM_DEV0_NAME "MX98357A:00" 27 #define DUAL_CHANNEL 2 28 #define QUAD_CHANNEL 4 29 30 static struct snd_soc_card *kabylake_audio_card; 31 static struct snd_soc_jack skylake_hdmi[3]; 32 33 struct kbl_hdmi_pcm { 34 struct list_head head; 35 struct snd_soc_dai *codec_dai; 36 int device; 37 }; 38 39 struct kbl_codec_private { 40 struct snd_soc_jack kabylake_headset; 41 struct list_head hdmi_pcm_list; 42 }; 43 44 enum { 45 KBL_DPCM_AUDIO_PB = 0, 46 KBL_DPCM_AUDIO_CP, 47 KBL_DPCM_AUDIO_REF_CP, 48 KBL_DPCM_AUDIO_DMIC_CP, 49 KBL_DPCM_AUDIO_HDMI1_PB, 50 KBL_DPCM_AUDIO_HDMI2_PB, 51 KBL_DPCM_AUDIO_HDMI3_PB, 52 }; 53 54 static int platform_clock_control(struct snd_soc_dapm_widget *w, 55 struct snd_kcontrol *k, int event) 56 { 57 struct snd_soc_dapm_context *dapm = w->dapm; 58 struct snd_soc_card *card = dapm->card; 59 struct snd_soc_dai *codec_dai; 60 int ret = 0; 61 62 codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI); 63 if (!codec_dai) { 64 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); 65 return -EIO; 66 } 67 68 if (SND_SOC_DAPM_EVENT_OFF(event)) { 69 ret = snd_soc_dai_set_pll(codec_dai, 0, 70 DA7219_SYSCLK_MCLK, 0, 0); 71 if (ret) 72 dev_err(card->dev, "failed to stop PLL: %d\n", ret); 73 } else if (SND_SOC_DAPM_EVENT_ON(event)) { 74 ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM, 75 0, DA7219_PLL_FREQ_OUT_98304); 76 if (ret) 77 dev_err(card->dev, "failed to start PLL: %d\n", ret); 78 } 79 80 return ret; 81 } 82 83 static const struct snd_kcontrol_new kabylake_controls[] = { 84 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 85 SOC_DAPM_PIN_SWITCH("Headset Mic"), 86 SOC_DAPM_PIN_SWITCH("Spk"), 87 }; 88 89 static const struct snd_soc_dapm_widget kabylake_widgets[] = { 90 SND_SOC_DAPM_HP("Headphone Jack", NULL), 91 SND_SOC_DAPM_MIC("Headset Mic", NULL), 92 SND_SOC_DAPM_SPK("Spk", NULL), 93 SND_SOC_DAPM_MIC("SoC DMIC", NULL), 94 SND_SOC_DAPM_SPK("HDMI1", NULL), 95 SND_SOC_DAPM_SPK("HDMI2", NULL), 96 SND_SOC_DAPM_SPK("HDMI3", NULL), 97 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, 98 platform_clock_control, SND_SOC_DAPM_PRE_PMU | 99 SND_SOC_DAPM_POST_PMD), 100 }; 101 102 static struct snd_soc_jack_pin jack_pins[] = { 103 { 104 .pin = "Headphone Jack", 105 .mask = SND_JACK_HEADPHONE, 106 }, 107 { 108 .pin = "Headset Mic", 109 .mask = SND_JACK_MICROPHONE, 110 }, 111 }; 112 113 static const struct snd_soc_dapm_route kabylake_map[] = { 114 { "Headphone Jack", NULL, "HPL" }, 115 { "Headphone Jack", NULL, "HPR" }, 116 117 /* speaker */ 118 { "Spk", NULL, "Speaker" }, 119 120 /* other jacks */ 121 { "MIC", NULL, "Headset Mic" }, 122 { "DMic", NULL, "SoC DMIC" }, 123 124 {"HDMI1", NULL, "hif5-0 Output"}, 125 {"HDMI2", NULL, "hif6-0 Output"}, 126 {"HDMI3", NULL, "hif7-0 Output"}, 127 128 /* CODEC BE connections */ 129 { "HiFi Playback", NULL, "ssp0 Tx" }, 130 { "ssp0 Tx", NULL, "codec0_out" }, 131 132 { "Playback", NULL, "ssp1 Tx" }, 133 { "ssp1 Tx", NULL, "codec1_out" }, 134 135 { "codec0_in", NULL, "ssp1 Rx" }, 136 { "ssp1 Rx", NULL, "Capture" }, 137 138 /* DMIC */ 139 { "dmic01_hifi", NULL, "DMIC01 Rx" }, 140 { "DMIC01 Rx", NULL, "DMIC AIF" }, 141 142 { "hifi1", NULL, "iDisp1 Tx" }, 143 { "iDisp1 Tx", NULL, "iDisp1_out" }, 144 { "hifi2", NULL, "iDisp2 Tx" }, 145 { "iDisp2 Tx", NULL, "iDisp2_out" }, 146 { "hifi3", NULL, "iDisp3 Tx"}, 147 { "iDisp3 Tx", NULL, "iDisp3_out"}, 148 149 { "Headphone Jack", NULL, "Platform Clock" }, 150 { "Headset Mic", NULL, "Platform Clock" }, 151 }; 152 153 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, 154 struct snd_pcm_hw_params *params) 155 { 156 struct snd_interval *rate = hw_param_interval(params, 157 SNDRV_PCM_HW_PARAM_RATE); 158 struct snd_interval *chan = hw_param_interval(params, 159 SNDRV_PCM_HW_PARAM_CHANNELS); 160 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 161 162 /* The ADSP will convert the FE rate to 48k, stereo */ 163 rate->min = rate->max = 48000; 164 chan->min = chan->max = DUAL_CHANNEL; 165 166 /* set SSP to 24 bit */ 167 snd_mask_none(fmt); 168 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); 169 170 return 0; 171 } 172 173 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) 174 { 175 struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); 176 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 177 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 178 struct snd_soc_jack *jack; 179 int ret; 180 181 /* Configure sysclk for codec */ 182 ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000, 183 SND_SOC_CLOCK_IN); 184 if (ret) { 185 dev_err(rtd->dev, "can't set codec sysclk configuration\n"); 186 return ret; 187 } 188 189 /* 190 * Headset buttons map to the google Reference headset. 191 * These can be configured by userspace. 192 */ 193 ret = snd_soc_card_jack_new_pins(kabylake_audio_card, "Headset Jack", 194 SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | 195 SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, 196 &ctx->kabylake_headset, 197 jack_pins, 198 ARRAY_SIZE(jack_pins)); 199 if (ret) { 200 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); 201 return ret; 202 } 203 204 jack = &ctx->kabylake_headset; 205 206 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); 207 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); 208 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); 209 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); 210 da7219_aad_jack_det(component, &ctx->kabylake_headset); 211 212 ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); 213 if (ret) 214 dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret); 215 216 return ret; 217 } 218 219 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device) 220 { 221 struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); 222 struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); 223 struct kbl_hdmi_pcm *pcm; 224 225 pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); 226 if (!pcm) 227 return -ENOMEM; 228 229 pcm->device = device; 230 pcm->codec_dai = dai; 231 232 list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); 233 234 return 0; 235 } 236 237 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) 238 { 239 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB); 240 } 241 242 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) 243 { 244 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB); 245 } 246 247 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) 248 { 249 return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB); 250 } 251 252 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd) 253 { 254 struct snd_soc_dapm_context *dapm; 255 struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component; 256 257 dapm = snd_soc_component_get_dapm(component); 258 snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); 259 260 return 0; 261 } 262 263 static const unsigned int rates[] = { 264 48000, 265 }; 266 267 static const struct snd_pcm_hw_constraint_list constraints_rates = { 268 .count = ARRAY_SIZE(rates), 269 .list = rates, 270 .mask = 0, 271 }; 272 273 static const unsigned int channels[] = { 274 DUAL_CHANNEL, 275 }; 276 277 static const struct snd_pcm_hw_constraint_list constraints_channels = { 278 .count = ARRAY_SIZE(channels), 279 .list = channels, 280 .mask = 0, 281 }; 282 283 static unsigned int channels_quad[] = { 284 QUAD_CHANNEL, 285 }; 286 287 static struct snd_pcm_hw_constraint_list constraints_channels_quad = { 288 .count = ARRAY_SIZE(channels_quad), 289 .list = channels_quad, 290 .mask = 0, 291 }; 292 293 static int kbl_fe_startup(struct snd_pcm_substream *substream) 294 { 295 struct snd_pcm_runtime *runtime = substream->runtime; 296 297 /* 298 * On this platform for PCM device we support, 299 * 48Khz 300 * stereo 301 * 16 bit audio 302 */ 303 304 runtime->hw.channels_max = DUAL_CHANNEL; 305 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 306 &constraints_channels); 307 308 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; 309 snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); 310 311 snd_pcm_hw_constraint_list(runtime, 0, 312 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); 313 314 return 0; 315 } 316 317 static const struct snd_soc_ops kabylake_da7219_fe_ops = { 318 .startup = kbl_fe_startup, 319 }; 320 321 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, 322 struct snd_pcm_hw_params *params) 323 { 324 struct snd_interval *chan = hw_param_interval(params, 325 SNDRV_PCM_HW_PARAM_CHANNELS); 326 327 /* 328 * set BE channel constraint as user FE channels 329 */ 330 331 if (params_channels(params) == 2) 332 chan->min = chan->max = 2; 333 else 334 chan->min = chan->max = 4; 335 336 return 0; 337 } 338 339 static int kabylake_dmic_startup(struct snd_pcm_substream *substream) 340 { 341 struct snd_pcm_runtime *runtime = substream->runtime; 342 343 runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL; 344 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 345 &constraints_channels_quad); 346 347 return snd_pcm_hw_constraint_list(substream->runtime, 0, 348 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); 349 } 350 351 static struct snd_soc_ops kabylake_dmic_ops = { 352 .startup = kabylake_dmic_startup, 353 }; 354 355 static unsigned int rates_16000[] = { 356 16000, 357 }; 358 359 static const struct snd_pcm_hw_constraint_list constraints_16000 = { 360 .count = ARRAY_SIZE(rates_16000), 361 .list = rates_16000, 362 }; 363 364 static const unsigned int ch_mono[] = { 365 1, 366 }; 367 368 static const struct snd_pcm_hw_constraint_list constraints_refcap = { 369 .count = ARRAY_SIZE(ch_mono), 370 .list = ch_mono, 371 }; 372 373 static int kabylake_refcap_startup(struct snd_pcm_substream *substream) 374 { 375 substream->runtime->hw.channels_max = 1; 376 snd_pcm_hw_constraint_list(substream->runtime, 0, 377 SNDRV_PCM_HW_PARAM_CHANNELS, 378 &constraints_refcap); 379 380 return snd_pcm_hw_constraint_list(substream->runtime, 0, 381 SNDRV_PCM_HW_PARAM_RATE, 382 &constraints_16000); 383 } 384 385 static struct snd_soc_ops skylake_refcap_ops = { 386 .startup = kabylake_refcap_startup, 387 }; 388 389 SND_SOC_DAILINK_DEF(dummy, 390 DAILINK_COMP_ARRAY(COMP_DUMMY())); 391 392 SND_SOC_DAILINK_DEF(system, 393 DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); 394 395 SND_SOC_DAILINK_DEF(reference, 396 DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin"))); 397 398 SND_SOC_DAILINK_DEF(dmic, 399 DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin"))); 400 401 SND_SOC_DAILINK_DEF(hdmi1, 402 DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin"))); 403 404 SND_SOC_DAILINK_DEF(hdmi2, 405 DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin"))); 406 407 SND_SOC_DAILINK_DEF(hdmi3, 408 DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin"))); 409 410 SND_SOC_DAILINK_DEF(ssp0_pin, 411 DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin"))); 412 SND_SOC_DAILINK_DEF(ssp0_codec, 413 DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME, 414 KBL_MAXIM_CODEC_DAI))); 415 416 SND_SOC_DAILINK_DEF(ssp1_pin, 417 DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin"))); 418 SND_SOC_DAILINK_DEF(ssp1_codec, 419 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00", 420 KBL_DIALOG_CODEC_DAI))); 421 422 SND_SOC_DAILINK_DEF(dmic_pin, 423 DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); 424 SND_SOC_DAILINK_DEF(dmic_codec, 425 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); 426 427 SND_SOC_DAILINK_DEF(idisp1_pin, 428 DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); 429 SND_SOC_DAILINK_DEF(idisp1_codec, 430 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", 431 "intel-hdmi-hifi1"))); 432 433 SND_SOC_DAILINK_DEF(idisp2_pin, 434 DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); 435 SND_SOC_DAILINK_DEF(idisp2_codec, 436 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); 437 438 SND_SOC_DAILINK_DEF(idisp3_pin, 439 DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); 440 SND_SOC_DAILINK_DEF(idisp3_codec, 441 DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); 442 443 SND_SOC_DAILINK_DEF(platform, 444 DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3"))); 445 446 /* kabylake digital audio interface glue - connects codec <--> CPU */ 447 static struct snd_soc_dai_link kabylake_dais[] = { 448 /* Front End DAI links */ 449 [KBL_DPCM_AUDIO_PB] = { 450 .name = "Kbl Audio Port", 451 .stream_name = "Audio", 452 .dynamic = 1, 453 .nonatomic = 1, 454 .init = kabylake_da7219_fe_init, 455 .trigger = { 456 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 457 .dpcm_playback = 1, 458 .ops = &kabylake_da7219_fe_ops, 459 SND_SOC_DAILINK_REG(system, dummy, platform), 460 }, 461 [KBL_DPCM_AUDIO_CP] = { 462 .name = "Kbl Audio Capture Port", 463 .stream_name = "Audio Record", 464 .dynamic = 1, 465 .nonatomic = 1, 466 .trigger = { 467 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 468 .dpcm_capture = 1, 469 .ops = &kabylake_da7219_fe_ops, 470 SND_SOC_DAILINK_REG(system, dummy, platform), 471 }, 472 [KBL_DPCM_AUDIO_REF_CP] = { 473 .name = "Kbl Audio Reference cap", 474 .stream_name = "Wake on Voice", 475 .init = NULL, 476 .dpcm_capture = 1, 477 .nonatomic = 1, 478 .dynamic = 1, 479 .ops = &skylake_refcap_ops, 480 SND_SOC_DAILINK_REG(reference, dummy, platform), 481 }, 482 [KBL_DPCM_AUDIO_DMIC_CP] = { 483 .name = "Kbl Audio DMIC cap", 484 .stream_name = "dmiccap", 485 .init = NULL, 486 .dpcm_capture = 1, 487 .nonatomic = 1, 488 .dynamic = 1, 489 .ops = &kabylake_dmic_ops, 490 SND_SOC_DAILINK_REG(dmic, dummy, platform), 491 }, 492 [KBL_DPCM_AUDIO_HDMI1_PB] = { 493 .name = "Kbl HDMI Port1", 494 .stream_name = "Hdmi1", 495 .dpcm_playback = 1, 496 .init = NULL, 497 .trigger = { 498 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 499 .nonatomic = 1, 500 .dynamic = 1, 501 SND_SOC_DAILINK_REG(hdmi1, dummy, platform), 502 }, 503 [KBL_DPCM_AUDIO_HDMI2_PB] = { 504 .name = "Kbl HDMI Port2", 505 .stream_name = "Hdmi2", 506 .dpcm_playback = 1, 507 .init = NULL, 508 .trigger = { 509 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 510 .nonatomic = 1, 511 .dynamic = 1, 512 SND_SOC_DAILINK_REG(hdmi2, dummy, platform), 513 }, 514 [KBL_DPCM_AUDIO_HDMI3_PB] = { 515 .name = "Kbl HDMI Port3", 516 .stream_name = "Hdmi3", 517 .trigger = { 518 SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, 519 .dpcm_playback = 1, 520 .init = NULL, 521 .nonatomic = 1, 522 .dynamic = 1, 523 SND_SOC_DAILINK_REG(hdmi3, dummy, platform), 524 }, 525 526 /* Back End DAI links */ 527 { 528 /* SSP0 - Codec */ 529 .name = "SSP0-Codec", 530 .id = 0, 531 .no_pcm = 1, 532 .dai_fmt = SND_SOC_DAIFMT_I2S | 533 SND_SOC_DAIFMT_NB_NF | 534 SND_SOC_DAIFMT_CBC_CFC, 535 .ignore_pmdown_time = 1, 536 .be_hw_params_fixup = kabylake_ssp_fixup, 537 .dpcm_playback = 1, 538 SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform), 539 }, 540 { 541 /* SSP1 - Codec */ 542 .name = "SSP1-Codec", 543 .id = 1, 544 .no_pcm = 1, 545 .init = kabylake_da7219_codec_init, 546 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 547 SND_SOC_DAIFMT_CBC_CFC, 548 .ignore_pmdown_time = 1, 549 .be_hw_params_fixup = kabylake_ssp_fixup, 550 .dpcm_playback = 1, 551 .dpcm_capture = 1, 552 SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform), 553 }, 554 { 555 .name = "dmic01", 556 .id = 2, 557 .be_hw_params_fixup = kabylake_dmic_fixup, 558 .ignore_suspend = 1, 559 .dpcm_capture = 1, 560 .no_pcm = 1, 561 SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform), 562 }, 563 { 564 .name = "iDisp1", 565 .id = 3, 566 .dpcm_playback = 1, 567 .init = kabylake_hdmi1_init, 568 .no_pcm = 1, 569 SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform), 570 }, 571 { 572 .name = "iDisp2", 573 .id = 4, 574 .init = kabylake_hdmi2_init, 575 .dpcm_playback = 1, 576 .no_pcm = 1, 577 SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform), 578 }, 579 { 580 .name = "iDisp3", 581 .id = 5, 582 .init = kabylake_hdmi3_init, 583 .dpcm_playback = 1, 584 .no_pcm = 1, 585 SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform), 586 }, 587 }; 588 589 #define NAME_SIZE 32 590 static int kabylake_card_late_probe(struct snd_soc_card *card) 591 { 592 struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); 593 struct kbl_hdmi_pcm *pcm; 594 struct snd_soc_component *component = NULL; 595 int err, i = 0; 596 char jack_name[NAME_SIZE]; 597 598 list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { 599 component = pcm->codec_dai->component; 600 snprintf(jack_name, sizeof(jack_name), 601 "HDMI/DP, pcm=%d Jack", pcm->device); 602 err = snd_soc_card_jack_new(card, jack_name, 603 SND_JACK_AVOUT, &skylake_hdmi[i]); 604 605 if (err) 606 return err; 607 608 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, 609 &skylake_hdmi[i]); 610 if (err < 0) 611 return err; 612 613 i++; 614 615 } 616 617 if (!component) 618 return -EINVAL; 619 620 return hdac_hdmi_jack_port_init(component, &card->dapm); 621 } 622 623 /* kabylake audio machine driver for SPT + DA7219 */ 624 static struct snd_soc_card kabylake_audio_card_da7219_m98357a = { 625 .name = "kblda7219max", 626 .owner = THIS_MODULE, 627 .dai_link = kabylake_dais, 628 .num_links = ARRAY_SIZE(kabylake_dais), 629 .controls = kabylake_controls, 630 .num_controls = ARRAY_SIZE(kabylake_controls), 631 .dapm_widgets = kabylake_widgets, 632 .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets), 633 .dapm_routes = kabylake_map, 634 .num_dapm_routes = ARRAY_SIZE(kabylake_map), 635 .fully_routed = true, 636 .late_probe = kabylake_card_late_probe, 637 }; 638 639 static int kabylake_audio_probe(struct platform_device *pdev) 640 { 641 struct kbl_codec_private *ctx; 642 643 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 644 if (!ctx) 645 return -ENOMEM; 646 647 INIT_LIST_HEAD(&ctx->hdmi_pcm_list); 648 649 kabylake_audio_card = 650 (struct snd_soc_card *)pdev->id_entry->driver_data; 651 652 kabylake_audio_card->dev = &pdev->dev; 653 snd_soc_card_set_drvdata(kabylake_audio_card, ctx); 654 return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card); 655 } 656 657 static const struct platform_device_id kbl_board_ids[] = { 658 { 659 .name = "kbl_da7219_mx98357a", 660 .driver_data = 661 (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a, 662 }, 663 { } 664 }; 665 MODULE_DEVICE_TABLE(platform, kbl_board_ids); 666 667 static struct platform_driver kabylake_audio = { 668 .probe = kabylake_audio_probe, 669 .driver = { 670 .name = "kbl_da7219_max98357a", 671 .pm = &snd_soc_pm_ops, 672 }, 673 .id_table = kbl_board_ids, 674 }; 675 676 module_platform_driver(kabylake_audio) 677 678 /* Module information */ 679 MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode"); 680 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>"); 681 MODULE_LICENSE("GPL v2"); 682