root/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. kabylake_rt5663_fe_init
  2. kabylake_rt5663_codec_init
  3. kabylake_hdmi_init
  4. kabylake_hdmi1_init
  5. kabylake_hdmi2_init
  6. kbl_fe_startup
  7. kabylake_ssp_fixup
  8. kabylake_rt5663_hw_params
  9. kabylake_ssp0_hw_params
  10. kabylake_dmic_startup
  11. kabylake_card_late_probe
  12. kabylake_audio_probe

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

/* [<][>][^][v][top][bottom][index][help] */