Thomas Gleixner | 1802d0b | 2019-05-27 08:55:21 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Intel Skylake I2S Machine Driver |
| 4 | * |
| 5 | * Copyright (C) 2014-2015, Intel Corporation. All rights reserved. |
| 6 | * |
| 7 | * Modified from: |
| 8 | * Intel Broadwell Wildcatpoint SST Audio |
| 9 | * |
| 10 | * Copyright (C) 2013, Intel Corporation. All rights reserved. |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <sound/core.h> |
| 16 | #include <sound/pcm.h> |
| 17 | #include <sound/soc.h> |
| 18 | #include <sound/jack.h> |
| 19 | #include <sound/pcm_params.h> |
| 20 | #include "../../codecs/rt286.h" |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 21 | #include "../../codecs/hdac_hdmi.h" |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 22 | |
| 23 | static struct snd_soc_jack skylake_headset; |
Jeeja KP | f3af359 | 2017-02-07 19:09:50 +0530 | [diff] [blame] | 24 | static struct snd_soc_jack skylake_hdmi[3]; |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 25 | |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 26 | struct skl_hdmi_pcm { |
| 27 | struct list_head head; |
| 28 | struct snd_soc_dai *codec_dai; |
| 29 | int device; |
| 30 | }; |
| 31 | |
| 32 | struct skl_rt286_private { |
| 33 | struct list_head hdmi_pcm_list; |
| 34 | }; |
| 35 | |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 36 | enum { |
| 37 | SKL_DPCM_AUDIO_PB = 0, |
Subhransu S. Prusty | 1f0f8bd | 2017-06-19 11:59:21 +0530 | [diff] [blame] | 38 | SKL_DPCM_AUDIO_DB_PB, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 39 | SKL_DPCM_AUDIO_CP, |
| 40 | SKL_DPCM_AUDIO_REF_CP, |
| 41 | SKL_DPCM_AUDIO_DMIC_CP, |
| 42 | SKL_DPCM_AUDIO_HDMI1_PB, |
| 43 | SKL_DPCM_AUDIO_HDMI2_PB, |
| 44 | SKL_DPCM_AUDIO_HDMI3_PB, |
| 45 | }; |
| 46 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 47 | /* Headset jack detection DAPM pins */ |
| 48 | static struct snd_soc_jack_pin skylake_headset_pins[] = { |
| 49 | { |
| 50 | .pin = "Mic Jack", |
| 51 | .mask = SND_JACK_MICROPHONE, |
| 52 | }, |
| 53 | { |
| 54 | .pin = "Headphone Jack", |
| 55 | .mask = SND_JACK_HEADPHONE, |
| 56 | }, |
| 57 | }; |
| 58 | |
| 59 | static const struct snd_kcontrol_new skylake_controls[] = { |
| 60 | SOC_DAPM_PIN_SWITCH("Speaker"), |
| 61 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), |
| 62 | SOC_DAPM_PIN_SWITCH("Mic Jack"), |
| 63 | }; |
| 64 | |
| 65 | static const struct snd_soc_dapm_widget skylake_widgets[] = { |
| 66 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 67 | SND_SOC_DAPM_SPK("Speaker", NULL), |
| 68 | SND_SOC_DAPM_MIC("Mic Jack", NULL), |
| 69 | SND_SOC_DAPM_MIC("DMIC2", NULL), |
| 70 | SND_SOC_DAPM_MIC("SoC DMIC", NULL), |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 71 | SND_SOC_DAPM_SPK("HDMI1", NULL), |
| 72 | SND_SOC_DAPM_SPK("HDMI2", NULL), |
| 73 | SND_SOC_DAPM_SPK("HDMI3", NULL), |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | static const struct snd_soc_dapm_route skylake_rt286_map[] = { |
| 77 | /* speaker */ |
| 78 | {"Speaker", NULL, "SPOR"}, |
| 79 | {"Speaker", NULL, "SPOL"}, |
| 80 | |
| 81 | /* HP jack connectors - unknown if we have jack deteck */ |
| 82 | {"Headphone Jack", NULL, "HPO Pin"}, |
| 83 | |
| 84 | /* other jacks */ |
| 85 | {"MIC1", NULL, "Mic Jack"}, |
| 86 | |
| 87 | /* digital mics */ |
| 88 | {"DMIC1 Pin", NULL, "DMIC2"}, |
Vinod Koul | 820f339 | 2015-12-03 23:29:59 +0530 | [diff] [blame] | 89 | {"DMic", NULL, "SoC DMIC"}, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 90 | |
| 91 | /* CODEC BE connections */ |
| 92 | { "AIF1 Playback", NULL, "ssp0 Tx"}, |
| 93 | { "ssp0 Tx", NULL, "codec0_out"}, |
| 94 | { "ssp0 Tx", NULL, "codec1_out"}, |
| 95 | |
| 96 | { "codec0_in", NULL, "ssp0 Rx" }, |
| 97 | { "codec1_in", NULL, "ssp0 Rx" }, |
| 98 | { "ssp0 Rx", NULL, "AIF1 Capture" }, |
| 99 | |
| 100 | { "dmic01_hifi", NULL, "DMIC01 Rx" }, |
Vinod Koul | 820f339 | 2015-12-03 23:29:59 +0530 | [diff] [blame] | 101 | { "DMIC01 Rx", NULL, "DMIC AIF" }, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 102 | |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 103 | { "hifi3", NULL, "iDisp3 Tx"}, |
| 104 | { "iDisp3 Tx", NULL, "iDisp3_out"}, |
| 105 | { "hifi2", NULL, "iDisp2 Tx"}, |
| 106 | { "iDisp2 Tx", NULL, "iDisp2_out"}, |
| 107 | { "hifi1", NULL, "iDisp1 Tx"}, |
| 108 | { "iDisp1 Tx", NULL, "iDisp1_out"}, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 109 | |
| 110 | }; |
| 111 | |
Praveen Diwakar | 9ec2053 | 2015-12-03 23:30:01 +0530 | [diff] [blame] | 112 | static int skylake_rt286_fe_init(struct snd_soc_pcm_runtime *rtd) |
| 113 | { |
| 114 | struct snd_soc_dapm_context *dapm; |
| 115 | struct snd_soc_component *component = rtd->cpu_dai->component; |
| 116 | |
| 117 | dapm = snd_soc_component_get_dapm(component); |
| 118 | snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 123 | static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 124 | { |
Kuninori Morimoto | 4510112 | 2018-01-29 04:36:54 +0000 | [diff] [blame] | 125 | struct snd_soc_component *component = rtd->codec_dai->component; |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 126 | int ret; |
| 127 | |
| 128 | ret = snd_soc_card_jack_new(rtd->card, "Headset", |
| 129 | SND_JACK_HEADSET | SND_JACK_BTN_0, |
| 130 | &skylake_headset, |
| 131 | skylake_headset_pins, ARRAY_SIZE(skylake_headset_pins)); |
| 132 | |
| 133 | if (ret) |
| 134 | return ret; |
| 135 | |
Kuninori Morimoto | 4510112 | 2018-01-29 04:36:54 +0000 | [diff] [blame] | 136 | rt286_mic_detect(component, &skylake_headset); |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 137 | |
Praveen Diwakar | 9ec2053 | 2015-12-03 23:30:01 +0530 | [diff] [blame] | 138 | snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); |
Praveen Diwakar | 9ec2053 | 2015-12-03 23:30:01 +0530 | [diff] [blame] | 139 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 140 | return 0; |
| 141 | } |
| 142 | |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 143 | static int skylake_hdmi_init(struct snd_soc_pcm_runtime *rtd) |
| 144 | { |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 145 | struct skl_rt286_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 146 | struct snd_soc_dai *dai = rtd->codec_dai; |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 147 | struct skl_hdmi_pcm *pcm; |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 148 | |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 149 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); |
| 150 | if (!pcm) |
| 151 | return -ENOMEM; |
| 152 | |
| 153 | pcm->device = SKL_DPCM_AUDIO_HDMI1_PB + dai->id; |
| 154 | pcm->codec_dai = dai; |
| 155 | |
| 156 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); |
| 157 | |
| 158 | return 0; |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 159 | } |
| 160 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 161 | static const unsigned int rates[] = { |
Vinod Koul | 5eab6ab | 2015-11-13 19:22:12 +0530 | [diff] [blame] | 162 | 48000, |
| 163 | }; |
| 164 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 165 | static const struct snd_pcm_hw_constraint_list constraints_rates = { |
Vinod Koul | 5eab6ab | 2015-11-13 19:22:12 +0530 | [diff] [blame] | 166 | .count = ARRAY_SIZE(rates), |
| 167 | .list = rates, |
| 168 | .mask = 0, |
| 169 | }; |
| 170 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 171 | static const unsigned int channels[] = { |
Vinod Koul | 5eab6ab | 2015-11-13 19:22:12 +0530 | [diff] [blame] | 172 | 2, |
| 173 | }; |
| 174 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 175 | static const struct snd_pcm_hw_constraint_list constraints_channels = { |
Vinod Koul | 5eab6ab | 2015-11-13 19:22:12 +0530 | [diff] [blame] | 176 | .count = ARRAY_SIZE(channels), |
| 177 | .list = channels, |
| 178 | .mask = 0, |
| 179 | }; |
| 180 | |
| 181 | static int skl_fe_startup(struct snd_pcm_substream *substream) |
| 182 | { |
| 183 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 184 | |
| 185 | /* |
| 186 | * on this platform for PCM device we support, |
| 187 | * 48Khz |
| 188 | * stereo |
| 189 | * 16 bit audio |
| 190 | */ |
| 191 | |
| 192 | runtime->hw.channels_max = 2; |
| 193 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
| 194 | &constraints_channels); |
| 195 | |
| 196 | runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; |
| 197 | snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); |
| 198 | |
| 199 | snd_pcm_hw_constraint_list(runtime, 0, |
| 200 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static const struct snd_soc_ops skylake_rt286_fe_ops = { |
| 206 | .startup = skl_fe_startup, |
| 207 | }; |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 208 | |
| 209 | static int skylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, |
| 210 | struct snd_pcm_hw_params *params) |
| 211 | { |
| 212 | struct snd_interval *rate = hw_param_interval(params, |
| 213 | SNDRV_PCM_HW_PARAM_RATE); |
Pierre-Louis Bossart | 0c7288f | 2020-01-13 15:04:25 -0600 | [diff] [blame] | 214 | struct snd_interval *chan = hw_param_interval(params, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 215 | SNDRV_PCM_HW_PARAM_CHANNELS); |
Jeeja KP | 677165f | 2015-10-29 12:31:34 +0900 | [diff] [blame] | 216 | struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 217 | |
| 218 | /* The output is 48KHz, stereo, 16bits */ |
| 219 | rate->min = rate->max = 48000; |
Pierre-Louis Bossart | 0c7288f | 2020-01-13 15:04:25 -0600 | [diff] [blame] | 220 | chan->min = chan->max = 2; |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 221 | |
Jeeja KP | 677165f | 2015-10-29 12:31:34 +0900 | [diff] [blame] | 222 | /* set SSP0 to 24 bit */ |
| 223 | snd_mask_none(fmt); |
Takashi Iwai | b5453e8 | 2018-07-25 23:17:19 +0200 | [diff] [blame] | 224 | snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 225 | return 0; |
| 226 | } |
| 227 | |
| 228 | static int skylake_rt286_hw_params(struct snd_pcm_substream *substream, |
| 229 | struct snd_pcm_hw_params *params) |
| 230 | { |
| 231 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 232 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 233 | int ret; |
| 234 | |
| 235 | ret = snd_soc_dai_set_sysclk(codec_dai, RT286_SCLK_S_PLL, 24000000, |
| 236 | SND_SOC_CLOCK_IN); |
| 237 | if (ret < 0) |
| 238 | dev_err(rtd->dev, "set codec sysclk failed: %d\n", ret); |
| 239 | |
| 240 | return ret; |
| 241 | } |
| 242 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 243 | static const struct snd_soc_ops skylake_rt286_ops = { |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 244 | .hw_params = skylake_rt286_hw_params, |
| 245 | }; |
| 246 | |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 247 | static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, |
| 248 | struct snd_pcm_hw_params *params) |
| 249 | { |
Pierre-Louis Bossart | 0c7288f | 2020-01-13 15:04:25 -0600 | [diff] [blame] | 250 | struct snd_interval *chan = hw_param_interval(params, |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 251 | SNDRV_PCM_HW_PARAM_CHANNELS); |
Jeeja KP | 6e3ffa0 | 2016-02-03 17:59:53 +0530 | [diff] [blame] | 252 | if (params_channels(params) == 2) |
Pierre-Louis Bossart | 0c7288f | 2020-01-13 15:04:25 -0600 | [diff] [blame] | 253 | chan->min = chan->max = 2; |
Jeeja KP | 6e3ffa0 | 2016-02-03 17:59:53 +0530 | [diff] [blame] | 254 | else |
Pierre-Louis Bossart | 0c7288f | 2020-01-13 15:04:25 -0600 | [diff] [blame] | 255 | chan->min = chan->max = 4; |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 256 | |
| 257 | return 0; |
| 258 | } |
| 259 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 260 | static const unsigned int channels_dmic[] = { |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 261 | 2, 4, |
| 262 | }; |
| 263 | |
Takashi Iwai | 617647a | 2017-06-08 23:37:23 +0200 | [diff] [blame] | 264 | static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = { |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 265 | .count = ARRAY_SIZE(channels_dmic), |
| 266 | .list = channels_dmic, |
| 267 | .mask = 0, |
| 268 | }; |
| 269 | |
| 270 | static int skylake_dmic_startup(struct snd_pcm_substream *substream) |
| 271 | { |
| 272 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 273 | |
| 274 | runtime->hw.channels_max = 4; |
| 275 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
| 276 | &constraints_dmic_channels); |
| 277 | |
| 278 | return snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 279 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); |
| 280 | } |
| 281 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 282 | static const struct snd_soc_ops skylake_dmic_ops = { |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 283 | .startup = skylake_dmic_startup, |
| 284 | }; |
| 285 | |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 286 | SND_SOC_DAILINK_DEF(dummy, |
| 287 | DAILINK_COMP_ARRAY(COMP_DUMMY())); |
| 288 | |
| 289 | SND_SOC_DAILINK_DEF(system, |
| 290 | DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); |
| 291 | |
| 292 | SND_SOC_DAILINK_DEF(deepbuffer, |
| 293 | DAILINK_COMP_ARRAY(COMP_CPU("Deepbuffer Pin"))); |
| 294 | |
| 295 | SND_SOC_DAILINK_DEF(reference, |
| 296 | DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin"))); |
| 297 | |
| 298 | SND_SOC_DAILINK_DEF(dmic, |
| 299 | DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin"))); |
| 300 | |
| 301 | SND_SOC_DAILINK_DEF(hdmi1, |
| 302 | DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin"))); |
| 303 | |
| 304 | SND_SOC_DAILINK_DEF(hdmi2, |
| 305 | DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin"))); |
| 306 | |
| 307 | SND_SOC_DAILINK_DEF(hdmi3, |
| 308 | DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin"))); |
| 309 | |
| 310 | SND_SOC_DAILINK_DEF(ssp0_pin, |
| 311 | DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin"))); |
| 312 | SND_SOC_DAILINK_DEF(ssp0_codec, |
| 313 | DAILINK_COMP_ARRAY(COMP_CODEC("i2c-INT343A:00", "rt286-aif1"))); |
| 314 | |
| 315 | SND_SOC_DAILINK_DEF(dmic01_pin, |
| 316 | DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); |
| 317 | SND_SOC_DAILINK_DEF(dmic_codec, |
| 318 | DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); |
| 319 | |
| 320 | SND_SOC_DAILINK_DEF(idisp1_pin, |
| 321 | DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); |
| 322 | SND_SOC_DAILINK_DEF(idisp1_codec, |
| 323 | DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1"))); |
| 324 | |
| 325 | SND_SOC_DAILINK_DEF(idisp2_pin, |
| 326 | DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); |
| 327 | SND_SOC_DAILINK_DEF(idisp2_codec, |
| 328 | DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); |
| 329 | |
| 330 | SND_SOC_DAILINK_DEF(idisp3_pin, |
| 331 | DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); |
| 332 | SND_SOC_DAILINK_DEF(idisp3_codec, |
| 333 | DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); |
| 334 | |
| 335 | SND_SOC_DAILINK_DEF(platform, |
| 336 | DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3"))); |
| 337 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 338 | /* skylake digital audio interface glue - connects codec <--> CPU */ |
| 339 | static struct snd_soc_dai_link skylake_rt286_dais[] = { |
| 340 | /* Front End DAI links */ |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 341 | [SKL_DPCM_AUDIO_PB] = { |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 342 | .name = "Skl Audio Port", |
| 343 | .stream_name = "Audio", |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 344 | .nonatomic = 1, |
| 345 | .dynamic = 1, |
Praveen Diwakar | 9ec2053 | 2015-12-03 23:30:01 +0530 | [diff] [blame] | 346 | .init = skylake_rt286_fe_init, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 347 | .trigger = { |
| 348 | SND_SOC_DPCM_TRIGGER_POST, |
| 349 | SND_SOC_DPCM_TRIGGER_POST |
| 350 | }, |
| 351 | .dpcm_playback = 1, |
Vinod Koul | 5eab6ab | 2015-11-13 19:22:12 +0530 | [diff] [blame] | 352 | .ops = &skylake_rt286_fe_ops, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 353 | SND_SOC_DAILINK_REG(system, dummy, platform), |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 354 | }, |
Subhransu S. Prusty | 1f0f8bd | 2017-06-19 11:59:21 +0530 | [diff] [blame] | 355 | [SKL_DPCM_AUDIO_DB_PB] = { |
| 356 | .name = "Skl Deepbuffer Port", |
| 357 | .stream_name = "Deep Buffer Audio", |
Subhransu S. Prusty | 1f0f8bd | 2017-06-19 11:59:21 +0530 | [diff] [blame] | 358 | .nonatomic = 1, |
| 359 | .dynamic = 1, |
Subhransu S. Prusty | 1f0f8bd | 2017-06-19 11:59:21 +0530 | [diff] [blame] | 360 | .trigger = { |
| 361 | SND_SOC_DPCM_TRIGGER_POST, |
| 362 | SND_SOC_DPCM_TRIGGER_POST |
| 363 | }, |
| 364 | .dpcm_playback = 1, |
| 365 | .ops = &skylake_rt286_fe_ops, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 366 | SND_SOC_DAILINK_REG(deepbuffer, dummy, platform), |
Subhransu S. Prusty | 1f0f8bd | 2017-06-19 11:59:21 +0530 | [diff] [blame] | 367 | }, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 368 | [SKL_DPCM_AUDIO_CP] = { |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 369 | .name = "Skl Audio Capture Port", |
| 370 | .stream_name = "Audio Record", |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 371 | .nonatomic = 1, |
| 372 | .dynamic = 1, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 373 | .trigger = { |
| 374 | SND_SOC_DPCM_TRIGGER_POST, |
| 375 | SND_SOC_DPCM_TRIGGER_POST |
| 376 | }, |
| 377 | .dpcm_capture = 1, |
Vinod Koul | 5eab6ab | 2015-11-13 19:22:12 +0530 | [diff] [blame] | 378 | .ops = &skylake_rt286_fe_ops, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 379 | SND_SOC_DAILINK_REG(system, dummy, platform), |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 380 | }, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 381 | [SKL_DPCM_AUDIO_REF_CP] = { |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 382 | .name = "Skl Audio Reference cap", |
| 383 | .stream_name = "refcap", |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 384 | .init = NULL, |
| 385 | .dpcm_capture = 1, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 386 | .nonatomic = 1, |
| 387 | .dynamic = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 388 | SND_SOC_DAILINK_REG(reference, dummy, platform), |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 389 | }, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 390 | [SKL_DPCM_AUDIO_DMIC_CP] = { |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 391 | .name = "Skl Audio DMIC cap", |
| 392 | .stream_name = "dmiccap", |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 393 | .init = NULL, |
| 394 | .dpcm_capture = 1, |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 395 | .nonatomic = 1, |
| 396 | .dynamic = 1, |
| 397 | .ops = &skylake_dmic_ops, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 398 | SND_SOC_DAILINK_REG(dmic, dummy, platform), |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 399 | }, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 400 | [SKL_DPCM_AUDIO_HDMI1_PB] = { |
| 401 | .name = "Skl HDMI Port1", |
| 402 | .stream_name = "Hdmi1", |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 403 | .dpcm_playback = 1, |
| 404 | .init = NULL, |
| 405 | .nonatomic = 1, |
| 406 | .dynamic = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 407 | SND_SOC_DAILINK_REG(hdmi1, dummy, platform), |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 408 | }, |
| 409 | [SKL_DPCM_AUDIO_HDMI2_PB] = { |
| 410 | .name = "Skl HDMI Port2", |
| 411 | .stream_name = "Hdmi2", |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 412 | .dpcm_playback = 1, |
| 413 | .init = NULL, |
| 414 | .nonatomic = 1, |
| 415 | .dynamic = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 416 | SND_SOC_DAILINK_REG(hdmi2, dummy, platform), |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 417 | }, |
| 418 | [SKL_DPCM_AUDIO_HDMI3_PB] = { |
| 419 | .name = "Skl HDMI Port3", |
| 420 | .stream_name = "Hdmi3", |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 421 | .dpcm_playback = 1, |
| 422 | .init = NULL, |
| 423 | .nonatomic = 1, |
| 424 | .dynamic = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 425 | SND_SOC_DAILINK_REG(hdmi3, dummy, platform), |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 426 | }, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 427 | |
| 428 | /* Back End DAI links */ |
| 429 | { |
| 430 | /* SSP0 - Codec */ |
| 431 | .name = "SSP0-Codec", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 432 | .id = 0, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 433 | .no_pcm = 1, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 434 | .init = skylake_rt286_codec_init, |
| 435 | .dai_fmt = SND_SOC_DAIFMT_I2S | |
| 436 | SND_SOC_DAIFMT_NB_NF | |
| 437 | SND_SOC_DAIFMT_CBS_CFS, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 438 | .ignore_pmdown_time = 1, |
| 439 | .be_hw_params_fixup = skylake_ssp0_fixup, |
| 440 | .ops = &skylake_rt286_ops, |
| 441 | .dpcm_playback = 1, |
| 442 | .dpcm_capture = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 443 | SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform), |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 444 | }, |
| 445 | { |
| 446 | .name = "dmic01", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 447 | .id = 1, |
Jeeja KP | 4386b76 | 2015-12-03 23:29:57 +0530 | [diff] [blame] | 448 | .be_hw_params_fixup = skylake_dmic_fixup, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 449 | .ignore_suspend = 1, |
| 450 | .dpcm_capture = 1, |
| 451 | .no_pcm = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 452 | SND_SOC_DAILINK_REG(dmic01_pin, dmic_codec, platform), |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 453 | }, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 454 | { |
| 455 | .name = "iDisp1", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 456 | .id = 2, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 457 | .init = skylake_hdmi_init, |
| 458 | .dpcm_playback = 1, |
| 459 | .no_pcm = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 460 | SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform), |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 461 | }, |
| 462 | { |
| 463 | .name = "iDisp2", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 464 | .id = 3, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 465 | .init = skylake_hdmi_init, |
| 466 | .dpcm_playback = 1, |
| 467 | .no_pcm = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 468 | SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform), |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 469 | }, |
| 470 | { |
| 471 | .name = "iDisp3", |
Mengdong Lin | 2f0ad49 | 2016-04-19 13:12:35 +0800 | [diff] [blame] | 472 | .id = 4, |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 473 | .init = skylake_hdmi_init, |
| 474 | .dpcm_playback = 1, |
| 475 | .no_pcm = 1, |
Kuninori Morimoto | 9cb56a5 | 2019-06-06 13:21:41 +0900 | [diff] [blame] | 476 | SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform), |
Jeeja KP | 23905cd | 2016-02-24 11:27:38 +0530 | [diff] [blame] | 477 | }, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 478 | }; |
| 479 | |
Jeeja KP | f3af359 | 2017-02-07 19:09:50 +0530 | [diff] [blame] | 480 | #define NAME_SIZE 32 |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 481 | static int skylake_card_late_probe(struct snd_soc_card *card) |
| 482 | { |
| 483 | struct skl_rt286_private *ctx = snd_soc_card_get_drvdata(card); |
| 484 | struct skl_hdmi_pcm *pcm; |
Kuninori Morimoto | 4510112 | 2018-01-29 04:36:54 +0000 | [diff] [blame] | 485 | struct snd_soc_component *component = NULL; |
Jeeja KP | f3af359 | 2017-02-07 19:09:50 +0530 | [diff] [blame] | 486 | int err, i = 0; |
| 487 | char jack_name[NAME_SIZE]; |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 488 | |
| 489 | list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { |
Kuninori Morimoto | 4510112 | 2018-01-29 04:36:54 +0000 | [diff] [blame] | 490 | component = pcm->codec_dai->component; |
Jeeja KP | f3af359 | 2017-02-07 19:09:50 +0530 | [diff] [blame] | 491 | snprintf(jack_name, sizeof(jack_name), |
| 492 | "HDMI/DP, pcm=%d Jack", pcm->device); |
| 493 | err = snd_soc_card_jack_new(card, jack_name, |
| 494 | SND_JACK_AVOUT, &skylake_hdmi[i], |
| 495 | NULL, 0); |
| 496 | |
| 497 | if (err) |
| 498 | return err; |
| 499 | |
| 500 | err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, |
| 501 | &skylake_hdmi[i]); |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 502 | if (err < 0) |
| 503 | return err; |
Jeeja KP | f3af359 | 2017-02-07 19:09:50 +0530 | [diff] [blame] | 504 | |
| 505 | i++; |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 506 | } |
| 507 | |
Kuninori Morimoto | 4510112 | 2018-01-29 04:36:54 +0000 | [diff] [blame] | 508 | if (!component) |
Jeeja KP | 64f8620 | 2017-02-07 19:09:56 +0530 | [diff] [blame] | 509 | return -EINVAL; |
| 510 | |
Kuninori Morimoto | 4510112 | 2018-01-29 04:36:54 +0000 | [diff] [blame] | 511 | return hdac_hdmi_jack_port_init(component, &card->dapm); |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 512 | } |
| 513 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 514 | /* skylake audio machine driver for SPT + RT286S */ |
| 515 | static struct snd_soc_card skylake_rt286 = { |
| 516 | .name = "skylake-rt286", |
| 517 | .owner = THIS_MODULE, |
| 518 | .dai_link = skylake_rt286_dais, |
| 519 | .num_links = ARRAY_SIZE(skylake_rt286_dais), |
| 520 | .controls = skylake_controls, |
| 521 | .num_controls = ARRAY_SIZE(skylake_controls), |
| 522 | .dapm_widgets = skylake_widgets, |
| 523 | .num_dapm_widgets = ARRAY_SIZE(skylake_widgets), |
| 524 | .dapm_routes = skylake_rt286_map, |
| 525 | .num_dapm_routes = ARRAY_SIZE(skylake_rt286_map), |
| 526 | .fully_routed = true, |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 527 | .late_probe = skylake_card_late_probe, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 528 | }; |
| 529 | |
| 530 | static int skylake_audio_probe(struct platform_device *pdev) |
| 531 | { |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 532 | struct skl_rt286_private *ctx; |
| 533 | |
Jia-Ju Bai | a6b0983 | 2018-04-09 18:49:58 +0800 | [diff] [blame] | 534 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 535 | if (!ctx) |
| 536 | return -ENOMEM; |
| 537 | |
| 538 | INIT_LIST_HEAD(&ctx->hdmi_pcm_list); |
| 539 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 540 | skylake_rt286.dev = &pdev->dev; |
Subhransu S. Prusty | 1a10612 | 2016-04-14 10:07:31 +0530 | [diff] [blame] | 541 | snd_soc_card_set_drvdata(&skylake_rt286, ctx); |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 542 | |
Axel Lin | 4901aa0 | 2015-10-20 19:13:45 +0800 | [diff] [blame] | 543 | return devm_snd_soc_register_card(&pdev->dev, &skylake_rt286); |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 544 | } |
| 545 | |
Vinod Koul | 894a16d | 2016-07-11 22:02:11 +0530 | [diff] [blame] | 546 | static const struct platform_device_id skl_board_ids[] = { |
| 547 | { .name = "skl_alc286s_i2s" }, |
| 548 | { .name = "kbl_alc286s_i2s" }, |
| 549 | { } |
| 550 | }; |
| 551 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 552 | static struct platform_driver skylake_audio = { |
| 553 | .probe = skylake_audio_probe, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 554 | .driver = { |
| 555 | .name = "skl_alc286s_i2s", |
Jeeja KP | 314038e | 2015-11-13 19:22:13 +0530 | [diff] [blame] | 556 | .pm = &snd_soc_pm_ops, |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 557 | }, |
Vinod Koul | 894a16d | 2016-07-11 22:02:11 +0530 | [diff] [blame] | 558 | .id_table = skl_board_ids, |
| 559 | |
Omair M Abdullah | 624729f | 2015-10-14 21:11:43 +0530 | [diff] [blame] | 560 | }; |
| 561 | |
| 562 | module_platform_driver(skylake_audio) |
| 563 | |
| 564 | /* Module information */ |
| 565 | MODULE_AUTHOR("Omair Mohammed Abdullah <omair.m.abdullah@intel.com>"); |
| 566 | MODULE_DESCRIPTION("Intel SST Audio for Skylake"); |
| 567 | MODULE_LICENSE("GPL v2"); |
| 568 | MODULE_ALIAS("platform:skl_alc286s_i2s"); |
Vinod Koul | 894a16d | 2016-07-11 22:02:11 +0530 | [diff] [blame] | 569 | MODULE_ALIAS("platform:kbl_alc286s_i2s"); |