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

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

DEFINITIONS

This source file includes following definitions.
  1. platform_clock_control
  2. kabylake_ssp0_hw_params
  3. kabylake_ssp0_trigger
  4. kabylake_ssp_fixup
  5. kabylake_da7219_codec_init
  6. kabylake_dmic_init
  7. kabylake_hdmi_init
  8. kabylake_hdmi1_init
  9. kabylake_hdmi2_init
  10. kabylake_hdmi3_init
  11. kabylake_da7219_fe_init
  12. kbl_fe_startup
  13. kabylake_dmic_fixup
  14. kabylake_dmic_startup
  15. kabylake_refcap_startup
  16. kabylake_card_late_probe
  17. kabylake_audio_probe

   1 // SPDX-License-Identifier: GPL-2.0
   2 // Copyright(c) 2018 Intel Corporation.
   3 
   4 /*
   5  * Intel Kabylake I2S Machine Driver with MAX98927, MAX98373 & DA7219 Codecs
   6  *
   7  * Modified from:
   8  *   Intel Kabylake I2S Machine driver supporting MAX98927 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 MAX98927_CODEC_DAI      "max98927-aif1"
  26 #define MAX98927_DEV0_NAME      "i2c-MX98927:00"
  27 #define MAX98927_DEV1_NAME      "i2c-MX98927:01"
  28 
  29 #define MAX98373_CODEC_DAI      "max98373-aif1"
  30 #define MAX98373_DEV0_NAME      "i2c-MX98373:00"
  31 #define MAX98373_DEV1_NAME      "i2c-MX98373:01"
  32 
  33 
  34 #define DUAL_CHANNEL    2
  35 #define QUAD_CHANNEL    4
  36 #define NAME_SIZE       32
  37 
  38 static struct snd_soc_card *kabylake_audio_card;
  39 static struct snd_soc_jack kabylake_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_codec_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_ECHO_REF_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         KBL_DPCM_AUDIO_HS_PB,
  61         KBL_DPCM_AUDIO_CP,
  62 };
  63 
  64 static int platform_clock_control(struct snd_soc_dapm_widget *w,
  65                                         struct snd_kcontrol *k, int  event)
  66 {
  67         struct snd_soc_dapm_context *dapm = w->dapm;
  68         struct snd_soc_card *card = dapm->card;
  69         struct snd_soc_dai *codec_dai;
  70         int ret = 0;
  71 
  72         codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI);
  73         if (!codec_dai) {
  74                 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
  75                 return -EIO;
  76         }
  77 
  78         /* Configure sysclk for codec */
  79         ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000,
  80                                      SND_SOC_CLOCK_IN);
  81         if (ret) {
  82                 dev_err(card->dev, "can't set codec sysclk configuration\n");
  83                 return ret;
  84         }
  85 
  86         if (SND_SOC_DAPM_EVENT_OFF(event)) {
  87                 ret = snd_soc_dai_set_pll(codec_dai, 0,
  88                                      DA7219_SYSCLK_MCLK, 0, 0);
  89                 if (ret)
  90                         dev_err(card->dev, "failed to stop PLL: %d\n", ret);
  91         } else if (SND_SOC_DAPM_EVENT_ON(event)) {
  92                 ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM,
  93                                      0, DA7219_PLL_FREQ_OUT_98304);
  94                 if (ret)
  95                         dev_err(card->dev, "failed to start PLL: %d\n", ret);
  96         }
  97 
  98         return ret;
  99 }
 100 
 101 static const struct snd_kcontrol_new kabylake_controls[] = {
 102         SOC_DAPM_PIN_SWITCH("Headphone Jack"),
 103         SOC_DAPM_PIN_SWITCH("Headset Mic"),
 104         SOC_DAPM_PIN_SWITCH("Left Spk"),
 105         SOC_DAPM_PIN_SWITCH("Right Spk"),
 106 };
 107 
 108 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
 109         SND_SOC_DAPM_HP("Headphone Jack", NULL),
 110         SND_SOC_DAPM_MIC("Headset Mic", NULL),
 111         SND_SOC_DAPM_SPK("Left Spk", NULL),
 112         SND_SOC_DAPM_SPK("Right Spk", NULL),
 113         SND_SOC_DAPM_MIC("SoC DMIC", NULL),
 114         SND_SOC_DAPM_SPK("DP", NULL),
 115         SND_SOC_DAPM_SPK("HDMI", NULL),
 116         SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
 117                         platform_clock_control, SND_SOC_DAPM_PRE_PMU |
 118                         SND_SOC_DAPM_POST_PMD),
 119 };
 120 
 121 static const struct snd_soc_dapm_route kabylake_map[] = {
 122         /* speaker */
 123         { "Left Spk", NULL, "Left BE_OUT" },
 124         { "Right Spk", NULL, "Right BE_OUT" },
 125 
 126         /* other jacks */
 127         { "DMic", NULL, "SoC DMIC" },
 128 
 129         { "HDMI", NULL, "hif5 Output" },
 130         { "DP", NULL, "hif6 Output" },
 131 
 132         /* CODEC BE connections */
 133         { "Left HiFi Playback", NULL, "ssp0 Tx" },
 134         { "Right HiFi Playback", NULL, "ssp0 Tx" },
 135         { "ssp0 Tx", NULL, "spk_out" },
 136 
 137         /* IV feedback path */
 138         { "codec0_fb_in", NULL, "ssp0 Rx"},
 139         { "ssp0 Rx", NULL, "Left HiFi Capture" },
 140         { "ssp0 Rx", NULL, "Right HiFi Capture" },
 141 
 142         /* AEC capture path */
 143         { "echo_ref_out", NULL, "ssp0 Rx" },
 144 
 145         /* DMIC */
 146         { "dmic01_hifi", NULL, "DMIC01 Rx" },
 147         { "DMIC01 Rx", NULL, "DMIC AIF" },
 148 
 149         { "hifi1", NULL, "iDisp1 Tx" },
 150         { "iDisp1 Tx", NULL, "iDisp1_out" },
 151         { "hifi2", NULL, "iDisp2 Tx" },
 152         { "iDisp2 Tx", NULL, "iDisp2_out" },
 153         { "hifi3", NULL, "iDisp3 Tx"},
 154         { "iDisp3 Tx", NULL, "iDisp3_out"},
 155 };
 156 
 157 static const struct snd_soc_dapm_route kabylake_ssp1_map[] = {
 158         { "Headphone Jack", NULL, "HPL" },
 159         { "Headphone Jack", NULL, "HPR" },
 160 
 161         /* other jacks */
 162         { "MIC", NULL, "Headset Mic" },
 163 
 164         /* CODEC BE connections */
 165         { "Playback", NULL, "ssp1 Tx" },
 166         { "ssp1 Tx", NULL, "codec1_out" },
 167 
 168         { "hs_in", NULL, "ssp1 Rx" },
 169         { "ssp1 Rx", NULL, "Capture" },
 170 
 171         { "Headphone Jack", NULL, "Platform Clock" },
 172         { "Headset Mic", NULL, "Platform Clock" },
 173 };
 174 
 175 static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
 176         struct snd_pcm_hw_params *params)
 177 {
 178         struct snd_soc_pcm_runtime *runtime = substream->private_data;
 179         int ret = 0, j;
 180 
 181         for (j = 0; j < runtime->num_codecs; j++) {
 182                 struct snd_soc_dai *codec_dai = runtime->codec_dais[j];
 183 
 184                 if (!strcmp(codec_dai->component->name, MAX98927_DEV0_NAME)) {
 185                         ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
 186                         if (ret < 0) {
 187                                 dev_err(runtime->dev, "DEV0 TDM slot err:%d\n", ret);
 188                                 return ret;
 189                         }
 190                 }
 191                 if (!strcmp(codec_dai->component->name, MAX98927_DEV1_NAME)) {
 192                         ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16);
 193                         if (ret < 0) {
 194                                 dev_err(runtime->dev, "DEV1 TDM slot err:%d\n", ret);
 195                                 return ret;
 196                         }
 197                 }
 198                 if (!strcmp(codec_dai->component->name, MAX98373_DEV0_NAME)) {
 199                         ret = snd_soc_dai_set_tdm_slot(codec_dai,
 200                                                         0x03, 3, 8, 24);
 201                         if (ret < 0) {
 202                                 dev_err(runtime->dev,
 203                                                 "DEV0 TDM slot err:%d\n", ret);
 204                                 return ret;
 205                         }
 206                 }
 207                 if (!strcmp(codec_dai->component->name, MAX98373_DEV1_NAME)) {
 208                         ret = snd_soc_dai_set_tdm_slot(codec_dai,
 209                                                         0x0C, 3, 8, 24);
 210                         if (ret < 0) {
 211                                 dev_err(runtime->dev,
 212                                                 "DEV0 TDM slot err:%d\n", ret);
 213                                 return ret;
 214                         }
 215                 }
 216         }
 217 
 218         return 0;
 219 }
 220 
 221 static int kabylake_ssp0_trigger(struct snd_pcm_substream *substream, int cmd)
 222 {
 223         struct snd_soc_pcm_runtime *rtd = substream->private_data;
 224         int j, ret;
 225 
 226         for (j = 0; j < rtd->num_codecs; j++) {
 227                 struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
 228                 const char *name = codec_dai->component->name;
 229                 struct snd_soc_component *component = codec_dai->component;
 230                 struct snd_soc_dapm_context *dapm =
 231                                 snd_soc_component_get_dapm(component);
 232                 char pin_name[20];
 233 
 234                 if (strcmp(name, MAX98927_DEV0_NAME) &&
 235                         strcmp(name, MAX98927_DEV1_NAME) &&
 236                         strcmp(name, MAX98373_DEV0_NAME) &&
 237                         strcmp(name, MAX98373_DEV1_NAME))
 238                         continue;
 239 
 240                 snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk",
 241                         codec_dai->component->name_prefix);
 242 
 243                 switch (cmd) {
 244                 case SNDRV_PCM_TRIGGER_START:
 245                 case SNDRV_PCM_TRIGGER_RESUME:
 246                 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
 247                         ret = snd_soc_dapm_enable_pin(dapm, pin_name);
 248                         if (ret) {
 249                                 dev_err(rtd->dev, "failed to enable %s: %d\n",
 250                                 pin_name, ret);
 251                                 return ret;
 252                         }
 253                         snd_soc_dapm_sync(dapm);
 254                         break;
 255                 case SNDRV_PCM_TRIGGER_STOP:
 256                 case SNDRV_PCM_TRIGGER_SUSPEND:
 257                 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
 258                         ret = snd_soc_dapm_disable_pin(dapm, pin_name);
 259                         if (ret) {
 260                                 dev_err(rtd->dev, "failed to disable %s: %d\n",
 261                                 pin_name, ret);
 262                                 return ret;
 263                         }
 264                         snd_soc_dapm_sync(dapm);
 265                         break;
 266                 }
 267         }
 268 
 269         return 0;
 270 }
 271 
 272 static struct snd_soc_ops kabylake_ssp0_ops = {
 273         .hw_params = kabylake_ssp0_hw_params,
 274         .trigger = kabylake_ssp0_trigger,
 275 };
 276 
 277 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 278                         struct snd_pcm_hw_params *params)
 279 {
 280         struct snd_interval *rate = hw_param_interval(params,
 281                         SNDRV_PCM_HW_PARAM_RATE);
 282         struct snd_interval *channels = hw_param_interval(params,
 283                         SNDRV_PCM_HW_PARAM_CHANNELS);
 284         struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
 285         struct snd_soc_dpcm *dpcm = container_of(
 286                         params, struct snd_soc_dpcm, hw_params);
 287         struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
 288         struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
 289 
 290         /*
 291          * Topology for kblda7219m98373 & kblmax98373 supports only S24_LE,
 292          * where as kblda7219m98927 & kblmax98927 supports S16_LE by default.
 293          * Skipping the port wise FE and BE configuration for kblda7219m98373 &
 294          * kblmax98373 as the topology (FE & BE) supports S24_LE only.
 295          */
 296 
 297         if (!strcmp(rtd->card->name, "kblda7219m98373") ||
 298                 !strcmp(rtd->card->name, "kblmax98373")) {
 299                 /* The ADSP will convert the FE rate to 48k, stereo */
 300                 rate->min = rate->max = 48000;
 301                 channels->min = channels->max = DUAL_CHANNEL;
 302 
 303                 /* set SSP to 24 bit */
 304                 snd_mask_none(fmt);
 305                 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 306                 return 0;
 307         }
 308 
 309         /*
 310          * The ADSP will convert the FE rate to 48k, stereo, 24 bit
 311          */
 312         if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
 313             !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
 314             !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
 315                 rate->min = rate->max = 48000;
 316                 channels->min = channels->max = 2;
 317                 snd_mask_none(fmt);
 318                 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 319         }
 320 
 321         /*
 322          * The speaker on the SSP0 supports S16_LE and not S24_LE.
 323          * thus changing the mask here
 324          */
 325         if (!strcmp(be_dai_link->name, "SSP0-Codec"))
 326                 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
 327 
 328         return 0;
 329 }
 330 
 331 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
 332 {
 333         struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
 334         struct snd_soc_component *component = rtd->codec_dai->component;
 335         struct snd_soc_jack *jack;
 336         struct snd_soc_card *card = rtd->card;
 337         int ret;
 338 
 339 
 340         ret = snd_soc_dapm_add_routes(&card->dapm,
 341                         kabylake_ssp1_map,
 342                         ARRAY_SIZE(kabylake_ssp1_map));
 343 
 344         /*
 345          * Headset buttons map to the google Reference headset.
 346          * These can be configured by userspace.
 347          */
 348         ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
 349                         SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
 350                         SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
 351                         &ctx->kabylake_headset, NULL, 0);
 352         if (ret) {
 353                 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
 354                 return ret;
 355         }
 356 
 357         jack = &ctx->kabylake_headset;
 358         snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
 359         snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
 360         snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
 361         snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
 362 
 363         da7219_aad_jack_det(component, &ctx->kabylake_headset);
 364 
 365         return 0;
 366 }
 367 
 368 static int kabylake_dmic_init(struct snd_soc_pcm_runtime *rtd)
 369 {
 370         int ret;
 371         ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
 372         if (ret)
 373                 dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
 374 
 375         return ret;
 376 }
 377 
 378 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
 379 {
 380         struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
 381         struct snd_soc_dai *dai = rtd->codec_dai;
 382         struct kbl_hdmi_pcm *pcm;
 383 
 384         pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
 385         if (!pcm)
 386                 return -ENOMEM;
 387 
 388         pcm->device = device;
 389         pcm->codec_dai = dai;
 390 
 391         list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
 392 
 393         return 0;
 394 }
 395 
 396 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
 397 {
 398         return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
 399 }
 400 
 401 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
 402 {
 403         return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
 404 }
 405 
 406 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
 407 {
 408         return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
 409 }
 410 
 411 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
 412 {
 413         struct snd_soc_dapm_context *dapm;
 414         struct snd_soc_component *component = rtd->cpu_dai->component;
 415 
 416         dapm = snd_soc_component_get_dapm(component);
 417         snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
 418 
 419         return 0;
 420 }
 421 
 422 static const unsigned int rates[] = {
 423         48000,
 424 };
 425 
 426 static const struct snd_pcm_hw_constraint_list constraints_rates = {
 427         .count = ARRAY_SIZE(rates),
 428         .list  = rates,
 429         .mask = 0,
 430 };
 431 
 432 static const unsigned int channels[] = {
 433         DUAL_CHANNEL,
 434 };
 435 
 436 static const struct snd_pcm_hw_constraint_list constraints_channels = {
 437         .count = ARRAY_SIZE(channels),
 438         .list = channels,
 439         .mask = 0,
 440 };
 441 
 442 static unsigned int channels_quad[] = {
 443         QUAD_CHANNEL,
 444 };
 445 
 446 static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
 447         .count = ARRAY_SIZE(channels_quad),
 448         .list = channels_quad,
 449         .mask = 0,
 450 };
 451 
 452 static int kbl_fe_startup(struct snd_pcm_substream *substream)
 453 {
 454         struct snd_pcm_runtime *runtime = substream->runtime;
 455         struct snd_soc_pcm_runtime *soc_rt = substream->private_data;
 456 
 457         /*
 458          * On this platform for PCM device we support,
 459          * 48Khz
 460          * stereo
 461          */
 462 
 463         runtime->hw.channels_max = DUAL_CHANNEL;
 464         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
 465                                            &constraints_channels);
 466         /*
 467          * Setup S24_LE (32 bit container and 24 bit valid data) for
 468          * kblda7219m98373 & kblmax98373. For kblda7219m98927 &
 469          * kblmax98927 keeping it as 16/16 due to topology FW dependency.
 470          */
 471         if (!strcmp(soc_rt->card->name, "kblda7219m98373") ||
 472                 !strcmp(soc_rt->card->name, "kblmax98373")) {
 473                 runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_LE;
 474                 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
 475 
 476         } else {
 477                 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
 478                 snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
 479         }
 480 
 481         snd_pcm_hw_constraint_list(runtime, 0,
 482                                 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 483 
 484         return 0;
 485 }
 486 
 487 static const struct snd_soc_ops kabylake_da7219_fe_ops = {
 488         .startup = kbl_fe_startup,
 489 };
 490 
 491 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
 492                 struct snd_pcm_hw_params *params)
 493 {
 494         struct snd_interval *channels = hw_param_interval(params,
 495                                 SNDRV_PCM_HW_PARAM_CHANNELS);
 496 
 497         /*
 498          * set BE channel constraint as user FE channels
 499          */
 500 
 501         if (params_channels(params) == 2)
 502                 channels->min = channels->max = 2;
 503         else
 504                 channels->min = channels->max = 4;
 505 
 506         return 0;
 507 }
 508 
 509 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
 510 {
 511         struct snd_pcm_runtime *runtime = substream->runtime;
 512         struct snd_soc_pcm_runtime *soc_rt = substream->private_data;
 513 
 514         runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
 515         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
 516                         &constraints_channels_quad);
 517 
 518         /*
 519          * Topology for kblda7219m98373 & kblmax98373 supports only S24_LE.
 520          * The DMIC also configured for S24_LE. Forcing the DMIC format to
 521          * S24_LE due to the topology FW dependency.
 522          */
 523         if (!strcmp(soc_rt->card->name, "kblda7219m98373") ||
 524                 !strcmp(soc_rt->card->name, "kblmax98373")) {
 525                 runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_LE;
 526                 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
 527         }
 528 
 529         return snd_pcm_hw_constraint_list(substream->runtime, 0,
 530                         SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 531 }
 532 
 533 static struct snd_soc_ops kabylake_dmic_ops = {
 534         .startup = kabylake_dmic_startup,
 535 };
 536 
 537 static const unsigned int rates_16000[] = {
 538         16000,
 539 };
 540 
 541 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
 542         .count = ARRAY_SIZE(rates_16000),
 543         .list  = rates_16000,
 544 };
 545 
 546 static const unsigned int ch_mono[] = {
 547         1,
 548 };
 549 static const struct snd_pcm_hw_constraint_list constraints_refcap = {
 550         .count = ARRAY_SIZE(ch_mono),
 551         .list  = ch_mono,
 552 };
 553 
 554 static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
 555 {
 556         substream->runtime->hw.channels_max = 1;
 557         snd_pcm_hw_constraint_list(substream->runtime, 0,
 558                                         SNDRV_PCM_HW_PARAM_CHANNELS,
 559                                         &constraints_refcap);
 560 
 561         return snd_pcm_hw_constraint_list(substream->runtime, 0,
 562                                 SNDRV_PCM_HW_PARAM_RATE,
 563                                 &constraints_16000);
 564 }
 565 
 566 
 567 static struct snd_soc_ops skylake_refcap_ops = {
 568         .startup = kabylake_refcap_startup,
 569 };
 570 
 571 static struct snd_soc_codec_conf max98927_codec_conf[] = {
 572 
 573         {
 574                 .dev_name = MAX98927_DEV0_NAME,
 575                 .name_prefix = "Right",
 576         },
 577 
 578         {
 579                 .dev_name = MAX98927_DEV1_NAME,
 580                 .name_prefix = "Left",
 581         },
 582 };
 583 
 584 static struct snd_soc_codec_conf max98373_codec_conf[] = {
 585 
 586         {
 587                 .dev_name = MAX98373_DEV0_NAME,
 588                 .name_prefix = "Right",
 589         },
 590 
 591         {
 592                 .dev_name = MAX98373_DEV1_NAME,
 593                 .name_prefix = "Left",
 594         },
 595 };
 596 
 597 static struct snd_soc_dai_link_component max98373_ssp0_codec_components[] = {
 598         { /* Left */
 599                 .name = MAX98373_DEV0_NAME,
 600                 .dai_name = MAX98373_CODEC_DAI,
 601         },
 602 
 603         {  /* For Right */
 604                 .name = MAX98373_DEV1_NAME,
 605                 .dai_name = MAX98373_CODEC_DAI,
 606         },
 607 
 608 };
 609 
 610 SND_SOC_DAILINK_DEF(dummy,
 611         DAILINK_COMP_ARRAY(COMP_DUMMY()));
 612 
 613 SND_SOC_DAILINK_DEF(system,
 614         DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
 615 
 616 SND_SOC_DAILINK_DEF(echoref,
 617         DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin")));
 618 
 619 SND_SOC_DAILINK_DEF(reference,
 620         DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
 621 
 622 SND_SOC_DAILINK_DEF(dmic,
 623         DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
 624 
 625 SND_SOC_DAILINK_DEF(hdmi1,
 626         DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
 627 
 628 SND_SOC_DAILINK_DEF(hdmi2,
 629         DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
 630 
 631 SND_SOC_DAILINK_DEF(hdmi3,
 632         DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
 633 
 634 SND_SOC_DAILINK_DEF(system2,
 635         DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
 636 
 637 SND_SOC_DAILINK_DEF(ssp0_pin,
 638         DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
 639 SND_SOC_DAILINK_DEF(ssp0_codec,
 640         DAILINK_COMP_ARRAY(
 641         /* Left */      COMP_CODEC(MAX98927_DEV0_NAME, MAX98927_CODEC_DAI),
 642         /* For Right */ COMP_CODEC(MAX98927_DEV1_NAME, MAX98927_CODEC_DAI)));
 643 
 644 SND_SOC_DAILINK_DEF(ssp1_pin,
 645         DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
 646 SND_SOC_DAILINK_DEF(ssp1_codec,
 647         DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
 648                                       KBL_DIALOG_CODEC_DAI)));
 649 
 650 SND_SOC_DAILINK_DEF(dmic_pin,
 651         DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
 652 SND_SOC_DAILINK_DEF(dmic_codec,
 653         DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
 654 
 655 SND_SOC_DAILINK_DEF(idisp1_pin,
 656         DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
 657 SND_SOC_DAILINK_DEF(idisp1_codec,
 658         DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
 659 
 660 SND_SOC_DAILINK_DEF(idisp2_pin,
 661         DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
 662 SND_SOC_DAILINK_DEF(idisp2_codec,
 663         DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
 664 
 665 SND_SOC_DAILINK_DEF(idisp3_pin,
 666         DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
 667 SND_SOC_DAILINK_DEF(idisp3_codec,
 668         DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
 669 
 670 SND_SOC_DAILINK_DEF(platform,
 671         DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
 672 
 673 /* kabylake digital audio interface glue - connects codec <--> CPU */
 674 static struct snd_soc_dai_link kabylake_dais[] = {
 675         /* Front End DAI links */
 676         [KBL_DPCM_AUDIO_PB] = {
 677                 .name = "Kbl Audio Port",
 678                 .stream_name = "Audio",
 679                 .dynamic = 1,
 680                 .nonatomic = 1,
 681                 .init = kabylake_da7219_fe_init,
 682                 .trigger = {
 683                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 684                 .dpcm_playback = 1,
 685                 .ops = &kabylake_da7219_fe_ops,
 686                 SND_SOC_DAILINK_REG(system, dummy, platform),
 687         },
 688         [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
 689                 .name = "Kbl Audio Echo Reference cap",
 690                 .stream_name = "Echoreference Capture",
 691                 .init = NULL,
 692                 .capture_only = 1,
 693                 .nonatomic = 1,
 694                 SND_SOC_DAILINK_REG(echoref, dummy, platform),
 695         },
 696         [KBL_DPCM_AUDIO_REF_CP] = {
 697                 .name = "Kbl Audio Reference cap",
 698                 .stream_name = "Wake on Voice",
 699                 .init = NULL,
 700                 .dpcm_capture = 1,
 701                 .nonatomic = 1,
 702                 .dynamic = 1,
 703                 .ops = &skylake_refcap_ops,
 704                 SND_SOC_DAILINK_REG(reference, dummy, platform),
 705         },
 706         [KBL_DPCM_AUDIO_DMIC_CP] = {
 707                 .name = "Kbl Audio DMIC cap",
 708                 .stream_name = "dmiccap",
 709                 .init = NULL,
 710                 .dpcm_capture = 1,
 711                 .nonatomic = 1,
 712                 .dynamic = 1,
 713                 .ops = &kabylake_dmic_ops,
 714                 SND_SOC_DAILINK_REG(dmic, dummy, platform),
 715         },
 716         [KBL_DPCM_AUDIO_HDMI1_PB] = {
 717                 .name = "Kbl HDMI Port1",
 718                 .stream_name = "Hdmi1",
 719                 .dpcm_playback = 1,
 720                 .init = NULL,
 721                 .trigger = {
 722                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 723                 .nonatomic = 1,
 724                 .dynamic = 1,
 725                 SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
 726         },
 727         [KBL_DPCM_AUDIO_HDMI2_PB] = {
 728                 .name = "Kbl HDMI Port2",
 729                 .stream_name = "Hdmi2",
 730                 .dpcm_playback = 1,
 731                 .init = NULL,
 732                 .trigger = {
 733                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 734                 .nonatomic = 1,
 735                 .dynamic = 1,
 736                 SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
 737         },
 738         [KBL_DPCM_AUDIO_HDMI3_PB] = {
 739                 .name = "Kbl HDMI Port3",
 740                 .stream_name = "Hdmi3",
 741                 .trigger = {
 742                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 743                 .dpcm_playback = 1,
 744                 .init = NULL,
 745                 .nonatomic = 1,
 746                 .dynamic = 1,
 747                 SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
 748         },
 749         [KBL_DPCM_AUDIO_HS_PB] = {
 750                 .name = "Kbl Audio Headset Playback",
 751                 .stream_name = "Headset Audio",
 752                 .dpcm_playback = 1,
 753                 .nonatomic = 1,
 754                 .dynamic = 1,
 755                 .init = kabylake_da7219_fe_init,
 756                 .trigger = {
 757                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 758                 .ops = &kabylake_da7219_fe_ops,
 759                 SND_SOC_DAILINK_REG(system2, dummy, platform),
 760         },
 761         [KBL_DPCM_AUDIO_CP] = {
 762                 .name = "Kbl Audio Capture Port",
 763                 .stream_name = "Audio Record",
 764                 .dynamic = 1,
 765                 .nonatomic = 1,
 766                 .trigger = {
 767                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 768                 .dpcm_capture = 1,
 769                 .ops = &kabylake_da7219_fe_ops,
 770                 SND_SOC_DAILINK_REG(system, dummy, platform),
 771         },
 772 
 773         /* Back End DAI links */
 774         {
 775                 /* SSP0 - Codec */
 776                 .name = "SSP0-Codec",
 777                 .id = 0,
 778                 .no_pcm = 1,
 779                 .dai_fmt = SND_SOC_DAIFMT_DSP_B |
 780                         SND_SOC_DAIFMT_NB_NF |
 781                         SND_SOC_DAIFMT_CBS_CFS,
 782                 .dpcm_playback = 1,
 783                 .dpcm_capture = 1,
 784                 .ignore_pmdown_time = 1,
 785                 .be_hw_params_fixup = kabylake_ssp_fixup,
 786                 .ops = &kabylake_ssp0_ops,
 787                 SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
 788         },
 789         {
 790                 /* SSP1 - Codec */
 791                 .name = "SSP1-Codec",
 792                 .id = 1,
 793                 .no_pcm = 1,
 794                 .init = kabylake_da7219_codec_init,
 795                 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 796                         SND_SOC_DAIFMT_CBS_CFS,
 797                 .ignore_pmdown_time = 1,
 798                 .be_hw_params_fixup = kabylake_ssp_fixup,
 799                 .dpcm_playback = 1,
 800                 .dpcm_capture = 1,
 801                 SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
 802         },
 803         {
 804                 .name = "dmic01",
 805                 .id = 2,
 806                 .init = kabylake_dmic_init,
 807                 .be_hw_params_fixup = kabylake_dmic_fixup,
 808                 .ignore_suspend = 1,
 809                 .dpcm_capture = 1,
 810                 .no_pcm = 1,
 811                 SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
 812         },
 813         {
 814                 .name = "iDisp1",
 815                 .id = 3,
 816                 .dpcm_playback = 1,
 817                 .init = kabylake_hdmi1_init,
 818                 .no_pcm = 1,
 819                 SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
 820         },
 821         {
 822                 .name = "iDisp2",
 823                 .id = 4,
 824                 .init = kabylake_hdmi2_init,
 825                 .dpcm_playback = 1,
 826                 .no_pcm = 1,
 827                 SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
 828         },
 829         {
 830                 .name = "iDisp3",
 831                 .id = 5,
 832                 .init = kabylake_hdmi3_init,
 833                 .dpcm_playback = 1,
 834                 .no_pcm = 1,
 835                 SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
 836         },
 837 };
 838 
 839 /* kabylake digital audio interface glue - connects codec <--> CPU */
 840 static struct snd_soc_dai_link kabylake_max98_927_373_dais[] = {
 841         /* Front End DAI links */
 842         [KBL_DPCM_AUDIO_PB] = {
 843                 .name = "Kbl Audio Port",
 844                 .stream_name = "Audio",
 845                 .dynamic = 1,
 846                 .nonatomic = 1,
 847                 .init = kabylake_da7219_fe_init,
 848                 .trigger = {
 849                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 850                 .dpcm_playback = 1,
 851                 .ops = &kabylake_da7219_fe_ops,
 852                 SND_SOC_DAILINK_REG(system, dummy, platform),
 853         },
 854         [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
 855                 .name = "Kbl Audio Echo Reference cap",
 856                 .stream_name = "Echoreference Capture",
 857                 .init = NULL,
 858                 .capture_only = 1,
 859                 .nonatomic = 1,
 860                 SND_SOC_DAILINK_REG(echoref, dummy, platform),
 861         },
 862         [KBL_DPCM_AUDIO_REF_CP] = {
 863                 .name = "Kbl Audio Reference cap",
 864                 .stream_name = "Wake on Voice",
 865                 .init = NULL,
 866                 .dpcm_capture = 1,
 867                 .nonatomic = 1,
 868                 .dynamic = 1,
 869                 .ops = &skylake_refcap_ops,
 870                 SND_SOC_DAILINK_REG(reference, dummy, platform),
 871         },
 872         [KBL_DPCM_AUDIO_DMIC_CP] = {
 873                 .name = "Kbl Audio DMIC cap",
 874                 .stream_name = "dmiccap",
 875                 .init = NULL,
 876                 .dpcm_capture = 1,
 877                 .nonatomic = 1,
 878                 .dynamic = 1,
 879                 .ops = &kabylake_dmic_ops,
 880                 SND_SOC_DAILINK_REG(dmic, dummy, platform),
 881         },
 882         [KBL_DPCM_AUDIO_HDMI1_PB] = {
 883                 .name = "Kbl HDMI Port1",
 884                 .stream_name = "Hdmi1",
 885                 .dpcm_playback = 1,
 886                 .init = NULL,
 887                 .trigger = {
 888                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 889                 .nonatomic = 1,
 890                 .dynamic = 1,
 891                 SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
 892         },
 893         [KBL_DPCM_AUDIO_HDMI2_PB] = {
 894                 .name = "Kbl HDMI Port2",
 895                 .stream_name = "Hdmi2",
 896                 .dpcm_playback = 1,
 897                 .init = NULL,
 898                 .trigger = {
 899                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 900                 .nonatomic = 1,
 901                 .dynamic = 1,
 902                 SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
 903         },
 904         [KBL_DPCM_AUDIO_HDMI3_PB] = {
 905                 .name = "Kbl HDMI Port3",
 906                 .stream_name = "Hdmi3",
 907                 .trigger = {
 908                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 909                 .dpcm_playback = 1,
 910                 .init = NULL,
 911                 .nonatomic = 1,
 912                 .dynamic = 1,
 913                 SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
 914         },
 915 
 916         /* Back End DAI links */
 917         {
 918                 /* SSP0 - Codec */
 919                 .name = "SSP0-Codec",
 920                 .id = 0,
 921                 .no_pcm = 1,
 922                 .dai_fmt = SND_SOC_DAIFMT_DSP_B |
 923                         SND_SOC_DAIFMT_NB_NF |
 924                         SND_SOC_DAIFMT_CBS_CFS,
 925                 .dpcm_playback = 1,
 926                 .dpcm_capture = 1,
 927                 .ignore_pmdown_time = 1,
 928                 .be_hw_params_fixup = kabylake_ssp_fixup,
 929                 .ops = &kabylake_ssp0_ops,
 930                 SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec),
 931         },
 932         {
 933                 .name = "dmic01",
 934                 .id = 1,
 935                 .init = kabylake_dmic_init,
 936                 .be_hw_params_fixup = kabylake_dmic_fixup,
 937                 .ignore_suspend = 1,
 938                 .dpcm_capture = 1,
 939                 .no_pcm = 1,
 940                 SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
 941         },
 942         {
 943                 .name = "iDisp1",
 944                 .id = 2,
 945                 .dpcm_playback = 1,
 946                 .init = kabylake_hdmi1_init,
 947                 .no_pcm = 1,
 948                 SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
 949         },
 950         {
 951                 .name = "iDisp2",
 952                 .id = 3,
 953                 .init = kabylake_hdmi2_init,
 954                 .dpcm_playback = 1,
 955                 .no_pcm = 1,
 956                 SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
 957         },
 958         {
 959                 .name = "iDisp3",
 960                 .id = 4,
 961                 .init = kabylake_hdmi3_init,
 962                 .dpcm_playback = 1,
 963                 .no_pcm = 1,
 964                 SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
 965         },
 966 };
 967 
 968 static int kabylake_card_late_probe(struct snd_soc_card *card)
 969 {
 970         struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
 971         struct kbl_hdmi_pcm *pcm;
 972         struct snd_soc_dapm_context *dapm = &card->dapm;
 973         struct snd_soc_component *component = NULL;
 974         int err, i = 0;
 975         char jack_name[NAME_SIZE];
 976 
 977         list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
 978                 component = pcm->codec_dai->component;
 979                 snprintf(jack_name, sizeof(jack_name),
 980                         "HDMI/DP, pcm=%d Jack", pcm->device);
 981                 err = snd_soc_card_jack_new(card, jack_name,
 982                                         SND_JACK_AVOUT, &kabylake_hdmi[i],
 983                                         NULL, 0);
 984 
 985                 if (err)
 986                         return err;
 987 
 988                 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
 989                                                 &kabylake_hdmi[i]);
 990                 if (err < 0)
 991                         return err;
 992 
 993                 i++;
 994         }
 995 
 996         if (!component)
 997                 return -EINVAL;
 998 
 999 
1000         err = hdac_hdmi_jack_port_init(component, &card->dapm);
1001 
1002         if (err < 0)
1003                 return err;
1004 
1005         err = snd_soc_dapm_disable_pin(dapm, "Left Spk");
1006         if (err) {
1007                 dev_err(card->dev, "failed to disable Left Spk: %d\n", err);
1008                 return err;
1009         }
1010 
1011         err = snd_soc_dapm_disable_pin(dapm, "Right Spk");
1012         if (err) {
1013                 dev_err(card->dev, "failed to disable Right Spk: %d\n", err);
1014                 return err;
1015         }
1016 
1017         return snd_soc_dapm_sync(dapm);
1018 }
1019 
1020 /* kabylake audio machine driver for SPT + DA7219 */
1021 static struct snd_soc_card kbl_audio_card_da7219_m98927 = {
1022         .name = "kblda7219m98927",
1023         .owner = THIS_MODULE,
1024         .dai_link = kabylake_dais,
1025         .num_links = ARRAY_SIZE(kabylake_dais),
1026         .controls = kabylake_controls,
1027         .num_controls = ARRAY_SIZE(kabylake_controls),
1028         .dapm_widgets = kabylake_widgets,
1029         .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1030         .dapm_routes = kabylake_map,
1031         .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1032         .codec_conf = max98927_codec_conf,
1033         .num_configs = ARRAY_SIZE(max98927_codec_conf),
1034         .fully_routed = true,
1035         .late_probe = kabylake_card_late_probe,
1036 };
1037 
1038 /* kabylake audio machine driver for Maxim98927 */
1039 static struct snd_soc_card kbl_audio_card_max98927 = {
1040         .name = "kblmax98927",
1041         .owner = THIS_MODULE,
1042         .dai_link = kabylake_max98_927_373_dais,
1043         .num_links = ARRAY_SIZE(kabylake_max98_927_373_dais),
1044         .controls = kabylake_controls,
1045         .num_controls = ARRAY_SIZE(kabylake_controls),
1046         .dapm_widgets = kabylake_widgets,
1047         .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1048         .dapm_routes = kabylake_map,
1049         .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1050         .codec_conf = max98927_codec_conf,
1051         .num_configs = ARRAY_SIZE(max98927_codec_conf),
1052         .fully_routed = true,
1053         .late_probe = kabylake_card_late_probe,
1054 };
1055 
1056 static struct snd_soc_card kbl_audio_card_da7219_m98373 = {
1057         .name = "kblda7219m98373",
1058         .owner = THIS_MODULE,
1059         .dai_link = kabylake_dais,
1060         .num_links = ARRAY_SIZE(kabylake_dais),
1061         .controls = kabylake_controls,
1062         .num_controls = ARRAY_SIZE(kabylake_controls),
1063         .dapm_widgets = kabylake_widgets,
1064         .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1065         .dapm_routes = kabylake_map,
1066         .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1067         .codec_conf = max98373_codec_conf,
1068         .num_configs = ARRAY_SIZE(max98373_codec_conf),
1069         .fully_routed = true,
1070         .late_probe = kabylake_card_late_probe,
1071 };
1072 
1073 static struct snd_soc_card kbl_audio_card_max98373 = {
1074         .name = "kblmax98373",
1075         .owner = THIS_MODULE,
1076         .dai_link = kabylake_max98_927_373_dais,
1077         .num_links = ARRAY_SIZE(kabylake_max98_927_373_dais),
1078         .controls = kabylake_controls,
1079         .num_controls = ARRAY_SIZE(kabylake_controls),
1080         .dapm_widgets = kabylake_widgets,
1081         .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1082         .dapm_routes = kabylake_map,
1083         .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1084         .codec_conf = max98373_codec_conf,
1085         .num_configs = ARRAY_SIZE(max98373_codec_conf),
1086         .fully_routed = true,
1087         .late_probe = kabylake_card_late_probe,
1088 };
1089 
1090 static int kabylake_audio_probe(struct platform_device *pdev)
1091 {
1092         struct kbl_codec_private *ctx;
1093         struct snd_soc_dai_link *kbl_dai_link;
1094         struct snd_soc_dai_link_component **codecs;
1095         int i = 0;
1096 
1097         ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1098         if (!ctx)
1099                 return -ENOMEM;
1100 
1101         INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
1102 
1103         kabylake_audio_card =
1104                 (struct snd_soc_card *)pdev->id_entry->driver_data;
1105 
1106         kbl_dai_link = kabylake_audio_card->dai_link;
1107 
1108         /* Update codecs for SSP0 with max98373 codec info */
1109         if (!strcmp(pdev->name, "kbl_da7219_max98373") ||
1110                 (!strcmp(pdev->name, "kbl_max98373"))) {
1111                 for (i = 0; i < kabylake_audio_card->num_links; ++i) {
1112                         if (strcmp(kbl_dai_link[i].name, "SSP0-Codec"))
1113                                 continue;
1114 
1115                         codecs = &(kbl_dai_link[i].codecs);
1116                         *codecs = max98373_ssp0_codec_components;
1117                         kbl_dai_link[i].num_codecs =
1118                                 ARRAY_SIZE(max98373_ssp0_codec_components);
1119                         break;
1120                 }
1121         }
1122         kabylake_audio_card->dev = &pdev->dev;
1123         snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
1124 
1125         return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
1126 }
1127 
1128 static const struct platform_device_id kbl_board_ids[] = {
1129         {
1130                 .name = "kbl_da7219_max98927",
1131                 .driver_data =
1132                         (kernel_ulong_t)&kbl_audio_card_da7219_m98927,
1133         },
1134         {
1135                 .name = "kbl_max98927",
1136                 .driver_data =
1137                         (kernel_ulong_t)&kbl_audio_card_max98927,
1138         },
1139         {
1140                 .name = "kbl_da7219_max98373",
1141                 .driver_data =
1142                         (kernel_ulong_t)&kbl_audio_card_da7219_m98373,
1143         },
1144         {
1145                 .name = "kbl_max98373",
1146                 .driver_data =
1147                         (kernel_ulong_t)&kbl_audio_card_max98373,
1148         },
1149         { }
1150 };
1151 
1152 static struct platform_driver kabylake_audio = {
1153         .probe = kabylake_audio_probe,
1154         .driver = {
1155                 .name = "kbl_da7219_max98_927_373",
1156                 .pm = &snd_soc_pm_ops,
1157         },
1158         .id_table = kbl_board_ids,
1159 };
1160 
1161 module_platform_driver(kabylake_audio)
1162 
1163 /* Module information */
1164 MODULE_DESCRIPTION("Audio KabyLake Machine driver for MAX98927/MAX98373 & DA7219");
1165 MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
1166 MODULE_LICENSE("GPL v2");
1167 MODULE_ALIAS("platform:kbl_da7219_max98927");
1168 MODULE_ALIAS("platform:kbl_max98927");
1169 MODULE_ALIAS("platform:kbl_da7219_max98373");
1170 MODULE_ALIAS("platform:kbl_max98373");

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