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);
248 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
253 static int skl_pcm_prepare(struct snd_pcm_substream *substream,
254 struct snd_soc_dai *dai)
256 struct skl_dev *skl = get_skl_ctx(dai->dev);
257 struct skl_module_cfg *mconfig;
260 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
262 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
265 * In case of XRUN recovery or in the case when the application
266 * calls prepare another time, reset the FW pipe to clean state
269 (substream->runtime->state == SNDRV_PCM_STATE_XRUN ||
270 mconfig->pipe->state == SKL_PIPE_CREATED ||
271 mconfig->pipe->state == SKL_PIPE_PAUSED)) {
273 ret = skl_reset_pipe(skl, mconfig->pipe);
278 ret = skl_pcm_host_dma_prepare(dai->dev,
279 mconfig->pipe->p_params);
287 static int skl_pcm_hw_params(struct snd_pcm_substream *substream,
288 struct snd_pcm_hw_params *params,
289 struct snd_soc_dai *dai)
291 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
292 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
293 struct snd_pcm_runtime *runtime = substream->runtime;
294 struct skl_pipe_params p_params = {0};
295 struct skl_module_cfg *m_cfg;
298 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
299 ret = skl_substream_alloc_pages(bus, substream,
300 params_buffer_bytes(params));
304 dev_dbg(dai->dev, "format_val, rate=%d, ch=%d, format=%d\n",
305 runtime->rate, runtime->channels, runtime->format);
307 dma_id = hdac_stream(stream)->stream_tag - 1;
308 dev_dbg(dai->dev, "dma_id=%d\n", dma_id);
310 p_params.s_fmt = snd_pcm_format_width(params_format(params));
311 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
312 p_params.ch = params_channels(params);
313 p_params.s_freq = params_rate(params);
314 p_params.host_dma_id = dma_id;
315 p_params.stream = substream->stream;
316 p_params.format = params_format(params);
317 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
318 p_params.host_bps = dai->driver->playback.sig_bits;
320 p_params.host_bps = dai->driver->capture.sig_bits;
323 m_cfg = skl_tplg_fe_get_cpr_module(dai, p_params.stream);
325 skl_tplg_update_pipe_params(dai->dev, m_cfg, &p_params);
330 static void skl_pcm_close(struct snd_pcm_substream *substream,
331 struct snd_soc_dai *dai)
333 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
334 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
335 struct skl_dma_params *dma_params = NULL;
336 struct skl_dev *skl = bus_to_skl(bus);
337 struct skl_module_cfg *mconfig;
339 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
341 snd_hdac_ext_stream_release(stream, skl_get_host_stream_type(bus));
343 dma_params = snd_soc_dai_get_dma_data(dai, substream);
345 * now we should set this to NULL as we are freeing by the
348 snd_soc_dai_set_dma_data(dai, substream, NULL);
349 skl_set_suspend_active(substream, dai, false);
352 * check if close is for "Reference Pin" and set back the
353 * CGCTL.MISCBDCGE if disabled by driver
355 if (!strncmp(dai->name, "Reference Pin", 13) &&
356 skl->miscbdcg_disabled) {
357 skl->enable_miscbdcge(dai->dev, true);
358 skl->miscbdcg_disabled = false;
361 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
363 skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
368 static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
369 struct snd_soc_dai *dai)
371 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
372 struct skl_dev *skl = get_skl_ctx(dai->dev);
373 struct skl_module_cfg *mconfig;
376 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
378 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
381 ret = skl_reset_pipe(skl, mconfig->pipe);
383 dev_err(dai->dev, "%s:Reset failed ret =%d",
387 snd_hdac_stream_cleanup(hdac_stream(stream));
388 hdac_stream(stream)->prepared = 0;
393 static int skl_be_hw_params(struct snd_pcm_substream *substream,
394 struct snd_pcm_hw_params *params,
395 struct snd_soc_dai *dai)
397 struct skl_pipe_params p_params = {0};
399 p_params.s_fmt = snd_pcm_format_width(params_format(params));
400 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
401 p_params.ch = params_channels(params);
402 p_params.s_freq = params_rate(params);
403 p_params.stream = substream->stream;
405 return skl_tplg_be_update_params(dai, &p_params);
408 static int skl_decoupled_trigger(struct snd_pcm_substream *substream,
411 struct hdac_bus *bus = get_bus_ctx(substream);
412 struct hdac_ext_stream *stream;
414 unsigned long cookie;
415 struct hdac_stream *hstr;
417 stream = get_hdac_ext_stream(substream);
418 hstr = hdac_stream(stream);
424 case SNDRV_PCM_TRIGGER_START:
425 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
426 case SNDRV_PCM_TRIGGER_RESUME:
430 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
431 case SNDRV_PCM_TRIGGER_SUSPEND:
432 case SNDRV_PCM_TRIGGER_STOP:
440 spin_lock_irqsave(&bus->reg_lock, cookie);
443 snd_hdac_stream_start(hdac_stream(stream));
444 snd_hdac_stream_timecounter_init(hstr, 0);
446 snd_hdac_stream_stop(hdac_stream(stream));
449 spin_unlock_irqrestore(&bus->reg_lock, cookie);
454 static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
455 struct snd_soc_dai *dai)
457 struct skl_dev *skl = get_skl_ctx(dai->dev);
458 struct skl_module_cfg *mconfig;
459 struct hdac_bus *bus = get_bus_ctx(substream);
460 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
461 struct hdac_stream *hstream = hdac_stream(stream);
462 struct snd_soc_dapm_widget *w;
465 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
469 w = snd_soc_dai_get_widget(dai, substream->stream);
472 case SNDRV_PCM_TRIGGER_RESUME:
473 if (!w->ignore_suspend) {
475 * enable DMA Resume enable bit for the stream, set the
476 * dpib & lpib position to resume before starting the
479 snd_hdac_stream_drsm_enable(bus, true, hstream->index);
480 snd_hdac_stream_set_dpibr(bus, hstream, hstream->lpib);
481 snd_hdac_stream_set_lpib(hstream, hstream->lpib);
485 case SNDRV_PCM_TRIGGER_START:
486 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
488 * Start HOST DMA and Start FE Pipe.This is to make sure that
489 * there are no underrun/overrun in the case when the FE
490 * pipeline is started but there is a delay in starting the
491 * DMA channel on the host.
493 ret = skl_decoupled_trigger(substream, cmd);
496 return skl_run_pipe(skl, mconfig->pipe);
498 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
499 case SNDRV_PCM_TRIGGER_SUSPEND:
500 case SNDRV_PCM_TRIGGER_STOP:
502 * Stop FE Pipe first and stop DMA. This is to make sure that
503 * there are no underrun/overrun in the case if there is a delay
504 * between the two operations.
506 ret = skl_stop_pipe(skl, mconfig->pipe);
510 ret = skl_decoupled_trigger(substream, cmd);
514 if ((cmd == SNDRV_PCM_TRIGGER_SUSPEND) && !w->ignore_suspend) {
515 /* save the dpib and lpib positions */
516 hstream->dpib = readl(bus->remap_addr +
517 AZX_REG_VS_SDXDPIB_XBASE +
518 (AZX_REG_VS_SDXDPIB_XINTERVAL *
521 hstream->lpib = snd_hdac_stream_get_pos_lpib(hstream);
523 snd_hdac_ext_stream_decouple(bus, stream, false);
535 static int skl_link_hw_params(struct snd_pcm_substream *substream,
536 struct snd_pcm_hw_params *params,
537 struct snd_soc_dai *dai)
539 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
540 struct hdac_ext_stream *link_dev;
541 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
542 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
543 struct skl_pipe_params p_params = {0};
544 struct hdac_ext_link *link;
547 link_dev = snd_hdac_ext_stream_assign(bus, substream,
548 HDAC_EXT_STREAM_TYPE_LINK);
552 snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);
554 link = snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name);
558 stream_tag = hdac_stream(link_dev)->stream_tag;
560 /* set the hdac_stream in the codec dai */
561 snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream);
563 p_params.s_fmt = snd_pcm_format_width(params_format(params));
564 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
565 p_params.ch = params_channels(params);
566 p_params.s_freq = params_rate(params);
567 p_params.stream = substream->stream;
568 p_params.link_dma_id = stream_tag - 1;
569 p_params.link_index = link->index;
570 p_params.format = params_format(params);
572 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
573 p_params.link_bps = codec_dai->driver->playback.sig_bits;
575 p_params.link_bps = codec_dai->driver->capture.sig_bits;
577 return skl_tplg_be_update_params(dai, &p_params);
580 static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,
581 struct snd_soc_dai *dai)
583 struct skl_dev *skl = get_skl_ctx(dai->dev);
584 struct skl_module_cfg *mconfig = NULL;
586 /* In case of XRUN recovery, reset the FW pipe to clean state */
587 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream);
588 if (mconfig && !mconfig->pipe->passthru &&
589 (substream->runtime->state == SNDRV_PCM_STATE_XRUN))
590 skl_reset_pipe(skl, mconfig->pipe);
595 static int skl_link_pcm_trigger(struct snd_pcm_substream *substream,
596 int cmd, struct snd_soc_dai *dai)
598 struct hdac_ext_stream *link_dev =
599 snd_soc_dai_get_dma_data(dai, substream);
600 struct hdac_bus *bus = get_bus_ctx(substream);
601 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
603 dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd);
605 case SNDRV_PCM_TRIGGER_RESUME:
606 case SNDRV_PCM_TRIGGER_START:
607 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
608 snd_hdac_ext_stream_start(link_dev);
611 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
612 case SNDRV_PCM_TRIGGER_SUSPEND:
613 case SNDRV_PCM_TRIGGER_STOP:
614 snd_hdac_ext_stream_clear(link_dev);
615 if (cmd == SNDRV_PCM_TRIGGER_SUSPEND)
616 snd_hdac_ext_stream_decouple(bus, stream, false);
625 static int skl_link_hw_free(struct snd_pcm_substream *substream,
626 struct snd_soc_dai *dai)
628 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
629 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
630 struct hdac_ext_stream *link_dev =
631 snd_soc_dai_get_dma_data(dai, substream);
632 struct hdac_ext_link *link;
633 unsigned char stream_tag;
635 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
637 link_dev->link_prepared = 0;
639 link = snd_hdac_ext_bus_get_hlink_by_name(bus, snd_soc_rtd_to_codec(rtd, 0)->component->name);
643 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
644 stream_tag = hdac_stream(link_dev)->stream_tag;
645 snd_hdac_ext_bus_link_clear_stream_id(link, stream_tag);
648 snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
652 static const struct snd_soc_dai_ops skl_pcm_dai_ops = {
653 .startup = skl_pcm_open,
654 .shutdown = skl_pcm_close,
655 .prepare = skl_pcm_prepare,
656 .hw_params = skl_pcm_hw_params,
657 .hw_free = skl_pcm_hw_free,
658 .trigger = skl_pcm_trigger,
661 static const struct snd_soc_dai_ops skl_dmic_dai_ops = {
662 .hw_params = skl_be_hw_params,
665 static const struct snd_soc_dai_ops skl_be_ssp_dai_ops = {
666 .hw_params = skl_be_hw_params,
669 static const struct snd_soc_dai_ops skl_link_dai_ops = {
670 .prepare = skl_link_pcm_prepare,
671 .hw_params = skl_link_hw_params,
672 .hw_free = skl_link_hw_free,
673 .trigger = skl_link_pcm_trigger,
676 static struct snd_soc_dai_driver skl_fe_dai[] = {
678 .name = "System Pin",
679 .ops = &skl_pcm_dai_ops,
681 .stream_name = "System Playback",
682 .channels_min = HDA_MONO,
683 .channels_max = HDA_STEREO,
684 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_8000,
685 .formats = SNDRV_PCM_FMTBIT_S16_LE |
686 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
690 .stream_name = "System Capture",
691 .channels_min = HDA_MONO,
692 .channels_max = HDA_STEREO,
693 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
694 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
699 .name = "System Pin2",
700 .ops = &skl_pcm_dai_ops,
702 .stream_name = "Headset Playback",
703 .channels_min = HDA_MONO,
704 .channels_max = HDA_STEREO,
705 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
707 .formats = SNDRV_PCM_FMTBIT_S16_LE |
708 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
712 .name = "Echoref Pin",
713 .ops = &skl_pcm_dai_ops,
715 .stream_name = "Echoreference Capture",
716 .channels_min = HDA_STEREO,
717 .channels_max = HDA_STEREO,
718 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
720 .formats = SNDRV_PCM_FMTBIT_S16_LE |
721 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
725 .name = "Reference Pin",
726 .ops = &skl_pcm_dai_ops,
728 .stream_name = "Reference Capture",
729 .channels_min = HDA_MONO,
730 .channels_max = HDA_QUAD,
731 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
732 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
737 .name = "Deepbuffer Pin",
738 .ops = &skl_pcm_dai_ops,
740 .stream_name = "Deepbuffer Playback",
741 .channels_min = HDA_STEREO,
742 .channels_max = HDA_STEREO,
743 .rates = SNDRV_PCM_RATE_48000,
744 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
749 .name = "LowLatency Pin",
750 .ops = &skl_pcm_dai_ops,
752 .stream_name = "Low Latency Playback",
753 .channels_min = HDA_STEREO,
754 .channels_max = HDA_STEREO,
755 .rates = SNDRV_PCM_RATE_48000,
756 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
762 .ops = &skl_pcm_dai_ops,
764 .stream_name = "DMIC Capture",
765 .channels_min = HDA_MONO,
766 .channels_max = HDA_QUAD,
767 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
768 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
774 .ops = &skl_pcm_dai_ops,
776 .stream_name = "HDMI1 Playback",
777 .channels_min = HDA_STEREO,
779 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
780 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
781 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
782 SNDRV_PCM_RATE_192000,
783 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
784 SNDRV_PCM_FMTBIT_S32_LE,
790 .ops = &skl_pcm_dai_ops,
792 .stream_name = "HDMI2 Playback",
793 .channels_min = HDA_STEREO,
795 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
796 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
797 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
798 SNDRV_PCM_RATE_192000,
799 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
800 SNDRV_PCM_FMTBIT_S32_LE,
806 .ops = &skl_pcm_dai_ops,
808 .stream_name = "HDMI3 Playback",
809 .channels_min = HDA_STEREO,
811 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
812 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
813 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
814 SNDRV_PCM_RATE_192000,
815 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
816 SNDRV_PCM_FMTBIT_S32_LE,
823 static struct snd_soc_dai_driver skl_platform_dai[] = {
826 .ops = &skl_be_ssp_dai_ops,
828 .stream_name = "ssp0 Tx",
829 .channels_min = HDA_STEREO,
830 .channels_max = HDA_STEREO,
831 .rates = SNDRV_PCM_RATE_48000,
832 .formats = SNDRV_PCM_FMTBIT_S16_LE,
835 .stream_name = "ssp0 Rx",
836 .channels_min = HDA_STEREO,
837 .channels_max = HDA_STEREO,
838 .rates = SNDRV_PCM_RATE_48000,
839 .formats = SNDRV_PCM_FMTBIT_S16_LE,
844 .ops = &skl_be_ssp_dai_ops,
846 .stream_name = "ssp1 Tx",
847 .channels_min = HDA_STEREO,
848 .channels_max = HDA_STEREO,
849 .rates = SNDRV_PCM_RATE_48000,
850 .formats = SNDRV_PCM_FMTBIT_S16_LE,
853 .stream_name = "ssp1 Rx",
854 .channels_min = HDA_STEREO,
855 .channels_max = HDA_STEREO,
856 .rates = SNDRV_PCM_RATE_48000,
857 .formats = SNDRV_PCM_FMTBIT_S16_LE,
862 .ops = &skl_be_ssp_dai_ops,
864 .stream_name = "ssp2 Tx",
865 .channels_min = HDA_STEREO,
866 .channels_max = HDA_STEREO,
867 .rates = SNDRV_PCM_RATE_48000,
868 .formats = SNDRV_PCM_FMTBIT_S16_LE,
871 .stream_name = "ssp2 Rx",
872 .channels_min = HDA_STEREO,
873 .channels_max = HDA_STEREO,
874 .rates = SNDRV_PCM_RATE_48000,
875 .formats = SNDRV_PCM_FMTBIT_S16_LE,
880 .ops = &skl_be_ssp_dai_ops,
882 .stream_name = "ssp3 Tx",
883 .channels_min = HDA_STEREO,
884 .channels_max = HDA_STEREO,
885 .rates = SNDRV_PCM_RATE_48000,
886 .formats = SNDRV_PCM_FMTBIT_S16_LE,
889 .stream_name = "ssp3 Rx",
890 .channels_min = HDA_STEREO,
891 .channels_max = HDA_STEREO,
892 .rates = SNDRV_PCM_RATE_48000,
893 .formats = SNDRV_PCM_FMTBIT_S16_LE,
898 .ops = &skl_be_ssp_dai_ops,
900 .stream_name = "ssp4 Tx",
901 .channels_min = HDA_STEREO,
902 .channels_max = HDA_STEREO,
903 .rates = SNDRV_PCM_RATE_48000,
904 .formats = SNDRV_PCM_FMTBIT_S16_LE,
907 .stream_name = "ssp4 Rx",
908 .channels_min = HDA_STEREO,
909 .channels_max = HDA_STEREO,
910 .rates = SNDRV_PCM_RATE_48000,
911 .formats = SNDRV_PCM_FMTBIT_S16_LE,
916 .ops = &skl_be_ssp_dai_ops,
918 .stream_name = "ssp5 Tx",
919 .channels_min = HDA_STEREO,
920 .channels_max = HDA_STEREO,
921 .rates = SNDRV_PCM_RATE_48000,
922 .formats = SNDRV_PCM_FMTBIT_S16_LE,
925 .stream_name = "ssp5 Rx",
926 .channels_min = HDA_STEREO,
927 .channels_max = HDA_STEREO,
928 .rates = SNDRV_PCM_RATE_48000,
929 .formats = SNDRV_PCM_FMTBIT_S16_LE,
933 .name = "iDisp1 Pin",
934 .ops = &skl_link_dai_ops,
936 .stream_name = "iDisp1 Tx",
937 .channels_min = HDA_STEREO,
939 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_48000,
940 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
941 SNDRV_PCM_FMTBIT_S24_LE,
945 .name = "iDisp2 Pin",
946 .ops = &skl_link_dai_ops,
948 .stream_name = "iDisp2 Tx",
949 .channels_min = HDA_STEREO,
951 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
952 SNDRV_PCM_RATE_48000,
953 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
954 SNDRV_PCM_FMTBIT_S24_LE,
958 .name = "iDisp3 Pin",
959 .ops = &skl_link_dai_ops,
961 .stream_name = "iDisp3 Tx",
962 .channels_min = HDA_STEREO,
964 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
965 SNDRV_PCM_RATE_48000,
966 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
967 SNDRV_PCM_FMTBIT_S24_LE,
971 .name = "DMIC01 Pin",
972 .ops = &skl_dmic_dai_ops,
974 .stream_name = "DMIC01 Rx",
975 .channels_min = HDA_MONO,
976 .channels_max = HDA_QUAD,
977 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
978 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
982 .name = "DMIC16k Pin",
983 .ops = &skl_dmic_dai_ops,
985 .stream_name = "DMIC16k Rx",
986 .channels_min = HDA_MONO,
987 .channels_max = HDA_QUAD,
988 .rates = SNDRV_PCM_RATE_16000,
989 .formats = SNDRV_PCM_FMTBIT_S16_LE,
993 .name = "Analog CPU DAI",
994 .ops = &skl_link_dai_ops,
996 .stream_name = "Analog CPU Playback",
997 .channels_min = HDA_MONO,
998 .channels_max = HDA_MAX,
999 .rates = SNDRV_PCM_RATE_8000_192000,
1000 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1001 SNDRV_PCM_FMTBIT_S32_LE,
1004 .stream_name = "Analog CPU Capture",
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,
1013 .name = "Alt Analog CPU DAI",
1014 .ops = &skl_link_dai_ops,
1016 .stream_name = "Alt Analog CPU Playback",
1017 .channels_min = HDA_MONO,
1018 .channels_max = HDA_MAX,
1019 .rates = SNDRV_PCM_RATE_8000_192000,
1020 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1021 SNDRV_PCM_FMTBIT_S32_LE,
1024 .stream_name = "Alt Analog CPU Capture",
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,
1033 .name = "Digital CPU DAI",
1034 .ops = &skl_link_dai_ops,
1036 .stream_name = "Digital CPU Playback",
1037 .channels_min = HDA_MONO,
1038 .channels_max = HDA_MAX,
1039 .rates = SNDRV_PCM_RATE_8000_192000,
1040 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1041 SNDRV_PCM_FMTBIT_S32_LE,
1044 .stream_name = "Digital CPU Capture",
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,
1054 int skl_dai_load(struct snd_soc_component *cmp, int index,
1055 struct snd_soc_dai_driver *dai_drv,
1056 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai)
1058 dai_drv->ops = &skl_pcm_dai_ops;
1063 static int skl_platform_soc_open(struct snd_soc_component *component,
1064 struct snd_pcm_substream *substream)
1066 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1067 struct snd_soc_dai_link *dai_link = rtd->dai_link;
1069 dev_dbg(snd_soc_rtd_to_cpu(rtd, 0)->dev, "In %s:%s\n", __func__,
1070 dai_link->cpus->dai_name);
1072 snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
1077 static int skl_coupled_trigger(struct snd_pcm_substream *substream,
1080 struct hdac_bus *bus = get_bus_ctx(substream);
1081 struct hdac_ext_stream *stream;
1082 struct snd_pcm_substream *s;
1085 unsigned long cookie;
1086 struct hdac_stream *hstr;
1088 stream = get_hdac_ext_stream(substream);
1089 hstr = hdac_stream(stream);
1091 dev_dbg(bus->dev, "In %s cmd=%d\n", __func__, cmd);
1093 if (!hstr->prepared)
1097 case SNDRV_PCM_TRIGGER_START:
1098 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1099 case SNDRV_PCM_TRIGGER_RESUME:
1103 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1104 case SNDRV_PCM_TRIGGER_SUSPEND:
1105 case SNDRV_PCM_TRIGGER_STOP:
1113 snd_pcm_group_for_each_entry(s, substream) {
1114 if (s->pcm->card != substream->pcm->card)
1116 stream = get_hdac_ext_stream(s);
1117 sbits |= 1 << hdac_stream(stream)->index;
1118 snd_pcm_trigger_done(s, substream);
1121 spin_lock_irqsave(&bus->reg_lock, cookie);
1123 /* first, set SYNC bits of corresponding streams */
1124 snd_hdac_stream_sync_trigger(hstr, true, sbits, AZX_REG_SSYNC);
1126 snd_pcm_group_for_each_entry(s, substream) {
1127 if (s->pcm->card != substream->pcm->card)
1129 stream = get_hdac_ext_stream(s);
1131 snd_hdac_stream_start(hdac_stream(stream));
1133 snd_hdac_stream_stop(hdac_stream(stream));
1135 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1137 snd_hdac_stream_sync(hstr, start, sbits);
1139 spin_lock_irqsave(&bus->reg_lock, cookie);
1141 /* reset SYNC bits */
1142 snd_hdac_stream_sync_trigger(hstr, false, sbits, AZX_REG_SSYNC);
1144 snd_hdac_stream_timecounter_init(hstr, sbits);
1145 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1150 static int skl_platform_soc_trigger(struct snd_soc_component *component,
1151 struct snd_pcm_substream *substream,
1154 struct hdac_bus *bus = get_bus_ctx(substream);
1157 return skl_coupled_trigger(substream, cmd);
1162 static snd_pcm_uframes_t skl_platform_soc_pointer(
1163 struct snd_soc_component *component,
1164 struct snd_pcm_substream *substream)
1166 struct hdac_ext_stream *hstream = get_hdac_ext_stream(substream);
1167 struct hdac_bus *bus = get_bus_ctx(substream);
1171 * Use DPIB for Playback stream as the periodic DMA Position-in-
1172 * Buffer Writes may be scheduled at the same time or later than
1173 * the MSI and does not guarantee to reflect the Position of the
1174 * last buffer that was transferred. Whereas DPIB register in
1175 * HAD space reflects the actual data that is transferred.
1176 * Use the position buffer for capture, as DPIB write gets
1177 * completed earlier than the actual data written to the DDR.
1179 * For capture stream following workaround is required to fix the
1180 * incorrect position reporting.
1182 * 1. Wait for 20us before reading the DMA position in buffer once
1183 * the interrupt is generated for stream completion as update happens
1184 * on the HDA frame boundary i.e. 20.833uSec.
1185 * 2. Read DPIB register to flush the DMA position value. This dummy
1186 * read is required to flush DMA position value.
1187 * 3. Read the DMA Position-in-Buffer. This value now will be equal to
1188 * or greater than period boundary.
1191 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1192 pos = readl(bus->remap_addr + AZX_REG_VS_SDXDPIB_XBASE +
1193 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1194 hdac_stream(hstream)->index));
1197 readl(bus->remap_addr +
1198 AZX_REG_VS_SDXDPIB_XBASE +
1199 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1200 hdac_stream(hstream)->index));
1201 pos = snd_hdac_stream_get_pos_posbuf(hdac_stream(hstream));
1204 if (pos >= hdac_stream(hstream)->bufsize)
1207 return bytes_to_frames(substream->runtime, pos);
1210 static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
1213 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1214 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
1215 u64 codec_frames, codec_nsecs;
1217 if (!codec_dai->driver->ops->delay)
1220 codec_frames = codec_dai->driver->ops->delay(substream, codec_dai);
1221 codec_nsecs = div_u64(codec_frames * 1000000000LL,
1222 substream->runtime->rate);
1224 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1225 return nsec + codec_nsecs;
1227 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
1230 static int skl_platform_soc_get_time_info(
1231 struct snd_soc_component *component,
1232 struct snd_pcm_substream *substream,
1233 struct timespec64 *system_ts, struct timespec64 *audio_ts,
1234 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
1235 struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
1237 struct hdac_ext_stream *sstream = get_hdac_ext_stream(substream);
1238 struct hdac_stream *hstr = hdac_stream(sstream);
1241 if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
1242 (audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
1244 snd_pcm_gettime(substream->runtime, system_ts);
1246 nsec = timecounter_read(&hstr->tc);
1247 if (audio_tstamp_config->report_delay)
1248 nsec = skl_adjust_codec_delay(substream, nsec);
1250 *audio_ts = ns_to_timespec64(nsec);
1252 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
1253 audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
1254 audio_tstamp_report->accuracy = 42; /* 24MHzWallClk == 42ns resolution */
1257 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
1263 #define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
1265 static int skl_platform_soc_new(struct snd_soc_component *component,
1266 struct snd_soc_pcm_runtime *rtd)
1268 struct snd_soc_dai *dai = snd_soc_rtd_to_cpu(rtd, 0);
1269 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1270 struct snd_pcm *pcm = rtd->pcm;
1272 struct skl_dev *skl = bus_to_skl(bus);
1274 if (dai->driver->playback.channels_min ||
1275 dai->driver->capture.channels_min) {
1276 /* buffer pre-allocation */
1277 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1278 if (size > MAX_PREALLOC_SIZE)
1279 size = MAX_PREALLOC_SIZE;
1280 snd_pcm_set_managed_buffer_all(pcm,
1281 SNDRV_DMA_TYPE_DEV_SG,
1283 size, MAX_PREALLOC_SIZE);
1289 static int skl_get_module_info(struct skl_dev *skl,
1290 struct skl_module_cfg *mconfig)
1292 struct skl_module_inst_id *pin_id;
1293 guid_t *uuid_mod, *uuid_tplg;
1294 struct skl_module *skl_module;
1295 struct uuid_module *module;
1298 uuid_mod = (guid_t *)mconfig->guid;
1300 if (list_empty(&skl->uuid_list)) {
1301 dev_err(skl->dev, "Module list is empty\n");
1305 for (i = 0; i < skl->nr_modules; i++) {
1306 skl_module = skl->modules[i];
1307 uuid_tplg = &skl_module->uuid;
1308 if (guid_equal(uuid_mod, uuid_tplg)) {
1309 mconfig->module = skl_module;
1315 if (skl->nr_modules && ret)
1319 list_for_each_entry(module, &skl->uuid_list, list) {
1320 if (guid_equal(uuid_mod, &module->uuid)) {
1321 mconfig->id.module_id = module->id;
1322 mconfig->module->loadable = module->is_loadable;
1326 for (i = 0; i < MAX_IN_QUEUE; i++) {
1327 pin_id = &mconfig->m_in_pin[i].id;
1328 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1329 pin_id->module_id = module->id;
1332 for (i = 0; i < MAX_OUT_QUEUE; i++) {
1333 pin_id = &mconfig->m_out_pin[i].id;
1334 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1335 pin_id->module_id = module->id;
1342 static int skl_populate_modules(struct skl_dev *skl)
1344 struct skl_pipeline *p;
1345 struct skl_pipe_module *m;
1346 struct snd_soc_dapm_widget *w;
1347 struct skl_module_cfg *mconfig;
1350 list_for_each_entry(p, &skl->ppl_list, node) {
1351 list_for_each_entry(m, &p->pipe->w_list, node) {
1355 ret = skl_get_module_info(skl, mconfig);
1358 "query module info failed\n");
1362 skl_tplg_add_moduleid_in_bind_params(skl, w);
1369 static int skl_platform_soc_probe(struct snd_soc_component *component)
1371 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1372 struct skl_dev *skl = bus_to_skl(bus);
1373 const struct skl_dsp_ops *ops;
1376 ret = pm_runtime_resume_and_get(component->dev);
1377 if (ret < 0 && ret != -EACCES)
1381 skl->component = component;
1384 skl->debugfs = skl_debugfs_init(skl);
1386 ret = skl_tplg_init(component, bus);
1388 dev_err(component->dev, "Failed to init topology!\n");
1392 /* load the firmwares, since all is set */
1393 ops = skl_get_dsp_ops(skl->pci->device);
1398 * Disable dynamic clock and power gating during firmware
1399 * and library download
1401 skl->enable_miscbdcge(component->dev, false);
1402 skl->clock_power_gating(component->dev, false);
1404 ret = ops->init_fw(component->dev, skl);
1405 skl->enable_miscbdcge(component->dev, true);
1406 skl->clock_power_gating(component->dev, true);
1408 dev_err(component->dev, "Failed to boot first fw: %d\n", ret);
1411 skl_populate_modules(skl);
1412 skl->update_d0i3c = skl_update_d0i3c;
1414 if (skl->cfg.astate_cfg != NULL) {
1415 skl_dsp_set_astate_cfg(skl,
1416 skl->cfg.astate_cfg->count,
1417 skl->cfg.astate_cfg);
1420 pm_runtime_mark_last_busy(component->dev);
1421 pm_runtime_put_autosuspend(component->dev);
1426 static void skl_platform_soc_remove(struct snd_soc_component *component)
1428 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1429 struct skl_dev *skl = bus_to_skl(bus);
1431 skl_tplg_exit(component, bus);
1433 skl_debugfs_exit(skl);
1436 static const struct snd_soc_component_driver skl_component = {
1438 .probe = skl_platform_soc_probe,
1439 .remove = skl_platform_soc_remove,
1440 .open = skl_platform_soc_open,
1441 .trigger = skl_platform_soc_trigger,
1442 .pointer = skl_platform_soc_pointer,
1443 .get_time_info = skl_platform_soc_get_time_info,
1444 .pcm_construct = skl_platform_soc_new,
1445 .module_get_upon_open = 1, /* increment refcount when a pcm is opened */
1448 int skl_platform_register(struct device *dev)
1451 struct snd_soc_dai_driver *dais;
1452 int num_dais = ARRAY_SIZE(skl_platform_dai);
1453 struct hdac_bus *bus = dev_get_drvdata(dev);
1454 struct skl_dev *skl = bus_to_skl(bus);
1456 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
1463 if (!skl->use_tplg_pcm) {
1464 dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
1465 sizeof(skl_platform_dai), GFP_KERNEL);
1473 memcpy(&skl->dais[ARRAY_SIZE(skl_platform_dai)], skl_fe_dai,
1474 sizeof(skl_fe_dai));
1475 num_dais += ARRAY_SIZE(skl_fe_dai);
1478 ret = devm_snd_soc_register_component(dev, &skl_component,
1479 skl->dais, num_dais);
1482 dev_err(dev, "soc component registration failed %d\n", ret);
1488 int skl_platform_unregister(struct device *dev)
1490 struct hdac_bus *bus = dev_get_drvdata(dev);
1491 struct skl_dev *skl = bus_to_skl(bus);
1492 struct skl_module_deferred_bind *modules, *tmp;
1494 list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
1495 list_del(&modules->node);