Naveen M | ec040dd | 2017-05-15 13:42:16 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Intel Kabylake I2S Machine Driver with MAXIM98927 |
| 3 | * and RT5663 Codecs |
| 4 | * |
| 5 | * Copyright (C) 2017, Intel Corporation. All rights reserved. |
| 6 | * |
| 7 | * Modified from: |
| 8 | * Intel Skylake I2S Machine driver |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License version |
| 12 | * 2 as published by the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <sound/core.h> |
| 23 | #include <sound/jack.h> |
| 24 | #include <sound/pcm.h> |
| 25 | #include <sound/pcm_params.h> |
| 26 | #include <sound/soc.h> |
| 27 | #include "../../codecs/rt5663.h" |
| 28 | #include "../../codecs/hdac_hdmi.h" |
| 29 | #include "../skylake/skl.h" |
| 30 | |
| 31 | #define KBL_REALTEK_CODEC_DAI "rt5663-aif" |
| 32 | #define KBL_MAXIM_CODEC_DAI "max98927-aif1" |
| 33 | #define DMIC_CH(p) p->list[p->count-1] |
| 34 | #define MAXIM_DEV0_NAME "i2c-MX98927:00" |
| 35 | #define MAXIM_DEV1_NAME "i2c-MX98927:01" |
| 36 | |
| 37 | static struct snd_soc_card kabylake_audio_card; |
| 38 | static const struct snd_pcm_hw_constraint_list *dmic_constraints; |
| 39 | static struct snd_soc_jack skylake_hdmi[3]; |
| 40 | |
| 41 | struct kbl_hdmi_pcm { |
| 42 | struct list_head head; |
| 43 | struct snd_soc_dai *codec_dai; |
| 44 | int device; |
| 45 | }; |
| 46 | |
| 47 | struct kbl_rt5663_private { |
| 48 | struct snd_soc_jack kabylake_headset; |
| 49 | struct list_head hdmi_pcm_list; |
| 50 | }; |
| 51 | |
| 52 | enum { |
| 53 | KBL_DPCM_AUDIO_PB = 0, |
| 54 | KBL_DPCM_AUDIO_CP, |
| 55 | KBL_DPCM_AUDIO_REF_CP, |
| 56 | KBL_DPCM_AUDIO_DMIC_CP, |
| 57 | KBL_DPCM_AUDIO_HDMI1_PB, |
| 58 | KBL_DPCM_AUDIO_HDMI2_PB, |
| 59 | KBL_DPCM_AUDIO_HDMI3_PB, |
| 60 | }; |
| 61 | |
| 62 | static const struct snd_kcontrol_new kabylake_controls[] = { |
| 63 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), |
| 64 | SOC_DAPM_PIN_SWITCH("Headset Mic"), |
| 65 | SOC_DAPM_PIN_SWITCH("Left Spk"), |
| 66 | SOC_DAPM_PIN_SWITCH("Right Spk"), |
| 67 | }; |
| 68 | |
| 69 | static const struct snd_soc_dapm_widget kabylake_widgets[] = { |
| 70 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 71 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 72 | SND_SOC_DAPM_SPK("Left Spk", NULL), |
| 73 | SND_SOC_DAPM_SPK("Right Spk", NULL), |
| 74 | SND_SOC_DAPM_MIC("SoC DMIC", NULL), |
| 75 | SND_SOC_DAPM_SPK("DP", NULL), |
| 76 | SND_SOC_DAPM_SPK("HDMI", NULL), |
| 77 | |
| 78 | }; |
| 79 | |
| 80 | static const struct snd_soc_dapm_route kabylake_map[] = { |
| 81 | /* HP jack connectors - unknown if we have jack detection */ |
| 82 | { "Headphone Jack", NULL, "HPOL" }, |
| 83 | { "Headphone Jack", NULL, "HPOR" }, |
| 84 | |
| 85 | /* speaker */ |
| 86 | { "Left Spk", NULL, "Left BE_OUT" }, |
| 87 | { "Right Spk", NULL, "Right BE_OUT" }, |
| 88 | |
| 89 | /* other jacks */ |
| 90 | { "IN1P", NULL, "Headset Mic" }, |
| 91 | { "IN1N", NULL, "Headset Mic" }, |
| 92 | { "DMic", NULL, "SoC DMIC" }, |
| 93 | |
| 94 | { "HDMI", NULL, "hif5 Output" }, |
| 95 | { "DP", NULL, "hif6 Output" }, |
| 96 | |
| 97 | /* CODEC BE connections */ |
| 98 | { "Left HiFi Playback", NULL, "ssp0 Tx" }, |
| 99 | { "Right HiFi Playback", NULL, "ssp0 Tx" }, |
| 100 | { "ssp0 Tx", NULL, "codec0_out" }, |
| 101 | |
| 102 | { "AIF Playback", NULL, "ssp1 Tx" }, |
| 103 | { "ssp1 Tx", NULL, "codec1_out" }, |
| 104 | |
| 105 | { "codec0_in", NULL, "ssp1 Rx" }, |
| 106 | { "ssp1 Rx", NULL, "AIF Capture" }, |
| 107 | |
| 108 | /* DMIC */ |
| 109 | { "dmic01_hifi", NULL, "DMIC01 Rx" }, |
| 110 | { "DMIC01 Rx", NULL, "DMIC AIF" }, |
| 111 | |
| 112 | { "hifi3", NULL, "iDisp3 Tx"}, |
| 113 | { "iDisp3 Tx", NULL, "iDisp3_out"}, |
| 114 | { "hifi2", NULL, "iDisp2 Tx"}, |
| 115 | { "iDisp2 Tx", NULL, "iDisp2_out"}, |
| 116 | { "hifi1", NULL, "iDisp1 Tx"}, |
| 117 | { "iDisp1 Tx", NULL, "iDisp1_out"}, |
| 118 | }; |
| 119 | |
| 120 | static struct snd_soc_codec_conf max98927_codec_conf[] = { |
| 121 | { |
| 122 | .dev_name = MAXIM_DEV0_NAME, |
| 123 | .name_prefix = "Right", |
| 124 | }, |
| 125 | { |
| 126 | .dev_name = MAXIM_DEV1_NAME, |
| 127 | .name_prefix = "Left", |
| 128 | }, |
| 129 | }; |
| 130 | |
| 131 | static struct snd_soc_dai_link_component max98927_codec_components[] = { |
| 132 | { /* Left */ |
| 133 | .name = MAXIM_DEV0_NAME, |
| 134 | .dai_name = KBL_MAXIM_CODEC_DAI, |
| 135 | }, |
| 136 | { /* Right */ |
| 137 | .name = MAXIM_DEV1_NAME, |
| 138 | .dai_name = KBL_MAXIM_CODEC_DAI, |
| 139 | }, |
| 140 | }; |
| 141 | |
| 142 | static int kabylake_rt5663_fe_init(struct snd_soc_pcm_runtime *rtd) |
| 143 | { |
| 144 | int ret; |
| 145 | struct snd_soc_dapm_context *dapm; |
| 146 | struct snd_soc_component *component = rtd->cpu_dai->component; |
| 147 | |
| 148 | dapm = snd_soc_component_get_dapm(component); |
| 149 | ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); |
| 150 | if (ret) { |
| 151 | dev_err(rtd->dev, "Ref Cap ignore suspend failed %d\n", ret); |
| 152 | return ret; |
| 153 | } |
| 154 | |
| 155 | return ret; |
| 156 | } |
| 157 | |
| 158 | static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 159 | { |
| 160 | int ret; |
| 161 | struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
| 162 | struct snd_soc_codec *codec = rtd->codec; |
| 163 | |
| 164 | /* |
| 165 | * Headset buttons map to the google Reference headset. |
| 166 | * These can be configured by userspace. |
| 167 | */ |
| 168 | ret = snd_soc_card_jack_new(&kabylake_audio_card, "Headset Jack", |
| 169 | SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
| 170 | SND_JACK_BTN_2 | SND_JACK_BTN_3, &ctx->kabylake_headset, |
| 171 | NULL, 0); |
| 172 | if (ret) { |
| 173 | dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret); |
| 174 | return ret; |
| 175 | } |
| 176 | |
| 177 | rt5663_set_jack_detect(codec, &ctx->kabylake_headset); |
| 178 | ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); |
| 179 | if (ret) { |
| 180 | dev_err(rtd->dev, "SoC DMIC ignore suspend failed %d\n", ret); |
| 181 | return ret; |
| 182 | } |
| 183 | |
| 184 | return ret; |
| 185 | } |
| 186 | |
| 187 | static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) |
| 188 | { |
| 189 | struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
| 190 | struct snd_soc_dai *dai = rtd->codec_dai; |
| 191 | struct kbl_hdmi_pcm *pcm; |
| 192 | |
| 193 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
| 194 | if (!pcm) |
| 195 | return -ENOMEM; |
| 196 | |
| 197 | pcm->device = KBL_DPCM_AUDIO_HDMI1_PB; |
| 198 | pcm->codec_dai = dai; |
| 199 | |
| 200 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) |
| 206 | { |
| 207 | struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
| 208 | struct snd_soc_dai *dai = rtd->codec_dai; |
| 209 | struct kbl_hdmi_pcm *pcm; |
| 210 | |
| 211 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
| 212 | if (!pcm) |
| 213 | return -ENOMEM; |
| 214 | |
| 215 | pcm->device = KBL_DPCM_AUDIO_HDMI2_PB; |
| 216 | pcm->codec_dai = dai; |
| 217 | |
| 218 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
| 219 | |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) |
| 224 | { |
| 225 | struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
| 226 | struct snd_soc_dai *dai = rtd->codec_dai; |
| 227 | struct kbl_hdmi_pcm *pcm; |
| 228 | |
| 229 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
| 230 | if (!pcm) |
| 231 | return -ENOMEM; |
| 232 | |
| 233 | pcm->device = KBL_DPCM_AUDIO_HDMI3_PB; |
| 234 | pcm->codec_dai = dai; |
| 235 | |
| 236 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | static unsigned int rates[] = { |
| 242 | 48000, |
| 243 | }; |
| 244 | |
| 245 | static struct snd_pcm_hw_constraint_list constraints_rates = { |
| 246 | .count = ARRAY_SIZE(rates), |
| 247 | .list = rates, |
| 248 | .mask = 0, |
| 249 | }; |
| 250 | |
| 251 | static unsigned int channels[] = { |
| 252 | 2, |
| 253 | }; |
| 254 | |
| 255 | static struct snd_pcm_hw_constraint_list constraints_channels = { |
| 256 | .count = ARRAY_SIZE(channels), |
| 257 | .list = channels, |
| 258 | .mask = 0, |
| 259 | }; |
| 260 | |
| 261 | static int kbl_fe_startup(struct snd_pcm_substream *substream) |
| 262 | { |
| 263 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 264 | |
| 265 | /* |
| 266 | * On this platform for PCM device we support, |
| 267 | * 48Khz |
| 268 | * stereo |
| 269 | * 16 bit audio |
| 270 | */ |
| 271 | |
| 272 | runtime->hw.channels_max = 2; |
| 273 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
| 274 | &constraints_channels); |
| 275 | |
| 276 | runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; |
| 277 | snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); |
| 278 | |
| 279 | snd_pcm_hw_constraint_list(runtime, 0, |
| 280 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); |
| 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | static const struct snd_soc_ops kabylake_rt5663_fe_ops = { |
| 286 | .startup = kbl_fe_startup, |
| 287 | }; |
| 288 | |
| 289 | static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, |
| 290 | struct snd_pcm_hw_params *params) |
| 291 | { |
| 292 | struct snd_interval *rate = hw_param_interval(params, |
| 293 | SNDRV_PCM_HW_PARAM_RATE); |
| 294 | struct snd_interval *channels = hw_param_interval(params, |
| 295 | SNDRV_PCM_HW_PARAM_CHANNELS); |
| 296 | struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
| 297 | |
| 298 | /* The ADSP will convert the FE rate to 48k, stereo */ |
| 299 | rate->min = rate->max = 48000; |
| 300 | channels->min = channels->max = 2; |
| 301 | /* set SSP1 to 24 bit */ |
| 302 | snd_mask_none(fmt); |
| 303 | snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, |
| 309 | struct snd_pcm_hw_params *params) |
| 310 | { |
| 311 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 312 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 313 | int ret; |
| 314 | |
| 315 | ret = snd_soc_dai_set_sysclk(codec_dai, |
| 316 | RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN); |
| 317 | /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ |
| 318 | rt5663_sel_asrc_clk_src(codec_dai->codec, RT5663_DA_STEREO_FILTER, 1); |
| 319 | |
| 320 | if (ret < 0) |
| 321 | dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); |
| 322 | |
| 323 | return ret; |
| 324 | } |
| 325 | |
| 326 | static struct snd_soc_ops kabylake_rt5663_ops = { |
| 327 | .hw_params = kabylake_rt5663_hw_params, |
| 328 | }; |
| 329 | |
| 330 | static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, |
| 331 | struct snd_pcm_hw_params *params) |
| 332 | { |
| 333 | struct snd_interval *channels = hw_param_interval(params, |
| 334 | SNDRV_PCM_HW_PARAM_CHANNELS); |
| 335 | |
| 336 | if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) |
| 337 | channels->min = channels->max = 2; |
| 338 | else |
| 339 | channels->min = channels->max = 4; |
| 340 | |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | static unsigned int channels_dmic[] = { |
| 345 | 2, 4, |
| 346 | }; |
| 347 | |
| 348 | static struct snd_pcm_hw_constraint_list constraints_dmic_channels = { |
| 349 | .count = ARRAY_SIZE(channels_dmic), |
| 350 | .list = channels_dmic, |
| 351 | .mask = 0, |
| 352 | }; |
| 353 | |
| 354 | static const unsigned int dmic_2ch[] = { |
| 355 | 2, |
| 356 | }; |
| 357 | |
| 358 | static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = { |
| 359 | .count = ARRAY_SIZE(dmic_2ch), |
| 360 | .list = dmic_2ch, |
| 361 | .mask = 0, |
| 362 | }; |
| 363 | |
| 364 | static int kabylake_dmic_startup(struct snd_pcm_substream *substream) |
| 365 | { |
| 366 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 367 | |
| 368 | runtime->hw.channels_max = DMIC_CH(dmic_constraints); |
| 369 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
| 370 | dmic_constraints); |
| 371 | |
| 372 | return snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 373 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); |
| 374 | } |
| 375 | |
| 376 | static struct snd_soc_ops kabylake_dmic_ops = { |
| 377 | .startup = kabylake_dmic_startup, |
| 378 | }; |
| 379 | |
| 380 | static unsigned int rates_16000[] = { |
| 381 | 16000, |
| 382 | }; |
| 383 | |
| 384 | static struct snd_pcm_hw_constraint_list constraints_16000 = { |
| 385 | .count = ARRAY_SIZE(rates_16000), |
| 386 | .list = rates_16000, |
| 387 | }; |
| 388 | |
| 389 | static const unsigned int ch_mono[] = { |
| 390 | 1, |
| 391 | }; |
| 392 | |
| 393 | static const struct snd_pcm_hw_constraint_list constraints_refcap = { |
| 394 | .count = ARRAY_SIZE(ch_mono), |
| 395 | .list = ch_mono, |
| 396 | }; |
| 397 | |
| 398 | static int kabylake_refcap_startup(struct snd_pcm_substream *substream) |
| 399 | { |
| 400 | substream->runtime->hw.channels_max = 1; |
| 401 | snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 402 | SNDRV_PCM_HW_PARAM_CHANNELS, |
| 403 | &constraints_refcap); |
| 404 | |
| 405 | return snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 406 | SNDRV_PCM_HW_PARAM_RATE, |
| 407 | &constraints_16000); |
| 408 | } |
| 409 | |
| 410 | static struct snd_soc_ops skylaye_refcap_ops = { |
| 411 | .startup = kabylake_refcap_startup, |
| 412 | }; |
| 413 | |
| 414 | /* kabylake digital audio interface glue - connects codec <--> CPU */ |
| 415 | static struct snd_soc_dai_link kabylake_dais[] = { |
| 416 | /* Front End DAI links */ |
| 417 | [KBL_DPCM_AUDIO_PB] = { |
| 418 | .name = "Kbl Audio Port", |
| 419 | .stream_name = "Audio", |
| 420 | .cpu_dai_name = "System Pin", |
| 421 | .platform_name = "0000:00:1f.3", |
| 422 | .dynamic = 1, |
| 423 | .codec_name = "snd-soc-dummy", |
| 424 | .codec_dai_name = "snd-soc-dummy-dai", |
| 425 | .nonatomic = 1, |
| 426 | .init = kabylake_rt5663_fe_init, |
| 427 | .trigger = { |
| 428 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 429 | .dpcm_playback = 1, |
| 430 | .ops = &kabylake_rt5663_fe_ops, |
| 431 | }, |
| 432 | [KBL_DPCM_AUDIO_CP] = { |
| 433 | .name = "Kbl Audio Capture Port", |
| 434 | .stream_name = "Audio Record", |
| 435 | .cpu_dai_name = "System Pin", |
| 436 | .platform_name = "0000:00:1f.3", |
| 437 | .dynamic = 1, |
| 438 | .codec_name = "snd-soc-dummy", |
| 439 | .codec_dai_name = "snd-soc-dummy-dai", |
| 440 | .nonatomic = 1, |
| 441 | .trigger = { |
| 442 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 443 | .dpcm_capture = 1, |
| 444 | .ops = &kabylake_rt5663_fe_ops, |
| 445 | }, |
| 446 | [KBL_DPCM_AUDIO_REF_CP] = { |
| 447 | .name = "Kbl Audio Reference cap", |
| 448 | .stream_name = "Wake on Voice", |
| 449 | .cpu_dai_name = "Reference Pin", |
| 450 | .codec_name = "snd-soc-dummy", |
| 451 | .codec_dai_name = "snd-soc-dummy-dai", |
| 452 | .platform_name = "0000:00:1f.3", |
| 453 | .init = NULL, |
| 454 | .dpcm_capture = 1, |
| 455 | .nonatomic = 1, |
| 456 | .dynamic = 1, |
| 457 | .ops = &skylaye_refcap_ops, |
| 458 | }, |
| 459 | [KBL_DPCM_AUDIO_DMIC_CP] = { |
| 460 | .name = "Kbl Audio DMIC cap", |
| 461 | .stream_name = "dmiccap", |
| 462 | .cpu_dai_name = "DMIC Pin", |
| 463 | .codec_name = "snd-soc-dummy", |
| 464 | .codec_dai_name = "snd-soc-dummy-dai", |
| 465 | .platform_name = "0000:00:1f.3", |
| 466 | .init = NULL, |
| 467 | .dpcm_capture = 1, |
| 468 | .nonatomic = 1, |
| 469 | .dynamic = 1, |
| 470 | .ops = &kabylake_dmic_ops, |
| 471 | }, |
| 472 | [KBL_DPCM_AUDIO_HDMI1_PB] = { |
| 473 | .name = "Kbl HDMI Port1", |
| 474 | .stream_name = "Hdmi1", |
| 475 | .cpu_dai_name = "HDMI1 Pin", |
| 476 | .codec_name = "snd-soc-dummy", |
| 477 | .codec_dai_name = "snd-soc-dummy-dai", |
| 478 | .platform_name = "0000:00:1f.3", |
| 479 | .dpcm_playback = 1, |
| 480 | .init = NULL, |
| 481 | .trigger = { |
| 482 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 483 | .nonatomic = 1, |
| 484 | .dynamic = 1, |
| 485 | }, |
| 486 | [KBL_DPCM_AUDIO_HDMI2_PB] = { |
| 487 | .name = "Kbl HDMI Port2", |
| 488 | .stream_name = "Hdmi2", |
| 489 | .cpu_dai_name = "HDMI2 Pin", |
| 490 | .codec_name = "snd-soc-dummy", |
| 491 | .codec_dai_name = "snd-soc-dummy-dai", |
| 492 | .platform_name = "0000:00:1f.3", |
| 493 | .dpcm_playback = 1, |
| 494 | .init = NULL, |
| 495 | .trigger = { |
| 496 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 497 | .nonatomic = 1, |
| 498 | .dynamic = 1, |
| 499 | }, |
| 500 | [KBL_DPCM_AUDIO_HDMI3_PB] = { |
| 501 | .name = "Kbl HDMI Port3", |
| 502 | .stream_name = "Hdmi3", |
| 503 | .cpu_dai_name = "HDMI3 Pin", |
| 504 | .codec_name = "snd-soc-dummy", |
| 505 | .codec_dai_name = "snd-soc-dummy-dai", |
| 506 | .platform_name = "0000:00:1f.3", |
| 507 | .trigger = { |
| 508 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 509 | .dpcm_playback = 1, |
| 510 | .init = NULL, |
| 511 | .nonatomic = 1, |
| 512 | .dynamic = 1, |
| 513 | }, |
| 514 | |
| 515 | /* Back End DAI links */ |
| 516 | { |
| 517 | /* SSP0 - Codec */ |
| 518 | .name = "SSP0-Codec", |
| 519 | .id = 0, |
| 520 | .cpu_dai_name = "SSP0 Pin", |
| 521 | .platform_name = "0000:00:1f.3", |
| 522 | .no_pcm = 1, |
| 523 | .codecs = max98927_codec_components, |
| 524 | .num_codecs = ARRAY_SIZE(max98927_codec_components), |
| 525 | .dai_fmt = SND_SOC_DAIFMT_I2S | |
| 526 | SND_SOC_DAIFMT_NB_NF | |
| 527 | SND_SOC_DAIFMT_CBS_CFS, |
| 528 | .ignore_pmdown_time = 1, |
| 529 | .be_hw_params_fixup = kabylake_ssp_fixup, |
| 530 | .dpcm_playback = 1, |
| 531 | }, |
| 532 | { |
| 533 | /* SSP1 - Codec */ |
| 534 | .name = "SSP1-Codec", |
| 535 | .id = 1, |
| 536 | .cpu_dai_name = "SSP1 Pin", |
| 537 | .platform_name = "0000:00:1f.3", |
| 538 | .no_pcm = 1, |
| 539 | .codec_name = "i2c-10EC5663:00", |
| 540 | .codec_dai_name = KBL_REALTEK_CODEC_DAI, |
| 541 | .init = kabylake_rt5663_codec_init, |
| 542 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 543 | SND_SOC_DAIFMT_CBS_CFS, |
| 544 | .ignore_pmdown_time = 1, |
| 545 | .be_hw_params_fixup = kabylake_ssp_fixup, |
| 546 | .ops = &kabylake_rt5663_ops, |
| 547 | .dpcm_playback = 1, |
| 548 | .dpcm_capture = 1, |
| 549 | }, |
| 550 | { |
| 551 | .name = "dmic01", |
| 552 | .id = 2, |
| 553 | .cpu_dai_name = "DMIC01 Pin", |
| 554 | .codec_name = "dmic-codec", |
| 555 | .codec_dai_name = "dmic-hifi", |
| 556 | .platform_name = "0000:00:1f.3", |
| 557 | .be_hw_params_fixup = kabylake_dmic_fixup, |
| 558 | .ignore_suspend = 1, |
| 559 | .dpcm_capture = 1, |
| 560 | .no_pcm = 1, |
| 561 | }, |
| 562 | { |
| 563 | .name = "iDisp1", |
| 564 | .id = 3, |
| 565 | .cpu_dai_name = "iDisp1 Pin", |
| 566 | .codec_name = "ehdaudio0D2", |
| 567 | .codec_dai_name = "intel-hdmi-hifi1", |
| 568 | .platform_name = "0000:00:1f.3", |
| 569 | .dpcm_playback = 1, |
| 570 | .init = kabylake_hdmi1_init, |
| 571 | .no_pcm = 1, |
| 572 | }, |
| 573 | { |
| 574 | .name = "iDisp2", |
| 575 | .id = 4, |
| 576 | .cpu_dai_name = "iDisp2 Pin", |
| 577 | .codec_name = "ehdaudio0D2", |
| 578 | .codec_dai_name = "intel-hdmi-hifi2", |
| 579 | .platform_name = "0000:00:1f.3", |
| 580 | .init = kabylake_hdmi2_init, |
| 581 | .dpcm_playback = 1, |
| 582 | .no_pcm = 1, |
| 583 | }, |
| 584 | { |
| 585 | .name = "iDisp3", |
| 586 | .id = 5, |
| 587 | .cpu_dai_name = "iDisp3 Pin", |
| 588 | .codec_name = "ehdaudio0D2", |
| 589 | .codec_dai_name = "intel-hdmi-hifi3", |
| 590 | .platform_name = "0000:00:1f.3", |
| 591 | .init = kabylake_hdmi3_init, |
| 592 | .dpcm_playback = 1, |
| 593 | .no_pcm = 1, |
| 594 | }, |
| 595 | }; |
| 596 | |
| 597 | #define NAME_SIZE 32 |
| 598 | static int kabylake_card_late_probe(struct snd_soc_card *card) |
| 599 | { |
| 600 | struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card); |
| 601 | struct kbl_hdmi_pcm *pcm; |
| 602 | int err, i = 0; |
| 603 | char jack_name[NAME_SIZE]; |
| 604 | |
| 605 | list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { |
| 606 | snprintf(jack_name, sizeof(jack_name), |
| 607 | "HDMI/DP, pcm=%d Jack", pcm->device); |
| 608 | err = snd_soc_card_jack_new(card, jack_name, |
| 609 | SND_JACK_AVOUT, &skylake_hdmi[i], |
| 610 | NULL, 0); |
| 611 | |
| 612 | if (err) |
| 613 | return err; |
| 614 | |
| 615 | err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, |
| 616 | &skylake_hdmi[i]); |
| 617 | if (err < 0) |
| 618 | return err; |
| 619 | |
| 620 | i++; |
| 621 | } |
| 622 | |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | /* kabylake audio machine driver for SPT + RT5663 */ |
| 627 | static struct snd_soc_card kabylake_audio_card = { |
| 628 | .name = "kblrt5663max", |
| 629 | .owner = THIS_MODULE, |
| 630 | .dai_link = kabylake_dais, |
| 631 | .num_links = ARRAY_SIZE(kabylake_dais), |
| 632 | .controls = kabylake_controls, |
| 633 | .num_controls = ARRAY_SIZE(kabylake_controls), |
| 634 | .dapm_widgets = kabylake_widgets, |
| 635 | .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets), |
| 636 | .dapm_routes = kabylake_map, |
| 637 | .num_dapm_routes = ARRAY_SIZE(kabylake_map), |
| 638 | .codec_conf = max98927_codec_conf, |
| 639 | .num_configs = ARRAY_SIZE(max98927_codec_conf), |
| 640 | .fully_routed = true, |
| 641 | .late_probe = kabylake_card_late_probe, |
| 642 | }; |
| 643 | |
| 644 | static int kabylake_audio_probe(struct platform_device *pdev) |
| 645 | { |
| 646 | struct kbl_rt5663_private *ctx; |
| 647 | struct skl_machine_pdata *pdata; |
| 648 | |
| 649 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); |
| 650 | if (!ctx) |
| 651 | return -ENOMEM; |
| 652 | |
| 653 | INIT_LIST_HEAD(&ctx->hdmi_pcm_list); |
| 654 | |
| 655 | kabylake_audio_card.dev = &pdev->dev; |
| 656 | snd_soc_card_set_drvdata(&kabylake_audio_card, ctx); |
| 657 | |
| 658 | pdata = dev_get_drvdata(&pdev->dev); |
| 659 | if (pdata) |
| 660 | dmic_constraints = pdata->dmic_num == 2 ? |
| 661 | &constraints_dmic_2ch : &constraints_dmic_channels; |
| 662 | |
| 663 | return devm_snd_soc_register_card(&pdev->dev, &kabylake_audio_card); |
| 664 | } |
| 665 | |
| 666 | static const struct platform_device_id kbl_board_ids[] = { |
| 667 | { .name = "kbl_rt5663_m98927" }, |
| 668 | { } |
| 669 | }; |
| 670 | |
| 671 | static struct platform_driver kabylake_audio = { |
| 672 | .probe = kabylake_audio_probe, |
| 673 | .driver = { |
| 674 | .name = "kbl_rt5663_m98927", |
| 675 | .pm = &snd_soc_pm_ops, |
| 676 | }, |
| 677 | .id_table = kbl_board_ids, |
| 678 | }; |
| 679 | |
| 680 | module_platform_driver(kabylake_audio) |
| 681 | |
| 682 | /* Module information */ |
| 683 | MODULE_DESCRIPTION("Audio Machine driver-RT5663 & MAX98927 in I2S mode"); |
| 684 | MODULE_AUTHOR("Naveen M <naveen.m@intel.com>"); |
| 685 | MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>"); |
| 686 | MODULE_LICENSE("GPL v2"); |
| 687 | MODULE_ALIAS("platform:kbl_rt5663_m98927"); |