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_link_stream_reset(stream);
195 snd_hdac_ext_link_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_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->status->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.ch = params_channels(params);
321 p_params.s_freq = params_rate(params);
322 p_params.host_dma_id = dma_id;
323 p_params.stream = substream->stream;
324 p_params.format = params_format(params);
325 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
326 p_params.host_bps = dai->driver->playback.sig_bits;
328 p_params.host_bps = dai->driver->capture.sig_bits;
331 m_cfg = skl_tplg_fe_get_cpr_module(dai, p_params.stream);
333 skl_tplg_update_pipe_params(dai->dev, m_cfg, &p_params);
338 static void skl_pcm_close(struct snd_pcm_substream *substream,
339 struct snd_soc_dai *dai)
341 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
342 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
343 struct skl_dma_params *dma_params = NULL;
344 struct skl_dev *skl = bus_to_skl(bus);
345 struct skl_module_cfg *mconfig;
347 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
349 snd_hdac_ext_stream_release(stream, skl_get_host_stream_type(bus));
351 dma_params = snd_soc_dai_get_dma_data(dai, substream);
353 * now we should set this to NULL as we are freeing by the
356 snd_soc_dai_set_dma_data(dai, substream, NULL);
357 skl_set_suspend_active(substream, dai, false);
360 * check if close is for "Reference Pin" and set back the
361 * CGCTL.MISCBDCGE if disabled by driver
363 if (!strncmp(dai->name, "Reference Pin", 13) &&
364 skl->miscbdcg_disabled) {
365 skl->enable_miscbdcge(dai->dev, true);
366 skl->miscbdcg_disabled = false;
369 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
371 skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
376 static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
377 struct snd_soc_dai *dai)
379 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
380 struct skl_dev *skl = get_skl_ctx(dai->dev);
381 struct skl_module_cfg *mconfig;
384 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
386 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
389 ret = skl_reset_pipe(skl, mconfig->pipe);
391 dev_err(dai->dev, "%s:Reset failed ret =%d",
395 snd_hdac_stream_cleanup(hdac_stream(stream));
396 hdac_stream(stream)->prepared = 0;
401 static int skl_be_hw_params(struct snd_pcm_substream *substream,
402 struct snd_pcm_hw_params *params,
403 struct snd_soc_dai *dai)
405 struct skl_pipe_params p_params = {0};
407 p_params.s_fmt = snd_pcm_format_width(params_format(params));
408 p_params.ch = params_channels(params);
409 p_params.s_freq = params_rate(params);
410 p_params.stream = substream->stream;
412 return skl_tplg_be_update_params(dai, &p_params);
415 static int skl_decoupled_trigger(struct snd_pcm_substream *substream,
418 struct hdac_bus *bus = get_bus_ctx(substream);
419 struct hdac_ext_stream *stream;
421 unsigned long cookie;
422 struct hdac_stream *hstr;
424 stream = get_hdac_ext_stream(substream);
425 hstr = hdac_stream(stream);
431 case SNDRV_PCM_TRIGGER_START:
432 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
433 case SNDRV_PCM_TRIGGER_RESUME:
437 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
438 case SNDRV_PCM_TRIGGER_SUSPEND:
439 case SNDRV_PCM_TRIGGER_STOP:
447 spin_lock_irqsave(&bus->reg_lock, cookie);
450 snd_hdac_stream_start(hdac_stream(stream), true);
451 snd_hdac_stream_timecounter_init(hstr, 0);
453 snd_hdac_stream_stop(hdac_stream(stream));
456 spin_unlock_irqrestore(&bus->reg_lock, cookie);
461 static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
462 struct snd_soc_dai *dai)
464 struct skl_dev *skl = get_skl_ctx(dai->dev);
465 struct skl_module_cfg *mconfig;
466 struct hdac_bus *bus = get_bus_ctx(substream);
467 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
468 struct snd_soc_dapm_widget *w;
471 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
475 w = snd_soc_dai_get_widget(dai, substream->stream);
478 case SNDRV_PCM_TRIGGER_RESUME:
479 if (!w->ignore_suspend) {
481 * enable DMA Resume enable bit for the stream, set the
482 * dpib & lpib position to resume before starting the
485 snd_hdac_ext_stream_drsm_enable(bus, true,
486 hdac_stream(stream)->index);
487 snd_hdac_ext_stream_set_dpibr(bus, stream,
489 snd_hdac_ext_stream_set_lpib(stream, stream->lpib);
493 case SNDRV_PCM_TRIGGER_START:
494 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
496 * Start HOST DMA and Start FE Pipe.This is to make sure that
497 * there are no underrun/overrun in the case when the FE
498 * pipeline is started but there is a delay in starting the
499 * DMA channel on the host.
501 ret = skl_decoupled_trigger(substream, cmd);
504 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 stream->dpib = readl(bus->remap_addr +
523 AZX_REG_VS_SDXDPIB_XBASE +
524 (AZX_REG_VS_SDXDPIB_XINTERVAL *
525 hdac_stream(stream)->index));
527 stream->lpib = snd_hdac_stream_get_pos_lpib(
528 hdac_stream(stream));
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_link(bus, codec_dai->component->name);
564 stream_tag = hdac_stream(link_dev)->stream_tag;
566 /* set the stream tag in the codec dai dma params */
567 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
568 snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0);
570 snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0);
572 p_params.s_fmt = snd_pcm_format_width(params_format(params));
573 p_params.ch = params_channels(params);
574 p_params.s_freq = params_rate(params);
575 p_params.stream = substream->stream;
576 p_params.link_dma_id = stream_tag - 1;
577 p_params.link_index = link->index;
578 p_params.format = params_format(params);
580 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
581 p_params.link_bps = codec_dai->driver->playback.sig_bits;
583 p_params.link_bps = codec_dai->driver->capture.sig_bits;
585 return skl_tplg_be_update_params(dai, &p_params);
588 static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,
589 struct snd_soc_dai *dai)
591 struct skl_dev *skl = get_skl_ctx(dai->dev);
592 struct skl_module_cfg *mconfig = NULL;
594 /* In case of XRUN recovery, reset the FW pipe to clean state */
595 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream);
596 if (mconfig && !mconfig->pipe->passthru &&
597 (substream->runtime->status->state == SNDRV_PCM_STATE_XRUN))
598 skl_reset_pipe(skl, mconfig->pipe);
603 static int skl_link_pcm_trigger(struct snd_pcm_substream *substream,
604 int cmd, struct snd_soc_dai *dai)
606 struct hdac_ext_stream *link_dev =
607 snd_soc_dai_get_dma_data(dai, substream);
608 struct hdac_bus *bus = get_bus_ctx(substream);
609 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
611 dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd);
613 case SNDRV_PCM_TRIGGER_RESUME:
614 case SNDRV_PCM_TRIGGER_START:
615 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
616 snd_hdac_ext_link_stream_start(link_dev);
619 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
620 case SNDRV_PCM_TRIGGER_SUSPEND:
621 case SNDRV_PCM_TRIGGER_STOP:
622 snd_hdac_ext_link_stream_clear(link_dev);
623 if (cmd == SNDRV_PCM_TRIGGER_SUSPEND)
624 snd_hdac_ext_stream_decouple(bus, stream, false);
633 static int skl_link_hw_free(struct snd_pcm_substream *substream,
634 struct snd_soc_dai *dai)
636 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
637 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
638 struct hdac_ext_stream *link_dev =
639 snd_soc_dai_get_dma_data(dai, substream);
640 struct hdac_ext_link *link;
641 unsigned char stream_tag;
643 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
645 link_dev->link_prepared = 0;
647 link = snd_hdac_ext_bus_get_link(bus, asoc_rtd_to_codec(rtd, 0)->component->name);
651 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
652 stream_tag = hdac_stream(link_dev)->stream_tag;
653 snd_hdac_ext_link_clear_stream_id(link, stream_tag);
656 snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
660 static const struct snd_soc_dai_ops skl_pcm_dai_ops = {
661 .startup = skl_pcm_open,
662 .shutdown = skl_pcm_close,
663 .prepare = skl_pcm_prepare,
664 .hw_params = skl_pcm_hw_params,
665 .hw_free = skl_pcm_hw_free,
666 .trigger = skl_pcm_trigger,
669 static const struct snd_soc_dai_ops skl_dmic_dai_ops = {
670 .hw_params = skl_be_hw_params,
673 static const struct snd_soc_dai_ops skl_be_ssp_dai_ops = {
674 .hw_params = skl_be_hw_params,
677 static const struct snd_soc_dai_ops skl_link_dai_ops = {
678 .prepare = skl_link_pcm_prepare,
679 .hw_params = skl_link_hw_params,
680 .hw_free = skl_link_hw_free,
681 .trigger = skl_link_pcm_trigger,
684 static struct snd_soc_dai_driver skl_fe_dai[] = {
686 .name = "System Pin",
687 .ops = &skl_pcm_dai_ops,
689 .stream_name = "System Playback",
690 .channels_min = HDA_MONO,
691 .channels_max = HDA_STEREO,
692 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_8000,
693 .formats = SNDRV_PCM_FMTBIT_S16_LE |
694 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
698 .stream_name = "System Capture",
699 .channels_min = HDA_MONO,
700 .channels_max = HDA_STEREO,
701 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
702 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
707 .name = "System Pin2",
708 .ops = &skl_pcm_dai_ops,
710 .stream_name = "Headset Playback",
711 .channels_min = HDA_MONO,
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 = "Echoref Pin",
721 .ops = &skl_pcm_dai_ops,
723 .stream_name = "Echoreference Capture",
724 .channels_min = HDA_STEREO,
725 .channels_max = HDA_STEREO,
726 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
728 .formats = SNDRV_PCM_FMTBIT_S16_LE |
729 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
733 .name = "Reference Pin",
734 .ops = &skl_pcm_dai_ops,
736 .stream_name = "Reference Capture",
737 .channels_min = HDA_MONO,
738 .channels_max = HDA_QUAD,
739 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
740 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
745 .name = "Deepbuffer Pin",
746 .ops = &skl_pcm_dai_ops,
748 .stream_name = "Deepbuffer Playback",
749 .channels_min = HDA_STEREO,
750 .channels_max = HDA_STEREO,
751 .rates = SNDRV_PCM_RATE_48000,
752 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
757 .name = "LowLatency Pin",
758 .ops = &skl_pcm_dai_ops,
760 .stream_name = "Low Latency Playback",
761 .channels_min = HDA_STEREO,
762 .channels_max = HDA_STEREO,
763 .rates = SNDRV_PCM_RATE_48000,
764 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
770 .ops = &skl_pcm_dai_ops,
772 .stream_name = "DMIC Capture",
773 .channels_min = HDA_MONO,
774 .channels_max = HDA_QUAD,
775 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
776 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
782 .ops = &skl_pcm_dai_ops,
784 .stream_name = "HDMI1 Playback",
785 .channels_min = HDA_STEREO,
787 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
788 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
789 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
790 SNDRV_PCM_RATE_192000,
791 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
792 SNDRV_PCM_FMTBIT_S32_LE,
798 .ops = &skl_pcm_dai_ops,
800 .stream_name = "HDMI2 Playback",
801 .channels_min = HDA_STEREO,
803 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
804 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
805 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
806 SNDRV_PCM_RATE_192000,
807 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
808 SNDRV_PCM_FMTBIT_S32_LE,
814 .ops = &skl_pcm_dai_ops,
816 .stream_name = "HDMI3 Playback",
817 .channels_min = HDA_STEREO,
819 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
820 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
821 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
822 SNDRV_PCM_RATE_192000,
823 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
824 SNDRV_PCM_FMTBIT_S32_LE,
831 static struct snd_soc_dai_driver skl_platform_dai[] = {
834 .ops = &skl_be_ssp_dai_ops,
836 .stream_name = "ssp0 Tx",
837 .channels_min = HDA_STEREO,
838 .channels_max = HDA_STEREO,
839 .rates = SNDRV_PCM_RATE_48000,
840 .formats = SNDRV_PCM_FMTBIT_S16_LE,
843 .stream_name = "ssp0 Rx",
844 .channels_min = HDA_STEREO,
845 .channels_max = HDA_STEREO,
846 .rates = SNDRV_PCM_RATE_48000,
847 .formats = SNDRV_PCM_FMTBIT_S16_LE,
852 .ops = &skl_be_ssp_dai_ops,
854 .stream_name = "ssp1 Tx",
855 .channels_min = HDA_STEREO,
856 .channels_max = HDA_STEREO,
857 .rates = SNDRV_PCM_RATE_48000,
858 .formats = SNDRV_PCM_FMTBIT_S16_LE,
861 .stream_name = "ssp1 Rx",
862 .channels_min = HDA_STEREO,
863 .channels_max = HDA_STEREO,
864 .rates = SNDRV_PCM_RATE_48000,
865 .formats = SNDRV_PCM_FMTBIT_S16_LE,
870 .ops = &skl_be_ssp_dai_ops,
872 .stream_name = "ssp2 Tx",
873 .channels_min = HDA_STEREO,
874 .channels_max = HDA_STEREO,
875 .rates = SNDRV_PCM_RATE_48000,
876 .formats = SNDRV_PCM_FMTBIT_S16_LE,
879 .stream_name = "ssp2 Rx",
880 .channels_min = HDA_STEREO,
881 .channels_max = HDA_STEREO,
882 .rates = SNDRV_PCM_RATE_48000,
883 .formats = SNDRV_PCM_FMTBIT_S16_LE,
888 .ops = &skl_be_ssp_dai_ops,
890 .stream_name = "ssp3 Tx",
891 .channels_min = HDA_STEREO,
892 .channels_max = HDA_STEREO,
893 .rates = SNDRV_PCM_RATE_48000,
894 .formats = SNDRV_PCM_FMTBIT_S16_LE,
897 .stream_name = "ssp3 Rx",
898 .channels_min = HDA_STEREO,
899 .channels_max = HDA_STEREO,
900 .rates = SNDRV_PCM_RATE_48000,
901 .formats = SNDRV_PCM_FMTBIT_S16_LE,
906 .ops = &skl_be_ssp_dai_ops,
908 .stream_name = "ssp4 Tx",
909 .channels_min = HDA_STEREO,
910 .channels_max = HDA_STEREO,
911 .rates = SNDRV_PCM_RATE_48000,
912 .formats = SNDRV_PCM_FMTBIT_S16_LE,
915 .stream_name = "ssp4 Rx",
916 .channels_min = HDA_STEREO,
917 .channels_max = HDA_STEREO,
918 .rates = SNDRV_PCM_RATE_48000,
919 .formats = SNDRV_PCM_FMTBIT_S16_LE,
924 .ops = &skl_be_ssp_dai_ops,
926 .stream_name = "ssp5 Tx",
927 .channels_min = HDA_STEREO,
928 .channels_max = HDA_STEREO,
929 .rates = SNDRV_PCM_RATE_48000,
930 .formats = SNDRV_PCM_FMTBIT_S16_LE,
933 .stream_name = "ssp5 Rx",
934 .channels_min = HDA_STEREO,
935 .channels_max = HDA_STEREO,
936 .rates = SNDRV_PCM_RATE_48000,
937 .formats = SNDRV_PCM_FMTBIT_S16_LE,
941 .name = "iDisp1 Pin",
942 .ops = &skl_link_dai_ops,
944 .stream_name = "iDisp1 Tx",
945 .channels_min = HDA_STEREO,
947 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_48000,
948 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
949 SNDRV_PCM_FMTBIT_S24_LE,
953 .name = "iDisp2 Pin",
954 .ops = &skl_link_dai_ops,
956 .stream_name = "iDisp2 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 = "iDisp3 Pin",
967 .ops = &skl_link_dai_ops,
969 .stream_name = "iDisp3 Tx",
970 .channels_min = HDA_STEREO,
972 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
973 SNDRV_PCM_RATE_48000,
974 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
975 SNDRV_PCM_FMTBIT_S24_LE,
979 .name = "DMIC01 Pin",
980 .ops = &skl_dmic_dai_ops,
982 .stream_name = "DMIC01 Rx",
983 .channels_min = HDA_MONO,
984 .channels_max = HDA_QUAD,
985 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
986 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
990 .name = "DMIC16k Pin",
991 .ops = &skl_dmic_dai_ops,
993 .stream_name = "DMIC16k Rx",
994 .channels_min = HDA_MONO,
995 .channels_max = HDA_QUAD,
996 .rates = SNDRV_PCM_RATE_16000,
997 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1001 .name = "Analog CPU DAI",
1002 .ops = &skl_link_dai_ops,
1004 .stream_name = "Analog CPU Playback",
1005 .channels_min = HDA_MONO,
1006 .channels_max = HDA_MAX,
1007 .rates = SNDRV_PCM_RATE_8000_192000,
1008 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1009 SNDRV_PCM_FMTBIT_S32_LE,
1012 .stream_name = "Analog CPU Capture",
1013 .channels_min = HDA_MONO,
1014 .channels_max = HDA_MAX,
1015 .rates = SNDRV_PCM_RATE_8000_192000,
1016 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1017 SNDRV_PCM_FMTBIT_S32_LE,
1021 .name = "Alt Analog CPU DAI",
1022 .ops = &skl_link_dai_ops,
1024 .stream_name = "Alt Analog CPU Playback",
1025 .channels_min = HDA_MONO,
1026 .channels_max = HDA_MAX,
1027 .rates = SNDRV_PCM_RATE_8000_192000,
1028 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1029 SNDRV_PCM_FMTBIT_S32_LE,
1032 .stream_name = "Alt Analog CPU Capture",
1033 .channels_min = HDA_MONO,
1034 .channels_max = HDA_MAX,
1035 .rates = SNDRV_PCM_RATE_8000_192000,
1036 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1037 SNDRV_PCM_FMTBIT_S32_LE,
1041 .name = "Digital CPU DAI",
1042 .ops = &skl_link_dai_ops,
1044 .stream_name = "Digital CPU Playback",
1045 .channels_min = HDA_MONO,
1046 .channels_max = HDA_MAX,
1047 .rates = SNDRV_PCM_RATE_8000_192000,
1048 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1049 SNDRV_PCM_FMTBIT_S32_LE,
1052 .stream_name = "Digital CPU Capture",
1053 .channels_min = HDA_MONO,
1054 .channels_max = HDA_MAX,
1055 .rates = SNDRV_PCM_RATE_8000_192000,
1056 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1057 SNDRV_PCM_FMTBIT_S32_LE,
1062 int skl_dai_load(struct snd_soc_component *cmp, int index,
1063 struct snd_soc_dai_driver *dai_drv,
1064 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai)
1066 dai_drv->ops = &skl_pcm_dai_ops;
1071 static int skl_platform_soc_open(struct snd_soc_component *component,
1072 struct snd_pcm_substream *substream)
1074 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1075 struct snd_soc_dai_link *dai_link = rtd->dai_link;
1077 dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "In %s:%s\n", __func__,
1078 dai_link->cpus->dai_name);
1080 snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
1085 static int skl_coupled_trigger(struct snd_pcm_substream *substream,
1088 struct hdac_bus *bus = get_bus_ctx(substream);
1089 struct hdac_ext_stream *stream;
1090 struct snd_pcm_substream *s;
1093 unsigned long cookie;
1094 struct hdac_stream *hstr;
1096 stream = get_hdac_ext_stream(substream);
1097 hstr = hdac_stream(stream);
1099 dev_dbg(bus->dev, "In %s cmd=%d\n", __func__, cmd);
1101 if (!hstr->prepared)
1105 case SNDRV_PCM_TRIGGER_START:
1106 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1107 case SNDRV_PCM_TRIGGER_RESUME:
1111 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1112 case SNDRV_PCM_TRIGGER_SUSPEND:
1113 case SNDRV_PCM_TRIGGER_STOP:
1121 snd_pcm_group_for_each_entry(s, substream) {
1122 if (s->pcm->card != substream->pcm->card)
1124 stream = get_hdac_ext_stream(s);
1125 sbits |= 1 << hdac_stream(stream)->index;
1126 snd_pcm_trigger_done(s, substream);
1129 spin_lock_irqsave(&bus->reg_lock, cookie);
1131 /* first, set SYNC bits of corresponding streams */
1132 snd_hdac_stream_sync_trigger(hstr, true, sbits, AZX_REG_SSYNC);
1134 snd_pcm_group_for_each_entry(s, substream) {
1135 if (s->pcm->card != substream->pcm->card)
1137 stream = get_hdac_ext_stream(s);
1139 snd_hdac_stream_start(hdac_stream(stream), true);
1141 snd_hdac_stream_stop(hdac_stream(stream));
1143 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1145 snd_hdac_stream_sync(hstr, start, sbits);
1147 spin_lock_irqsave(&bus->reg_lock, cookie);
1149 /* reset SYNC bits */
1150 snd_hdac_stream_sync_trigger(hstr, false, sbits, AZX_REG_SSYNC);
1152 snd_hdac_stream_timecounter_init(hstr, sbits);
1153 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1158 static int skl_platform_soc_trigger(struct snd_soc_component *component,
1159 struct snd_pcm_substream *substream,
1162 struct hdac_bus *bus = get_bus_ctx(substream);
1165 return skl_coupled_trigger(substream, cmd);
1170 static snd_pcm_uframes_t skl_platform_soc_pointer(
1171 struct snd_soc_component *component,
1172 struct snd_pcm_substream *substream)
1174 struct hdac_ext_stream *hstream = get_hdac_ext_stream(substream);
1175 struct hdac_bus *bus = get_bus_ctx(substream);
1179 * Use DPIB for Playback stream as the periodic DMA Position-in-
1180 * Buffer Writes may be scheduled at the same time or later than
1181 * the MSI and does not guarantee to reflect the Position of the
1182 * last buffer that was transferred. Whereas DPIB register in
1183 * HAD space reflects the actual data that is transferred.
1184 * Use the position buffer for capture, as DPIB write gets
1185 * completed earlier than the actual data written to the DDR.
1187 * For capture stream following workaround is required to fix the
1188 * incorrect position reporting.
1190 * 1. Wait for 20us before reading the DMA position in buffer once
1191 * the interrupt is generated for stream completion as update happens
1192 * on the HDA frame boundary i.e. 20.833uSec.
1193 * 2. Read DPIB register to flush the DMA position value. This dummy
1194 * read is required to flush DMA position value.
1195 * 3. Read the DMA Position-in-Buffer. This value now will be equal to
1196 * or greater than period boundary.
1199 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1200 pos = readl(bus->remap_addr + AZX_REG_VS_SDXDPIB_XBASE +
1201 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1202 hdac_stream(hstream)->index));
1205 readl(bus->remap_addr +
1206 AZX_REG_VS_SDXDPIB_XBASE +
1207 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1208 hdac_stream(hstream)->index));
1209 pos = snd_hdac_stream_get_pos_posbuf(hdac_stream(hstream));
1212 if (pos >= hdac_stream(hstream)->bufsize)
1215 return bytes_to_frames(substream->runtime, pos);
1218 static int skl_platform_soc_mmap(struct snd_soc_component *component,
1219 struct snd_pcm_substream *substream,
1220 struct vm_area_struct *area)
1222 return snd_pcm_lib_default_mmap(substream, area);
1225 static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
1228 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1229 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
1230 u64 codec_frames, codec_nsecs;
1232 if (!codec_dai->driver->ops->delay)
1235 codec_frames = codec_dai->driver->ops->delay(substream, codec_dai);
1236 codec_nsecs = div_u64(codec_frames * 1000000000LL,
1237 substream->runtime->rate);
1239 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1240 return nsec + codec_nsecs;
1242 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
1245 static int skl_platform_soc_get_time_info(
1246 struct snd_soc_component *component,
1247 struct snd_pcm_substream *substream,
1248 struct timespec64 *system_ts, struct timespec64 *audio_ts,
1249 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
1250 struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
1252 struct hdac_ext_stream *sstream = get_hdac_ext_stream(substream);
1253 struct hdac_stream *hstr = hdac_stream(sstream);
1256 if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
1257 (audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
1259 snd_pcm_gettime(substream->runtime, system_ts);
1261 nsec = timecounter_read(&hstr->tc);
1262 nsec = div_u64(nsec, 3); /* can be optimized */
1263 if (audio_tstamp_config->report_delay)
1264 nsec = skl_adjust_codec_delay(substream, nsec);
1266 *audio_ts = ns_to_timespec64(nsec);
1268 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
1269 audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
1270 audio_tstamp_report->accuracy = 42; /* 24MHzWallClk == 42ns resolution */
1273 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
1279 #define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
1281 static int skl_platform_soc_new(struct snd_soc_component *component,
1282 struct snd_soc_pcm_runtime *rtd)
1284 struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
1285 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1286 struct snd_pcm *pcm = rtd->pcm;
1288 struct skl_dev *skl = bus_to_skl(bus);
1290 if (dai->driver->playback.channels_min ||
1291 dai->driver->capture.channels_min) {
1292 /* buffer pre-allocation */
1293 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1294 if (size > MAX_PREALLOC_SIZE)
1295 size = MAX_PREALLOC_SIZE;
1296 snd_pcm_set_managed_buffer_all(pcm,
1297 SNDRV_DMA_TYPE_DEV_SG,
1299 size, MAX_PREALLOC_SIZE);
1305 static int skl_get_module_info(struct skl_dev *skl,
1306 struct skl_module_cfg *mconfig)
1308 struct skl_module_inst_id *pin_id;
1309 guid_t *uuid_mod, *uuid_tplg;
1310 struct skl_module *skl_module;
1311 struct uuid_module *module;
1314 uuid_mod = (guid_t *)mconfig->guid;
1316 if (list_empty(&skl->uuid_list)) {
1317 dev_err(skl->dev, "Module list is empty\n");
1321 for (i = 0; i < skl->nr_modules; i++) {
1322 skl_module = skl->modules[i];
1323 uuid_tplg = &skl_module->uuid;
1324 if (guid_equal(uuid_mod, uuid_tplg)) {
1325 mconfig->module = skl_module;
1331 if (skl->nr_modules && ret)
1335 list_for_each_entry(module, &skl->uuid_list, list) {
1336 if (guid_equal(uuid_mod, &module->uuid)) {
1337 mconfig->id.module_id = module->id;
1338 mconfig->module->loadable = module->is_loadable;
1342 for (i = 0; i < MAX_IN_QUEUE; i++) {
1343 pin_id = &mconfig->m_in_pin[i].id;
1344 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1345 pin_id->module_id = module->id;
1348 for (i = 0; i < MAX_OUT_QUEUE; i++) {
1349 pin_id = &mconfig->m_out_pin[i].id;
1350 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1351 pin_id->module_id = module->id;
1358 static int skl_populate_modules(struct skl_dev *skl)
1360 struct skl_pipeline *p;
1361 struct skl_pipe_module *m;
1362 struct snd_soc_dapm_widget *w;
1363 struct skl_module_cfg *mconfig;
1366 list_for_each_entry(p, &skl->ppl_list, node) {
1367 list_for_each_entry(m, &p->pipe->w_list, node) {
1371 ret = skl_get_module_info(skl, mconfig);
1374 "query module info failed\n");
1378 skl_tplg_add_moduleid_in_bind_params(skl, w);
1385 static int skl_platform_soc_probe(struct snd_soc_component *component)
1387 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1388 struct skl_dev *skl = bus_to_skl(bus);
1389 const struct skl_dsp_ops *ops;
1392 pm_runtime_get_sync(component->dev);
1394 skl->component = component;
1397 skl->debugfs = skl_debugfs_init(skl);
1399 ret = skl_tplg_init(component, bus);
1401 dev_err(component->dev, "Failed to init topology!\n");
1405 /* load the firmwares, since all is set */
1406 ops = skl_get_dsp_ops(skl->pci->device);
1411 * Disable dynamic clock and power gating during firmware
1412 * and library download
1414 skl->enable_miscbdcge(component->dev, false);
1415 skl->clock_power_gating(component->dev, false);
1417 ret = ops->init_fw(component->dev, skl);
1418 skl->enable_miscbdcge(component->dev, true);
1419 skl->clock_power_gating(component->dev, true);
1421 dev_err(component->dev, "Failed to boot first fw: %d\n", ret);
1424 skl_populate_modules(skl);
1425 skl->update_d0i3c = skl_update_d0i3c;
1427 if (skl->cfg.astate_cfg != NULL) {
1428 skl_dsp_set_astate_cfg(skl,
1429 skl->cfg.astate_cfg->count,
1430 skl->cfg.astate_cfg);
1433 pm_runtime_mark_last_busy(component->dev);
1434 pm_runtime_put_autosuspend(component->dev);
1439 static void skl_platform_soc_remove(struct snd_soc_component *component)
1441 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1442 struct skl_dev *skl = bus_to_skl(bus);
1444 skl_tplg_exit(component, bus);
1446 skl_debugfs_exit(skl);
1449 static const struct snd_soc_component_driver skl_component = {
1451 .probe = skl_platform_soc_probe,
1452 .remove = skl_platform_soc_remove,
1453 .open = skl_platform_soc_open,
1454 .trigger = skl_platform_soc_trigger,
1455 .pointer = skl_platform_soc_pointer,
1456 .get_time_info = skl_platform_soc_get_time_info,
1457 .mmap = skl_platform_soc_mmap,
1458 .pcm_construct = skl_platform_soc_new,
1459 .module_get_upon_open = 1, /* increment refcount when a pcm is opened */
1462 int skl_platform_register(struct device *dev)
1465 struct snd_soc_dai_driver *dais;
1466 int num_dais = ARRAY_SIZE(skl_platform_dai);
1467 struct hdac_bus *bus = dev_get_drvdata(dev);
1468 struct skl_dev *skl = bus_to_skl(bus);
1470 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
1477 if (!skl->use_tplg_pcm) {
1478 dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
1479 sizeof(skl_platform_dai), GFP_KERNEL);
1486 memcpy(&skl->dais[ARRAY_SIZE(skl_platform_dai)], skl_fe_dai,
1487 sizeof(skl_fe_dai));
1488 num_dais += ARRAY_SIZE(skl_fe_dai);
1491 ret = devm_snd_soc_register_component(dev, &skl_component,
1492 skl->dais, num_dais);
1494 dev_err(dev, "soc component registration failed %d\n", ret);
1499 int skl_platform_unregister(struct device *dev)
1501 struct hdac_bus *bus = dev_get_drvdata(dev);
1502 struct skl_dev *skl = bus_to_skl(bus);
1503 struct skl_module_deferred_bind *modules, *tmp;
1505 list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
1506 list_del(&modules->node);