Commit | Line | Data |
---|---|---|
723bad3f SN |
1 | /* |
2 | * Intel Broxton-P I2S Machine Driver | |
3 | * | |
4 | * Copyright (C) 2016, Intel Corporation. All rights reserved. | |
5 | * | |
6 | * Modified from: | |
7 | * Intel Skylake I2S Machine driver | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU General Public License version | |
11 | * 2 as published by the Free Software Foundation. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | */ | |
18 | ||
19 | #include <linux/module.h> | |
20 | #include <linux/platform_device.h> | |
21 | #include <sound/core.h> | |
22 | #include <sound/jack.h> | |
23 | #include <sound/pcm.h> | |
24 | #include <sound/pcm_params.h> | |
25 | #include <sound/soc.h> | |
26 | #include "../../codecs/hdac_hdmi.h" | |
27 | #include "../../codecs/da7219.h" | |
28 | #include "../../codecs/da7219-aad.h" | |
29 | ||
30 | #define BXT_DIALOG_CODEC_DAI "da7219-hifi" | |
31 | #define BXT_MAXIM_CODEC_DAI "HiFi" | |
32 | #define DUAL_CHANNEL 2 | |
c1aee1d8 | 33 | #define QUAD_CHANNEL 4 |
723bad3f SN |
34 | |
35 | static struct snd_soc_jack broxton_headset; | |
625de2bf | 36 | static struct snd_soc_jack broxton_hdmi[3]; |
723bad3f | 37 | |
ba210346 JK |
38 | struct bxt_hdmi_pcm { |
39 | struct list_head head; | |
40 | struct snd_soc_dai *codec_dai; | |
41 | int device; | |
42 | }; | |
43 | ||
44 | struct bxt_card_private { | |
45 | struct list_head hdmi_pcm_list; | |
46 | }; | |
47 | ||
723bad3f SN |
48 | enum { |
49 | BXT_DPCM_AUDIO_PB = 0, | |
50 | BXT_DPCM_AUDIO_CP, | |
51 | BXT_DPCM_AUDIO_REF_CP, | |
43c02ede | 52 | BXT_DPCM_AUDIO_DMIC_CP, |
723bad3f SN |
53 | BXT_DPCM_AUDIO_HDMI1_PB, |
54 | BXT_DPCM_AUDIO_HDMI2_PB, | |
55 | BXT_DPCM_AUDIO_HDMI3_PB, | |
56 | }; | |
57 | ||
d7fba9dc HP |
58 | static int platform_clock_control(struct snd_soc_dapm_widget *w, |
59 | struct snd_kcontrol *k, int event) | |
60 | { | |
61 | int ret = 0; | |
62 | struct snd_soc_dapm_context *dapm = w->dapm; | |
63 | struct snd_soc_card *card = dapm->card; | |
64 | struct snd_soc_dai *codec_dai; | |
65 | ||
dfb6ec7a | 66 | codec_dai = snd_soc_card_get_codec_dai(card, BXT_DIALOG_CODEC_DAI); |
d7fba9dc HP |
67 | if (!codec_dai) { |
68 | dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); | |
69 | return -EIO; | |
70 | } | |
71 | ||
72 | if (SND_SOC_DAPM_EVENT_OFF(event)) { | |
73 | ret = snd_soc_dai_set_pll(codec_dai, 0, | |
74 | DA7219_SYSCLK_MCLK, 0, 0); | |
75 | if (ret) | |
76 | dev_err(card->dev, "failed to stop PLL: %d\n", ret); | |
77 | } else if(SND_SOC_DAPM_EVENT_ON(event)) { | |
d7fba9dc HP |
78 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
79 | DA7219_SYSCLK_PLL_SRM, 0, DA7219_PLL_FREQ_OUT_98304); | |
80 | if (ret) | |
81 | dev_err(card->dev, "failed to start PLL: %d\n", ret); | |
82 | } | |
83 | ||
84 | return ret; | |
85 | } | |
86 | ||
723bad3f SN |
87 | static const struct snd_kcontrol_new broxton_controls[] = { |
88 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), | |
89 | SOC_DAPM_PIN_SWITCH("Headset Mic"), | |
90 | SOC_DAPM_PIN_SWITCH("Spk"), | |
91 | }; | |
92 | ||
93 | static const struct snd_soc_dapm_widget broxton_widgets[] = { | |
94 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | |
95 | SND_SOC_DAPM_MIC("Headset Mic", NULL), | |
96 | SND_SOC_DAPM_SPK("Spk", NULL), | |
97 | SND_SOC_DAPM_MIC("SoC DMIC", NULL), | |
98 | SND_SOC_DAPM_SPK("HDMI1", NULL), | |
99 | SND_SOC_DAPM_SPK("HDMI2", NULL), | |
100 | SND_SOC_DAPM_SPK("HDMI3", NULL), | |
d7fba9dc HP |
101 | SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, |
102 | platform_clock_control, SND_SOC_DAPM_POST_PMD|SND_SOC_DAPM_PRE_PMU), | |
723bad3f SN |
103 | }; |
104 | ||
105 | static const struct snd_soc_dapm_route broxton_map[] = { | |
106 | /* HP jack connectors - unknown if we have jack detection */ | |
107 | {"Headphone Jack", NULL, "HPL"}, | |
108 | {"Headphone Jack", NULL, "HPR"}, | |
109 | ||
110 | /* speaker */ | |
111 | {"Spk", NULL, "Speaker"}, | |
112 | ||
113 | /* other jacks */ | |
114 | {"MIC", NULL, "Headset Mic"}, | |
115 | ||
116 | /* digital mics */ | |
117 | {"DMic", NULL, "SoC DMIC"}, | |
118 | ||
119 | /* CODEC BE connections */ | |
120 | {"HiFi Playback", NULL, "ssp5 Tx"}, | |
121 | {"ssp5 Tx", NULL, "codec0_out"}, | |
122 | ||
123 | {"Playback", NULL, "ssp1 Tx"}, | |
124 | {"ssp1 Tx", NULL, "codec1_out"}, | |
125 | ||
126 | {"codec0_in", NULL, "ssp1 Rx"}, | |
127 | {"ssp1 Rx", NULL, "Capture"}, | |
128 | ||
6d707a74 JK |
129 | {"HDMI1", NULL, "hif5-0 Output"}, |
130 | {"HDMI2", NULL, "hif6-0 Output"}, | |
131 | {"HDMI2", NULL, "hif7-0 Output"}, | |
723bad3f SN |
132 | |
133 | {"hifi3", NULL, "iDisp3 Tx"}, | |
134 | {"iDisp3 Tx", NULL, "iDisp3_out"}, | |
135 | {"hifi2", NULL, "iDisp2 Tx"}, | |
136 | {"iDisp2 Tx", NULL, "iDisp2_out"}, | |
137 | {"hifi1", NULL, "iDisp1 Tx"}, | |
138 | {"iDisp1 Tx", NULL, "iDisp1_out"}, | |
139 | ||
140 | /* DMIC */ | |
141 | {"dmic01_hifi", NULL, "DMIC01 Rx"}, | |
142 | {"DMIC01 Rx", NULL, "DMIC AIF"}, | |
d7fba9dc HP |
143 | |
144 | { "Headphone Jack", NULL, "Platform Clock" }, | |
145 | { "Headset Mic", NULL, "Platform Clock" }, | |
723bad3f SN |
146 | }; |
147 | ||
148 | static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd, | |
149 | struct snd_pcm_hw_params *params) | |
150 | { | |
151 | struct snd_interval *rate = hw_param_interval(params, | |
152 | SNDRV_PCM_HW_PARAM_RATE); | |
153 | struct snd_interval *channels = hw_param_interval(params, | |
154 | SNDRV_PCM_HW_PARAM_CHANNELS); | |
155 | struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); | |
156 | ||
157 | /* The ADSP will convert the FE rate to 48k, stereo */ | |
158 | rate->min = rate->max = 48000; | |
159 | channels->min = channels->max = DUAL_CHANNEL; | |
160 | ||
161 | /* set SSP to 24 bit */ | |
162 | snd_mask_none(fmt); | |
163 | snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); | |
164 | ||
165 | return 0; | |
166 | } | |
167 | ||
168 | static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) | |
169 | { | |
170 | int ret; | |
fd0f2375 | 171 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
45101122 | 172 | struct snd_soc_component *component = rtd->codec_dai->component; |
723bad3f | 173 | |
fd0f2375 AT |
174 | /* Configure sysclk for codec */ |
175 | ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 19200000, | |
176 | SND_SOC_CLOCK_IN); | |
177 | if (ret) { | |
178 | dev_err(rtd->dev, "can't set codec sysclk configuration\n"); | |
179 | return ret; | |
180 | } | |
181 | ||
723bad3f SN |
182 | /* |
183 | * Headset buttons map to the google Reference headset. | |
184 | * These can be configured by userspace. | |
185 | */ | |
186 | ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", | |
187 | SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | | |
a31b466f SN |
188 | SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, |
189 | &broxton_headset, NULL, 0); | |
723bad3f SN |
190 | if (ret) { |
191 | dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); | |
192 | return ret; | |
193 | } | |
194 | ||
45101122 | 195 | da7219_aad_jack_det(component, &broxton_headset); |
723bad3f SN |
196 | |
197 | snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); | |
198 | ||
199 | return ret; | |
200 | } | |
201 | ||
202 | static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd) | |
203 | { | |
ba210346 | 204 | struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card); |
723bad3f | 205 | struct snd_soc_dai *dai = rtd->codec_dai; |
ba210346 JK |
206 | struct bxt_hdmi_pcm *pcm; |
207 | ||
208 | pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); | |
209 | if (!pcm) | |
210 | return -ENOMEM; | |
723bad3f | 211 | |
ba210346 JK |
212 | pcm->device = BXT_DPCM_AUDIO_HDMI1_PB + dai->id; |
213 | pcm->codec_dai = dai; | |
214 | ||
215 | list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); | |
216 | ||
217 | return 0; | |
723bad3f SN |
218 | } |
219 | ||
220 | static int broxton_da7219_fe_init(struct snd_soc_pcm_runtime *rtd) | |
221 | { | |
222 | struct snd_soc_dapm_context *dapm; | |
223 | struct snd_soc_component *component = rtd->cpu_dai->component; | |
224 | ||
225 | dapm = snd_soc_component_get_dapm(component); | |
226 | snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); | |
227 | ||
228 | return 0; | |
229 | } | |
230 | ||
21031d53 | 231 | static const unsigned int rates[] = { |
723bad3f SN |
232 | 48000, |
233 | }; | |
234 | ||
21031d53 | 235 | static const struct snd_pcm_hw_constraint_list constraints_rates = { |
723bad3f SN |
236 | .count = ARRAY_SIZE(rates), |
237 | .list = rates, | |
238 | .mask = 0, | |
239 | }; | |
240 | ||
21031d53 | 241 | static const unsigned int channels[] = { |
723bad3f SN |
242 | DUAL_CHANNEL, |
243 | }; | |
244 | ||
21031d53 | 245 | static const struct snd_pcm_hw_constraint_list constraints_channels = { |
723bad3f SN |
246 | .count = ARRAY_SIZE(channels), |
247 | .list = channels, | |
248 | .mask = 0, | |
249 | }; | |
250 | ||
21031d53 | 251 | static const unsigned int channels_quad[] = { |
c1aee1d8 SN |
252 | QUAD_CHANNEL, |
253 | }; | |
254 | ||
21031d53 | 255 | static const struct snd_pcm_hw_constraint_list constraints_channels_quad = { |
c1aee1d8 SN |
256 | .count = ARRAY_SIZE(channels_quad), |
257 | .list = channels_quad, | |
258 | .mask = 0, | |
259 | }; | |
260 | ||
723bad3f SN |
261 | static int bxt_fe_startup(struct snd_pcm_substream *substream) |
262 | { | |
263 | struct snd_pcm_runtime *runtime = substream->runtime; | |
264 | ||
265 | /* | |
266 | * On this platform for PCM device we support, | |
267 | * 48Khz | |
268 | * stereo | |
269 | * 16 bit audio | |
270 | */ | |
271 | ||
272 | runtime->hw.channels_max = DUAL_CHANNEL; | |
273 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | |
274 | &constraints_channels); | |
275 | ||
276 | runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; | |
277 | snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); | |
278 | ||
279 | snd_pcm_hw_constraint_list(runtime, 0, | |
280 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); | |
281 | ||
282 | return 0; | |
283 | } | |
284 | ||
285 | static const struct snd_soc_ops broxton_da7219_fe_ops = { | |
286 | .startup = bxt_fe_startup, | |
287 | }; | |
288 | ||
43c02ede YZ |
289 | static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd, |
290 | struct snd_pcm_hw_params *params) | |
291 | { | |
292 | struct snd_interval *channels = hw_param_interval(params, | |
293 | SNDRV_PCM_HW_PARAM_CHANNELS); | |
c1aee1d8 SN |
294 | if (params_channels(params) == 2) |
295 | channels->min = channels->max = 2; | |
296 | else | |
297 | channels->min = channels->max = 4; | |
43c02ede YZ |
298 | |
299 | return 0; | |
300 | } | |
301 | ||
302 | static int broxton_dmic_startup(struct snd_pcm_substream *substream) | |
303 | { | |
304 | struct snd_pcm_runtime *runtime = substream->runtime; | |
305 | ||
c1aee1d8 | 306 | runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL; |
43c02ede | 307 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
c1aee1d8 | 308 | &constraints_channels_quad); |
43c02ede YZ |
309 | |
310 | return snd_pcm_hw_constraint_list(substream->runtime, 0, | |
311 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); | |
312 | } | |
313 | ||
314 | static const struct snd_soc_ops broxton_dmic_ops = { | |
315 | .startup = broxton_dmic_startup, | |
316 | }; | |
317 | ||
318 | static const unsigned int rates_16000[] = { | |
319 | 16000, | |
320 | }; | |
321 | ||
322 | static const struct snd_pcm_hw_constraint_list constraints_16000 = { | |
323 | .count = ARRAY_SIZE(rates_16000), | |
324 | .list = rates_16000, | |
325 | }; | |
326 | ||
327 | static int broxton_refcap_startup(struct snd_pcm_substream *substream) | |
328 | { | |
329 | return snd_pcm_hw_constraint_list(substream->runtime, 0, | |
330 | SNDRV_PCM_HW_PARAM_RATE, | |
331 | &constraints_16000); | |
332 | }; | |
333 | ||
9b6fdef6 | 334 | static const struct snd_soc_ops broxton_refcap_ops = { |
43c02ede YZ |
335 | .startup = broxton_refcap_startup, |
336 | }; | |
337 | ||
723bad3f SN |
338 | /* broxton digital audio interface glue - connects codec <--> CPU */ |
339 | static struct snd_soc_dai_link broxton_dais[] = { | |
340 | /* Front End DAI links */ | |
43d443dc | 341 | [BXT_DPCM_AUDIO_PB] = |
723bad3f SN |
342 | { |
343 | .name = "Bxt Audio Port", | |
344 | .stream_name = "Audio", | |
345 | .cpu_dai_name = "System Pin", | |
346 | .platform_name = "0000:00:0e.0", | |
347 | .dynamic = 1, | |
348 | .codec_name = "snd-soc-dummy", | |
349 | .codec_dai_name = "snd-soc-dummy-dai", | |
350 | .nonatomic = 1, | |
351 | .init = broxton_da7219_fe_init, | |
352 | .trigger = { | |
353 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | |
354 | .dpcm_playback = 1, | |
355 | .ops = &broxton_da7219_fe_ops, | |
356 | }, | |
43d443dc | 357 | [BXT_DPCM_AUDIO_CP] = |
723bad3f SN |
358 | { |
359 | .name = "Bxt Audio Capture Port", | |
360 | .stream_name = "Audio Record", | |
361 | .cpu_dai_name = "System Pin", | |
362 | .platform_name = "0000:00:0e.0", | |
363 | .dynamic = 1, | |
364 | .codec_name = "snd-soc-dummy", | |
365 | .codec_dai_name = "snd-soc-dummy-dai", | |
366 | .nonatomic = 1, | |
367 | .trigger = { | |
368 | SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | |
369 | .dpcm_capture = 1, | |
370 | .ops = &broxton_da7219_fe_ops, | |
371 | }, | |
43d443dc | 372 | [BXT_DPCM_AUDIO_REF_CP] = |
723bad3f SN |
373 | { |
374 | .name = "Bxt Audio Reference cap", | |
375 | .stream_name = "Refcap", | |
376 | .cpu_dai_name = "Reference Pin", | |
377 | .codec_name = "snd-soc-dummy", | |
378 | .codec_dai_name = "snd-soc-dummy-dai", | |
379 | .platform_name = "0000:00:0e.0", | |
380 | .init = NULL, | |
381 | .dpcm_capture = 1, | |
723bad3f SN |
382 | .nonatomic = 1, |
383 | .dynamic = 1, | |
43c02ede YZ |
384 | .ops = &broxton_refcap_ops, |
385 | }, | |
89c03ddb | 386 | [BXT_DPCM_AUDIO_DMIC_CP] = |
43c02ede YZ |
387 | { |
388 | .name = "Bxt Audio DMIC cap", | |
389 | .stream_name = "dmiccap", | |
390 | .cpu_dai_name = "DMIC Pin", | |
391 | .codec_name = "snd-soc-dummy", | |
392 | .codec_dai_name = "snd-soc-dummy-dai", | |
393 | .platform_name = "0000:00:0e.0", | |
394 | .init = NULL, | |
395 | .dpcm_capture = 1, | |
396 | .nonatomic = 1, | |
397 | .dynamic = 1, | |
398 | .ops = &broxton_dmic_ops, | |
723bad3f | 399 | }, |
43d443dc | 400 | [BXT_DPCM_AUDIO_HDMI1_PB] = |
723bad3f SN |
401 | { |
402 | .name = "Bxt HDMI Port1", | |
403 | .stream_name = "Hdmi1", | |
404 | .cpu_dai_name = "HDMI1 Pin", | |
405 | .codec_name = "snd-soc-dummy", | |
406 | .codec_dai_name = "snd-soc-dummy-dai", | |
407 | .platform_name = "0000:00:0e.0", | |
408 | .dpcm_playback = 1, | |
409 | .init = NULL, | |
410 | .nonatomic = 1, | |
411 | .dynamic = 1, | |
412 | }, | |
43d443dc | 413 | [BXT_DPCM_AUDIO_HDMI2_PB] = |
723bad3f SN |
414 | { |
415 | .name = "Bxt HDMI Port2", | |
416 | .stream_name = "Hdmi2", | |
417 | .cpu_dai_name = "HDMI2 Pin", | |
418 | .codec_name = "snd-soc-dummy", | |
419 | .codec_dai_name = "snd-soc-dummy-dai", | |
420 | .platform_name = "0000:00:0e.0", | |
421 | .dpcm_playback = 1, | |
422 | .init = NULL, | |
423 | .nonatomic = 1, | |
424 | .dynamic = 1, | |
425 | }, | |
43d443dc | 426 | [BXT_DPCM_AUDIO_HDMI3_PB] = |
723bad3f SN |
427 | { |
428 | .name = "Bxt HDMI Port3", | |
429 | .stream_name = "Hdmi3", | |
430 | .cpu_dai_name = "HDMI3 Pin", | |
431 | .codec_name = "snd-soc-dummy", | |
432 | .codec_dai_name = "snd-soc-dummy-dai", | |
433 | .platform_name = "0000:00:0e.0", | |
434 | .dpcm_playback = 1, | |
435 | .init = NULL, | |
436 | .nonatomic = 1, | |
437 | .dynamic = 1, | |
438 | }, | |
439 | /* Back End DAI links */ | |
440 | { | |
441 | /* SSP5 - Codec */ | |
442 | .name = "SSP5-Codec", | |
443 | .id = 0, | |
444 | .cpu_dai_name = "SSP5 Pin", | |
445 | .platform_name = "0000:00:0e.0", | |
446 | .no_pcm = 1, | |
447 | .codec_name = "MX98357A:00", | |
448 | .codec_dai_name = BXT_MAXIM_CODEC_DAI, | |
449 | .dai_fmt = SND_SOC_DAIFMT_I2S | | |
450 | SND_SOC_DAIFMT_NB_NF | | |
451 | SND_SOC_DAIFMT_CBS_CFS, | |
452 | .ignore_pmdown_time = 1, | |
453 | .be_hw_params_fixup = broxton_ssp_fixup, | |
454 | .dpcm_playback = 1, | |
455 | }, | |
456 | { | |
457 | /* SSP1 - Codec */ | |
458 | .name = "SSP1-Codec", | |
459 | .id = 1, | |
460 | .cpu_dai_name = "SSP1 Pin", | |
461 | .platform_name = "0000:00:0e.0", | |
462 | .no_pcm = 1, | |
463 | .codec_name = "i2c-DLGS7219:00", | |
464 | .codec_dai_name = BXT_DIALOG_CODEC_DAI, | |
465 | .init = broxton_da7219_codec_init, | |
466 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | |
467 | SND_SOC_DAIFMT_CBS_CFS, | |
468 | .ignore_pmdown_time = 1, | |
469 | .be_hw_params_fixup = broxton_ssp_fixup, | |
723bad3f SN |
470 | .dpcm_playback = 1, |
471 | .dpcm_capture = 1, | |
472 | }, | |
473 | { | |
474 | .name = "dmic01", | |
475 | .id = 2, | |
476 | .cpu_dai_name = "DMIC01 Pin", | |
477 | .codec_name = "dmic-codec", | |
478 | .codec_dai_name = "dmic-hifi", | |
479 | .platform_name = "0000:00:0e.0", | |
480 | .ignore_suspend = 1, | |
43c02ede | 481 | .be_hw_params_fixup = broxton_dmic_fixup, |
723bad3f SN |
482 | .dpcm_capture = 1, |
483 | .no_pcm = 1, | |
484 | }, | |
485 | { | |
486 | .name = "iDisp1", | |
487 | .id = 3, | |
488 | .cpu_dai_name = "iDisp1 Pin", | |
489 | .codec_name = "ehdaudio0D2", | |
490 | .codec_dai_name = "intel-hdmi-hifi1", | |
491 | .platform_name = "0000:00:0e.0", | |
492 | .init = broxton_hdmi_init, | |
493 | .dpcm_playback = 1, | |
494 | .no_pcm = 1, | |
495 | }, | |
496 | { | |
497 | .name = "iDisp2", | |
498 | .id = 4, | |
499 | .cpu_dai_name = "iDisp2 Pin", | |
500 | .codec_name = "ehdaudio0D2", | |
501 | .codec_dai_name = "intel-hdmi-hifi2", | |
502 | .platform_name = "0000:00:0e.0", | |
503 | .init = broxton_hdmi_init, | |
504 | .dpcm_playback = 1, | |
505 | .no_pcm = 1, | |
506 | }, | |
507 | { | |
508 | .name = "iDisp3", | |
509 | .id = 5, | |
510 | .cpu_dai_name = "iDisp3 Pin", | |
511 | .codec_name = "ehdaudio0D2", | |
512 | .codec_dai_name = "intel-hdmi-hifi3", | |
513 | .platform_name = "0000:00:0e.0", | |
514 | .init = broxton_hdmi_init, | |
515 | .dpcm_playback = 1, | |
516 | .no_pcm = 1, | |
517 | }, | |
518 | }; | |
519 | ||
625de2bf | 520 | #define NAME_SIZE 32 |
ba210346 JK |
521 | static int bxt_card_late_probe(struct snd_soc_card *card) |
522 | { | |
523 | struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); | |
524 | struct bxt_hdmi_pcm *pcm; | |
45101122 | 525 | struct snd_soc_component *component = NULL; |
625de2bf JK |
526 | int err, i = 0; |
527 | char jack_name[NAME_SIZE]; | |
ba210346 JK |
528 | |
529 | list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { | |
45101122 | 530 | component = pcm->codec_dai->component; |
625de2bf JK |
531 | snprintf(jack_name, sizeof(jack_name), |
532 | "HDMI/DP, pcm=%d Jack", pcm->device); | |
533 | err = snd_soc_card_jack_new(card, jack_name, | |
534 | SND_JACK_AVOUT, &broxton_hdmi[i], | |
535 | NULL, 0); | |
536 | ||
537 | if (err) | |
538 | return err; | |
539 | ||
540 | err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, | |
541 | &broxton_hdmi[i]); | |
ba210346 JK |
542 | if (err < 0) |
543 | return err; | |
625de2bf JK |
544 | |
545 | i++; | |
ba210346 JK |
546 | } |
547 | ||
45101122 | 548 | if (!component) |
c5cf9f37 JK |
549 | return -EINVAL; |
550 | ||
45101122 | 551 | return hdac_hdmi_jack_port_init(component, &card->dapm); |
ba210346 JK |
552 | } |
553 | ||
723bad3f SN |
554 | /* broxton audio machine driver for SPT + da7219 */ |
555 | static struct snd_soc_card broxton_audio_card = { | |
556 | .name = "bxtda7219max", | |
557 | .owner = THIS_MODULE, | |
558 | .dai_link = broxton_dais, | |
559 | .num_links = ARRAY_SIZE(broxton_dais), | |
560 | .controls = broxton_controls, | |
561 | .num_controls = ARRAY_SIZE(broxton_controls), | |
562 | .dapm_widgets = broxton_widgets, | |
563 | .num_dapm_widgets = ARRAY_SIZE(broxton_widgets), | |
564 | .dapm_routes = broxton_map, | |
565 | .num_dapm_routes = ARRAY_SIZE(broxton_map), | |
566 | .fully_routed = true, | |
ba210346 | 567 | .late_probe = bxt_card_late_probe, |
723bad3f SN |
568 | }; |
569 | ||
570 | static int broxton_audio_probe(struct platform_device *pdev) | |
571 | { | |
ba210346 JK |
572 | struct bxt_card_private *ctx; |
573 | ||
574 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); | |
575 | if (!ctx) | |
576 | return -ENOMEM; | |
577 | ||
578 | INIT_LIST_HEAD(&ctx->hdmi_pcm_list); | |
579 | ||
723bad3f | 580 | broxton_audio_card.dev = &pdev->dev; |
ba210346 JK |
581 | snd_soc_card_set_drvdata(&broxton_audio_card, ctx); |
582 | ||
723bad3f SN |
583 | return devm_snd_soc_register_card(&pdev->dev, &broxton_audio_card); |
584 | } | |
585 | ||
586 | static struct platform_driver broxton_audio = { | |
587 | .probe = broxton_audio_probe, | |
588 | .driver = { | |
589 | .name = "bxt_da7219_max98357a_i2s", | |
590 | .pm = &snd_soc_pm_ops, | |
591 | }, | |
592 | }; | |
593 | module_platform_driver(broxton_audio) | |
594 | ||
595 | /* Module information */ | |
596 | MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode"); | |
597 | MODULE_AUTHOR("Sathyanarayana Nujella <sathyanarayana.nujella@intel.com>"); | |
598 | MODULE_AUTHOR("Rohit Ainapure <rohit.m.ainapure@intel.com>"); | |
599 | MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>"); | |
600 | MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>"); | |
601 | MODULE_LICENSE("GPL v2"); | |
602 | MODULE_ALIAS("platform:bxt_da7219_max98357a_i2s"); |