1 // SPDX-License-Identifier: GPL-2.0-only
3 * skl-pcm.c -ASoC HDA Platform driver file implementing PCM functionality
5 * Copyright (C) 2014-2015 Intel Corp
6 * Author: Jeeja KP <jeeja.kp@intel.com>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 #include <linux/pci.h>
14 #include <linux/pm_runtime.h>
15 #include <linux/delay.h>
16 #include <sound/hdaudio.h>
17 #include <sound/pcm_params.h>
18 #include <sound/soc.h>
20 #include "skl-topology.h"
21 #include "skl-sst-dsp.h"
22 #include "skl-sst-ipc.h"
29 static const struct snd_pcm_hardware azx_pcm_hw = {
30 .info = (SNDRV_PCM_INFO_MMAP |
31 SNDRV_PCM_INFO_INTERLEAVED |
32 SNDRV_PCM_INFO_BLOCK_TRANSFER |
33 SNDRV_PCM_INFO_MMAP_VALID |
34 SNDRV_PCM_INFO_PAUSE |
35 SNDRV_PCM_INFO_RESUME |
36 SNDRV_PCM_INFO_SYNC_START |
37 SNDRV_PCM_INFO_HAS_WALL_CLOCK | /* legacy */
38 SNDRV_PCM_INFO_HAS_LINK_ATIME |
39 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
40 .formats = SNDRV_PCM_FMTBIT_S16_LE |
41 SNDRV_PCM_FMTBIT_S32_LE |
42 SNDRV_PCM_FMTBIT_S24_LE,
43 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
49 .buffer_bytes_max = AZX_MAX_BUF_SIZE,
50 .period_bytes_min = 128,
51 .period_bytes_max = AZX_MAX_BUF_SIZE / 2,
53 .periods_max = AZX_MAX_FRAG,
58 struct hdac_ext_stream *get_hdac_ext_stream(struct snd_pcm_substream *substream)
60 return substream->runtime->private_data;
63 static struct hdac_bus *get_bus_ctx(struct snd_pcm_substream *substream)
65 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
66 struct hdac_stream *hstream = hdac_stream(stream);
67 struct hdac_bus *bus = hstream->bus;
71 static int skl_substream_alloc_pages(struct hdac_bus *bus,
72 struct snd_pcm_substream *substream,
75 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
77 hdac_stream(stream)->bufsize = 0;
78 hdac_stream(stream)->period_bytes = 0;
79 hdac_stream(stream)->format_val = 0;
84 static void skl_set_pcm_constrains(struct hdac_bus *bus,
85 struct snd_pcm_runtime *runtime)
87 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
89 /* avoid wrap-around with wall-clock */
90 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
94 static enum hdac_ext_stream_type skl_get_host_stream_type(struct hdac_bus *bus)
97 return HDAC_EXT_STREAM_TYPE_HOST;
99 return HDAC_EXT_STREAM_TYPE_COUPLED;
103 * check if the stream opened is marked as ignore_suspend by machine, if so
104 * then enable suspend_active refcount
106 * The count supend_active does not need lock as it is used in open/close
107 * and suspend context
109 static void skl_set_suspend_active(struct snd_pcm_substream *substream,
110 struct snd_soc_dai *dai, bool enable)
112 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
113 struct snd_soc_dapm_widget *w;
114 struct skl_dev *skl = bus_to_skl(bus);
116 w = snd_soc_dai_get_widget(dai, substream->stream);
118 if (w->ignore_suspend && enable)
119 skl->supend_active++;
120 else if (w->ignore_suspend && !enable)
121 skl->supend_active--;
124 int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params)
126 struct hdac_bus *bus = dev_get_drvdata(dev);
127 unsigned int format_val;
128 struct hdac_stream *hstream;
129 struct hdac_ext_stream *stream;
132 hstream = snd_hdac_get_stream(bus, params->stream,
133 params->host_dma_id + 1);
137 stream = stream_to_hdac_ext_stream(hstream);
138 snd_hdac_ext_stream_decouple(bus, stream, true);
140 format_val = snd_hdac_calc_stream_format(params->s_freq,
141 params->ch, params->format, params->host_bps, 0);
143 dev_dbg(dev, "format_val=%d, rate=%d, ch=%d, format=%d\n",
144 format_val, params->s_freq, params->ch, params->format);
146 snd_hdac_stream_reset(hdac_stream(stream));
147 err = snd_hdac_stream_set_params(hdac_stream(stream), format_val);
151 err = snd_hdac_ext_host_stream_setup(stream, false);
155 hdac_stream(stream)->prepared = 1;
160 int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
162 struct hdac_bus *bus = dev_get_drvdata(dev);
163 unsigned int format_val;
164 struct hdac_stream *hstream;
165 struct hdac_ext_stream *stream;
166 struct hdac_ext_link *link;
167 unsigned char stream_tag;
169 hstream = snd_hdac_get_stream(bus, params->stream,
170 params->link_dma_id + 1);
174 stream = stream_to_hdac_ext_stream(hstream);
175 snd_hdac_ext_stream_decouple(bus, stream, true);
176 format_val = snd_hdac_calc_stream_format(params->s_freq, params->ch,
177 params->format, params->link_bps, 0);
179 dev_dbg(dev, "format_val=%d, rate=%d, ch=%d, format=%d\n",
180 format_val, params->s_freq, params->ch, params->format);
182 snd_hdac_ext_stream_reset(stream);
184 snd_hdac_ext_stream_setup(stream, format_val);
186 stream_tag = hstream->stream_tag;
187 if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
188 list_for_each_entry(link, &bus->hlink_list, list) {
189 if (link->index == params->link_index)
190 snd_hdac_ext_bus_link_set_stream_id(link,
195 stream->link_prepared = 1;
200 static int skl_pcm_open(struct snd_pcm_substream *substream,
201 struct snd_soc_dai *dai)
203 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
204 struct hdac_ext_stream *stream;
205 struct snd_pcm_runtime *runtime = substream->runtime;
206 struct skl_dma_params *dma_params;
207 struct skl_dev *skl = get_skl_ctx(dai->dev);
208 struct skl_module_cfg *mconfig;
210 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
212 stream = snd_hdac_ext_stream_assign(bus, substream,
213 skl_get_host_stream_type(bus));
217 skl_set_pcm_constrains(bus, runtime);
220 * disable WALLCLOCK timestamps for capture streams
221 * until we figure out how to handle digital inputs
223 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
224 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; /* legacy */
225 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME;
228 runtime->private_data = stream;
230 dma_params = kzalloc(sizeof(*dma_params), GFP_KERNEL);
234 dma_params->stream_tag = hdac_stream(stream)->stream_tag;
235 snd_soc_dai_set_dma_data(dai, substream, dma_params);
237 dev_dbg(dai->dev, "stream tag set in dma params=%d\n",
238 dma_params->stream_tag);
239 skl_set_suspend_active(substream, dai, true);
240 snd_pcm_set_sync(substream);
242 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
246 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
251 static int skl_pcm_prepare(struct snd_pcm_substream *substream,
252 struct snd_soc_dai *dai)
254 struct skl_dev *skl = get_skl_ctx(dai->dev);
255 struct skl_module_cfg *mconfig;
258 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
260 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
263 * In case of XRUN recovery or in the case when the application
264 * calls prepare another time, reset the FW pipe to clean state
267 (substream->runtime->state == SNDRV_PCM_STATE_XRUN ||
268 mconfig->pipe->state == SKL_PIPE_CREATED ||
269 mconfig->pipe->state == SKL_PIPE_PAUSED)) {
271 ret = skl_reset_pipe(skl, mconfig->pipe);
276 ret = skl_pcm_host_dma_prepare(dai->dev,
277 mconfig->pipe->p_params);
285 static int skl_pcm_hw_params(struct snd_pcm_substream *substream,
286 struct snd_pcm_hw_params *params,
287 struct snd_soc_dai *dai)
289 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
290 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
291 struct snd_pcm_runtime *runtime = substream->runtime;
292 struct skl_pipe_params p_params = {0};
293 struct skl_module_cfg *m_cfg;
296 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
297 ret = skl_substream_alloc_pages(bus, substream,
298 params_buffer_bytes(params));
302 dev_dbg(dai->dev, "format_val, rate=%d, ch=%d, format=%d\n",
303 runtime->rate, runtime->channels, runtime->format);
305 dma_id = hdac_stream(stream)->stream_tag - 1;
306 dev_dbg(dai->dev, "dma_id=%d\n", dma_id);
308 p_params.s_fmt = snd_pcm_format_width(params_format(params));
309 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
310 p_params.ch = params_channels(params);
311 p_params.s_freq = params_rate(params);
312 p_params.host_dma_id = dma_id;
313 p_params.stream = substream->stream;
314 p_params.format = params_format(params);
315 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
316 p_params.host_bps = dai->driver->playback.sig_bits;
318 p_params.host_bps = dai->driver->capture.sig_bits;
321 m_cfg = skl_tplg_fe_get_cpr_module(dai, p_params.stream);
323 skl_tplg_update_pipe_params(dai->dev, m_cfg, &p_params);
328 static void skl_pcm_close(struct snd_pcm_substream *substream,
329 struct snd_soc_dai *dai)
331 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
332 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
333 struct skl_dma_params *dma_params = NULL;
334 struct skl_dev *skl = bus_to_skl(bus);
335 struct skl_module_cfg *mconfig;
337 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
339 snd_hdac_ext_stream_release(stream, skl_get_host_stream_type(bus));
341 dma_params = snd_soc_dai_get_dma_data(dai, substream);
343 * now we should set this to NULL as we are freeing by the
346 snd_soc_dai_set_dma_data(dai, substream, NULL);
347 skl_set_suspend_active(substream, dai, false);
350 * check if close is for "Reference Pin" and set back the
351 * CGCTL.MISCBDCGE if disabled by driver
353 if (!strncmp(dai->name, "Reference Pin", 13) &&
354 skl->miscbdcg_disabled) {
355 skl->enable_miscbdcge(dai->dev, true);
356 skl->miscbdcg_disabled = false;
359 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
361 skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
366 static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
367 struct snd_soc_dai *dai)
369 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
370 struct skl_dev *skl = get_skl_ctx(dai->dev);
371 struct skl_module_cfg *mconfig;
374 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
376 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
379 ret = skl_reset_pipe(skl, mconfig->pipe);
381 dev_err(dai->dev, "%s:Reset failed ret =%d",
385 snd_hdac_stream_cleanup(hdac_stream(stream));
386 hdac_stream(stream)->prepared = 0;
391 static int skl_be_hw_params(struct snd_pcm_substream *substream,
392 struct snd_pcm_hw_params *params,
393 struct snd_soc_dai *dai)
395 struct skl_pipe_params p_params = {0};
397 p_params.s_fmt = snd_pcm_format_width(params_format(params));
398 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
399 p_params.ch = params_channels(params);
400 p_params.s_freq = params_rate(params);
401 p_params.stream = substream->stream;
403 return skl_tplg_be_update_params(dai, &p_params);
406 static int skl_decoupled_trigger(struct snd_pcm_substream *substream,
409 struct hdac_bus *bus = get_bus_ctx(substream);
410 struct hdac_ext_stream *stream;
412 unsigned long cookie;
413 struct hdac_stream *hstr;
415 stream = get_hdac_ext_stream(substream);
416 hstr = hdac_stream(stream);
422 case SNDRV_PCM_TRIGGER_START:
423 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
424 case SNDRV_PCM_TRIGGER_RESUME:
428 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
429 case SNDRV_PCM_TRIGGER_SUSPEND:
430 case SNDRV_PCM_TRIGGER_STOP:
438 spin_lock_irqsave(&bus->reg_lock, cookie);
441 snd_hdac_stream_start(hdac_stream(stream));
442 snd_hdac_stream_timecounter_init(hstr, 0);
444 snd_hdac_stream_stop(hdac_stream(stream));
447 spin_unlock_irqrestore(&bus->reg_lock, cookie);
452 static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
453 struct snd_soc_dai *dai)
455 struct skl_dev *skl = get_skl_ctx(dai->dev);
456 struct skl_module_cfg *mconfig;
457 struct hdac_bus *bus = get_bus_ctx(substream);
458 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
459 struct hdac_stream *hstream = hdac_stream(stream);
460 struct snd_soc_dapm_widget *w;
463 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
467 w = snd_soc_dai_get_widget(dai, substream->stream);
470 case SNDRV_PCM_TRIGGER_RESUME:
471 if (!w->ignore_suspend) {
473 * enable DMA Resume enable bit for the stream, set the
474 * dpib & lpib position to resume before starting the
477 snd_hdac_stream_drsm_enable(bus, true, hstream->index);
478 snd_hdac_stream_set_dpibr(bus, hstream, hstream->lpib);
479 snd_hdac_stream_set_lpib(hstream, hstream->lpib);
483 case SNDRV_PCM_TRIGGER_START:
484 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
486 * Start HOST DMA and Start FE Pipe.This is to make sure that
487 * there are no underrun/overrun in the case when the FE
488 * pipeline is started but there is a delay in starting the
489 * DMA channel on the host.
491 ret = skl_decoupled_trigger(substream, cmd);
494 return skl_run_pipe(skl, mconfig->pipe);
496 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
497 case SNDRV_PCM_TRIGGER_SUSPEND:
498 case SNDRV_PCM_TRIGGER_STOP:
500 * Stop FE Pipe first and stop DMA. This is to make sure that
501 * there are no underrun/overrun in the case if there is a delay
502 * between the two operations.
504 ret = skl_stop_pipe(skl, mconfig->pipe);
508 ret = skl_decoupled_trigger(substream, cmd);
509 if ((cmd == SNDRV_PCM_TRIGGER_SUSPEND) && !w->ignore_suspend) {
510 /* save the dpib and lpib positions */
511 hstream->dpib = readl(bus->remap_addr +
512 AZX_REG_VS_SDXDPIB_XBASE +
513 (AZX_REG_VS_SDXDPIB_XINTERVAL *
516 hstream->lpib = snd_hdac_stream_get_pos_lpib(hstream);
518 snd_hdac_ext_stream_decouple(bus, stream, false);
530 static int skl_link_hw_params(struct snd_pcm_substream *substream,
531 struct snd_pcm_hw_params *params,
532 struct snd_soc_dai *dai)
534 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
535 struct hdac_ext_stream *link_dev;
536 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
537 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
538 struct skl_pipe_params p_params = {0};
539 struct hdac_ext_link *link;
542 link_dev = snd_hdac_ext_stream_assign(bus, substream,
543 HDAC_EXT_STREAM_TYPE_LINK);
547 snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);
549 link = snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name);
553 stream_tag = hdac_stream(link_dev)->stream_tag;
555 /* set the hdac_stream in the codec dai */
556 snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream);
558 p_params.s_fmt = snd_pcm_format_width(params_format(params));
559 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
560 p_params.ch = params_channels(params);
561 p_params.s_freq = params_rate(params);
562 p_params.stream = substream->stream;
563 p_params.link_dma_id = stream_tag - 1;
564 p_params.link_index = link->index;
565 p_params.format = params_format(params);
567 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
568 p_params.link_bps = codec_dai->driver->playback.sig_bits;
570 p_params.link_bps = codec_dai->driver->capture.sig_bits;
572 return skl_tplg_be_update_params(dai, &p_params);
575 static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,
576 struct snd_soc_dai *dai)
578 struct skl_dev *skl = get_skl_ctx(dai->dev);
579 struct skl_module_cfg *mconfig = NULL;
581 /* In case of XRUN recovery, reset the FW pipe to clean state */
582 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream);
583 if (mconfig && !mconfig->pipe->passthru &&
584 (substream->runtime->state == SNDRV_PCM_STATE_XRUN))
585 skl_reset_pipe(skl, mconfig->pipe);
590 static int skl_link_pcm_trigger(struct snd_pcm_substream *substream,
591 int cmd, struct snd_soc_dai *dai)
593 struct hdac_ext_stream *link_dev =
594 snd_soc_dai_get_dma_data(dai, substream);
595 struct hdac_bus *bus = get_bus_ctx(substream);
596 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
598 dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd);
600 case SNDRV_PCM_TRIGGER_RESUME:
601 case SNDRV_PCM_TRIGGER_START:
602 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
603 snd_hdac_ext_stream_start(link_dev);
606 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
607 case SNDRV_PCM_TRIGGER_SUSPEND:
608 case SNDRV_PCM_TRIGGER_STOP:
609 snd_hdac_ext_stream_clear(link_dev);
610 if (cmd == SNDRV_PCM_TRIGGER_SUSPEND)
611 snd_hdac_ext_stream_decouple(bus, stream, false);
620 static int skl_link_hw_free(struct snd_pcm_substream *substream,
621 struct snd_soc_dai *dai)
623 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
624 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
625 struct hdac_ext_stream *link_dev =
626 snd_soc_dai_get_dma_data(dai, substream);
627 struct hdac_ext_link *link;
628 unsigned char stream_tag;
630 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
632 link_dev->link_prepared = 0;
634 link = snd_hdac_ext_bus_get_hlink_by_name(bus, snd_soc_rtd_to_codec(rtd, 0)->component->name);
638 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
639 stream_tag = hdac_stream(link_dev)->stream_tag;
640 snd_hdac_ext_bus_link_clear_stream_id(link, stream_tag);
643 snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
647 static const struct snd_soc_dai_ops skl_pcm_dai_ops = {
648 .startup = skl_pcm_open,
649 .shutdown = skl_pcm_close,
650 .prepare = skl_pcm_prepare,
651 .hw_params = skl_pcm_hw_params,
652 .hw_free = skl_pcm_hw_free,
653 .trigger = skl_pcm_trigger,
656 static const struct snd_soc_dai_ops skl_dmic_dai_ops = {
657 .hw_params = skl_be_hw_params,
660 static const struct snd_soc_dai_ops skl_be_ssp_dai_ops = {
661 .hw_params = skl_be_hw_params,
664 static const struct snd_soc_dai_ops skl_link_dai_ops = {
665 .prepare = skl_link_pcm_prepare,
666 .hw_params = skl_link_hw_params,
667 .hw_free = skl_link_hw_free,
668 .trigger = skl_link_pcm_trigger,
671 static struct snd_soc_dai_driver skl_fe_dai[] = {
673 .name = "System Pin",
674 .ops = &skl_pcm_dai_ops,
676 .stream_name = "System Playback",
677 .channels_min = HDA_MONO,
678 .channels_max = HDA_STEREO,
679 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_8000,
680 .formats = SNDRV_PCM_FMTBIT_S16_LE |
681 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
685 .stream_name = "System Capture",
686 .channels_min = HDA_MONO,
687 .channels_max = HDA_STEREO,
688 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
689 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
694 .name = "System Pin2",
695 .ops = &skl_pcm_dai_ops,
697 .stream_name = "Headset Playback",
698 .channels_min = HDA_MONO,
699 .channels_max = HDA_STEREO,
700 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
702 .formats = SNDRV_PCM_FMTBIT_S16_LE |
703 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
707 .name = "Echoref Pin",
708 .ops = &skl_pcm_dai_ops,
710 .stream_name = "Echoreference Capture",
711 .channels_min = HDA_STEREO,
712 .channels_max = HDA_STEREO,
713 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
715 .formats = SNDRV_PCM_FMTBIT_S16_LE |
716 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
720 .name = "Reference Pin",
721 .ops = &skl_pcm_dai_ops,
723 .stream_name = "Reference Capture",
724 .channels_min = HDA_MONO,
725 .channels_max = HDA_QUAD,
726 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
727 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
732 .name = "Deepbuffer Pin",
733 .ops = &skl_pcm_dai_ops,
735 .stream_name = "Deepbuffer Playback",
736 .channels_min = HDA_STEREO,
737 .channels_max = HDA_STEREO,
738 .rates = SNDRV_PCM_RATE_48000,
739 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
744 .name = "LowLatency Pin",
745 .ops = &skl_pcm_dai_ops,
747 .stream_name = "Low Latency Playback",
748 .channels_min = HDA_STEREO,
749 .channels_max = HDA_STEREO,
750 .rates = SNDRV_PCM_RATE_48000,
751 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
757 .ops = &skl_pcm_dai_ops,
759 .stream_name = "DMIC Capture",
760 .channels_min = HDA_MONO,
761 .channels_max = HDA_QUAD,
762 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
763 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
769 .ops = &skl_pcm_dai_ops,
771 .stream_name = "HDMI1 Playback",
772 .channels_min = HDA_STEREO,
774 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
775 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
776 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
777 SNDRV_PCM_RATE_192000,
778 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
779 SNDRV_PCM_FMTBIT_S32_LE,
785 .ops = &skl_pcm_dai_ops,
787 .stream_name = "HDMI2 Playback",
788 .channels_min = HDA_STEREO,
790 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
791 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
792 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
793 SNDRV_PCM_RATE_192000,
794 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
795 SNDRV_PCM_FMTBIT_S32_LE,
801 .ops = &skl_pcm_dai_ops,
803 .stream_name = "HDMI3 Playback",
804 .channels_min = HDA_STEREO,
806 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
807 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
808 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
809 SNDRV_PCM_RATE_192000,
810 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
811 SNDRV_PCM_FMTBIT_S32_LE,
818 static struct snd_soc_dai_driver skl_platform_dai[] = {
821 .ops = &skl_be_ssp_dai_ops,
823 .stream_name = "ssp0 Tx",
824 .channels_min = HDA_STEREO,
825 .channels_max = HDA_STEREO,
826 .rates = SNDRV_PCM_RATE_48000,
827 .formats = SNDRV_PCM_FMTBIT_S16_LE,
830 .stream_name = "ssp0 Rx",
831 .channels_min = HDA_STEREO,
832 .channels_max = HDA_STEREO,
833 .rates = SNDRV_PCM_RATE_48000,
834 .formats = SNDRV_PCM_FMTBIT_S16_LE,
839 .ops = &skl_be_ssp_dai_ops,
841 .stream_name = "ssp1 Tx",
842 .channels_min = HDA_STEREO,
843 .channels_max = HDA_STEREO,
844 .rates = SNDRV_PCM_RATE_48000,
845 .formats = SNDRV_PCM_FMTBIT_S16_LE,
848 .stream_name = "ssp1 Rx",
849 .channels_min = HDA_STEREO,
850 .channels_max = HDA_STEREO,
851 .rates = SNDRV_PCM_RATE_48000,
852 .formats = SNDRV_PCM_FMTBIT_S16_LE,
857 .ops = &skl_be_ssp_dai_ops,
859 .stream_name = "ssp2 Tx",
860 .channels_min = HDA_STEREO,
861 .channels_max = HDA_STEREO,
862 .rates = SNDRV_PCM_RATE_48000,
863 .formats = SNDRV_PCM_FMTBIT_S16_LE,
866 .stream_name = "ssp2 Rx",
867 .channels_min = HDA_STEREO,
868 .channels_max = HDA_STEREO,
869 .rates = SNDRV_PCM_RATE_48000,
870 .formats = SNDRV_PCM_FMTBIT_S16_LE,
875 .ops = &skl_be_ssp_dai_ops,
877 .stream_name = "ssp3 Tx",
878 .channels_min = HDA_STEREO,
879 .channels_max = HDA_STEREO,
880 .rates = SNDRV_PCM_RATE_48000,
881 .formats = SNDRV_PCM_FMTBIT_S16_LE,
884 .stream_name = "ssp3 Rx",
885 .channels_min = HDA_STEREO,
886 .channels_max = HDA_STEREO,
887 .rates = SNDRV_PCM_RATE_48000,
888 .formats = SNDRV_PCM_FMTBIT_S16_LE,
893 .ops = &skl_be_ssp_dai_ops,
895 .stream_name = "ssp4 Tx",
896 .channels_min = HDA_STEREO,
897 .channels_max = HDA_STEREO,
898 .rates = SNDRV_PCM_RATE_48000,
899 .formats = SNDRV_PCM_FMTBIT_S16_LE,
902 .stream_name = "ssp4 Rx",
903 .channels_min = HDA_STEREO,
904 .channels_max = HDA_STEREO,
905 .rates = SNDRV_PCM_RATE_48000,
906 .formats = SNDRV_PCM_FMTBIT_S16_LE,
911 .ops = &skl_be_ssp_dai_ops,
913 .stream_name = "ssp5 Tx",
914 .channels_min = HDA_STEREO,
915 .channels_max = HDA_STEREO,
916 .rates = SNDRV_PCM_RATE_48000,
917 .formats = SNDRV_PCM_FMTBIT_S16_LE,
920 .stream_name = "ssp5 Rx",
921 .channels_min = HDA_STEREO,
922 .channels_max = HDA_STEREO,
923 .rates = SNDRV_PCM_RATE_48000,
924 .formats = SNDRV_PCM_FMTBIT_S16_LE,
928 .name = "iDisp1 Pin",
929 .ops = &skl_link_dai_ops,
931 .stream_name = "iDisp1 Tx",
932 .channels_min = HDA_STEREO,
934 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_48000,
935 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
936 SNDRV_PCM_FMTBIT_S24_LE,
940 .name = "iDisp2 Pin",
941 .ops = &skl_link_dai_ops,
943 .stream_name = "iDisp2 Tx",
944 .channels_min = HDA_STEREO,
946 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
947 SNDRV_PCM_RATE_48000,
948 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
949 SNDRV_PCM_FMTBIT_S24_LE,
953 .name = "iDisp3 Pin",
954 .ops = &skl_link_dai_ops,
956 .stream_name = "iDisp3 Tx",
957 .channels_min = HDA_STEREO,
959 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
960 SNDRV_PCM_RATE_48000,
961 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
962 SNDRV_PCM_FMTBIT_S24_LE,
966 .name = "DMIC01 Pin",
967 .ops = &skl_dmic_dai_ops,
969 .stream_name = "DMIC01 Rx",
970 .channels_min = HDA_MONO,
971 .channels_max = HDA_QUAD,
972 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
973 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
977 .name = "DMIC16k Pin",
978 .ops = &skl_dmic_dai_ops,
980 .stream_name = "DMIC16k Rx",
981 .channels_min = HDA_MONO,
982 .channels_max = HDA_QUAD,
983 .rates = SNDRV_PCM_RATE_16000,
984 .formats = SNDRV_PCM_FMTBIT_S16_LE,
988 .name = "Analog CPU DAI",
989 .ops = &skl_link_dai_ops,
991 .stream_name = "Analog CPU Playback",
992 .channels_min = HDA_MONO,
993 .channels_max = HDA_MAX,
994 .rates = SNDRV_PCM_RATE_8000_192000,
995 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
996 SNDRV_PCM_FMTBIT_S32_LE,
999 .stream_name = "Analog CPU Capture",
1000 .channels_min = HDA_MONO,
1001 .channels_max = HDA_MAX,
1002 .rates = SNDRV_PCM_RATE_8000_192000,
1003 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1004 SNDRV_PCM_FMTBIT_S32_LE,
1008 .name = "Alt Analog CPU DAI",
1009 .ops = &skl_link_dai_ops,
1011 .stream_name = "Alt Analog CPU Playback",
1012 .channels_min = HDA_MONO,
1013 .channels_max = HDA_MAX,
1014 .rates = SNDRV_PCM_RATE_8000_192000,
1015 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1016 SNDRV_PCM_FMTBIT_S32_LE,
1019 .stream_name = "Alt Analog CPU Capture",
1020 .channels_min = HDA_MONO,
1021 .channels_max = HDA_MAX,
1022 .rates = SNDRV_PCM_RATE_8000_192000,
1023 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1024 SNDRV_PCM_FMTBIT_S32_LE,
1028 .name = "Digital CPU DAI",
1029 .ops = &skl_link_dai_ops,
1031 .stream_name = "Digital CPU Playback",
1032 .channels_min = HDA_MONO,
1033 .channels_max = HDA_MAX,
1034 .rates = SNDRV_PCM_RATE_8000_192000,
1035 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1036 SNDRV_PCM_FMTBIT_S32_LE,
1039 .stream_name = "Digital CPU Capture",
1040 .channels_min = HDA_MONO,
1041 .channels_max = HDA_MAX,
1042 .rates = SNDRV_PCM_RATE_8000_192000,
1043 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1044 SNDRV_PCM_FMTBIT_S32_LE,
1049 int skl_dai_load(struct snd_soc_component *cmp, int index,
1050 struct snd_soc_dai_driver *dai_drv,
1051 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai)
1053 dai_drv->ops = &skl_pcm_dai_ops;
1058 static int skl_platform_soc_open(struct snd_soc_component *component,
1059 struct snd_pcm_substream *substream)
1061 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1062 struct snd_soc_dai_link *dai_link = rtd->dai_link;
1064 dev_dbg(snd_soc_rtd_to_cpu(rtd, 0)->dev, "In %s:%s\n", __func__,
1065 dai_link->cpus->dai_name);
1067 snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
1072 static int skl_coupled_trigger(struct snd_pcm_substream *substream,
1075 struct hdac_bus *bus = get_bus_ctx(substream);
1076 struct hdac_ext_stream *stream;
1077 struct snd_pcm_substream *s;
1080 unsigned long cookie;
1081 struct hdac_stream *hstr;
1083 stream = get_hdac_ext_stream(substream);
1084 hstr = hdac_stream(stream);
1086 dev_dbg(bus->dev, "In %s cmd=%d\n", __func__, cmd);
1088 if (!hstr->prepared)
1092 case SNDRV_PCM_TRIGGER_START:
1093 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1094 case SNDRV_PCM_TRIGGER_RESUME:
1098 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1099 case SNDRV_PCM_TRIGGER_SUSPEND:
1100 case SNDRV_PCM_TRIGGER_STOP:
1108 snd_pcm_group_for_each_entry(s, substream) {
1109 if (s->pcm->card != substream->pcm->card)
1111 stream = get_hdac_ext_stream(s);
1112 sbits |= 1 << hdac_stream(stream)->index;
1113 snd_pcm_trigger_done(s, substream);
1116 spin_lock_irqsave(&bus->reg_lock, cookie);
1118 /* first, set SYNC bits of corresponding streams */
1119 snd_hdac_stream_sync_trigger(hstr, true, sbits, AZX_REG_SSYNC);
1121 snd_pcm_group_for_each_entry(s, substream) {
1122 if (s->pcm->card != substream->pcm->card)
1124 stream = get_hdac_ext_stream(s);
1126 snd_hdac_stream_start(hdac_stream(stream));
1128 snd_hdac_stream_stop(hdac_stream(stream));
1130 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1132 snd_hdac_stream_sync(hstr, start, sbits);
1134 spin_lock_irqsave(&bus->reg_lock, cookie);
1136 /* reset SYNC bits */
1137 snd_hdac_stream_sync_trigger(hstr, false, sbits, AZX_REG_SSYNC);
1139 snd_hdac_stream_timecounter_init(hstr, sbits);
1140 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1145 static int skl_platform_soc_trigger(struct snd_soc_component *component,
1146 struct snd_pcm_substream *substream,
1149 struct hdac_bus *bus = get_bus_ctx(substream);
1152 return skl_coupled_trigger(substream, cmd);
1157 static snd_pcm_uframes_t skl_platform_soc_pointer(
1158 struct snd_soc_component *component,
1159 struct snd_pcm_substream *substream)
1161 struct hdac_ext_stream *hstream = get_hdac_ext_stream(substream);
1162 struct hdac_bus *bus = get_bus_ctx(substream);
1166 * Use DPIB for Playback stream as the periodic DMA Position-in-
1167 * Buffer Writes may be scheduled at the same time or later than
1168 * the MSI and does not guarantee to reflect the Position of the
1169 * last buffer that was transferred. Whereas DPIB register in
1170 * HAD space reflects the actual data that is transferred.
1171 * Use the position buffer for capture, as DPIB write gets
1172 * completed earlier than the actual data written to the DDR.
1174 * For capture stream following workaround is required to fix the
1175 * incorrect position reporting.
1177 * 1. Wait for 20us before reading the DMA position in buffer once
1178 * the interrupt is generated for stream completion as update happens
1179 * on the HDA frame boundary i.e. 20.833uSec.
1180 * 2. Read DPIB register to flush the DMA position value. This dummy
1181 * read is required to flush DMA position value.
1182 * 3. Read the DMA Position-in-Buffer. This value now will be equal to
1183 * or greater than period boundary.
1186 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1187 pos = readl(bus->remap_addr + AZX_REG_VS_SDXDPIB_XBASE +
1188 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1189 hdac_stream(hstream)->index));
1192 readl(bus->remap_addr +
1193 AZX_REG_VS_SDXDPIB_XBASE +
1194 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1195 hdac_stream(hstream)->index));
1196 pos = snd_hdac_stream_get_pos_posbuf(hdac_stream(hstream));
1199 if (pos >= hdac_stream(hstream)->bufsize)
1202 return bytes_to_frames(substream->runtime, pos);
1205 static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
1208 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1209 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
1210 u64 codec_frames, codec_nsecs;
1212 if (!codec_dai->driver->ops->delay)
1215 codec_frames = codec_dai->driver->ops->delay(substream, codec_dai);
1216 codec_nsecs = div_u64(codec_frames * 1000000000LL,
1217 substream->runtime->rate);
1219 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1220 return nsec + codec_nsecs;
1222 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
1225 static int skl_platform_soc_get_time_info(
1226 struct snd_soc_component *component,
1227 struct snd_pcm_substream *substream,
1228 struct timespec64 *system_ts, struct timespec64 *audio_ts,
1229 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
1230 struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
1232 struct hdac_ext_stream *sstream = get_hdac_ext_stream(substream);
1233 struct hdac_stream *hstr = hdac_stream(sstream);
1236 if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
1237 (audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
1239 snd_pcm_gettime(substream->runtime, system_ts);
1241 nsec = timecounter_read(&hstr->tc);
1242 if (audio_tstamp_config->report_delay)
1243 nsec = skl_adjust_codec_delay(substream, nsec);
1245 *audio_ts = ns_to_timespec64(nsec);
1247 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
1248 audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
1249 audio_tstamp_report->accuracy = 42; /* 24MHzWallClk == 42ns resolution */
1252 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
1258 #define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
1260 static int skl_platform_soc_new(struct snd_soc_component *component,
1261 struct snd_soc_pcm_runtime *rtd)
1263 struct snd_soc_dai *dai = snd_soc_rtd_to_cpu(rtd, 0);
1264 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1265 struct snd_pcm *pcm = rtd->pcm;
1267 struct skl_dev *skl = bus_to_skl(bus);
1269 if (dai->driver->playback.channels_min ||
1270 dai->driver->capture.channels_min) {
1271 /* buffer pre-allocation */
1272 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1273 if (size > MAX_PREALLOC_SIZE)
1274 size = MAX_PREALLOC_SIZE;
1275 snd_pcm_set_managed_buffer_all(pcm,
1276 SNDRV_DMA_TYPE_DEV_SG,
1278 size, MAX_PREALLOC_SIZE);
1284 static int skl_get_module_info(struct skl_dev *skl,
1285 struct skl_module_cfg *mconfig)
1287 struct skl_module_inst_id *pin_id;
1288 guid_t *uuid_mod, *uuid_tplg;
1289 struct skl_module *skl_module;
1290 struct uuid_module *module;
1293 uuid_mod = (guid_t *)mconfig->guid;
1295 if (list_empty(&skl->uuid_list)) {
1296 dev_err(skl->dev, "Module list is empty\n");
1300 for (i = 0; i < skl->nr_modules; i++) {
1301 skl_module = skl->modules[i];
1302 uuid_tplg = &skl_module->uuid;
1303 if (guid_equal(uuid_mod, uuid_tplg)) {
1304 mconfig->module = skl_module;
1310 if (skl->nr_modules && ret)
1314 list_for_each_entry(module, &skl->uuid_list, list) {
1315 if (guid_equal(uuid_mod, &module->uuid)) {
1316 mconfig->id.module_id = module->id;
1317 mconfig->module->loadable = module->is_loadable;
1321 for (i = 0; i < MAX_IN_QUEUE; i++) {
1322 pin_id = &mconfig->m_in_pin[i].id;
1323 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1324 pin_id->module_id = module->id;
1327 for (i = 0; i < MAX_OUT_QUEUE; i++) {
1328 pin_id = &mconfig->m_out_pin[i].id;
1329 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1330 pin_id->module_id = module->id;
1337 static int skl_populate_modules(struct skl_dev *skl)
1339 struct skl_pipeline *p;
1340 struct skl_pipe_module *m;
1341 struct snd_soc_dapm_widget *w;
1342 struct skl_module_cfg *mconfig;
1345 list_for_each_entry(p, &skl->ppl_list, node) {
1346 list_for_each_entry(m, &p->pipe->w_list, node) {
1350 ret = skl_get_module_info(skl, mconfig);
1353 "query module info failed\n");
1357 skl_tplg_add_moduleid_in_bind_params(skl, w);
1364 static int skl_platform_soc_probe(struct snd_soc_component *component)
1366 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1367 struct skl_dev *skl = bus_to_skl(bus);
1368 const struct skl_dsp_ops *ops;
1371 ret = pm_runtime_resume_and_get(component->dev);
1372 if (ret < 0 && ret != -EACCES)
1376 skl->component = component;
1379 skl->debugfs = skl_debugfs_init(skl);
1381 ret = skl_tplg_init(component, bus);
1383 dev_err(component->dev, "Failed to init topology!\n");
1387 /* load the firmwares, since all is set */
1388 ops = skl_get_dsp_ops(skl->pci->device);
1393 * Disable dynamic clock and power gating during firmware
1394 * and library download
1396 skl->enable_miscbdcge(component->dev, false);
1397 skl->clock_power_gating(component->dev, false);
1399 ret = ops->init_fw(component->dev, skl);
1400 skl->enable_miscbdcge(component->dev, true);
1401 skl->clock_power_gating(component->dev, true);
1403 dev_err(component->dev, "Failed to boot first fw: %d\n", ret);
1406 skl_populate_modules(skl);
1407 skl->update_d0i3c = skl_update_d0i3c;
1409 if (skl->cfg.astate_cfg != NULL) {
1410 skl_dsp_set_astate_cfg(skl,
1411 skl->cfg.astate_cfg->count,
1412 skl->cfg.astate_cfg);
1415 pm_runtime_mark_last_busy(component->dev);
1416 pm_runtime_put_autosuspend(component->dev);
1421 static void skl_platform_soc_remove(struct snd_soc_component *component)
1423 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1424 struct skl_dev *skl = bus_to_skl(bus);
1426 skl_tplg_exit(component, bus);
1428 skl_debugfs_exit(skl);
1431 static const struct snd_soc_component_driver skl_component = {
1433 .probe = skl_platform_soc_probe,
1434 .remove = skl_platform_soc_remove,
1435 .open = skl_platform_soc_open,
1436 .trigger = skl_platform_soc_trigger,
1437 .pointer = skl_platform_soc_pointer,
1438 .get_time_info = skl_platform_soc_get_time_info,
1439 .pcm_construct = skl_platform_soc_new,
1440 .module_get_upon_open = 1, /* increment refcount when a pcm is opened */
1443 int skl_platform_register(struct device *dev)
1446 struct snd_soc_dai_driver *dais;
1447 int num_dais = ARRAY_SIZE(skl_platform_dai);
1448 struct hdac_bus *bus = dev_get_drvdata(dev);
1449 struct skl_dev *skl = bus_to_skl(bus);
1451 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
1458 if (!skl->use_tplg_pcm) {
1459 dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
1460 sizeof(skl_platform_dai), GFP_KERNEL);
1467 memcpy(&skl->dais[ARRAY_SIZE(skl_platform_dai)], skl_fe_dai,
1468 sizeof(skl_fe_dai));
1469 num_dais += ARRAY_SIZE(skl_fe_dai);
1472 ret = devm_snd_soc_register_component(dev, &skl_component,
1473 skl->dais, num_dais);
1475 dev_err(dev, "soc component registration failed %d\n", ret);
1480 int skl_platform_unregister(struct device *dev)
1482 struct hdac_bus *bus = dev_get_drvdata(dev);
1483 struct skl_dev *skl = bus_to_skl(bus);
1484 struct skl_module_deferred_bind *modules, *tmp;
1486 list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
1487 list_del(&modules->node);