~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/intel/boards/kbl_da7219_max98357a.c

Version: ~ [ linux-5.10-rc5 ] ~ [ linux-5.9.10 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.79 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.159 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.208 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.245 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.245 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 // Copyright(c) 2017-18 Intel Corporation.
  3 
  4 /*
  5  * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs
  6  *
  7  * Modified from:
  8  *   Intel Kabylake I2S Machine driver supporting MAXIM98927 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 KBL_MAXIM_CODEC_DAI "HiFi"
 26 #define MAXIM_DEV0_NAME "MX98357A:00"
 27 #define DUAL_CHANNEL 2
 28 #define QUAD_CHANNEL 4
 29 
 30 static struct snd_soc_card *kabylake_audio_card;
 31 static struct snd_soc_jack skylake_hdmi[3];
 32 
 33 struct kbl_hdmi_pcm {
 34         struct list_head head;
 35         struct snd_soc_dai *codec_dai;
 36         int device;
 37 };
 38 
 39 struct kbl_codec_private {
 40         struct snd_soc_jack kabylake_headset;
 41         struct list_head hdmi_pcm_list;
 42 };
 43 
 44 enum {
 45         KBL_DPCM_AUDIO_PB = 0,
 46         KBL_DPCM_AUDIO_CP,
 47         KBL_DPCM_AUDIO_DMIC_CP,
 48         KBL_DPCM_AUDIO_HDMI1_PB,
 49         KBL_DPCM_AUDIO_HDMI2_PB,
 50         KBL_DPCM_AUDIO_HDMI3_PB,
 51 };
 52 
 53 static int platform_clock_control(struct snd_soc_dapm_widget *w,
 54                                         struct snd_kcontrol *k, int  event)
 55 {
 56         struct snd_soc_dapm_context *dapm = w->dapm;
 57         struct snd_soc_card *card = dapm->card;
 58         struct snd_soc_dai *codec_dai;
 59         int ret = 0;
 60 
 61         codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI);
 62         if (!codec_dai) {
 63                 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
 64                 return -EIO;
 65         }
 66 
 67         if (SND_SOC_DAPM_EVENT_OFF(event)) {
 68                 ret = snd_soc_dai_set_pll(codec_dai, 0,
 69                                      DA7219_SYSCLK_MCLK, 0, 0);
 70                 if (ret)
 71                         dev_err(card->dev, "failed to stop PLL: %d\n", ret);
 72         } else if (SND_SOC_DAPM_EVENT_ON(event)) {
 73                 ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM,
 74                                      0, DA7219_PLL_FREQ_OUT_98304);
 75                 if (ret)
 76                         dev_err(card->dev, "failed to start PLL: %d\n", ret);
 77         }
 78 
 79         return ret;
 80 }
 81 
 82 static const struct snd_kcontrol_new kabylake_controls[] = {
 83         SOC_DAPM_PIN_SWITCH("Headphone Jack"),
 84         SOC_DAPM_PIN_SWITCH("Headset Mic"),
 85         SOC_DAPM_PIN_SWITCH("Spk"),
 86 };
 87 
 88 static const struct snd_soc_dapm_widget kabylake_widgets[] = {
 89         SND_SOC_DAPM_HP("Headphone Jack", NULL),
 90         SND_SOC_DAPM_MIC("Headset Mic", NULL),
 91         SND_SOC_DAPM_SPK("Spk", NULL),
 92         SND_SOC_DAPM_MIC("SoC DMIC", NULL),
 93         SND_SOC_DAPM_SPK("DP", NULL),
 94         SND_SOC_DAPM_SPK("HDMI", NULL),
 95         SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
 96                         platform_clock_control, SND_SOC_DAPM_PRE_PMU |
 97                         SND_SOC_DAPM_POST_PMD),
 98 };
 99 
100 static const struct snd_soc_dapm_route kabylake_map[] = {
101         { "Headphone Jack", NULL, "HPL" },
102         { "Headphone Jack", NULL, "HPR" },
103 
104         /* speaker */
105         { "Spk", NULL, "Speaker" },
106 
107         /* other jacks */
108         { "MIC", NULL, "Headset Mic" },
109         { "DMic", NULL, "SoC DMIC" },
110 
111         { "HDMI", NULL, "hif5 Output" },
112         { "DP", NULL, "hif6 Output" },
113 
114         /* CODEC BE connections */
115         { "HiFi Playback", NULL, "ssp0 Tx" },
116         { "ssp0 Tx", NULL, "codec0_out" },
117 
118         { "Playback", NULL, "ssp1 Tx" },
119         { "ssp1 Tx", NULL, "codec1_out" },
120 
121         { "codec0_in", NULL, "ssp1 Rx" },
122         { "ssp1 Rx", NULL, "Capture" },
123 
124         /* DMIC */
125         { "dmic01_hifi", NULL, "DMIC01 Rx" },
126         { "DMIC01 Rx", NULL, "DMIC AIF" },
127 
128         { "hifi1", NULL, "iDisp1 Tx" },
129         { "iDisp1 Tx", NULL, "iDisp1_out" },
130         { "hifi2", NULL, "iDisp2 Tx" },
131         { "iDisp2 Tx", NULL, "iDisp2_out" },
132         { "hifi3", NULL, "iDisp3 Tx"},
133         { "iDisp3 Tx", NULL, "iDisp3_out"},
134 
135         { "Headphone Jack", NULL, "Platform Clock" },
136         { "Headset Mic", NULL, "Platform Clock" },
137 };
138 
139 static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
140                         struct snd_pcm_hw_params *params)
141 {
142         struct snd_interval *rate = hw_param_interval(params,
143                         SNDRV_PCM_HW_PARAM_RATE);
144         struct snd_interval *channels = hw_param_interval(params,
145                         SNDRV_PCM_HW_PARAM_CHANNELS);
146         struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
147 
148         /* The ADSP will convert the FE rate to 48k, stereo */
149         rate->min = rate->max = 48000;
150         channels->min = channels->max = DUAL_CHANNEL;
151 
152         /* set SSP to 24 bit */
153         snd_mask_none(fmt);
154         snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
155 
156         return 0;
157 }
158 
159 static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
160 {
161         struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
162         struct snd_soc_component *component = rtd->codec_dai->component;
163         struct snd_soc_dai *codec_dai = rtd->codec_dai;
164         struct snd_soc_jack *jack;
165         int ret;
166 
167         /* Configure sysclk for codec */
168         ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000,
169                                                 SND_SOC_CLOCK_IN);
170         if (ret) {
171                 dev_err(rtd->dev, "can't set codec sysclk configuration\n");
172                 return ret;
173         }
174 
175         /*
176          * Headset buttons map to the google Reference headset.
177          * These can be configured by userspace.
178          */
179         ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
180                         SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
181                         SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
182                         &ctx->kabylake_headset, NULL, 0);
183         if (ret) {
184                 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
185                 return ret;
186         }
187 
188         jack = &ctx->kabylake_headset;
189 
190         snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
191         snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
192         snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
193         snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
194         da7219_aad_jack_det(component, &ctx->kabylake_headset);
195 
196         ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
197         if (ret)
198                 dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
199 
200         return ret;
201 }
202 
203 static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
204 {
205         struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
206         struct snd_soc_dai *dai = rtd->codec_dai;
207         struct kbl_hdmi_pcm *pcm;
208 
209         pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
210         if (!pcm)
211                 return -ENOMEM;
212 
213         pcm->device = device;
214         pcm->codec_dai = dai;
215 
216         list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
217 
218         return 0;
219 }
220 
221 static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
222 {
223         return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
224 }
225 
226 static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
227 {
228         return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
229 }
230 
231 static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
232 {
233         return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
234 }
235 
236 static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
237 {
238         struct snd_soc_dapm_context *dapm;
239         struct snd_soc_component *component = rtd->cpu_dai->component;
240 
241         dapm = snd_soc_component_get_dapm(component);
242         snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
243 
244         return 0;
245 }
246 
247 static const unsigned int rates[] = {
248         48000,
249 };
250 
251 static const struct snd_pcm_hw_constraint_list constraints_rates = {
252         .count = ARRAY_SIZE(rates),
253         .list  = rates,
254         .mask = 0,
255 };
256 
257 static const unsigned int channels[] = {
258         DUAL_CHANNEL,
259 };
260 
261 static const struct snd_pcm_hw_constraint_list constraints_channels = {
262         .count = ARRAY_SIZE(channels),
263         .list = channels,
264         .mask = 0,
265 };
266 
267 static unsigned int channels_quad[] = {
268         QUAD_CHANNEL,
269 };
270 
271 static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
272         .count = ARRAY_SIZE(channels_quad),
273         .list = channels_quad,
274         .mask = 0,
275 };
276 
277 static int kbl_fe_startup(struct snd_pcm_substream *substream)
278 {
279         struct snd_pcm_runtime *runtime = substream->runtime;
280 
281         /*
282          * On this platform for PCM device we support,
283          * 48Khz
284          * stereo
285          * 16 bit audio
286          */
287 
288         runtime->hw.channels_max = DUAL_CHANNEL;
289         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
290                                            &constraints_channels);
291 
292         runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
293         snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
294 
295         snd_pcm_hw_constraint_list(runtime, 0,
296                                 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
297 
298         return 0;
299 }
300 
301 static const struct snd_soc_ops kabylake_da7219_fe_ops = {
302         .startup = kbl_fe_startup,
303 };
304 
305 static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
306                 struct snd_pcm_hw_params *params)
307 {
308         struct snd_interval *channels = hw_param_interval(params,
309                                 SNDRV_PCM_HW_PARAM_CHANNELS);
310 
311         /*
312          * set BE channel constraint as user FE channels
313          */
314 
315         if (params_channels(params) == 2)
316                 channels->min = channels->max = 2;
317         else
318                 channels->min = channels->max = 4;
319 
320         return 0;
321 }
322 
323 static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
324 {
325         struct snd_pcm_runtime *runtime = substream->runtime;
326 
327         runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
328         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
329                         &constraints_channels_quad);
330 
331         return snd_pcm_hw_constraint_list(substream->runtime, 0,
332                         SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
333 }
334 
335 static struct snd_soc_ops kabylake_dmic_ops = {
336         .startup = kabylake_dmic_startup,
337 };
338 
339 static const unsigned int rates_16000[] = {
340         16000,
341 };
342 
343 static const struct snd_pcm_hw_constraint_list constraints_16000 = {
344         .count = ARRAY_SIZE(rates_16000),
345         .list  = rates_16000,
346 };
347 
348 static const unsigned int ch_mono[] = {
349         1,
350 };
351 
352 SND_SOC_DAILINK_DEF(dummy,
353         DAILINK_COMP_ARRAY(COMP_DUMMY()));
354 
355 SND_SOC_DAILINK_DEF(system,
356         DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
357 
358 SND_SOC_DAILINK_DEF(dmic,
359         DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
360 
361 SND_SOC_DAILINK_DEF(hdmi1,
362         DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
363 
364 SND_SOC_DAILINK_DEF(hdmi2,
365         DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
366 
367 SND_SOC_DAILINK_DEF(hdmi3,
368         DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
369 
370 SND_SOC_DAILINK_DEF(ssp0_pin,
371         DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
372 SND_SOC_DAILINK_DEF(ssp0_codec,
373         DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME,
374                                       KBL_MAXIM_CODEC_DAI)));
375 
376 SND_SOC_DAILINK_DEF(ssp1_pin,
377         DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
378 SND_SOC_DAILINK_DEF(ssp1_codec,
379         DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00",
380                                       KBL_DIALOG_CODEC_DAI)));
381 
382 SND_SOC_DAILINK_DEF(dmic_pin,
383         DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
384 SND_SOC_DAILINK_DEF(dmic_codec,
385         DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
386 
387 SND_SOC_DAILINK_DEF(idisp1_pin,
388         DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
389 SND_SOC_DAILINK_DEF(idisp1_codec,
390         DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2",
391                                       "intel-hdmi-hifi1")));
392 
393 SND_SOC_DAILINK_DEF(idisp2_pin,
394         DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
395 SND_SOC_DAILINK_DEF(idisp2_codec,
396         DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
397 
398 SND_SOC_DAILINK_DEF(idisp3_pin,
399         DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
400 SND_SOC_DAILINK_DEF(idisp3_codec,
401         DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
402 
403 SND_SOC_DAILINK_DEF(platform,
404         DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
405 
406 /* kabylake digital audio interface glue - connects codec <--> CPU */
407 static struct snd_soc_dai_link kabylake_dais[] = {
408         /* Front End DAI links */
409         [KBL_DPCM_AUDIO_PB] = {
410                 .name = "Kbl Audio Port",
411                 .stream_name = "Audio",
412                 .dynamic = 1,
413                 .nonatomic = 1,
414                 .init = kabylake_da7219_fe_init,
415                 .trigger = {
416                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
417                 .dpcm_playback = 1,
418                 .ops = &kabylake_da7219_fe_ops,
419                 SND_SOC_DAILINK_REG(system, dummy, platform),
420         },
421         [KBL_DPCM_AUDIO_CP] = {
422                 .name = "Kbl Audio Capture Port",
423                 .stream_name = "Audio Record",
424                 .dynamic = 1,
425                 .nonatomic = 1,
426                 .trigger = {
427                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
428                 .dpcm_capture = 1,
429                 .ops = &kabylake_da7219_fe_ops,
430                 SND_SOC_DAILINK_REG(system, dummy, platform),
431         },
432         [KBL_DPCM_AUDIO_DMIC_CP] = {
433                 .name = "Kbl Audio DMIC cap",
434                 .stream_name = "dmiccap",
435                 .init = NULL,
436                 .dpcm_capture = 1,
437                 .nonatomic = 1,
438                 .dynamic = 1,
439                 .ops = &kabylake_dmic_ops,
440                 SND_SOC_DAILINK_REG(dmic, dummy, platform),
441         },
442         [KBL_DPCM_AUDIO_HDMI1_PB] = {
443                 .name = "Kbl HDMI Port1",
444                 .stream_name = "Hdmi1",
445                 .dpcm_playback = 1,
446                 .init = NULL,
447                 .trigger = {
448                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
449                 .nonatomic = 1,
450                 .dynamic = 1,
451                 SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
452         },
453         [KBL_DPCM_AUDIO_HDMI2_PB] = {
454                 .name = "Kbl HDMI Port2",
455                 .stream_name = "Hdmi2",
456                 .dpcm_playback = 1,
457                 .init = NULL,
458                 .trigger = {
459                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
460                 .nonatomic = 1,
461                 .dynamic = 1,
462                 SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
463         },
464         [KBL_DPCM_AUDIO_HDMI3_PB] = {
465                 .name = "Kbl HDMI Port3",
466                 .stream_name = "Hdmi3",
467                 .trigger = {
468                         SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
469                 .dpcm_playback = 1,
470                 .init = NULL,
471                 .nonatomic = 1,
472                 .dynamic = 1,
473                 SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
474         },
475 
476         /* Back End DAI links */
477         {
478                 /* SSP0 - Codec */
479                 .name = "SSP0-Codec",
480                 .id = 0,
481                 .no_pcm = 1,
482                 .dai_fmt = SND_SOC_DAIFMT_I2S |
483                         SND_SOC_DAIFMT_NB_NF |
484                         SND_SOC_DAIFMT_CBS_CFS,
485                 .ignore_pmdown_time = 1,
486                 .be_hw_params_fixup = kabylake_ssp_fixup,
487                 .dpcm_playback = 1,
488                 SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
489         },
490         {
491                 /* SSP1 - Codec */
492                 .name = "SSP1-Codec",
493                 .id = 1,
494                 .no_pcm = 1,
495                 .init = kabylake_da7219_codec_init,
496                 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
497                         SND_SOC_DAIFMT_CBS_CFS,
498                 .ignore_pmdown_time = 1,
499                 .be_hw_params_fixup = kabylake_ssp_fixup,
500                 .dpcm_playback = 1,
501                 .dpcm_capture = 1,
502                 SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
503         },
504         {
505                 .name = "dmic01",
506                 .id = 2,
507                 .be_hw_params_fixup = kabylake_dmic_fixup,
508                 .ignore_suspend = 1,
509                 .dpcm_capture = 1,
510                 .no_pcm = 1,
511                 SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
512         },
513         {
514                 .name = "iDisp1",
515                 .id = 3,
516                 .dpcm_playback = 1,
517                 .init = kabylake_hdmi1_init,
518                 .no_pcm = 1,
519                 SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
520         },
521         {
522                 .name = "iDisp2",
523                 .id = 4,
524                 .init = kabylake_hdmi2_init,
525                 .dpcm_playback = 1,
526                 .no_pcm = 1,
527                 SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
528         },
529         {
530                 .name = "iDisp3",
531                 .id = 5,
532                 .init = kabylake_hdmi3_init,
533                 .dpcm_playback = 1,
534                 .no_pcm = 1,
535                 SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
536         },
537 };
538 
539 #define NAME_SIZE       32
540 static int kabylake_card_late_probe(struct snd_soc_card *card)
541 {
542         struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
543         struct kbl_hdmi_pcm *pcm;
544         struct snd_soc_component *component = NULL;
545         int err, i = 0;
546         char jack_name[NAME_SIZE];
547 
548         list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
549                 component = pcm->codec_dai->component;
550                 snprintf(jack_name, sizeof(jack_name),
551                         "HDMI/DP, pcm=%d Jack", pcm->device);
552                 err = snd_soc_card_jack_new(card, jack_name,
553                                         SND_JACK_AVOUT, &skylake_hdmi[i],
554                                         NULL, 0);
555 
556                 if (err)
557                         return err;
558 
559                 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
560                                 &skylake_hdmi[i]);
561                 if (err < 0)
562                         return err;
563 
564                 i++;
565 
566         }
567 
568         if (!component)
569                 return -EINVAL;
570 
571         return hdac_hdmi_jack_port_init(component, &card->dapm);
572 }
573 
574 /* kabylake audio machine driver for SPT + DA7219 */
575 static struct snd_soc_card kabylake_audio_card_da7219_m98357a = {
576         .name = "kblda7219max",
577         .owner = THIS_MODULE,
578         .dai_link = kabylake_dais,
579         .num_links = ARRAY_SIZE(kabylake_dais),
580         .controls = kabylake_controls,
581         .num_controls = ARRAY_SIZE(kabylake_controls),
582         .dapm_widgets = kabylake_widgets,
583         .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
584         .dapm_routes = kabylake_map,
585         .num_dapm_routes = ARRAY_SIZE(kabylake_map),
586         .fully_routed = true,
587         .late_probe = kabylake_card_late_probe,
588 };
589 
590 static int kabylake_audio_probe(struct platform_device *pdev)
591 {
592         struct kbl_codec_private *ctx;
593 
594         ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
595         if (!ctx)
596                 return -ENOMEM;
597 
598         INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
599 
600         kabylake_audio_card =
601                 (struct snd_soc_card *)pdev->id_entry->driver_data;
602 
603         kabylake_audio_card->dev = &pdev->dev;
604         snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
605         return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
606 }
607 
608 static const struct platform_device_id kbl_board_ids[] = {
609         {
610                 .name = "kbl_da7219_max98357a",
611                 .driver_data =
612                         (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a,
613         },
614         { }
615 };
616 
617 static struct platform_driver kabylake_audio = {
618         .probe = kabylake_audio_probe,
619         .driver = {
620                 .name = "kbl_da7219_max98357a",
621                 .pm = &snd_soc_pm_ops,
622         },
623         .id_table = kbl_board_ids,
624 };
625 
626 module_platform_driver(kabylake_audio)
627 
628 /* Module information */
629 MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode");
630 MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
631 MODULE_LICENSE("GPL v2");
632 MODULE_ALIAS("platform:kbl_da7219_max98357a");
633 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp