Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Intel Skylake I2S Machine Driver for NAU88L25+SSM4567 |
| 3 | * |
| 4 | * Copyright (C) 2015, Intel Corporation. All rights reserved. |
| 5 | * |
| 6 | * Modified from: |
| 7 | * Intel Skylake I2S Machine Driver for NAU88L25 and SSM4567 |
| 8 | * |
| 9 | * Copyright (C) 2015, Intel Corporation. All rights reserved. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License version |
| 13 | * 2 as published by the Free Software Foundation. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <sound/core.h> |
| 24 | #include <sound/pcm.h> |
| 25 | #include <sound/soc.h> |
| 26 | #include <sound/jack.h> |
| 27 | #include <sound/pcm_params.h> |
| 28 | #include "../../codecs/nau8825.h" |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 29 | #include "../../codecs/hdac_hdmi.h" |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 30 | #include "../skylake/skl.h" |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 31 | |
| 32 | #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" |
| 33 | #define SKL_SSM_CODEC_DAI "ssm4567-hifi" |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 34 | #define DMIC_CH(p) p->list[p->count-1] |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 35 | |
| 36 | static struct snd_soc_jack skylake_headset; |
| 37 | static struct snd_soc_card skylake_audio_card; |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 38 | static const struct snd_pcm_hw_constraint_list *dmic_constraints; |
Jeeja KP | 9e4278c | 2017-02-07 19:09:52 +0530 | [diff] [blame] | 39 | static struct snd_soc_jack skylake_hdmi[3]; |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 40 | |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 41 | struct skl_hdmi_pcm { |
| 42 | struct list_head head; |
| 43 | struct snd_soc_dai *codec_dai; |
| 44 | int device; |
| 45 | }; |
| 46 | |
| 47 | struct skl_nau88125_private { |
| 48 | struct list_head hdmi_pcm_list; |
| 49 | }; |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 50 | enum { |
| 51 | SKL_DPCM_AUDIO_PB = 0, |
| 52 | SKL_DPCM_AUDIO_CP, |
| 53 | SKL_DPCM_AUDIO_REF_CP, |
| 54 | SKL_DPCM_AUDIO_DMIC_CP, |
| 55 | SKL_DPCM_AUDIO_HDMI1_PB, |
| 56 | SKL_DPCM_AUDIO_HDMI2_PB, |
| 57 | SKL_DPCM_AUDIO_HDMI3_PB, |
| 58 | }; |
| 59 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 60 | static inline struct snd_soc_dai *skl_get_codec_dai(struct snd_soc_card *card) |
| 61 | { |
Vinod Koul | 85af2a6 | 2015-11-20 22:34:41 +0530 | [diff] [blame] | 62 | struct snd_soc_pcm_runtime *rtd; |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 63 | |
Vinod Koul | 85af2a6 | 2015-11-20 22:34:41 +0530 | [diff] [blame] | 64 | list_for_each_entry(rtd, &card->rtd_list, list) { |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 65 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 66 | if (!strncmp(rtd->codec_dai->name, SKL_NUVOTON_CODEC_DAI, |
| 67 | strlen(SKL_NUVOTON_CODEC_DAI))) |
| 68 | return rtd->codec_dai; |
| 69 | } |
| 70 | |
| 71 | return NULL; |
| 72 | } |
| 73 | |
| 74 | static const struct snd_kcontrol_new skylake_controls[] = { |
| 75 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), |
| 76 | SOC_DAPM_PIN_SWITCH("Headset Mic"), |
| 77 | SOC_DAPM_PIN_SWITCH("Left Speaker"), |
| 78 | SOC_DAPM_PIN_SWITCH("Right Speaker"), |
| 79 | }; |
| 80 | |
| 81 | static int platform_clock_control(struct snd_soc_dapm_widget *w, |
| 82 | struct snd_kcontrol *k, int event) |
| 83 | { |
| 84 | struct snd_soc_dapm_context *dapm = w->dapm; |
| 85 | struct snd_soc_card *card = dapm->card; |
| 86 | struct snd_soc_dai *codec_dai; |
| 87 | int ret; |
| 88 | |
| 89 | codec_dai = skl_get_codec_dai(card); |
| 90 | if (!codec_dai) { |
| 91 | dev_err(card->dev, "Codec dai not found\n"); |
| 92 | return -EIO; |
| 93 | } |
| 94 | |
| 95 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 96 | ret = snd_soc_dai_set_sysclk(codec_dai, |
| 97 | NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN); |
| 98 | if (ret < 0) { |
| 99 | dev_err(card->dev, "set sysclk err = %d\n", ret); |
| 100 | return -EIO; |
| 101 | } |
| 102 | } else { |
| 103 | ret = snd_soc_dai_set_sysclk(codec_dai, |
| 104 | NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN); |
| 105 | if (ret < 0) { |
| 106 | dev_err(card->dev, "set sysclk err = %d\n", ret); |
| 107 | return -EIO; |
| 108 | } |
| 109 | } |
| 110 | return ret; |
| 111 | } |
| 112 | |
| 113 | static const struct snd_soc_dapm_widget skylake_widgets[] = { |
| 114 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 115 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 116 | SND_SOC_DAPM_SPK("Left Speaker", NULL), |
| 117 | SND_SOC_DAPM_SPK("Right Speaker", NULL), |
| 118 | SND_SOC_DAPM_MIC("SoC DMIC", NULL), |
Jeeja KP | 8d13640 | 2017-02-06 12:09:16 +0530 | [diff] [blame] | 119 | SND_SOC_DAPM_SPK("DP1", NULL), |
| 120 | SND_SOC_DAPM_SPK("DP2", NULL), |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 121 | SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, |
| 122 | platform_clock_control, SND_SOC_DAPM_PRE_PMU | |
| 123 | SND_SOC_DAPM_POST_PMD), |
| 124 | }; |
| 125 | |
| 126 | static const struct snd_soc_dapm_route skylake_map[] = { |
| 127 | /* HP jack connectors - unknown if we have jack detection */ |
| 128 | {"Headphone Jack", NULL, "HPOL"}, |
| 129 | {"Headphone Jack", NULL, "HPOR"}, |
| 130 | |
| 131 | /* speaker */ |
| 132 | {"Left Speaker", NULL, "Left OUT"}, |
| 133 | {"Right Speaker", NULL, "Right OUT"}, |
| 134 | |
| 135 | /* other jacks */ |
| 136 | {"MIC", NULL, "Headset Mic"}, |
Fang, Yang A | 4c6ebc3 | 2015-12-11 11:29:09 -0800 | [diff] [blame] | 137 | {"DMic", NULL, "SoC DMIC"}, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 138 | |
| 139 | /* CODEC BE connections */ |
| 140 | { "Left Playback", NULL, "ssp0 Tx"}, |
| 141 | { "Right Playback", NULL, "ssp0 Tx"}, |
| 142 | { "ssp0 Tx", NULL, "codec0_out"}, |
| 143 | |
Sathya Prakash M R | 5093f92 | 2016-02-24 11:27:41 +0530 | [diff] [blame] | 144 | /* IV feedback path */ |
| 145 | { "codec0_lp_in", NULL, "ssp0 Rx"}, |
Jeeja KP | 5188b95 | 2016-03-01 07:59:11 +0530 | [diff] [blame] | 146 | { "ssp0 Rx", NULL, "Left Capture Sense" }, |
| 147 | { "ssp0 Rx", NULL, "Right Capture Sense" }, |
Sathya Prakash M R | 5093f92 | 2016-02-24 11:27:41 +0530 | [diff] [blame] | 148 | |
Fang, Yang A | 4c6ebc3 | 2015-12-11 11:29:09 -0800 | [diff] [blame] | 149 | { "Playback", NULL, "ssp1 Tx"}, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 150 | { "ssp1 Tx", NULL, "codec1_out"}, |
| 151 | |
| 152 | { "codec0_in", NULL, "ssp1 Rx" }, |
Fang, Yang A | 4c6ebc3 | 2015-12-11 11:29:09 -0800 | [diff] [blame] | 153 | { "ssp1 Rx", NULL, "Capture" }, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 154 | |
| 155 | /* DMIC */ |
| 156 | { "dmic01_hifi", NULL, "DMIC01 Rx" }, |
Fang, Yang A | 4c6ebc3 | 2015-12-11 11:29:09 -0800 | [diff] [blame] | 157 | { "DMIC01 Rx", NULL, "DMIC AIF" }, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 158 | |
| 159 | { "hifi3", NULL, "iDisp3 Tx"}, |
| 160 | { "iDisp3 Tx", NULL, "iDisp3_out"}, |
| 161 | { "hifi2", NULL, "iDisp2 Tx"}, |
| 162 | { "iDisp2 Tx", NULL, "iDisp2_out"}, |
| 163 | { "hifi1", NULL, "iDisp1 Tx"}, |
| 164 | { "iDisp1 Tx", NULL, "iDisp1_out"}, |
| 165 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 166 | { "Headphone Jack", NULL, "Platform Clock" }, |
| 167 | { "Headset Mic", NULL, "Platform Clock" }, |
| 168 | }; |
| 169 | |
| 170 | static struct snd_soc_codec_conf ssm4567_codec_conf[] = { |
| 171 | { |
| 172 | .dev_name = "i2c-INT343B:00", |
| 173 | .name_prefix = "Left", |
| 174 | }, |
| 175 | { |
| 176 | .dev_name = "i2c-INT343B:01", |
| 177 | .name_prefix = "Right", |
| 178 | }, |
| 179 | }; |
| 180 | |
| 181 | static struct snd_soc_dai_link_component ssm4567_codec_components[] = { |
| 182 | { /* Left */ |
| 183 | .name = "i2c-INT343B:00", |
| 184 | .dai_name = SKL_SSM_CODEC_DAI, |
| 185 | }, |
| 186 | { /* Right */ |
| 187 | .name = "i2c-INT343B:01", |
| 188 | .dai_name = SKL_SSM_CODEC_DAI, |
| 189 | }, |
| 190 | }; |
| 191 | |
| 192 | static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 193 | { |
| 194 | int ret; |
| 195 | |
| 196 | /* Slot 1 for left */ |
| 197 | ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[0], 0x01, 0x01, 2, 48); |
| 198 | if (ret < 0) |
| 199 | return ret; |
| 200 | |
| 201 | /* Slot 2 for right */ |
| 202 | ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[1], 0x02, 0x02, 2, 48); |
| 203 | if (ret < 0) |
| 204 | return ret; |
| 205 | |
| 206 | return ret; |
| 207 | } |
| 208 | |
| 209 | static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 210 | { |
| 211 | int ret; |
| 212 | struct snd_soc_codec *codec = rtd->codec; |
| 213 | |
| 214 | /* |
| 215 | * 4 buttons here map to the google Reference headset |
| 216 | * The use of these buttons can be decided by the user space. |
| 217 | */ |
| 218 | ret = snd_soc_card_jack_new(&skylake_audio_card, "Headset Jack", |
| 219 | SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
| 220 | SND_JACK_BTN_2 | SND_JACK_BTN_3, &skylake_headset, |
| 221 | NULL, 0); |
| 222 | if (ret) { |
| 223 | dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret); |
| 224 | return ret; |
| 225 | } |
| 226 | |
| 227 | nau8825_enable_jack_detect(codec, &skylake_headset); |
| 228 | |
Yong Zhi | 941eee7 | 2015-12-11 11:29:10 -0800 | [diff] [blame] | 229 | snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); |
| 230 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 231 | return ret; |
| 232 | } |
| 233 | |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 234 | static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) |
| 235 | { |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 236 | struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 237 | struct snd_soc_dai *dai = rtd->codec_dai; |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 238 | struct skl_hdmi_pcm *pcm; |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 239 | |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 240 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
| 241 | if (!pcm) |
| 242 | return -ENOMEM; |
| 243 | |
| 244 | pcm->device = SKL_DPCM_AUDIO_HDMI1_PB; |
| 245 | pcm->codec_dai = dai; |
| 246 | |
| 247 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
| 248 | |
| 249 | return 0; |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) |
| 253 | { |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 254 | struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 255 | struct snd_soc_dai *dai = rtd->codec_dai; |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 256 | struct skl_hdmi_pcm *pcm; |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 257 | |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 258 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
| 259 | if (!pcm) |
| 260 | return -ENOMEM; |
| 261 | |
| 262 | pcm->device = SKL_DPCM_AUDIO_HDMI2_PB; |
| 263 | pcm->codec_dai = dai; |
| 264 | |
| 265 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
| 266 | |
| 267 | return 0; |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | |
| 271 | static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) |
| 272 | { |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 273 | struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 274 | struct snd_soc_dai *dai = rtd->codec_dai; |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 275 | struct skl_hdmi_pcm *pcm; |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 276 | |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 277 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
| 278 | if (!pcm) |
| 279 | return -ENOMEM; |
| 280 | |
| 281 | pcm->device = SKL_DPCM_AUDIO_HDMI3_PB; |
| 282 | pcm->codec_dai = dai; |
| 283 | |
| 284 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
| 285 | |
| 286 | return 0; |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 287 | } |
| 288 | |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 289 | static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd) |
| 290 | { |
| 291 | struct snd_soc_dapm_context *dapm; |
| 292 | struct snd_soc_component *component = rtd->cpu_dai->component; |
| 293 | |
| 294 | dapm = snd_soc_component_get_dapm(component); |
| 295 | snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 300 | static const unsigned int rates[] = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 301 | 48000, |
| 302 | }; |
| 303 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 304 | static const struct snd_pcm_hw_constraint_list constraints_rates = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 305 | .count = ARRAY_SIZE(rates), |
| 306 | .list = rates, |
| 307 | .mask = 0, |
| 308 | }; |
| 309 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 310 | static const unsigned int channels[] = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 311 | 2, |
| 312 | }; |
| 313 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 314 | static const struct snd_pcm_hw_constraint_list constraints_channels = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 315 | .count = ARRAY_SIZE(channels), |
| 316 | .list = channels, |
| 317 | .mask = 0, |
| 318 | }; |
| 319 | |
| 320 | static int skl_fe_startup(struct snd_pcm_substream *substream) |
| 321 | { |
| 322 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 323 | |
| 324 | /* |
| 325 | * on this platform for PCM device we support, |
| 326 | * 48Khz |
| 327 | * stereo |
| 328 | * 16 bit audio |
| 329 | */ |
| 330 | |
| 331 | runtime->hw.channels_max = 2; |
| 332 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
| 333 | &constraints_channels); |
| 334 | |
| 335 | runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; |
| 336 | snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); |
| 337 | |
| 338 | snd_pcm_hw_constraint_list(runtime, 0, |
| 339 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); |
| 340 | |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | static const struct snd_soc_ops skylake_nau8825_fe_ops = { |
| 345 | .startup = skl_fe_startup, |
| 346 | }; |
| 347 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 348 | static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, |
| 349 | struct snd_pcm_hw_params *params) |
| 350 | { |
| 351 | struct snd_interval *rate = hw_param_interval(params, |
| 352 | SNDRV_PCM_HW_PARAM_RATE); |
| 353 | struct snd_interval *channels = hw_param_interval(params, |
| 354 | SNDRV_PCM_HW_PARAM_CHANNELS); |
| 355 | struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
| 356 | |
| 357 | /* The ADSP will covert the FE rate to 48k, stereo */ |
| 358 | rate->min = rate->max = 48000; |
| 359 | channels->min = channels->max = 2; |
| 360 | |
| 361 | /* set SSP0 to 24 bit */ |
| 362 | snd_mask_none(fmt); |
| 363 | snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); |
| 364 | return 0; |
| 365 | } |
| 366 | |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 367 | static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, |
| 368 | struct snd_pcm_hw_params *params) |
| 369 | { |
| 370 | struct snd_interval *channels = hw_param_interval(params, |
| 371 | SNDRV_PCM_HW_PARAM_CHANNELS); |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 372 | if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 373 | channels->min = channels->max = 2; |
| 374 | else |
| 375 | channels->min = channels->max = 4; |
| 376 | |
| 377 | return 0; |
| 378 | } |
| 379 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 380 | static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream, |
| 381 | struct snd_pcm_hw_params *params) |
| 382 | { |
| 383 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 384 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 385 | int ret; |
| 386 | |
| 387 | ret = snd_soc_dai_set_sysclk(codec_dai, |
| 388 | NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN); |
| 389 | |
| 390 | if (ret < 0) |
| 391 | dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); |
| 392 | |
| 393 | return ret; |
| 394 | } |
| 395 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 396 | static const struct snd_soc_ops skylake_nau8825_ops = { |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 397 | .hw_params = skylake_nau8825_hw_params, |
| 398 | }; |
| 399 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 400 | static const unsigned int channels_dmic[] = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 401 | 2, 4, |
| 402 | }; |
| 403 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 404 | static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 405 | .count = ARRAY_SIZE(channels_dmic), |
| 406 | .list = channels_dmic, |
| 407 | .mask = 0, |
| 408 | }; |
| 409 | |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 410 | static const unsigned int dmic_2ch[] = { |
| 411 | 2, |
| 412 | }; |
| 413 | |
| 414 | static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = { |
| 415 | .count = ARRAY_SIZE(dmic_2ch), |
| 416 | .list = dmic_2ch, |
| 417 | .mask = 0, |
| 418 | }; |
| 419 | |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 420 | static int skylake_dmic_startup(struct snd_pcm_substream *substream) |
| 421 | { |
| 422 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 423 | |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 424 | runtime->hw.channels_max = DMIC_CH(dmic_constraints); |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 425 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 426 | dmic_constraints); |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 427 | |
| 428 | return snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 429 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); |
| 430 | } |
| 431 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 432 | static const struct snd_soc_ops skylake_dmic_ops = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 433 | .startup = skylake_dmic_startup, |
| 434 | }; |
| 435 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 436 | static const unsigned int rates_16000[] = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 437 | 16000, |
| 438 | }; |
| 439 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 440 | static const struct snd_pcm_hw_constraint_list constraints_16000 = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 441 | .count = ARRAY_SIZE(rates_16000), |
| 442 | .list = rates_16000, |
| 443 | }; |
| 444 | |
Yong Zhi | 0c7941a | 2016-05-17 09:43:05 -0700 | [diff] [blame] | 445 | static const unsigned int ch_mono[] = { |
| 446 | 1, |
| 447 | }; |
| 448 | |
| 449 | static const struct snd_pcm_hw_constraint_list constraints_refcap = { |
| 450 | .count = ARRAY_SIZE(ch_mono), |
| 451 | .list = ch_mono, |
| 452 | }; |
| 453 | |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 454 | static int skylake_refcap_startup(struct snd_pcm_substream *substream) |
| 455 | { |
Yong Zhi | 0c7941a | 2016-05-17 09:43:05 -0700 | [diff] [blame] | 456 | substream->runtime->hw.channels_max = 1; |
| 457 | snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 458 | SNDRV_PCM_HW_PARAM_CHANNELS, |
| 459 | &constraints_refcap); |
| 460 | |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 461 | return snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 462 | SNDRV_PCM_HW_PARAM_RATE, |
| 463 | &constraints_16000); |
| 464 | } |
| 465 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 466 | static const struct snd_soc_ops skylaye_refcap_ops = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 467 | .startup = skylake_refcap_startup, |
| 468 | }; |
| 469 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 470 | /* skylake digital audio interface glue - connects codec <--> CPU */ |
| 471 | static struct snd_soc_dai_link skylake_dais[] = { |
| 472 | /* Front End DAI links */ |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 473 | [SKL_DPCM_AUDIO_PB] = { |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 474 | .name = "Skl Audio Port", |
| 475 | .stream_name = "Audio", |
| 476 | .cpu_dai_name = "System Pin", |
| 477 | .platform_name = "0000:00:1f.3", |
| 478 | .dynamic = 1, |
| 479 | .codec_name = "snd-soc-dummy", |
| 480 | .codec_dai_name = "snd-soc-dummy-dai", |
| 481 | .nonatomic = 1, |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 482 | .init = skylake_nau8825_fe_init, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 483 | .trigger = { |
| 484 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 485 | .dpcm_playback = 1, |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 486 | .ops = &skylake_nau8825_fe_ops, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 487 | }, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 488 | [SKL_DPCM_AUDIO_CP] = { |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 489 | .name = "Skl Audio Capture Port", |
| 490 | .stream_name = "Audio Record", |
| 491 | .cpu_dai_name = "System Pin", |
| 492 | .platform_name = "0000:00:1f.3", |
| 493 | .dynamic = 1, |
| 494 | .codec_name = "snd-soc-dummy", |
| 495 | .codec_dai_name = "snd-soc-dummy-dai", |
| 496 | .nonatomic = 1, |
| 497 | .trigger = { |
| 498 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 499 | .dpcm_capture = 1, |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 500 | .ops = &skylake_nau8825_fe_ops, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 501 | }, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 502 | [SKL_DPCM_AUDIO_REF_CP] = { |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 503 | .name = "Skl Audio Reference cap", |
Sathyanarayana Nujella | 2154be3 | 2015-12-11 11:29:12 -0800 | [diff] [blame] | 504 | .stream_name = "Wake on Voice", |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 505 | .cpu_dai_name = "Reference Pin", |
| 506 | .codec_name = "snd-soc-dummy", |
| 507 | .codec_dai_name = "snd-soc-dummy-dai", |
| 508 | .platform_name = "0000:00:1f.3", |
| 509 | .init = NULL, |
| 510 | .dpcm_capture = 1, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 511 | .nonatomic = 1, |
| 512 | .dynamic = 1, |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 513 | .ops = &skylaye_refcap_ops, |
| 514 | }, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 515 | [SKL_DPCM_AUDIO_DMIC_CP] = { |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 516 | .name = "Skl Audio DMIC cap", |
| 517 | .stream_name = "dmiccap", |
| 518 | .cpu_dai_name = "DMIC Pin", |
| 519 | .codec_name = "snd-soc-dummy", |
| 520 | .codec_dai_name = "snd-soc-dummy-dai", |
| 521 | .platform_name = "0000:00:1f.3", |
| 522 | .init = NULL, |
| 523 | .dpcm_capture = 1, |
| 524 | .nonatomic = 1, |
| 525 | .dynamic = 1, |
| 526 | .ops = &skylake_dmic_ops, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 527 | }, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 528 | [SKL_DPCM_AUDIO_HDMI1_PB] = { |
| 529 | .name = "Skl HDMI Port1", |
| 530 | .stream_name = "Hdmi1", |
| 531 | .cpu_dai_name = "HDMI1 Pin", |
Fang, Yang A | 743ad80 | 2015-12-11 11:29:13 -0800 | [diff] [blame] | 532 | .codec_name = "snd-soc-dummy", |
| 533 | .codec_dai_name = "snd-soc-dummy-dai", |
| 534 | .platform_name = "0000:00:1f.3", |
| 535 | .dpcm_playback = 1, |
| 536 | .init = NULL, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 537 | .trigger = { |
| 538 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 539 | .nonatomic = 1, |
| 540 | .dynamic = 1, |
| 541 | }, |
| 542 | [SKL_DPCM_AUDIO_HDMI2_PB] = { |
| 543 | .name = "Skl HDMI Port2", |
| 544 | .stream_name = "Hdmi2", |
| 545 | .cpu_dai_name = "HDMI2 Pin", |
| 546 | .codec_name = "snd-soc-dummy", |
| 547 | .codec_dai_name = "snd-soc-dummy-dai", |
| 548 | .platform_name = "0000:00:1f.3", |
| 549 | .dpcm_playback = 1, |
| 550 | .init = NULL, |
| 551 | .trigger = { |
| 552 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 553 | .nonatomic = 1, |
| 554 | .dynamic = 1, |
| 555 | }, |
| 556 | [SKL_DPCM_AUDIO_HDMI3_PB] = { |
| 557 | .name = "Skl HDMI Port3", |
| 558 | .stream_name = "Hdmi3", |
| 559 | .cpu_dai_name = "HDMI3 Pin", |
| 560 | .codec_name = "snd-soc-dummy", |
| 561 | .codec_dai_name = "snd-soc-dummy-dai", |
| 562 | .platform_name = "0000:00:1f.3", |
| 563 | .trigger = { |
| 564 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 565 | .dpcm_playback = 1, |
| 566 | .init = NULL, |
Fang, Yang A | 743ad80 | 2015-12-11 11:29:13 -0800 | [diff] [blame] | 567 | .nonatomic = 1, |
| 568 | .dynamic = 1, |
| 569 | }, |
| 570 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 571 | /* Back End DAI links */ |
| 572 | { |
| 573 | /* SSP0 - Codec */ |
| 574 | .name = "SSP0-Codec", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 575 | .id = 0, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 576 | .cpu_dai_name = "SSP0 Pin", |
| 577 | .platform_name = "0000:00:1f.3", |
| 578 | .no_pcm = 1, |
| 579 | .codecs = ssm4567_codec_components, |
| 580 | .num_codecs = ARRAY_SIZE(ssm4567_codec_components), |
| 581 | .dai_fmt = SND_SOC_DAIFMT_DSP_A | |
| 582 | SND_SOC_DAIFMT_IB_NF | |
| 583 | SND_SOC_DAIFMT_CBS_CFS, |
| 584 | .init = skylake_ssm4567_codec_init, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 585 | .ignore_pmdown_time = 1, |
| 586 | .be_hw_params_fixup = skylake_ssp_fixup, |
| 587 | .dpcm_playback = 1, |
Jeeja KP | 5188b95 | 2016-03-01 07:59:11 +0530 | [diff] [blame] | 588 | .dpcm_capture = 1, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 589 | }, |
| 590 | { |
| 591 | /* SSP1 - Codec */ |
| 592 | .name = "SSP1-Codec", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 593 | .id = 1, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 594 | .cpu_dai_name = "SSP1 Pin", |
| 595 | .platform_name = "0000:00:1f.3", |
| 596 | .no_pcm = 1, |
| 597 | .codec_name = "i2c-10508825:00", |
| 598 | .codec_dai_name = SKL_NUVOTON_CODEC_DAI, |
| 599 | .init = skylake_nau8825_codec_init, |
| 600 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 601 | SND_SOC_DAIFMT_CBS_CFS, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 602 | .ignore_pmdown_time = 1, |
| 603 | .be_hw_params_fixup = skylake_ssp_fixup, |
| 604 | .ops = &skylake_nau8825_ops, |
| 605 | .dpcm_playback = 1, |
| 606 | .dpcm_capture = 1, |
| 607 | }, |
| 608 | { |
| 609 | .name = "dmic01", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 610 | .id = 2, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 611 | .cpu_dai_name = "DMIC01 Pin", |
| 612 | .codec_name = "dmic-codec", |
| 613 | .codec_dai_name = "dmic-hifi", |
| 614 | .platform_name = "0000:00:1f.3", |
| 615 | .ignore_suspend = 1, |
Yong Zhi | 2616e27 | 2015-12-11 11:29:11 -0800 | [diff] [blame] | 616 | .be_hw_params_fixup = skylake_dmic_fixup, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 617 | .dpcm_capture = 1, |
| 618 | .no_pcm = 1, |
| 619 | }, |
Fang, Yang A | 743ad80 | 2015-12-11 11:29:13 -0800 | [diff] [blame] | 620 | { |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 621 | .name = "iDisp1", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 622 | .id = 3, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 623 | .cpu_dai_name = "iDisp1 Pin", |
Fang, Yang A | 743ad80 | 2015-12-11 11:29:13 -0800 | [diff] [blame] | 624 | .codec_name = "ehdaudio0D2", |
| 625 | .codec_dai_name = "intel-hdmi-hifi1", |
| 626 | .platform_name = "0000:00:1f.3", |
| 627 | .dpcm_playback = 1, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 628 | .init = skylake_hdmi1_init, |
| 629 | .no_pcm = 1, |
| 630 | }, |
| 631 | { |
| 632 | .name = "iDisp2", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 633 | .id = 4, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 634 | .cpu_dai_name = "iDisp2 Pin", |
| 635 | .codec_name = "ehdaudio0D2", |
| 636 | .codec_dai_name = "intel-hdmi-hifi2", |
| 637 | .platform_name = "0000:00:1f.3", |
| 638 | .init = skylake_hdmi2_init, |
| 639 | .dpcm_playback = 1, |
| 640 | .no_pcm = 1, |
| 641 | }, |
| 642 | { |
| 643 | .name = "iDisp3", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 644 | .id = 5, |
Jeeja KP | bc5f6ac | 2016-02-24 11:27:39 +0530 | [diff] [blame] | 645 | .cpu_dai_name = "iDisp3 Pin", |
| 646 | .codec_name = "ehdaudio0D2", |
| 647 | .codec_dai_name = "intel-hdmi-hifi3", |
| 648 | .platform_name = "0000:00:1f.3", |
| 649 | .init = skylake_hdmi3_init, |
| 650 | .dpcm_playback = 1, |
Fang, Yang A | 743ad80 | 2015-12-11 11:29:13 -0800 | [diff] [blame] | 651 | .no_pcm = 1, |
| 652 | }, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 653 | }; |
| 654 | |
Jeeja KP | 9e4278c | 2017-02-07 19:09:52 +0530 | [diff] [blame] | 655 | #define NAME_SIZE 32 |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 656 | static int skylake_card_late_probe(struct snd_soc_card *card) |
| 657 | { |
| 658 | struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card); |
| 659 | struct skl_hdmi_pcm *pcm; |
Jeeja KP | 86b5703 | 2017-02-07 19:09:58 +0530 | [diff] [blame] | 660 | struct snd_soc_codec *codec = NULL; |
Jeeja KP | 9e4278c | 2017-02-07 19:09:52 +0530 | [diff] [blame] | 661 | int err, i = 0; |
| 662 | char jack_name[NAME_SIZE]; |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 663 | |
| 664 | list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { |
Jeeja KP | 86b5703 | 2017-02-07 19:09:58 +0530 | [diff] [blame] | 665 | codec = pcm->codec_dai->codec; |
Jeeja KP | 9e4278c | 2017-02-07 19:09:52 +0530 | [diff] [blame] | 666 | snprintf(jack_name, sizeof(jack_name), |
| 667 | "HDMI/DP, pcm=%d Jack", pcm->device); |
| 668 | err = snd_soc_card_jack_new(card, jack_name, |
| 669 | SND_JACK_AVOUT, |
| 670 | &skylake_hdmi[i], |
| 671 | NULL, 0); |
| 672 | |
| 673 | if (err) |
| 674 | return err; |
| 675 | |
| 676 | err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, |
| 677 | &skylake_hdmi[i]); |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 678 | if (err < 0) |
| 679 | return err; |
Jeeja KP | 9e4278c | 2017-02-07 19:09:52 +0530 | [diff] [blame] | 680 | |
| 681 | i++; |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 682 | } |
| 683 | |
Jeeja KP | 86b5703 | 2017-02-07 19:09:58 +0530 | [diff] [blame] | 684 | if (!codec) |
| 685 | return -EINVAL; |
| 686 | |
| 687 | return hdac_hdmi_jack_port_init(codec, &card->dapm); |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 688 | } |
| 689 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 690 | /* skylake audio machine driver for SPT + NAU88L25 */ |
| 691 | static struct snd_soc_card skylake_audio_card = { |
| 692 | .name = "sklnau8825adi", |
| 693 | .owner = THIS_MODULE, |
| 694 | .dai_link = skylake_dais, |
| 695 | .num_links = ARRAY_SIZE(skylake_dais), |
| 696 | .controls = skylake_controls, |
| 697 | .num_controls = ARRAY_SIZE(skylake_controls), |
| 698 | .dapm_widgets = skylake_widgets, |
| 699 | .num_dapm_widgets = ARRAY_SIZE(skylake_widgets), |
| 700 | .dapm_routes = skylake_map, |
| 701 | .num_dapm_routes = ARRAY_SIZE(skylake_map), |
| 702 | .codec_conf = ssm4567_codec_conf, |
| 703 | .num_configs = ARRAY_SIZE(ssm4567_codec_conf), |
Fang, Yang A | 4c6ebc3 | 2015-12-11 11:29:09 -0800 | [diff] [blame] | 704 | .fully_routed = true, |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 705 | .late_probe = skylake_card_late_probe, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 706 | }; |
| 707 | |
| 708 | static int skylake_audio_probe(struct platform_device *pdev) |
| 709 | { |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 710 | struct skl_nau88125_private *ctx; |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 711 | struct skl_machine_pdata *pdata; |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 712 | |
| 713 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); |
| 714 | if (!ctx) |
| 715 | return -ENOMEM; |
| 716 | |
| 717 | INIT_LIST_HEAD(&ctx->hdmi_pcm_list); |
| 718 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 719 | skylake_audio_card.dev = &pdev->dev; |
Subhransu S. Prusty | 46ed1a2 | 2016-04-14 10:07:33 +0530 | [diff] [blame] | 720 | snd_soc_card_set_drvdata(&skylake_audio_card, ctx); |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 721 | |
Yong Zhi | cfa1236 | 2016-05-31 10:22:48 -0500 | [diff] [blame] | 722 | pdata = dev_get_drvdata(&pdev->dev); |
| 723 | if (pdata) |
| 724 | dmic_constraints = pdata->dmic_num == 2 ? |
| 725 | &constraints_dmic_2ch : &constraints_dmic_channels; |
| 726 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 727 | return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card); |
| 728 | } |
| 729 | |
Vinod Koul | 9dc201c | 2016-07-13 22:13:47 +0530 | [diff] [blame] | 730 | static const struct platform_device_id skl_board_ids[] = { |
| 731 | { .name = "skl_n88l25_s4567" }, |
| 732 | { .name = "kbl_n88l25_s4567" }, |
| 733 | { } |
| 734 | }; |
| 735 | |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 736 | static struct platform_driver skylake_audio = { |
| 737 | .probe = skylake_audio_probe, |
| 738 | .driver = { |
Vinod Koul | 400ada0 | 2016-07-13 22:13:43 +0530 | [diff] [blame] | 739 | .name = "skl_n88l25_s4567", |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 740 | .pm = &snd_soc_pm_ops, |
| 741 | }, |
Vinod Koul | 9dc201c | 2016-07-13 22:13:47 +0530 | [diff] [blame] | 742 | .id_table = skl_board_ids, |
Harsha Priya | a86d505 | 2015-11-05 22:53:07 +0530 | [diff] [blame] | 743 | }; |
| 744 | |
| 745 | module_platform_driver(skylake_audio) |
| 746 | |
| 747 | /* Module information */ |
| 748 | MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>"); |
| 749 | MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>"); |
| 750 | MODULE_AUTHOR("Naveen M <naveen.m@intel.com>"); |
| 751 | MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>"); |
| 752 | MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>"); |
| 753 | MODULE_DESCRIPTION("Intel Audio Machine driver for SKL with NAU88L25 and SSM4567 in I2S Mode"); |
| 754 | MODULE_LICENSE("GPL v2"); |
Vinod Koul | 400ada0 | 2016-07-13 22:13:43 +0530 | [diff] [blame] | 755 | MODULE_ALIAS("platform:skl_n88l25_s4567"); |
Vinod Koul | 9dc201c | 2016-07-13 22:13:47 +0530 | [diff] [blame] | 756 | MODULE_ALIAS("platform:kbl_n88l25_s4567"); |