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/pcm_params.h>
17 #include <sound/soc.h>
19 #include "skl-topology.h"
20 #include "skl-sst-dsp.h"
21 #include "skl-sst-ipc.h"
28 static const struct snd_pcm_hardware azx_pcm_hw = {
29 .info = (SNDRV_PCM_INFO_MMAP |
30 SNDRV_PCM_INFO_INTERLEAVED |
31 SNDRV_PCM_INFO_BLOCK_TRANSFER |
32 SNDRV_PCM_INFO_MMAP_VALID |
33 SNDRV_PCM_INFO_PAUSE |
34 SNDRV_PCM_INFO_RESUME |
35 SNDRV_PCM_INFO_SYNC_START |
36 SNDRV_PCM_INFO_HAS_WALL_CLOCK | /* legacy */
37 SNDRV_PCM_INFO_HAS_LINK_ATIME |
38 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
39 .formats = SNDRV_PCM_FMTBIT_S16_LE |
40 SNDRV_PCM_FMTBIT_S32_LE |
41 SNDRV_PCM_FMTBIT_S24_LE,
42 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
48 .buffer_bytes_max = AZX_MAX_BUF_SIZE,
49 .period_bytes_min = 128,
50 .period_bytes_max = AZX_MAX_BUF_SIZE / 2,
52 .periods_max = AZX_MAX_FRAG,
57 struct hdac_ext_stream *get_hdac_ext_stream(struct snd_pcm_substream *substream)
59 return substream->runtime->private_data;
62 static struct hdac_bus *get_bus_ctx(struct snd_pcm_substream *substream)
64 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
65 struct hdac_stream *hstream = hdac_stream(stream);
66 struct hdac_bus *bus = hstream->bus;
70 static int skl_substream_alloc_pages(struct hdac_bus *bus,
71 struct snd_pcm_substream *substream,
74 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
76 hdac_stream(stream)->bufsize = 0;
77 hdac_stream(stream)->period_bytes = 0;
78 hdac_stream(stream)->format_val = 0;
83 static void skl_set_pcm_constrains(struct hdac_bus *bus,
84 struct snd_pcm_runtime *runtime)
86 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
88 /* avoid wrap-around with wall-clock */
89 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
93 static enum hdac_ext_stream_type skl_get_host_stream_type(struct hdac_bus *bus)
96 return HDAC_EXT_STREAM_TYPE_HOST;
98 return HDAC_EXT_STREAM_TYPE_COUPLED;
102 * check if the stream opened is marked as ignore_suspend by machine, if so
103 * then enable suspend_active refcount
105 * The count supend_active does not need lock as it is used in open/close
106 * and suspend context
108 static void skl_set_suspend_active(struct snd_pcm_substream *substream,
109 struct snd_soc_dai *dai, bool enable)
111 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
112 struct snd_soc_dapm_widget *w;
113 struct skl_dev *skl = bus_to_skl(bus);
115 w = snd_soc_dai_get_widget(dai, substream->stream);
117 if (w->ignore_suspend && enable)
118 skl->supend_active++;
119 else if (w->ignore_suspend && !enable)
120 skl->supend_active--;
123 int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params)
125 struct hdac_bus *bus = dev_get_drvdata(dev);
126 struct skl_dev *skl = bus_to_skl(bus);
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);
152 * The recommended SDxFMT programming sequence for BXT
153 * platforms is to couple the stream before writing the format
155 if (IS_BXT(skl->pci)) {
156 snd_hdac_ext_stream_decouple(bus, stream, false);
157 err = snd_hdac_stream_setup(hdac_stream(stream));
158 snd_hdac_ext_stream_decouple(bus, stream, true);
160 err = snd_hdac_stream_setup(hdac_stream(stream));
166 hdac_stream(stream)->prepared = 1;
171 int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
173 struct hdac_bus *bus = dev_get_drvdata(dev);
174 unsigned int format_val;
175 struct hdac_stream *hstream;
176 struct hdac_ext_stream *stream;
177 struct hdac_ext_link *link;
178 unsigned char stream_tag;
180 hstream = snd_hdac_get_stream(bus, params->stream,
181 params->link_dma_id + 1);
185 stream = stream_to_hdac_ext_stream(hstream);
186 snd_hdac_ext_stream_decouple(bus, stream, true);
187 format_val = snd_hdac_calc_stream_format(params->s_freq, params->ch,
188 params->format, params->link_bps, 0);
190 dev_dbg(dev, "format_val=%d, rate=%d, ch=%d, format=%d\n",
191 format_val, params->s_freq, params->ch, params->format);
193 snd_hdac_ext_stream_reset(stream);
195 snd_hdac_ext_stream_setup(stream, format_val);
197 stream_tag = hstream->stream_tag;
198 if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
199 list_for_each_entry(link, &bus->hlink_list, list) {
200 if (link->index == params->link_index)
201 snd_hdac_ext_bus_link_set_stream_id(link,
206 stream->link_prepared = 1;
211 static int skl_pcm_open(struct snd_pcm_substream *substream,
212 struct snd_soc_dai *dai)
214 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
215 struct hdac_ext_stream *stream;
216 struct snd_pcm_runtime *runtime = substream->runtime;
217 struct skl_dma_params *dma_params;
218 struct skl_dev *skl = get_skl_ctx(dai->dev);
219 struct skl_module_cfg *mconfig;
221 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
223 stream = snd_hdac_ext_stream_assign(bus, substream,
224 skl_get_host_stream_type(bus));
228 skl_set_pcm_constrains(bus, runtime);
231 * disable WALLCLOCK timestamps for capture streams
232 * until we figure out how to handle digital inputs
234 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
235 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; /* legacy */
236 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME;
239 runtime->private_data = stream;
241 dma_params = kzalloc(sizeof(*dma_params), GFP_KERNEL);
245 dma_params->stream_tag = hdac_stream(stream)->stream_tag;
246 snd_soc_dai_set_dma_data(dai, substream, dma_params);
248 dev_dbg(dai->dev, "stream tag set in dma params=%d\n",
249 dma_params->stream_tag);
250 skl_set_suspend_active(substream, dai, true);
251 snd_pcm_set_sync(substream);
253 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
257 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
262 static int skl_pcm_prepare(struct snd_pcm_substream *substream,
263 struct snd_soc_dai *dai)
265 struct skl_dev *skl = get_skl_ctx(dai->dev);
266 struct skl_module_cfg *mconfig;
269 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
271 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
274 * In case of XRUN recovery or in the case when the application
275 * calls prepare another time, reset the FW pipe to clean state
278 (substream->runtime->state == SNDRV_PCM_STATE_XRUN ||
279 mconfig->pipe->state == SKL_PIPE_CREATED ||
280 mconfig->pipe->state == SKL_PIPE_PAUSED)) {
282 ret = skl_reset_pipe(skl, mconfig->pipe);
287 ret = skl_pcm_host_dma_prepare(dai->dev,
288 mconfig->pipe->p_params);
296 static int skl_pcm_hw_params(struct snd_pcm_substream *substream,
297 struct snd_pcm_hw_params *params,
298 struct snd_soc_dai *dai)
300 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
301 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
302 struct snd_pcm_runtime *runtime = substream->runtime;
303 struct skl_pipe_params p_params = {0};
304 struct skl_module_cfg *m_cfg;
307 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
308 ret = skl_substream_alloc_pages(bus, substream,
309 params_buffer_bytes(params));
313 dev_dbg(dai->dev, "format_val, rate=%d, ch=%d, format=%d\n",
314 runtime->rate, runtime->channels, runtime->format);
316 dma_id = hdac_stream(stream)->stream_tag - 1;
317 dev_dbg(dai->dev, "dma_id=%d\n", dma_id);
319 p_params.s_fmt = snd_pcm_format_width(params_format(params));
320 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
321 p_params.ch = params_channels(params);
322 p_params.s_freq = params_rate(params);
323 p_params.host_dma_id = dma_id;
324 p_params.stream = substream->stream;
325 p_params.format = params_format(params);
326 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
327 p_params.host_bps = dai->driver->playback.sig_bits;
329 p_params.host_bps = dai->driver->capture.sig_bits;
332 m_cfg = skl_tplg_fe_get_cpr_module(dai, p_params.stream);
334 skl_tplg_update_pipe_params(dai->dev, m_cfg, &p_params);
339 static void skl_pcm_close(struct snd_pcm_substream *substream,
340 struct snd_soc_dai *dai)
342 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
343 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
344 struct skl_dma_params *dma_params = NULL;
345 struct skl_dev *skl = bus_to_skl(bus);
346 struct skl_module_cfg *mconfig;
348 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
350 snd_hdac_ext_stream_release(stream, skl_get_host_stream_type(bus));
352 dma_params = snd_soc_dai_get_dma_data(dai, substream);
354 * now we should set this to NULL as we are freeing by the
357 snd_soc_dai_set_dma_data(dai, substream, NULL);
358 skl_set_suspend_active(substream, dai, false);
361 * check if close is for "Reference Pin" and set back the
362 * CGCTL.MISCBDCGE if disabled by driver
364 if (!strncmp(dai->name, "Reference Pin", 13) &&
365 skl->miscbdcg_disabled) {
366 skl->enable_miscbdcge(dai->dev, true);
367 skl->miscbdcg_disabled = false;
370 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
372 skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
377 static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
378 struct snd_soc_dai *dai)
380 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
381 struct skl_dev *skl = get_skl_ctx(dai->dev);
382 struct skl_module_cfg *mconfig;
385 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
387 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
390 ret = skl_reset_pipe(skl, mconfig->pipe);
392 dev_err(dai->dev, "%s:Reset failed ret =%d",
396 snd_hdac_stream_cleanup(hdac_stream(stream));
397 hdac_stream(stream)->prepared = 0;
402 static int skl_be_hw_params(struct snd_pcm_substream *substream,
403 struct snd_pcm_hw_params *params,
404 struct snd_soc_dai *dai)
406 struct skl_pipe_params p_params = {0};
408 p_params.s_fmt = snd_pcm_format_width(params_format(params));
409 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
410 p_params.ch = params_channels(params);
411 p_params.s_freq = params_rate(params);
412 p_params.stream = substream->stream;
414 return skl_tplg_be_update_params(dai, &p_params);
417 static int skl_decoupled_trigger(struct snd_pcm_substream *substream,
420 struct hdac_bus *bus = get_bus_ctx(substream);
421 struct hdac_ext_stream *stream;
423 unsigned long cookie;
424 struct hdac_stream *hstr;
426 stream = get_hdac_ext_stream(substream);
427 hstr = hdac_stream(stream);
433 case SNDRV_PCM_TRIGGER_START:
434 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
435 case SNDRV_PCM_TRIGGER_RESUME:
439 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
440 case SNDRV_PCM_TRIGGER_SUSPEND:
441 case SNDRV_PCM_TRIGGER_STOP:
449 spin_lock_irqsave(&bus->reg_lock, cookie);
452 snd_hdac_stream_start(hdac_stream(stream));
453 snd_hdac_stream_timecounter_init(hstr, 0);
455 snd_hdac_stream_stop(hdac_stream(stream));
458 spin_unlock_irqrestore(&bus->reg_lock, cookie);
463 static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
464 struct snd_soc_dai *dai)
466 struct skl_dev *skl = get_skl_ctx(dai->dev);
467 struct skl_module_cfg *mconfig;
468 struct hdac_bus *bus = get_bus_ctx(substream);
469 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
470 struct hdac_stream *hstream = hdac_stream(stream);
471 struct snd_soc_dapm_widget *w;
474 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
478 w = snd_soc_dai_get_widget(dai, substream->stream);
481 case SNDRV_PCM_TRIGGER_RESUME:
482 if (!w->ignore_suspend) {
484 * enable DMA Resume enable bit for the stream, set the
485 * dpib & lpib position to resume before starting the
488 snd_hdac_stream_drsm_enable(bus, true, hstream->index);
489 snd_hdac_stream_set_dpibr(bus, hstream, hstream->lpib);
490 snd_hdac_stream_set_lpib(hstream, hstream->lpib);
494 case SNDRV_PCM_TRIGGER_START:
495 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
497 * Start HOST DMA and Start FE Pipe.This is to make sure that
498 * there are no underrun/overrun in the case when the FE
499 * pipeline is started but there is a delay in starting the
500 * DMA channel on the host.
502 ret = skl_decoupled_trigger(substream, cmd);
505 return skl_run_pipe(skl, mconfig->pipe);
507 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
508 case SNDRV_PCM_TRIGGER_SUSPEND:
509 case SNDRV_PCM_TRIGGER_STOP:
511 * Stop FE Pipe first and stop DMA. This is to make sure that
512 * there are no underrun/overrun in the case if there is a delay
513 * between the two operations.
515 ret = skl_stop_pipe(skl, mconfig->pipe);
519 ret = skl_decoupled_trigger(substream, cmd);
520 if ((cmd == SNDRV_PCM_TRIGGER_SUSPEND) && !w->ignore_suspend) {
521 /* save the dpib and lpib positions */
522 hstream->dpib = readl(bus->remap_addr +
523 AZX_REG_VS_SDXDPIB_XBASE +
524 (AZX_REG_VS_SDXDPIB_XINTERVAL *
527 hstream->lpib = snd_hdac_stream_get_pos_lpib(hstream);
529 snd_hdac_ext_stream_decouple(bus, stream, false);
541 static int skl_link_hw_params(struct snd_pcm_substream *substream,
542 struct snd_pcm_hw_params *params,
543 struct snd_soc_dai *dai)
545 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
546 struct hdac_ext_stream *link_dev;
547 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
548 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
549 struct skl_pipe_params p_params = {0};
550 struct hdac_ext_link *link;
553 link_dev = snd_hdac_ext_stream_assign(bus, substream,
554 HDAC_EXT_STREAM_TYPE_LINK);
558 snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);
560 link = snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name);
564 stream_tag = hdac_stream(link_dev)->stream_tag;
566 /* set the hdac_stream in the codec dai */
567 snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream);
569 p_params.s_fmt = snd_pcm_format_width(params_format(params));
570 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
571 p_params.ch = params_channels(params);
572 p_params.s_freq = params_rate(params);
573 p_params.stream = substream->stream;
574 p_params.link_dma_id = stream_tag - 1;
575 p_params.link_index = link->index;
576 p_params.format = params_format(params);
578 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
579 p_params.link_bps = codec_dai->driver->playback.sig_bits;
581 p_params.link_bps = codec_dai->driver->capture.sig_bits;
583 return skl_tplg_be_update_params(dai, &p_params);
586 static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,
587 struct snd_soc_dai *dai)
589 struct skl_dev *skl = get_skl_ctx(dai->dev);
590 struct skl_module_cfg *mconfig = NULL;
592 /* In case of XRUN recovery, reset the FW pipe to clean state */
593 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream);
594 if (mconfig && !mconfig->pipe->passthru &&
595 (substream->runtime->state == SNDRV_PCM_STATE_XRUN))
596 skl_reset_pipe(skl, mconfig->pipe);
601 static int skl_link_pcm_trigger(struct snd_pcm_substream *substream,
602 int cmd, struct snd_soc_dai *dai)
604 struct hdac_ext_stream *link_dev =
605 snd_soc_dai_get_dma_data(dai, substream);
606 struct hdac_bus *bus = get_bus_ctx(substream);
607 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
609 dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd);
611 case SNDRV_PCM_TRIGGER_RESUME:
612 case SNDRV_PCM_TRIGGER_START:
613 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
614 snd_hdac_ext_stream_start(link_dev);
617 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
618 case SNDRV_PCM_TRIGGER_SUSPEND:
619 case SNDRV_PCM_TRIGGER_STOP:
620 snd_hdac_ext_stream_clear(link_dev);
621 if (cmd == SNDRV_PCM_TRIGGER_SUSPEND)
622 snd_hdac_ext_stream_decouple(bus, stream, false);
631 static int skl_link_hw_free(struct snd_pcm_substream *substream,
632 struct snd_soc_dai *dai)
634 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
635 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
636 struct hdac_ext_stream *link_dev =
637 snd_soc_dai_get_dma_data(dai, substream);
638 struct hdac_ext_link *link;
639 unsigned char stream_tag;
641 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
643 link_dev->link_prepared = 0;
645 link = snd_hdac_ext_bus_get_hlink_by_name(bus, asoc_rtd_to_codec(rtd, 0)->component->name);
649 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
650 stream_tag = hdac_stream(link_dev)->stream_tag;
651 snd_hdac_ext_bus_link_clear_stream_id(link, stream_tag);
654 snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
658 static const struct snd_soc_dai_ops skl_pcm_dai_ops = {
659 .startup = skl_pcm_open,
660 .shutdown = skl_pcm_close,
661 .prepare = skl_pcm_prepare,
662 .hw_params = skl_pcm_hw_params,
663 .hw_free = skl_pcm_hw_free,
664 .trigger = skl_pcm_trigger,
667 static const struct snd_soc_dai_ops skl_dmic_dai_ops = {
668 .hw_params = skl_be_hw_params,
671 static const struct snd_soc_dai_ops skl_be_ssp_dai_ops = {
672 .hw_params = skl_be_hw_params,
675 static const struct snd_soc_dai_ops skl_link_dai_ops = {
676 .prepare = skl_link_pcm_prepare,
677 .hw_params = skl_link_hw_params,
678 .hw_free = skl_link_hw_free,
679 .trigger = skl_link_pcm_trigger,
682 static struct snd_soc_dai_driver skl_fe_dai[] = {
684 .name = "System Pin",
685 .ops = &skl_pcm_dai_ops,
687 .stream_name = "System Playback",
688 .channels_min = HDA_MONO,
689 .channels_max = HDA_STEREO,
690 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_8000,
691 .formats = SNDRV_PCM_FMTBIT_S16_LE |
692 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
696 .stream_name = "System Capture",
697 .channels_min = HDA_MONO,
698 .channels_max = HDA_STEREO,
699 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
700 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
705 .name = "System Pin2",
706 .ops = &skl_pcm_dai_ops,
708 .stream_name = "Headset Playback",
709 .channels_min = HDA_MONO,
710 .channels_max = HDA_STEREO,
711 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
713 .formats = SNDRV_PCM_FMTBIT_S16_LE |
714 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
718 .name = "Echoref Pin",
719 .ops = &skl_pcm_dai_ops,
721 .stream_name = "Echoreference Capture",
722 .channels_min = HDA_STEREO,
723 .channels_max = HDA_STEREO,
724 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
726 .formats = SNDRV_PCM_FMTBIT_S16_LE |
727 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
731 .name = "Reference Pin",
732 .ops = &skl_pcm_dai_ops,
734 .stream_name = "Reference Capture",
735 .channels_min = HDA_MONO,
736 .channels_max = HDA_QUAD,
737 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
738 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
743 .name = "Deepbuffer Pin",
744 .ops = &skl_pcm_dai_ops,
746 .stream_name = "Deepbuffer Playback",
747 .channels_min = HDA_STEREO,
748 .channels_max = HDA_STEREO,
749 .rates = SNDRV_PCM_RATE_48000,
750 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
755 .name = "LowLatency Pin",
756 .ops = &skl_pcm_dai_ops,
758 .stream_name = "Low Latency Playback",
759 .channels_min = HDA_STEREO,
760 .channels_max = HDA_STEREO,
761 .rates = SNDRV_PCM_RATE_48000,
762 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
768 .ops = &skl_pcm_dai_ops,
770 .stream_name = "DMIC Capture",
771 .channels_min = HDA_MONO,
772 .channels_max = HDA_QUAD,
773 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
774 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
780 .ops = &skl_pcm_dai_ops,
782 .stream_name = "HDMI1 Playback",
783 .channels_min = HDA_STEREO,
785 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
786 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
787 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
788 SNDRV_PCM_RATE_192000,
789 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
790 SNDRV_PCM_FMTBIT_S32_LE,
796 .ops = &skl_pcm_dai_ops,
798 .stream_name = "HDMI2 Playback",
799 .channels_min = HDA_STEREO,
801 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
802 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
803 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
804 SNDRV_PCM_RATE_192000,
805 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
806 SNDRV_PCM_FMTBIT_S32_LE,
812 .ops = &skl_pcm_dai_ops,
814 .stream_name = "HDMI3 Playback",
815 .channels_min = HDA_STEREO,
817 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
818 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
819 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
820 SNDRV_PCM_RATE_192000,
821 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
822 SNDRV_PCM_FMTBIT_S32_LE,
829 static struct snd_soc_dai_driver skl_platform_dai[] = {
832 .ops = &skl_be_ssp_dai_ops,
834 .stream_name = "ssp0 Tx",
835 .channels_min = HDA_STEREO,
836 .channels_max = HDA_STEREO,
837 .rates = SNDRV_PCM_RATE_48000,
838 .formats = SNDRV_PCM_FMTBIT_S16_LE,
841 .stream_name = "ssp0 Rx",
842 .channels_min = HDA_STEREO,
843 .channels_max = HDA_STEREO,
844 .rates = SNDRV_PCM_RATE_48000,
845 .formats = SNDRV_PCM_FMTBIT_S16_LE,
850 .ops = &skl_be_ssp_dai_ops,
852 .stream_name = "ssp1 Tx",
853 .channels_min = HDA_STEREO,
854 .channels_max = HDA_STEREO,
855 .rates = SNDRV_PCM_RATE_48000,
856 .formats = SNDRV_PCM_FMTBIT_S16_LE,
859 .stream_name = "ssp1 Rx",
860 .channels_min = HDA_STEREO,
861 .channels_max = HDA_STEREO,
862 .rates = SNDRV_PCM_RATE_48000,
863 .formats = SNDRV_PCM_FMTBIT_S16_LE,
868 .ops = &skl_be_ssp_dai_ops,
870 .stream_name = "ssp2 Tx",
871 .channels_min = HDA_STEREO,
872 .channels_max = HDA_STEREO,
873 .rates = SNDRV_PCM_RATE_48000,
874 .formats = SNDRV_PCM_FMTBIT_S16_LE,
877 .stream_name = "ssp2 Rx",
878 .channels_min = HDA_STEREO,
879 .channels_max = HDA_STEREO,
880 .rates = SNDRV_PCM_RATE_48000,
881 .formats = SNDRV_PCM_FMTBIT_S16_LE,
886 .ops = &skl_be_ssp_dai_ops,
888 .stream_name = "ssp3 Tx",
889 .channels_min = HDA_STEREO,
890 .channels_max = HDA_STEREO,
891 .rates = SNDRV_PCM_RATE_48000,
892 .formats = SNDRV_PCM_FMTBIT_S16_LE,
895 .stream_name = "ssp3 Rx",
896 .channels_min = HDA_STEREO,
897 .channels_max = HDA_STEREO,
898 .rates = SNDRV_PCM_RATE_48000,
899 .formats = SNDRV_PCM_FMTBIT_S16_LE,
904 .ops = &skl_be_ssp_dai_ops,
906 .stream_name = "ssp4 Tx",
907 .channels_min = HDA_STEREO,
908 .channels_max = HDA_STEREO,
909 .rates = SNDRV_PCM_RATE_48000,
910 .formats = SNDRV_PCM_FMTBIT_S16_LE,
913 .stream_name = "ssp4 Rx",
914 .channels_min = HDA_STEREO,
915 .channels_max = HDA_STEREO,
916 .rates = SNDRV_PCM_RATE_48000,
917 .formats = SNDRV_PCM_FMTBIT_S16_LE,
922 .ops = &skl_be_ssp_dai_ops,
924 .stream_name = "ssp5 Tx",
925 .channels_min = HDA_STEREO,
926 .channels_max = HDA_STEREO,
927 .rates = SNDRV_PCM_RATE_48000,
928 .formats = SNDRV_PCM_FMTBIT_S16_LE,
931 .stream_name = "ssp5 Rx",
932 .channels_min = HDA_STEREO,
933 .channels_max = HDA_STEREO,
934 .rates = SNDRV_PCM_RATE_48000,
935 .formats = SNDRV_PCM_FMTBIT_S16_LE,
939 .name = "iDisp1 Pin",
940 .ops = &skl_link_dai_ops,
942 .stream_name = "iDisp1 Tx",
943 .channels_min = HDA_STEREO,
945 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_48000,
946 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
947 SNDRV_PCM_FMTBIT_S24_LE,
951 .name = "iDisp2 Pin",
952 .ops = &skl_link_dai_ops,
954 .stream_name = "iDisp2 Tx",
955 .channels_min = HDA_STEREO,
957 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
958 SNDRV_PCM_RATE_48000,
959 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
960 SNDRV_PCM_FMTBIT_S24_LE,
964 .name = "iDisp3 Pin",
965 .ops = &skl_link_dai_ops,
967 .stream_name = "iDisp3 Tx",
968 .channels_min = HDA_STEREO,
970 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
971 SNDRV_PCM_RATE_48000,
972 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
973 SNDRV_PCM_FMTBIT_S24_LE,
977 .name = "DMIC01 Pin",
978 .ops = &skl_dmic_dai_ops,
980 .stream_name = "DMIC01 Rx",
981 .channels_min = HDA_MONO,
982 .channels_max = HDA_QUAD,
983 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
984 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
988 .name = "DMIC16k Pin",
989 .ops = &skl_dmic_dai_ops,
991 .stream_name = "DMIC16k Rx",
992 .channels_min = HDA_MONO,
993 .channels_max = HDA_QUAD,
994 .rates = SNDRV_PCM_RATE_16000,
995 .formats = SNDRV_PCM_FMTBIT_S16_LE,
999 .name = "Analog CPU DAI",
1000 .ops = &skl_link_dai_ops,
1002 .stream_name = "Analog CPU Playback",
1003 .channels_min = HDA_MONO,
1004 .channels_max = HDA_MAX,
1005 .rates = SNDRV_PCM_RATE_8000_192000,
1006 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1007 SNDRV_PCM_FMTBIT_S32_LE,
1010 .stream_name = "Analog CPU Capture",
1011 .channels_min = HDA_MONO,
1012 .channels_max = HDA_MAX,
1013 .rates = SNDRV_PCM_RATE_8000_192000,
1014 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1015 SNDRV_PCM_FMTBIT_S32_LE,
1019 .name = "Alt Analog CPU DAI",
1020 .ops = &skl_link_dai_ops,
1022 .stream_name = "Alt Analog CPU Playback",
1023 .channels_min = HDA_MONO,
1024 .channels_max = HDA_MAX,
1025 .rates = SNDRV_PCM_RATE_8000_192000,
1026 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1027 SNDRV_PCM_FMTBIT_S32_LE,
1030 .stream_name = "Alt Analog CPU Capture",
1031 .channels_min = HDA_MONO,
1032 .channels_max = HDA_MAX,
1033 .rates = SNDRV_PCM_RATE_8000_192000,
1034 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1035 SNDRV_PCM_FMTBIT_S32_LE,
1039 .name = "Digital CPU DAI",
1040 .ops = &skl_link_dai_ops,
1042 .stream_name = "Digital CPU Playback",
1043 .channels_min = HDA_MONO,
1044 .channels_max = HDA_MAX,
1045 .rates = SNDRV_PCM_RATE_8000_192000,
1046 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1047 SNDRV_PCM_FMTBIT_S32_LE,
1050 .stream_name = "Digital CPU Capture",
1051 .channels_min = HDA_MONO,
1052 .channels_max = HDA_MAX,
1053 .rates = SNDRV_PCM_RATE_8000_192000,
1054 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1055 SNDRV_PCM_FMTBIT_S32_LE,
1060 int skl_dai_load(struct snd_soc_component *cmp, int index,
1061 struct snd_soc_dai_driver *dai_drv,
1062 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai)
1064 dai_drv->ops = &skl_pcm_dai_ops;
1069 static int skl_platform_soc_open(struct snd_soc_component *component,
1070 struct snd_pcm_substream *substream)
1072 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1073 struct snd_soc_dai_link *dai_link = rtd->dai_link;
1075 dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "In %s:%s\n", __func__,
1076 dai_link->cpus->dai_name);
1078 snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
1083 static int skl_coupled_trigger(struct snd_pcm_substream *substream,
1086 struct hdac_bus *bus = get_bus_ctx(substream);
1087 struct hdac_ext_stream *stream;
1088 struct snd_pcm_substream *s;
1091 unsigned long cookie;
1092 struct hdac_stream *hstr;
1094 stream = get_hdac_ext_stream(substream);
1095 hstr = hdac_stream(stream);
1097 dev_dbg(bus->dev, "In %s cmd=%d\n", __func__, cmd);
1099 if (!hstr->prepared)
1103 case SNDRV_PCM_TRIGGER_START:
1104 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1105 case SNDRV_PCM_TRIGGER_RESUME:
1109 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1110 case SNDRV_PCM_TRIGGER_SUSPEND:
1111 case SNDRV_PCM_TRIGGER_STOP:
1119 snd_pcm_group_for_each_entry(s, substream) {
1120 if (s->pcm->card != substream->pcm->card)
1122 stream = get_hdac_ext_stream(s);
1123 sbits |= 1 << hdac_stream(stream)->index;
1124 snd_pcm_trigger_done(s, substream);
1127 spin_lock_irqsave(&bus->reg_lock, cookie);
1129 /* first, set SYNC bits of corresponding streams */
1130 snd_hdac_stream_sync_trigger(hstr, true, sbits, AZX_REG_SSYNC);
1132 snd_pcm_group_for_each_entry(s, substream) {
1133 if (s->pcm->card != substream->pcm->card)
1135 stream = get_hdac_ext_stream(s);
1137 snd_hdac_stream_start(hdac_stream(stream));
1139 snd_hdac_stream_stop(hdac_stream(stream));
1141 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1143 snd_hdac_stream_sync(hstr, start, sbits);
1145 spin_lock_irqsave(&bus->reg_lock, cookie);
1147 /* reset SYNC bits */
1148 snd_hdac_stream_sync_trigger(hstr, false, sbits, AZX_REG_SSYNC);
1150 snd_hdac_stream_timecounter_init(hstr, sbits);
1151 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1156 static int skl_platform_soc_trigger(struct snd_soc_component *component,
1157 struct snd_pcm_substream *substream,
1160 struct hdac_bus *bus = get_bus_ctx(substream);
1163 return skl_coupled_trigger(substream, cmd);
1168 static snd_pcm_uframes_t skl_platform_soc_pointer(
1169 struct snd_soc_component *component,
1170 struct snd_pcm_substream *substream)
1172 struct hdac_ext_stream *hstream = get_hdac_ext_stream(substream);
1173 struct hdac_bus *bus = get_bus_ctx(substream);
1177 * Use DPIB for Playback stream as the periodic DMA Position-in-
1178 * Buffer Writes may be scheduled at the same time or later than
1179 * the MSI and does not guarantee to reflect the Position of the
1180 * last buffer that was transferred. Whereas DPIB register in
1181 * HAD space reflects the actual data that is transferred.
1182 * Use the position buffer for capture, as DPIB write gets
1183 * completed earlier than the actual data written to the DDR.
1185 * For capture stream following workaround is required to fix the
1186 * incorrect position reporting.
1188 * 1. Wait for 20us before reading the DMA position in buffer once
1189 * the interrupt is generated for stream completion as update happens
1190 * on the HDA frame boundary i.e. 20.833uSec.
1191 * 2. Read DPIB register to flush the DMA position value. This dummy
1192 * read is required to flush DMA position value.
1193 * 3. Read the DMA Position-in-Buffer. This value now will be equal to
1194 * or greater than period boundary.
1197 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1198 pos = readl(bus->remap_addr + AZX_REG_VS_SDXDPIB_XBASE +
1199 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1200 hdac_stream(hstream)->index));
1203 readl(bus->remap_addr +
1204 AZX_REG_VS_SDXDPIB_XBASE +
1205 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1206 hdac_stream(hstream)->index));
1207 pos = snd_hdac_stream_get_pos_posbuf(hdac_stream(hstream));
1210 if (pos >= hdac_stream(hstream)->bufsize)
1213 return bytes_to_frames(substream->runtime, pos);
1216 static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
1219 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1220 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
1221 u64 codec_frames, codec_nsecs;
1223 if (!codec_dai->driver->ops->delay)
1226 codec_frames = codec_dai->driver->ops->delay(substream, codec_dai);
1227 codec_nsecs = div_u64(codec_frames * 1000000000LL,
1228 substream->runtime->rate);
1230 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1231 return nsec + codec_nsecs;
1233 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
1236 static int skl_platform_soc_get_time_info(
1237 struct snd_soc_component *component,
1238 struct snd_pcm_substream *substream,
1239 struct timespec64 *system_ts, struct timespec64 *audio_ts,
1240 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
1241 struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
1243 struct hdac_ext_stream *sstream = get_hdac_ext_stream(substream);
1244 struct hdac_stream *hstr = hdac_stream(sstream);
1247 if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
1248 (audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
1250 snd_pcm_gettime(substream->runtime, system_ts);
1252 nsec = timecounter_read(&hstr->tc);
1253 if (audio_tstamp_config->report_delay)
1254 nsec = skl_adjust_codec_delay(substream, nsec);
1256 *audio_ts = ns_to_timespec64(nsec);
1258 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
1259 audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
1260 audio_tstamp_report->accuracy = 42; /* 24MHzWallClk == 42ns resolution */
1263 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
1269 #define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
1271 static int skl_platform_soc_new(struct snd_soc_component *component,
1272 struct snd_soc_pcm_runtime *rtd)
1274 struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
1275 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1276 struct snd_pcm *pcm = rtd->pcm;
1278 struct skl_dev *skl = bus_to_skl(bus);
1280 if (dai->driver->playback.channels_min ||
1281 dai->driver->capture.channels_min) {
1282 /* buffer pre-allocation */
1283 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1284 if (size > MAX_PREALLOC_SIZE)
1285 size = MAX_PREALLOC_SIZE;
1286 snd_pcm_set_managed_buffer_all(pcm,
1287 SNDRV_DMA_TYPE_DEV_SG,
1289 size, MAX_PREALLOC_SIZE);
1295 static int skl_get_module_info(struct skl_dev *skl,
1296 struct skl_module_cfg *mconfig)
1298 struct skl_module_inst_id *pin_id;
1299 guid_t *uuid_mod, *uuid_tplg;
1300 struct skl_module *skl_module;
1301 struct uuid_module *module;
1304 uuid_mod = (guid_t *)mconfig->guid;
1306 if (list_empty(&skl->uuid_list)) {
1307 dev_err(skl->dev, "Module list is empty\n");
1311 for (i = 0; i < skl->nr_modules; i++) {
1312 skl_module = skl->modules[i];
1313 uuid_tplg = &skl_module->uuid;
1314 if (guid_equal(uuid_mod, uuid_tplg)) {
1315 mconfig->module = skl_module;
1321 if (skl->nr_modules && ret)
1325 list_for_each_entry(module, &skl->uuid_list, list) {
1326 if (guid_equal(uuid_mod, &module->uuid)) {
1327 mconfig->id.module_id = module->id;
1328 mconfig->module->loadable = module->is_loadable;
1332 for (i = 0; i < MAX_IN_QUEUE; i++) {
1333 pin_id = &mconfig->m_in_pin[i].id;
1334 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1335 pin_id->module_id = module->id;
1338 for (i = 0; i < MAX_OUT_QUEUE; i++) {
1339 pin_id = &mconfig->m_out_pin[i].id;
1340 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1341 pin_id->module_id = module->id;
1348 static int skl_populate_modules(struct skl_dev *skl)
1350 struct skl_pipeline *p;
1351 struct skl_pipe_module *m;
1352 struct snd_soc_dapm_widget *w;
1353 struct skl_module_cfg *mconfig;
1356 list_for_each_entry(p, &skl->ppl_list, node) {
1357 list_for_each_entry(m, &p->pipe->w_list, node) {
1361 ret = skl_get_module_info(skl, mconfig);
1364 "query module info failed\n");
1368 skl_tplg_add_moduleid_in_bind_params(skl, w);
1375 static int skl_platform_soc_probe(struct snd_soc_component *component)
1377 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1378 struct skl_dev *skl = bus_to_skl(bus);
1379 const struct skl_dsp_ops *ops;
1382 ret = pm_runtime_resume_and_get(component->dev);
1383 if (ret < 0 && ret != -EACCES)
1387 skl->component = component;
1390 skl->debugfs = skl_debugfs_init(skl);
1392 ret = skl_tplg_init(component, bus);
1394 dev_err(component->dev, "Failed to init topology!\n");
1398 /* load the firmwares, since all is set */
1399 ops = skl_get_dsp_ops(skl->pci->device);
1404 * Disable dynamic clock and power gating during firmware
1405 * and library download
1407 skl->enable_miscbdcge(component->dev, false);
1408 skl->clock_power_gating(component->dev, false);
1410 ret = ops->init_fw(component->dev, skl);
1411 skl->enable_miscbdcge(component->dev, true);
1412 skl->clock_power_gating(component->dev, true);
1414 dev_err(component->dev, "Failed to boot first fw: %d\n", ret);
1417 skl_populate_modules(skl);
1418 skl->update_d0i3c = skl_update_d0i3c;
1420 if (skl->cfg.astate_cfg != NULL) {
1421 skl_dsp_set_astate_cfg(skl,
1422 skl->cfg.astate_cfg->count,
1423 skl->cfg.astate_cfg);
1426 pm_runtime_mark_last_busy(component->dev);
1427 pm_runtime_put_autosuspend(component->dev);
1432 static void skl_platform_soc_remove(struct snd_soc_component *component)
1434 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1435 struct skl_dev *skl = bus_to_skl(bus);
1437 skl_tplg_exit(component, bus);
1439 skl_debugfs_exit(skl);
1442 static const struct snd_soc_component_driver skl_component = {
1444 .probe = skl_platform_soc_probe,
1445 .remove = skl_platform_soc_remove,
1446 .open = skl_platform_soc_open,
1447 .trigger = skl_platform_soc_trigger,
1448 .pointer = skl_platform_soc_pointer,
1449 .get_time_info = skl_platform_soc_get_time_info,
1450 .pcm_construct = skl_platform_soc_new,
1451 .module_get_upon_open = 1, /* increment refcount when a pcm is opened */
1454 int skl_platform_register(struct device *dev)
1457 struct snd_soc_dai_driver *dais;
1458 int num_dais = ARRAY_SIZE(skl_platform_dai);
1459 struct hdac_bus *bus = dev_get_drvdata(dev);
1460 struct skl_dev *skl = bus_to_skl(bus);
1462 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
1469 if (!skl->use_tplg_pcm) {
1470 dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
1471 sizeof(skl_platform_dai), GFP_KERNEL);
1478 memcpy(&skl->dais[ARRAY_SIZE(skl_platform_dai)], skl_fe_dai,
1479 sizeof(skl_fe_dai));
1480 num_dais += ARRAY_SIZE(skl_fe_dai);
1483 ret = devm_snd_soc_register_component(dev, &skl_component,
1484 skl->dais, num_dais);
1486 dev_err(dev, "soc component registration failed %d\n", ret);
1491 int skl_platform_unregister(struct device *dev)
1493 struct hdac_bus *bus = dev_get_drvdata(dev);
1494 struct skl_dev *skl = bus_to_skl(bus);
1495 struct skl_module_deferred_bind *modules, *tmp;
1497 list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
1498 list_del(&modules->node);