linux/sound/soc/intel/boards/kbl_da7219_max98927.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   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
  38static struct snd_soc_card *kabylake_audio_card;
  39static struct snd_soc_jack kabylake_hdmi[3];
  40
  41struct kbl_hdmi_pcm {
  42        struct list_head head;
  43        struct snd_soc_dai *codec_dai;
  44        int device;
  45};
  46
  47struct kbl_codec_private {
  48        struct snd_soc_jack kabylake_headset;
  49        struct list_head hdmi_pcm_list;
  50};
  51
  52enum {
  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
  64static 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
 101static 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
 108static 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
 121static 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
 157static 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
 175static 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 = asoc_substream_to_rtd(substream);
 179        struct snd_soc_dai *codec_dai;
 180        int ret, j;
 181
 182        for_each_rtd_codec_dais(runtime, j, codec_dai) {
 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
 221static int kabylake_ssp0_trigger(struct snd_pcm_substream *substream, int cmd)
 222{
 223        struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 224        struct snd_soc_dai *codec_dai;
 225        int j, ret;
 226
 227        for_each_rtd_codec_dais(rtd, j, codec_dai) {
 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
 272static struct snd_soc_ops kabylake_ssp0_ops = {
 273        .hw_params = kabylake_ssp0_hw_params,
 274        .trigger = kabylake_ssp0_trigger,
 275};
 276
 277static 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 *chan = 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                chan->min = chan->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                chan->min = chan->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
 331static 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 = asoc_rtd_to_codec(rtd, 0)->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        if (ret)
 345                return ret;
 346
 347        /*
 348         * Headset buttons map to the google Reference headset.
 349         * These can be configured by userspace.
 350         */
 351        ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
 352                        SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
 353                        SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
 354                        &ctx->kabylake_headset, NULL, 0);
 355        if (ret) {
 356                dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
 357                return ret;
 358        }
 359
 360        jack = &ctx->kabylake_headset;
 361        snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
 362        snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
 363        snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
 364        snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
 365
 366        da7219_aad_jack_det(component, &ctx->kabylake_headset);
 367
 368        return 0;
 369}
 370
 371static int kabylake_dmic_init(struct snd_soc_pcm_runtime *rtd)
 372{
 373        int ret;
 374        ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
 375        if (ret)
 376                dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
 377
 378        return ret;
 379}
 380
 381static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
 382{
 383        struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
 384        struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
 385        struct kbl_hdmi_pcm *pcm;
 386
 387        pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
 388        if (!pcm)
 389                return -ENOMEM;
 390
 391        pcm->device = device;
 392        pcm->codec_dai = dai;
 393
 394        list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
 395
 396        return 0;
 397}
 398
 399static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
 400{
 401        return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
 402}
 403
 404static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
 405{
 406        return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
 407}
 408
 409static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
 410{
 411        return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
 412}
 413
 414static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
 415{
 416        struct snd_soc_dapm_context *dapm;
 417        struct snd_soc_component *component = asoc_rtd_to_cpu(rtd, 0)->component;
 418
 419        dapm = snd_soc_component_get_dapm(component);
 420        snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
 421
 422        return 0;
 423}
 424
 425static const unsigned int rates[] = {
 426        48000,
 427};
 428
 429static const struct snd_pcm_hw_constraint_list constraints_rates = {
 430        .count = ARRAY_SIZE(rates),
 431        .list  = rates,
 432        .mask = 0,
 433};
 434
 435static const unsigned int channels[] = {
 436        DUAL_CHANNEL,
 437};
 438
 439static const struct snd_pcm_hw_constraint_list constraints_channels = {
 440        .count = ARRAY_SIZE(channels),
 441        .list = channels,
 442        .mask = 0,
 443};
 444
 445static unsigned int channels_quad[] = {
 446        QUAD_CHANNEL,
 447};
 448
 449static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
 450        .count = ARRAY_SIZE(channels_quad),
 451        .list = channels_quad,
 452        .mask = 0,
 453};
 454
 455static int kbl_fe_startup(struct snd_pcm_substream *substream)
 456{
 457        struct snd_pcm_runtime *runtime = substream->runtime;
 458        struct snd_soc_pcm_runtime *soc_rt = asoc_substream_to_rtd(substream);
 459
 460        /*
 461         * On this platform for PCM device we support,
 462         * 48Khz
 463         * stereo
 464         */
 465
 466        runtime->hw.channels_max = DUAL_CHANNEL;
 467        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
 468                                           &constraints_channels);
 469        /*
 470         * Setup S24_LE (32 bit container and 24 bit valid data) for
 471         * kblda7219m98373 & kblmax98373. For kblda7219m98927 &
 472         * kblmax98927 keeping it as 16/16 due to topology FW dependency.
 473         */
 474        if (!strcmp(soc_rt->card->name, "kblda7219m98373") ||
 475                !strcmp(soc_rt->card->name, "kblmax98373")) {
 476                runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_LE;
 477                snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
 478
 479        } else {
 480                runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
 481                snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
 482        }
 483
 484        snd_pcm_hw_constraint_list(runtime, 0,
 485                                SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 486
 487        return 0;
 488}
 489
 490static const struct snd_soc_ops kabylake_da7219_fe_ops = {
 491        .startup = kbl_fe_startup,
 492};
 493
 494static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
 495                struct snd_pcm_hw_params *params)
 496{
 497        struct snd_interval *chan = hw_param_interval(params,
 498                                SNDRV_PCM_HW_PARAM_CHANNELS);
 499
 500        /*
 501         * set BE channel constraint as user FE channels
 502         */
 503
 504        if (params_channels(params) == 2)
 505                chan->min = chan->max = 2;
 506        else
 507                chan->min = chan->max = 4;
 508
 509        return 0;
 510}
 511
 512static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
 513{
 514        struct snd_pcm_runtime *runtime = substream->runtime;
 515        struct snd_soc_pcm_runtime *soc_rt = asoc_substream_to_rtd(substream);
 516
 517        runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
 518        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
 519                        &constraints_channels_quad);
 520
 521        /*
 522         * Topology for kblda7219m98373 & kblmax98373 supports only S24_LE.
 523         * The DMIC also configured for S24_LE. Forcing the DMIC format to
 524         * S24_LE due to the topology FW dependency.
 525         */
 526        if (!strcmp(soc_rt->card->name, "kblda7219m98373") ||
 527                !strcmp(soc_rt->card->name, "kblmax98373")) {
 528                runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_LE;
 529                snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
 530        }
 531
 532        return snd_pcm_hw_constraint_list(substream->runtime, 0,
 533                        SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 534}
 535
 536static struct snd_soc_ops kabylake_dmic_ops = {
 537        .startup = kabylake_dmic_startup,
 538};
 539
 540static const unsigned int rates_16000[] = {
 541        16000,
 542};
 543
 544static const struct snd_pcm_hw_constraint_list constraints_16000 = {
 545        .count = ARRAY_SIZE(rates_16000),
 546        .list  = rates_16000,
 547};
 548
 549static const unsigned int ch_mono[] = {
 550        1,
 551};
 552static const struct snd_pcm_hw_constraint_list constraints_refcap = {
 553        .count = ARRAY_SIZE(ch_mono),
 554        .list  = ch_mono,
 555};
 556
 557static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
 558{
 559        substream->runtime->hw.channels_max = 1;
 560        snd_pcm_hw_constraint_list(substream->runtime, 0,
 561                                        SNDRV_PCM_HW_PARAM_CHANNELS,
 562                                        &constraints_refcap);
 563
 564        return snd_pcm_hw_constraint_list(substream->runtime, 0,
 565                                SNDRV_PCM_HW_PARAM_RATE,
 566                                &constraints_16000);
 567}
 568
 569
 570static struct snd_soc_ops skylake_refcap_ops = {
 571        .startup = kabylake_refcap_startup,
 572};
 573
 574static struct snd_soc_codec_conf max98927_codec_conf[] = {
 575
 576        {
 577                .dlc = COMP_CODEC_CONF(MAX98927_DEV0_NAME),
 578                .name_prefix = "Right",
 579        },
 580
 581        {
 582                .dlc = COMP_CODEC_CONF(MAX98927_DEV1_NAME),
 583                .name_prefix = "Left",
 584        },
 585};
 586
 587static struct snd_soc_codec_conf max98373_codec_conf[] = {
 588
 589        {
 590                .dlc = COMP_CODEC_CONF(MAX98373_DEV0_NAME),
 591                .name_prefix = "Right",
 592        },
 593
 594        {
 595                .dlc = COMP_CODEC_CONF(MAX98373_DEV1_NAME),
 596                .name_prefix = "Left",
 597        },
 598};
 599
 600static struct snd_soc_dai_link_component max98373_ssp0_codec_components[] = {
 601        { /* Left */
 602                .name = MAX98373_DEV0_NAME,
 603                .dai_name = MAX98373_CODEC_DAI,
 604        },
 605
 606        {  /* For Right */
 607                .name = MAX98373_DEV1_NAME,
 608                .dai_name = MAX98373_CODEC_DAI,
 609        },
 610
 611};
 612
 613SND_SOC_DAILINK_DEF(dummy,
 614        DAILINK_COMP_ARRAY(COMP_DUMMY()));
 615
 616SND_SOC_DAILINK_DEF(system,
 617        DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
 618
 619SND_SOC_DAILINK_DEF(echoref,
 620        DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin")));
 621
 622SND_SOC_DAILINK_DEF(reference,
 623        DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
 624
 625SND_SOC_DAILINK_DEF(dmic,
 626        DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
 627
 628SND_SOC_DAILINK_DEF(hdmi1,
 629        DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
 630
 631SND_SOC_DAILINK_DEF(hdmi2,
 632        DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
 633
 634SND_SOC_DAILINK_DEF(hdmi3,
 635        DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
 636
 637SND_SOC_DAILINK_DEF(system2,
 638        DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
 639
 640SND_SOC_DAILINK_DEF(ssp0_pin,
 641        DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
 642SND_SOC_DAILINK_DEF(ssp0_codec,
 643        DAILINK_COMP_ARRAY(
 644        /* Left */      COMP_CODEC(MAX98927_DEV0_NAME, MAX98927_CODEC_DAI),
 645        /* For Right */ COMP_CODEC(MAX98927_DEV1_NAME, MAX98927_CODEC_DAI)));
 646
 647SND_SOC_DAILINK_DEF(ssp1_pin,
 648        DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
 649SND_SOC_DAILINK_DEF(ssp1_codec,
 650        DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
 651                                      KBL_DIALOG_CODEC_DAI)));
 652
 653SND_SOC_DAILINK_DEF(dmic_pin,
 654        DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
 655SND_SOC_DAILINK_DEF(dmic_codec,
 656        DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
 657
 658SND_SOC_DAILINK_DEF(idisp1_pin,
 659        DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
 660SND_SOC_DAILINK_DEF(idisp1_codec,
 661        DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
 662
 663SND_SOC_DAILINK_DEF(idisp2_pin,
 664        DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
 665SND_SOC_DAILINK_DEF(idisp2_codec,
 666        DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
 667
 668SND_SOC_DAILINK_DEF(idisp3_pin,
 669        DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
 670SND_SOC_DAILINK_DEF(idisp3_codec,
 671        DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
 672
 673SND_SOC_DAILINK_DEF(platform,
 674        DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
 675
 676/* kabylake digital audio interface glue - connects codec <--> CPU */
 677static struct snd_soc_dai_link kabylake_dais[] = {
 678        /* Front End DAI links */
 679        [KBL_DPCM_AUDIO_PB] = {
 680                .name = "Kbl Audio Port",
 681                .stream_name = "Audio",
 682                .dynamic = 1,
 683                .nonatomic = 1,
 684                .init = kabylake_da7219_fe_init,
 685                .trigger = {
 686                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 687                .dpcm_playback = 1,
 688                .ops = &kabylake_da7219_fe_ops,
 689                SND_SOC_DAILINK_REG(system, dummy, platform),
 690        },
 691        [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
 692                .name = "Kbl Audio Echo Reference cap",
 693                .stream_name = "Echoreference Capture",
 694                .init = NULL,
 695                .dpcm_capture = 1,
 696                .nonatomic = 1,
 697                SND_SOC_DAILINK_REG(echoref, dummy, platform),
 698        },
 699        [KBL_DPCM_AUDIO_REF_CP] = {
 700                .name = "Kbl Audio Reference cap",
 701                .stream_name = "Wake on Voice",
 702                .init = NULL,
 703                .dpcm_capture = 1,
 704                .nonatomic = 1,
 705                .dynamic = 1,
 706                .ops = &skylake_refcap_ops,
 707                SND_SOC_DAILINK_REG(reference, dummy, platform),
 708        },
 709        [KBL_DPCM_AUDIO_DMIC_CP] = {
 710                .name = "Kbl Audio DMIC cap",
 711                .stream_name = "dmiccap",
 712                .init = NULL,
 713                .dpcm_capture = 1,
 714                .nonatomic = 1,
 715                .dynamic = 1,
 716                .ops = &kabylake_dmic_ops,
 717                SND_SOC_DAILINK_REG(dmic, dummy, platform),
 718        },
 719        [KBL_DPCM_AUDIO_HDMI1_PB] = {
 720                .name = "Kbl HDMI Port1",
 721                .stream_name = "Hdmi1",
 722                .dpcm_playback = 1,
 723                .init = NULL,
 724                .trigger = {
 725                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 726                .nonatomic = 1,
 727                .dynamic = 1,
 728                SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
 729        },
 730        [KBL_DPCM_AUDIO_HDMI2_PB] = {
 731                .name = "Kbl HDMI Port2",
 732                .stream_name = "Hdmi2",
 733                .dpcm_playback = 1,
 734                .init = NULL,
 735                .trigger = {
 736                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 737                .nonatomic = 1,
 738                .dynamic = 1,
 739                SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
 740        },
 741        [KBL_DPCM_AUDIO_HDMI3_PB] = {
 742                .name = "Kbl HDMI Port3",
 743                .stream_name = "Hdmi3",
 744                .trigger = {
 745                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 746                .dpcm_playback = 1,
 747                .init = NULL,
 748                .nonatomic = 1,
 749                .dynamic = 1,
 750                SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
 751        },
 752        [KBL_DPCM_AUDIO_HS_PB] = {
 753                .name = "Kbl Audio Headset Playback",
 754                .stream_name = "Headset Audio",
 755                .dpcm_playback = 1,
 756                .nonatomic = 1,
 757                .dynamic = 1,
 758                .init = kabylake_da7219_fe_init,
 759                .trigger = {
 760                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 761                .ops = &kabylake_da7219_fe_ops,
 762                SND_SOC_DAILINK_REG(system2, dummy, platform),
 763        },
 764        [KBL_DPCM_AUDIO_CP] = {
 765                .name = "Kbl Audio Capture Port",
 766                .stream_name = "Audio Record",
 767                .dynamic = 1,
 768                .nonatomic = 1,
 769                .trigger = {
 770                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 771                .dpcm_capture = 1,
 772                .ops = &kabylake_da7219_fe_ops,
 773                SND_SOC_DAILINK_REG(system, dummy, platform),
 774        },
 775
 776        /* Back End DAI links */
 777        {
 778                /* SSP0 - Codec */
 779                .name = "SSP0-Codec",
 780                .id = 0,
 781                .no_pcm = 1,
 782                .dai_fmt = SND_SOC_DAIFMT_DSP_B |
 783                        SND_SOC_DAIFMT_NB_NF |
 784                        SND_SOC_DAIFMT_CBS_CFS,
 785                .dpcm_playback = 1,
 786                .dpcm_capture = 1,
 787                .ignore_pmdown_time = 1,
 788                .be_hw_params_fixup = kabylake_ssp_fixup,
 789                .ops = &kabylake_ssp0_ops,
 790                SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
 791        },
 792        {
 793                /* SSP1 - Codec */
 794                .name = "SSP1-Codec",
 795                .id = 1,
 796                .no_pcm = 1,
 797                .init = kabylake_da7219_codec_init,
 798                .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 799                        SND_SOC_DAIFMT_CBS_CFS,
 800                .ignore_pmdown_time = 1,
 801                .be_hw_params_fixup = kabylake_ssp_fixup,
 802                .dpcm_playback = 1,
 803                .dpcm_capture = 1,
 804                SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
 805        },
 806        {
 807                .name = "dmic01",
 808                .id = 2,
 809                .init = kabylake_dmic_init,
 810                .be_hw_params_fixup = kabylake_dmic_fixup,
 811                .ignore_suspend = 1,
 812                .dpcm_capture = 1,
 813                .no_pcm = 1,
 814                SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
 815        },
 816        {
 817                .name = "iDisp1",
 818                .id = 3,
 819                .dpcm_playback = 1,
 820                .init = kabylake_hdmi1_init,
 821                .no_pcm = 1,
 822                SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
 823        },
 824        {
 825                .name = "iDisp2",
 826                .id = 4,
 827                .init = kabylake_hdmi2_init,
 828                .dpcm_playback = 1,
 829                .no_pcm = 1,
 830                SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
 831        },
 832        {
 833                .name = "iDisp3",
 834                .id = 5,
 835                .init = kabylake_hdmi3_init,
 836                .dpcm_playback = 1,
 837                .no_pcm = 1,
 838                SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
 839        },
 840};
 841
 842/* kabylake digital audio interface glue - connects codec <--> CPU */
 843static struct snd_soc_dai_link kabylake_max98_927_373_dais[] = {
 844        /* Front End DAI links */
 845        [KBL_DPCM_AUDIO_PB] = {
 846                .name = "Kbl Audio Port",
 847                .stream_name = "Audio",
 848                .dynamic = 1,
 849                .nonatomic = 1,
 850                .init = kabylake_da7219_fe_init,
 851                .trigger = {
 852                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 853                .dpcm_playback = 1,
 854                .ops = &kabylake_da7219_fe_ops,
 855                SND_SOC_DAILINK_REG(system, dummy, platform),
 856        },
 857        [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
 858                .name = "Kbl Audio Echo Reference cap",
 859                .stream_name = "Echoreference Capture",
 860                .init = NULL,
 861                .dpcm_capture = 1,
 862                .nonatomic = 1,
 863                SND_SOC_DAILINK_REG(echoref, dummy, platform),
 864        },
 865        [KBL_DPCM_AUDIO_REF_CP] = {
 866                .name = "Kbl Audio Reference cap",
 867                .stream_name = "Wake on Voice",
 868                .init = NULL,
 869                .dpcm_capture = 1,
 870                .nonatomic = 1,
 871                .dynamic = 1,
 872                .ops = &skylake_refcap_ops,
 873                SND_SOC_DAILINK_REG(reference, dummy, platform),
 874        },
 875        [KBL_DPCM_AUDIO_DMIC_CP] = {
 876                .name = "Kbl Audio DMIC cap",
 877                .stream_name = "dmiccap",
 878                .init = NULL,
 879                .dpcm_capture = 1,
 880                .nonatomic = 1,
 881                .dynamic = 1,
 882                .ops = &kabylake_dmic_ops,
 883                SND_SOC_DAILINK_REG(dmic, dummy, platform),
 884        },
 885        [KBL_DPCM_AUDIO_HDMI1_PB] = {
 886                .name = "Kbl HDMI Port1",
 887                .stream_name = "Hdmi1",
 888                .dpcm_playback = 1,
 889                .init = NULL,
 890                .trigger = {
 891                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 892                .nonatomic = 1,
 893                .dynamic = 1,
 894                SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
 895        },
 896        [KBL_DPCM_AUDIO_HDMI2_PB] = {
 897                .name = "Kbl HDMI Port2",
 898                .stream_name = "Hdmi2",
 899                .dpcm_playback = 1,
 900                .init = NULL,
 901                .trigger = {
 902                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 903                .nonatomic = 1,
 904                .dynamic = 1,
 905                SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
 906        },
 907        [KBL_DPCM_AUDIO_HDMI3_PB] = {
 908                .name = "Kbl HDMI Port3",
 909                .stream_name = "Hdmi3",
 910                .trigger = {
 911                        SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
 912                .dpcm_playback = 1,
 913                .init = NULL,
 914                .nonatomic = 1,
 915                .dynamic = 1,
 916                SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
 917        },
 918
 919        /* Back End DAI links */
 920        {
 921                /* SSP0 - Codec */
 922                .name = "SSP0-Codec",
 923                .id = 0,
 924                .no_pcm = 1,
 925                .dai_fmt = SND_SOC_DAIFMT_DSP_B |
 926                        SND_SOC_DAIFMT_NB_NF |
 927                        SND_SOC_DAIFMT_CBS_CFS,
 928                .dpcm_playback = 1,
 929                .dpcm_capture = 1,
 930                .ignore_pmdown_time = 1,
 931                .be_hw_params_fixup = kabylake_ssp_fixup,
 932                .ops = &kabylake_ssp0_ops,
 933                SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec),
 934        },
 935        {
 936                .name = "dmic01",
 937                .id = 1,
 938                .init = kabylake_dmic_init,
 939                .be_hw_params_fixup = kabylake_dmic_fixup,
 940                .ignore_suspend = 1,
 941                .dpcm_capture = 1,
 942                .no_pcm = 1,
 943                SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
 944        },
 945        {
 946                .name = "iDisp1",
 947                .id = 2,
 948                .dpcm_playback = 1,
 949                .init = kabylake_hdmi1_init,
 950                .no_pcm = 1,
 951                SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
 952        },
 953        {
 954                .name = "iDisp2",
 955                .id = 3,
 956                .init = kabylake_hdmi2_init,
 957                .dpcm_playback = 1,
 958                .no_pcm = 1,
 959                SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
 960        },
 961        {
 962                .name = "iDisp3",
 963                .id = 4,
 964                .init = kabylake_hdmi3_init,
 965                .dpcm_playback = 1,
 966                .no_pcm = 1,
 967                SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
 968        },
 969};
 970
 971static int kabylake_card_late_probe(struct snd_soc_card *card)
 972{
 973        struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
 974        struct kbl_hdmi_pcm *pcm;
 975        struct snd_soc_dapm_context *dapm = &card->dapm;
 976        struct snd_soc_component *component = NULL;
 977        int err, i = 0;
 978        char jack_name[NAME_SIZE];
 979
 980        list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
 981                component = pcm->codec_dai->component;
 982                snprintf(jack_name, sizeof(jack_name),
 983                        "HDMI/DP, pcm=%d Jack", pcm->device);
 984                err = snd_soc_card_jack_new(card, jack_name,
 985                                        SND_JACK_AVOUT, &kabylake_hdmi[i],
 986                                        NULL, 0);
 987
 988                if (err)
 989                        return err;
 990
 991                err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
 992                                                &kabylake_hdmi[i]);
 993                if (err < 0)
 994                        return err;
 995
 996                i++;
 997        }
 998
 999        if (!component)
1000                return -EINVAL;
1001
1002
1003        err = hdac_hdmi_jack_port_init(component, &card->dapm);
1004
1005        if (err < 0)
1006                return err;
1007
1008        err = snd_soc_dapm_disable_pin(dapm, "Left Spk");
1009        if (err) {
1010                dev_err(card->dev, "failed to disable Left Spk: %d\n", err);
1011                return err;
1012        }
1013
1014        err = snd_soc_dapm_disable_pin(dapm, "Right Spk");
1015        if (err) {
1016                dev_err(card->dev, "failed to disable Right Spk: %d\n", err);
1017                return err;
1018        }
1019
1020        return snd_soc_dapm_sync(dapm);
1021}
1022
1023/* kabylake audio machine driver for SPT + DA7219 */
1024static struct snd_soc_card kbl_audio_card_da7219_m98927 = {
1025        .name = "kblda7219m98927",
1026        .owner = THIS_MODULE,
1027        .dai_link = kabylake_dais,
1028        .num_links = ARRAY_SIZE(kabylake_dais),
1029        .controls = kabylake_controls,
1030        .num_controls = ARRAY_SIZE(kabylake_controls),
1031        .dapm_widgets = kabylake_widgets,
1032        .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1033        .dapm_routes = kabylake_map,
1034        .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1035        .codec_conf = max98927_codec_conf,
1036        .num_configs = ARRAY_SIZE(max98927_codec_conf),
1037        .fully_routed = true,
1038        .late_probe = kabylake_card_late_probe,
1039};
1040
1041/* kabylake audio machine driver for Maxim98927 */
1042static struct snd_soc_card kbl_audio_card_max98927 = {
1043        .name = "kblmax98927",
1044        .owner = THIS_MODULE,
1045        .dai_link = kabylake_max98_927_373_dais,
1046        .num_links = ARRAY_SIZE(kabylake_max98_927_373_dais),
1047        .controls = kabylake_controls,
1048        .num_controls = ARRAY_SIZE(kabylake_controls),
1049        .dapm_widgets = kabylake_widgets,
1050        .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1051        .dapm_routes = kabylake_map,
1052        .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1053        .codec_conf = max98927_codec_conf,
1054        .num_configs = ARRAY_SIZE(max98927_codec_conf),
1055        .fully_routed = true,
1056        .late_probe = kabylake_card_late_probe,
1057};
1058
1059static struct snd_soc_card kbl_audio_card_da7219_m98373 = {
1060        .name = "kblda7219m98373",
1061        .owner = THIS_MODULE,
1062        .dai_link = kabylake_dais,
1063        .num_links = ARRAY_SIZE(kabylake_dais),
1064        .controls = kabylake_controls,
1065        .num_controls = ARRAY_SIZE(kabylake_controls),
1066        .dapm_widgets = kabylake_widgets,
1067        .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1068        .dapm_routes = kabylake_map,
1069        .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1070        .codec_conf = max98373_codec_conf,
1071        .num_configs = ARRAY_SIZE(max98373_codec_conf),
1072        .fully_routed = true,
1073        .late_probe = kabylake_card_late_probe,
1074};
1075
1076static struct snd_soc_card kbl_audio_card_max98373 = {
1077        .name = "kblmax98373",
1078        .owner = THIS_MODULE,
1079        .dai_link = kabylake_max98_927_373_dais,
1080        .num_links = ARRAY_SIZE(kabylake_max98_927_373_dais),
1081        .controls = kabylake_controls,
1082        .num_controls = ARRAY_SIZE(kabylake_controls),
1083        .dapm_widgets = kabylake_widgets,
1084        .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
1085        .dapm_routes = kabylake_map,
1086        .num_dapm_routes = ARRAY_SIZE(kabylake_map),
1087        .codec_conf = max98373_codec_conf,
1088        .num_configs = ARRAY_SIZE(max98373_codec_conf),
1089        .fully_routed = true,
1090        .late_probe = kabylake_card_late_probe,
1091};
1092
1093static int kabylake_audio_probe(struct platform_device *pdev)
1094{
1095        struct kbl_codec_private *ctx;
1096        struct snd_soc_dai_link *kbl_dai_link;
1097        struct snd_soc_dai_link_component **codecs;
1098        int i;
1099
1100        ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1101        if (!ctx)
1102                return -ENOMEM;
1103
1104        INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
1105
1106        kabylake_audio_card =
1107                (struct snd_soc_card *)pdev->id_entry->driver_data;
1108
1109        kbl_dai_link = kabylake_audio_card->dai_link;
1110
1111        /* Update codecs for SSP0 with max98373 codec info */
1112        if (!strcmp(pdev->name, "kbl_da7219_max98373") ||
1113                (!strcmp(pdev->name, "kbl_max98373"))) {
1114                for (i = 0; i < kabylake_audio_card->num_links; ++i) {
1115                        if (strcmp(kbl_dai_link[i].name, "SSP0-Codec"))
1116                                continue;
1117
1118                        codecs = &(kbl_dai_link[i].codecs);
1119                        *codecs = max98373_ssp0_codec_components;
1120                        kbl_dai_link[i].num_codecs =
1121                                ARRAY_SIZE(max98373_ssp0_codec_components);
1122                        break;
1123                }
1124        }
1125        kabylake_audio_card->dev = &pdev->dev;
1126        snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
1127
1128        return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
1129}
1130
1131static const struct platform_device_id kbl_board_ids[] = {
1132        {
1133                .name = "kbl_da7219_max98927",
1134                .driver_data =
1135                        (kernel_ulong_t)&kbl_audio_card_da7219_m98927,
1136        },
1137        {
1138                .name = "kbl_max98927",
1139                .driver_data =
1140                        (kernel_ulong_t)&kbl_audio_card_max98927,
1141        },
1142        {
1143                .name = "kbl_da7219_max98373",
1144                .driver_data =
1145                        (kernel_ulong_t)&kbl_audio_card_da7219_m98373,
1146        },
1147        {
1148                .name = "kbl_max98373",
1149                .driver_data =
1150                        (kernel_ulong_t)&kbl_audio_card_max98373,
1151        },
1152        { }
1153};
1154
1155static struct platform_driver kabylake_audio = {
1156        .probe = kabylake_audio_probe,
1157        .driver = {
1158                .name = "kbl_da7219_max98_927_373",
1159                .pm = &snd_soc_pm_ops,
1160        },
1161        .id_table = kbl_board_ids,
1162};
1163
1164module_platform_driver(kabylake_audio)
1165
1166/* Module information */
1167MODULE_DESCRIPTION("Audio KabyLake Machine driver for MAX98927/MAX98373 & DA7219");
1168MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
1169MODULE_LICENSE("GPL v2");
1170MODULE_ALIAS("platform:kbl_da7219_max98927");
1171MODULE_ALIAS("platform:kbl_max98927");
1172MODULE_ALIAS("platform:kbl_da7219_max98373");
1173MODULE_ALIAS("platform:kbl_max98373");
1174