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;
133 hstream = snd_hdac_get_stream(bus, params->stream,
134 params->host_dma_id + 1);
138 stream = stream_to_hdac_ext_stream(hstream);
139 snd_hdac_ext_stream_decouple(bus, stream, true);
141 bits = snd_hdac_stream_format_bits(params->format, SNDRV_PCM_SUBFORMAT_STD,
143 format_val = snd_hdac_stream_format(params->ch, bits, params->s_freq);
145 dev_dbg(dev, "format_val=%d, rate=%d, ch=%d, format=%d\n",
146 format_val, params->s_freq, params->ch, params->format);
148 snd_hdac_stream_reset(hdac_stream(stream));
149 err = snd_hdac_stream_set_params(hdac_stream(stream), format_val);
153 err = snd_hdac_ext_host_stream_setup(stream, false);
157 hdac_stream(stream)->prepared = 1;
162 int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
164 struct hdac_bus *bus = dev_get_drvdata(dev);
165 unsigned int format_val;
166 struct hdac_stream *hstream;
167 struct hdac_ext_stream *stream;
168 struct hdac_ext_link *link;
169 unsigned char stream_tag;
172 hstream = snd_hdac_get_stream(bus, params->stream,
173 params->link_dma_id + 1);
177 stream = stream_to_hdac_ext_stream(hstream);
178 snd_hdac_ext_stream_decouple(bus, stream, true);
180 bits = snd_hdac_stream_format_bits(params->format, SNDRV_PCM_SUBFORMAT_STD,
182 format_val = snd_hdac_stream_format(params->ch, bits, params->s_freq);
184 dev_dbg(dev, "format_val=%d, rate=%d, ch=%d, format=%d\n",
185 format_val, params->s_freq, params->ch, params->format);
187 snd_hdac_ext_stream_reset(stream);
189 snd_hdac_ext_stream_setup(stream, format_val);
191 stream_tag = hstream->stream_tag;
192 if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
193 list_for_each_entry(link, &bus->hlink_list, list) {
194 if (link->index == params->link_index)
195 snd_hdac_ext_bus_link_set_stream_id(link,
200 stream->link_prepared = 1;
205 static int skl_pcm_open(struct snd_pcm_substream *substream,
206 struct snd_soc_dai *dai)
208 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
209 struct hdac_ext_stream *stream;
210 struct snd_pcm_runtime *runtime = substream->runtime;
211 struct skl_dma_params *dma_params;
212 struct skl_dev *skl = get_skl_ctx(dai->dev);
213 struct skl_module_cfg *mconfig;
215 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
217 stream = snd_hdac_ext_stream_assign(bus, substream,
218 skl_get_host_stream_type(bus));
222 skl_set_pcm_constrains(bus, runtime);
225 * disable WALLCLOCK timestamps for capture streams
226 * until we figure out how to handle digital inputs
228 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
229 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; /* legacy */
230 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME;
233 runtime->private_data = stream;
235 dma_params = kzalloc(sizeof(*dma_params), GFP_KERNEL);
239 dma_params->stream_tag = hdac_stream(stream)->stream_tag;
240 snd_soc_dai_set_dma_data(dai, substream, dma_params);
242 dev_dbg(dai->dev, "stream tag set in dma params=%d\n",
243 dma_params->stream_tag);
244 skl_set_suspend_active(substream, dai, true);
245 snd_pcm_set_sync(substream);
247 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
253 skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
258 static int skl_pcm_prepare(struct snd_pcm_substream *substream,
259 struct snd_soc_dai *dai)
261 struct skl_dev *skl = get_skl_ctx(dai->dev);
262 struct skl_module_cfg *mconfig;
265 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
267 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
270 * In case of XRUN recovery or in the case when the application
271 * calls prepare another time, reset the FW pipe to clean state
274 (substream->runtime->state == SNDRV_PCM_STATE_XRUN ||
275 mconfig->pipe->state == SKL_PIPE_CREATED ||
276 mconfig->pipe->state == SKL_PIPE_PAUSED)) {
278 ret = skl_reset_pipe(skl, mconfig->pipe);
283 ret = skl_pcm_host_dma_prepare(dai->dev,
284 mconfig->pipe->p_params);
292 static int skl_pcm_hw_params(struct snd_pcm_substream *substream,
293 struct snd_pcm_hw_params *params,
294 struct snd_soc_dai *dai)
296 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
297 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
298 struct snd_pcm_runtime *runtime = substream->runtime;
299 struct skl_pipe_params p_params = {0};
300 struct skl_module_cfg *m_cfg;
303 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
304 ret = skl_substream_alloc_pages(bus, substream,
305 params_buffer_bytes(params));
309 dev_dbg(dai->dev, "format_val, rate=%d, ch=%d, format=%d\n",
310 runtime->rate, runtime->channels, runtime->format);
312 dma_id = hdac_stream(stream)->stream_tag - 1;
313 dev_dbg(dai->dev, "dma_id=%d\n", dma_id);
315 p_params.s_fmt = snd_pcm_format_width(params_format(params));
316 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
317 p_params.ch = params_channels(params);
318 p_params.s_freq = params_rate(params);
319 p_params.host_dma_id = dma_id;
320 p_params.stream = substream->stream;
321 p_params.format = params_format(params);
322 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
323 p_params.host_bps = dai->driver->playback.sig_bits;
325 p_params.host_bps = dai->driver->capture.sig_bits;
328 m_cfg = skl_tplg_fe_get_cpr_module(dai, p_params.stream);
330 skl_tplg_update_pipe_params(dai->dev, m_cfg, &p_params);
335 static void skl_pcm_close(struct snd_pcm_substream *substream,
336 struct snd_soc_dai *dai)
338 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
339 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
340 struct skl_dma_params *dma_params = NULL;
341 struct skl_dev *skl = bus_to_skl(bus);
342 struct skl_module_cfg *mconfig;
344 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
346 snd_hdac_ext_stream_release(stream, skl_get_host_stream_type(bus));
348 dma_params = snd_soc_dai_get_dma_data(dai, substream);
350 * now we should set this to NULL as we are freeing by the
353 snd_soc_dai_set_dma_data(dai, substream, NULL);
354 skl_set_suspend_active(substream, dai, false);
357 * check if close is for "Reference Pin" and set back the
358 * CGCTL.MISCBDCGE if disabled by driver
360 if (!strncmp(dai->name, "Reference Pin", 13) &&
361 skl->miscbdcg_disabled) {
362 skl->enable_miscbdcge(dai->dev, true);
363 skl->miscbdcg_disabled = false;
366 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
368 skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
373 static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
374 struct snd_soc_dai *dai)
376 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
377 struct skl_dev *skl = get_skl_ctx(dai->dev);
378 struct skl_module_cfg *mconfig;
381 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
383 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
386 ret = skl_reset_pipe(skl, mconfig->pipe);
388 dev_err(dai->dev, "%s:Reset failed ret =%d",
392 snd_hdac_stream_cleanup(hdac_stream(stream));
393 hdac_stream(stream)->prepared = 0;
398 static int skl_be_hw_params(struct snd_pcm_substream *substream,
399 struct snd_pcm_hw_params *params,
400 struct snd_soc_dai *dai)
402 struct skl_pipe_params p_params = {0};
404 p_params.s_fmt = snd_pcm_format_width(params_format(params));
405 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
406 p_params.ch = params_channels(params);
407 p_params.s_freq = params_rate(params);
408 p_params.stream = substream->stream;
410 return skl_tplg_be_update_params(dai, &p_params);
413 static int skl_decoupled_trigger(struct snd_pcm_substream *substream,
416 struct hdac_bus *bus = get_bus_ctx(substream);
417 struct hdac_ext_stream *stream;
419 unsigned long cookie;
420 struct hdac_stream *hstr;
422 stream = get_hdac_ext_stream(substream);
423 hstr = hdac_stream(stream);
429 case SNDRV_PCM_TRIGGER_START:
430 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
431 case SNDRV_PCM_TRIGGER_RESUME:
435 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
436 case SNDRV_PCM_TRIGGER_SUSPEND:
437 case SNDRV_PCM_TRIGGER_STOP:
445 spin_lock_irqsave(&bus->reg_lock, cookie);
448 snd_hdac_stream_start(hdac_stream(stream));
449 snd_hdac_stream_timecounter_init(hstr, 0);
451 snd_hdac_stream_stop(hdac_stream(stream));
454 spin_unlock_irqrestore(&bus->reg_lock, cookie);
459 static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
460 struct snd_soc_dai *dai)
462 struct skl_dev *skl = get_skl_ctx(dai->dev);
463 struct skl_module_cfg *mconfig;
464 struct hdac_bus *bus = get_bus_ctx(substream);
465 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
466 struct hdac_stream *hstream = hdac_stream(stream);
467 struct snd_soc_dapm_widget *w;
470 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
474 w = snd_soc_dai_get_widget(dai, substream->stream);
477 case SNDRV_PCM_TRIGGER_RESUME:
478 if (!w->ignore_suspend) {
480 * enable DMA Resume enable bit for the stream, set the
481 * dpib & lpib position to resume before starting the
484 snd_hdac_stream_drsm_enable(bus, true, hstream->index);
485 snd_hdac_stream_set_dpibr(bus, hstream, hstream->lpib);
486 snd_hdac_stream_set_lpib(hstream, hstream->lpib);
490 case SNDRV_PCM_TRIGGER_START:
491 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
493 * Start HOST DMA and Start FE Pipe.This is to make sure that
494 * there are no underrun/overrun in the case when the FE
495 * pipeline is started but there is a delay in starting the
496 * DMA channel on the host.
498 ret = skl_decoupled_trigger(substream, cmd);
501 return skl_run_pipe(skl, mconfig->pipe);
503 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
504 case SNDRV_PCM_TRIGGER_SUSPEND:
505 case SNDRV_PCM_TRIGGER_STOP:
507 * Stop FE Pipe first and stop DMA. This is to make sure that
508 * there are no underrun/overrun in the case if there is a delay
509 * between the two operations.
511 ret = skl_stop_pipe(skl, mconfig->pipe);
515 ret = skl_decoupled_trigger(substream, cmd);
519 if ((cmd == SNDRV_PCM_TRIGGER_SUSPEND) && !w->ignore_suspend) {
520 /* save the dpib and lpib positions */
521 hstream->dpib = readl(bus->remap_addr +
522 AZX_REG_VS_SDXDPIB_XBASE +
523 (AZX_REG_VS_SDXDPIB_XINTERVAL *
526 hstream->lpib = snd_hdac_stream_get_pos_lpib(hstream);
528 snd_hdac_ext_stream_decouple(bus, stream, false);
540 static int skl_link_hw_params(struct snd_pcm_substream *substream,
541 struct snd_pcm_hw_params *params,
542 struct snd_soc_dai *dai)
544 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
545 struct hdac_ext_stream *link_dev;
546 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
547 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
548 struct skl_pipe_params p_params = {0};
549 struct hdac_ext_link *link;
552 link_dev = snd_hdac_ext_stream_assign(bus, substream,
553 HDAC_EXT_STREAM_TYPE_LINK);
557 snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);
559 link = snd_hdac_ext_bus_get_hlink_by_name(bus, codec_dai->component->name);
563 stream_tag = hdac_stream(link_dev)->stream_tag;
565 /* set the hdac_stream in the codec dai */
566 snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream);
568 p_params.s_fmt = snd_pcm_format_width(params_format(params));
569 p_params.s_cont = snd_pcm_format_physical_width(params_format(params));
570 p_params.ch = params_channels(params);
571 p_params.s_freq = params_rate(params);
572 p_params.stream = substream->stream;
573 p_params.link_dma_id = stream_tag - 1;
574 p_params.link_index = link->index;
575 p_params.format = params_format(params);
577 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
578 p_params.link_bps = codec_dai->driver->playback.sig_bits;
580 p_params.link_bps = codec_dai->driver->capture.sig_bits;
582 return skl_tplg_be_update_params(dai, &p_params);
585 static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,
586 struct snd_soc_dai *dai)
588 struct skl_dev *skl = get_skl_ctx(dai->dev);
589 struct skl_module_cfg *mconfig = NULL;
591 /* In case of XRUN recovery, reset the FW pipe to clean state */
592 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream);
593 if (mconfig && !mconfig->pipe->passthru &&
594 (substream->runtime->state == SNDRV_PCM_STATE_XRUN))
595 skl_reset_pipe(skl, mconfig->pipe);
600 static int skl_link_pcm_trigger(struct snd_pcm_substream *substream,
601 int cmd, struct snd_soc_dai *dai)
603 struct hdac_ext_stream *link_dev =
604 snd_soc_dai_get_dma_data(dai, substream);
605 struct hdac_bus *bus = get_bus_ctx(substream);
606 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
608 dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd);
610 case SNDRV_PCM_TRIGGER_RESUME:
611 case SNDRV_PCM_TRIGGER_START:
612 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
613 snd_hdac_ext_stream_start(link_dev);
616 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
617 case SNDRV_PCM_TRIGGER_SUSPEND:
618 case SNDRV_PCM_TRIGGER_STOP:
619 snd_hdac_ext_stream_clear(link_dev);
620 if (cmd == SNDRV_PCM_TRIGGER_SUSPEND)
621 snd_hdac_ext_stream_decouple(bus, stream, false);
630 static int skl_link_hw_free(struct snd_pcm_substream *substream,
631 struct snd_soc_dai *dai)
633 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
634 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
635 struct hdac_ext_stream *link_dev =
636 snd_soc_dai_get_dma_data(dai, substream);
637 struct hdac_ext_link *link;
638 unsigned char stream_tag;
640 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
642 link_dev->link_prepared = 0;
644 link = snd_hdac_ext_bus_get_hlink_by_name(bus, snd_soc_rtd_to_codec(rtd, 0)->component->name);
648 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
649 stream_tag = hdac_stream(link_dev)->stream_tag;
650 snd_hdac_ext_bus_link_clear_stream_id(link, stream_tag);
653 snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
657 static const struct snd_soc_dai_ops skl_pcm_dai_ops = {
658 .startup = skl_pcm_open,
659 .shutdown = skl_pcm_close,
660 .prepare = skl_pcm_prepare,
661 .hw_params = skl_pcm_hw_params,
662 .hw_free = skl_pcm_hw_free,
663 .trigger = skl_pcm_trigger,
666 static const struct snd_soc_dai_ops skl_dmic_dai_ops = {
667 .hw_params = skl_be_hw_params,
670 static const struct snd_soc_dai_ops skl_be_ssp_dai_ops = {
671 .hw_params = skl_be_hw_params,
674 static const struct snd_soc_dai_ops skl_link_dai_ops = {
675 .prepare = skl_link_pcm_prepare,
676 .hw_params = skl_link_hw_params,
677 .hw_free = skl_link_hw_free,
678 .trigger = skl_link_pcm_trigger,
681 static struct snd_soc_dai_driver skl_fe_dai[] = {
683 .name = "System Pin",
684 .ops = &skl_pcm_dai_ops,
686 .stream_name = "System Playback",
687 .channels_min = HDA_MONO,
688 .channels_max = HDA_STEREO,
689 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_8000,
690 .formats = SNDRV_PCM_FMTBIT_S16_LE |
691 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
695 .stream_name = "System Capture",
696 .channels_min = HDA_MONO,
697 .channels_max = HDA_STEREO,
698 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
699 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
704 .name = "System Pin2",
705 .ops = &skl_pcm_dai_ops,
707 .stream_name = "Headset Playback",
708 .channels_min = HDA_MONO,
709 .channels_max = HDA_STEREO,
710 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
712 .formats = SNDRV_PCM_FMTBIT_S16_LE |
713 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
717 .name = "Echoref Pin",
718 .ops = &skl_pcm_dai_ops,
720 .stream_name = "Echoreference Capture",
721 .channels_min = HDA_STEREO,
722 .channels_max = HDA_STEREO,
723 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 |
725 .formats = SNDRV_PCM_FMTBIT_S16_LE |
726 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
730 .name = "Reference Pin",
731 .ops = &skl_pcm_dai_ops,
733 .stream_name = "Reference Capture",
734 .channels_min = HDA_MONO,
735 .channels_max = HDA_QUAD,
736 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
737 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
742 .name = "Deepbuffer Pin",
743 .ops = &skl_pcm_dai_ops,
745 .stream_name = "Deepbuffer Playback",
746 .channels_min = HDA_STEREO,
747 .channels_max = HDA_STEREO,
748 .rates = SNDRV_PCM_RATE_48000,
749 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
754 .name = "LowLatency Pin",
755 .ops = &skl_pcm_dai_ops,
757 .stream_name = "Low Latency Playback",
758 .channels_min = HDA_STEREO,
759 .channels_max = HDA_STEREO,
760 .rates = SNDRV_PCM_RATE_48000,
761 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
767 .ops = &skl_pcm_dai_ops,
769 .stream_name = "DMIC Capture",
770 .channels_min = HDA_MONO,
771 .channels_max = HDA_QUAD,
772 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
773 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
779 .ops = &skl_pcm_dai_ops,
781 .stream_name = "HDMI1 Playback",
782 .channels_min = HDA_STEREO,
784 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
785 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
786 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
787 SNDRV_PCM_RATE_192000,
788 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
789 SNDRV_PCM_FMTBIT_S32_LE,
795 .ops = &skl_pcm_dai_ops,
797 .stream_name = "HDMI2 Playback",
798 .channels_min = HDA_STEREO,
800 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
801 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
802 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
803 SNDRV_PCM_RATE_192000,
804 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
805 SNDRV_PCM_FMTBIT_S32_LE,
811 .ops = &skl_pcm_dai_ops,
813 .stream_name = "HDMI3 Playback",
814 .channels_min = HDA_STEREO,
816 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
817 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
818 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
819 SNDRV_PCM_RATE_192000,
820 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
821 SNDRV_PCM_FMTBIT_S32_LE,
828 static struct snd_soc_dai_driver skl_platform_dai[] = {
831 .ops = &skl_be_ssp_dai_ops,
833 .stream_name = "ssp0 Tx",
834 .channels_min = HDA_STEREO,
835 .channels_max = HDA_STEREO,
836 .rates = SNDRV_PCM_RATE_48000,
837 .formats = SNDRV_PCM_FMTBIT_S16_LE,
840 .stream_name = "ssp0 Rx",
841 .channels_min = HDA_STEREO,
842 .channels_max = HDA_STEREO,
843 .rates = SNDRV_PCM_RATE_48000,
844 .formats = SNDRV_PCM_FMTBIT_S16_LE,
849 .ops = &skl_be_ssp_dai_ops,
851 .stream_name = "ssp1 Tx",
852 .channels_min = HDA_STEREO,
853 .channels_max = HDA_STEREO,
854 .rates = SNDRV_PCM_RATE_48000,
855 .formats = SNDRV_PCM_FMTBIT_S16_LE,
858 .stream_name = "ssp1 Rx",
859 .channels_min = HDA_STEREO,
860 .channels_max = HDA_STEREO,
861 .rates = SNDRV_PCM_RATE_48000,
862 .formats = SNDRV_PCM_FMTBIT_S16_LE,
867 .ops = &skl_be_ssp_dai_ops,
869 .stream_name = "ssp2 Tx",
870 .channels_min = HDA_STEREO,
871 .channels_max = HDA_STEREO,
872 .rates = SNDRV_PCM_RATE_48000,
873 .formats = SNDRV_PCM_FMTBIT_S16_LE,
876 .stream_name = "ssp2 Rx",
877 .channels_min = HDA_STEREO,
878 .channels_max = HDA_STEREO,
879 .rates = SNDRV_PCM_RATE_48000,
880 .formats = SNDRV_PCM_FMTBIT_S16_LE,
885 .ops = &skl_be_ssp_dai_ops,
887 .stream_name = "ssp3 Tx",
888 .channels_min = HDA_STEREO,
889 .channels_max = HDA_STEREO,
890 .rates = SNDRV_PCM_RATE_48000,
891 .formats = SNDRV_PCM_FMTBIT_S16_LE,
894 .stream_name = "ssp3 Rx",
895 .channels_min = HDA_STEREO,
896 .channels_max = HDA_STEREO,
897 .rates = SNDRV_PCM_RATE_48000,
898 .formats = SNDRV_PCM_FMTBIT_S16_LE,
903 .ops = &skl_be_ssp_dai_ops,
905 .stream_name = "ssp4 Tx",
906 .channels_min = HDA_STEREO,
907 .channels_max = HDA_STEREO,
908 .rates = SNDRV_PCM_RATE_48000,
909 .formats = SNDRV_PCM_FMTBIT_S16_LE,
912 .stream_name = "ssp4 Rx",
913 .channels_min = HDA_STEREO,
914 .channels_max = HDA_STEREO,
915 .rates = SNDRV_PCM_RATE_48000,
916 .formats = SNDRV_PCM_FMTBIT_S16_LE,
921 .ops = &skl_be_ssp_dai_ops,
923 .stream_name = "ssp5 Tx",
924 .channels_min = HDA_STEREO,
925 .channels_max = HDA_STEREO,
926 .rates = SNDRV_PCM_RATE_48000,
927 .formats = SNDRV_PCM_FMTBIT_S16_LE,
930 .stream_name = "ssp5 Rx",
931 .channels_min = HDA_STEREO,
932 .channels_max = HDA_STEREO,
933 .rates = SNDRV_PCM_RATE_48000,
934 .formats = SNDRV_PCM_FMTBIT_S16_LE,
938 .name = "iDisp1 Pin",
939 .ops = &skl_link_dai_ops,
941 .stream_name = "iDisp1 Tx",
942 .channels_min = HDA_STEREO,
944 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_48000,
945 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
946 SNDRV_PCM_FMTBIT_S24_LE,
950 .name = "iDisp2 Pin",
951 .ops = &skl_link_dai_ops,
953 .stream_name = "iDisp2 Tx",
954 .channels_min = HDA_STEREO,
956 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
957 SNDRV_PCM_RATE_48000,
958 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
959 SNDRV_PCM_FMTBIT_S24_LE,
963 .name = "iDisp3 Pin",
964 .ops = &skl_link_dai_ops,
966 .stream_name = "iDisp3 Tx",
967 .channels_min = HDA_STEREO,
969 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|
970 SNDRV_PCM_RATE_48000,
971 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE |
972 SNDRV_PCM_FMTBIT_S24_LE,
976 .name = "DMIC01 Pin",
977 .ops = &skl_dmic_dai_ops,
979 .stream_name = "DMIC01 Rx",
980 .channels_min = HDA_MONO,
981 .channels_max = HDA_QUAD,
982 .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000,
983 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
987 .name = "DMIC16k Pin",
988 .ops = &skl_dmic_dai_ops,
990 .stream_name = "DMIC16k Rx",
991 .channels_min = HDA_MONO,
992 .channels_max = HDA_QUAD,
993 .rates = SNDRV_PCM_RATE_16000,
994 .formats = SNDRV_PCM_FMTBIT_S16_LE,
998 .name = "Analog CPU DAI",
999 .ops = &skl_link_dai_ops,
1001 .stream_name = "Analog CPU Playback",
1002 .channels_min = HDA_MONO,
1003 .channels_max = HDA_MAX,
1004 .rates = SNDRV_PCM_RATE_8000_192000,
1005 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1006 SNDRV_PCM_FMTBIT_S32_LE,
1009 .stream_name = "Analog CPU Capture",
1010 .channels_min = HDA_MONO,
1011 .channels_max = HDA_MAX,
1012 .rates = SNDRV_PCM_RATE_8000_192000,
1013 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1014 SNDRV_PCM_FMTBIT_S32_LE,
1018 .name = "Alt Analog CPU DAI",
1019 .ops = &skl_link_dai_ops,
1021 .stream_name = "Alt Analog CPU Playback",
1022 .channels_min = HDA_MONO,
1023 .channels_max = HDA_MAX,
1024 .rates = SNDRV_PCM_RATE_8000_192000,
1025 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1026 SNDRV_PCM_FMTBIT_S32_LE,
1029 .stream_name = "Alt Analog CPU Capture",
1030 .channels_min = HDA_MONO,
1031 .channels_max = HDA_MAX,
1032 .rates = SNDRV_PCM_RATE_8000_192000,
1033 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1034 SNDRV_PCM_FMTBIT_S32_LE,
1038 .name = "Digital CPU DAI",
1039 .ops = &skl_link_dai_ops,
1041 .stream_name = "Digital CPU Playback",
1042 .channels_min = HDA_MONO,
1043 .channels_max = HDA_MAX,
1044 .rates = SNDRV_PCM_RATE_8000_192000,
1045 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1046 SNDRV_PCM_FMTBIT_S32_LE,
1049 .stream_name = "Digital CPU Capture",
1050 .channels_min = HDA_MONO,
1051 .channels_max = HDA_MAX,
1052 .rates = SNDRV_PCM_RATE_8000_192000,
1053 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1054 SNDRV_PCM_FMTBIT_S32_LE,
1059 int skl_dai_load(struct snd_soc_component *cmp, int index,
1060 struct snd_soc_dai_driver *dai_drv,
1061 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai)
1063 dai_drv->ops = &skl_pcm_dai_ops;
1068 static int skl_platform_soc_open(struct snd_soc_component *component,
1069 struct snd_pcm_substream *substream)
1071 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1072 struct snd_soc_dai_link *dai_link = rtd->dai_link;
1074 dev_dbg(snd_soc_rtd_to_cpu(rtd, 0)->dev, "In %s:%s\n", __func__,
1075 dai_link->cpus->dai_name);
1077 snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
1082 static int skl_coupled_trigger(struct snd_pcm_substream *substream,
1085 struct hdac_bus *bus = get_bus_ctx(substream);
1086 struct hdac_ext_stream *stream;
1087 struct snd_pcm_substream *s;
1090 unsigned long cookie;
1091 struct hdac_stream *hstr;
1093 stream = get_hdac_ext_stream(substream);
1094 hstr = hdac_stream(stream);
1096 dev_dbg(bus->dev, "In %s cmd=%d\n", __func__, cmd);
1098 if (!hstr->prepared)
1102 case SNDRV_PCM_TRIGGER_START:
1103 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1104 case SNDRV_PCM_TRIGGER_RESUME:
1108 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1109 case SNDRV_PCM_TRIGGER_SUSPEND:
1110 case SNDRV_PCM_TRIGGER_STOP:
1118 snd_pcm_group_for_each_entry(s, substream) {
1119 if (s->pcm->card != substream->pcm->card)
1121 stream = get_hdac_ext_stream(s);
1122 sbits |= 1 << hdac_stream(stream)->index;
1123 snd_pcm_trigger_done(s, substream);
1126 spin_lock_irqsave(&bus->reg_lock, cookie);
1128 /* first, set SYNC bits of corresponding streams */
1129 snd_hdac_stream_sync_trigger(hstr, true, sbits, AZX_REG_SSYNC);
1131 snd_pcm_group_for_each_entry(s, substream) {
1132 if (s->pcm->card != substream->pcm->card)
1134 stream = get_hdac_ext_stream(s);
1136 snd_hdac_stream_start(hdac_stream(stream));
1138 snd_hdac_stream_stop(hdac_stream(stream));
1140 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1142 snd_hdac_stream_sync(hstr, start, sbits);
1144 spin_lock_irqsave(&bus->reg_lock, cookie);
1146 /* reset SYNC bits */
1147 snd_hdac_stream_sync_trigger(hstr, false, sbits, AZX_REG_SSYNC);
1149 snd_hdac_stream_timecounter_init(hstr, sbits);
1150 spin_unlock_irqrestore(&bus->reg_lock, cookie);
1155 static int skl_platform_soc_trigger(struct snd_soc_component *component,
1156 struct snd_pcm_substream *substream,
1159 struct hdac_bus *bus = get_bus_ctx(substream);
1162 return skl_coupled_trigger(substream, cmd);
1167 static snd_pcm_uframes_t skl_platform_soc_pointer(
1168 struct snd_soc_component *component,
1169 struct snd_pcm_substream *substream)
1171 struct hdac_ext_stream *hstream = get_hdac_ext_stream(substream);
1172 struct hdac_bus *bus = get_bus_ctx(substream);
1176 * Use DPIB for Playback stream as the periodic DMA Position-in-
1177 * Buffer Writes may be scheduled at the same time or later than
1178 * the MSI and does not guarantee to reflect the Position of the
1179 * last buffer that was transferred. Whereas DPIB register in
1180 * HAD space reflects the actual data that is transferred.
1181 * Use the position buffer for capture, as DPIB write gets
1182 * completed earlier than the actual data written to the DDR.
1184 * For capture stream following workaround is required to fix the
1185 * incorrect position reporting.
1187 * 1. Wait for 20us before reading the DMA position in buffer once
1188 * the interrupt is generated for stream completion as update happens
1189 * on the HDA frame boundary i.e. 20.833uSec.
1190 * 2. Read DPIB register to flush the DMA position value. This dummy
1191 * read is required to flush DMA position value.
1192 * 3. Read the DMA Position-in-Buffer. This value now will be equal to
1193 * or greater than period boundary.
1196 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1197 pos = readl(bus->remap_addr + AZX_REG_VS_SDXDPIB_XBASE +
1198 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1199 hdac_stream(hstream)->index));
1202 readl(bus->remap_addr +
1203 AZX_REG_VS_SDXDPIB_XBASE +
1204 (AZX_REG_VS_SDXDPIB_XINTERVAL *
1205 hdac_stream(hstream)->index));
1206 pos = snd_hdac_stream_get_pos_posbuf(hdac_stream(hstream));
1209 if (pos >= hdac_stream(hstream)->bufsize)
1212 return bytes_to_frames(substream->runtime, pos);
1215 static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
1218 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1219 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
1220 u64 codec_frames, codec_nsecs;
1222 if (!codec_dai->driver->ops->delay)
1225 codec_frames = codec_dai->driver->ops->delay(substream, codec_dai);
1226 codec_nsecs = div_u64(codec_frames * 1000000000LL,
1227 substream->runtime->rate);
1229 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1230 return nsec + codec_nsecs;
1232 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
1235 static int skl_platform_soc_get_time_info(
1236 struct snd_soc_component *component,
1237 struct snd_pcm_substream *substream,
1238 struct timespec64 *system_ts, struct timespec64 *audio_ts,
1239 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
1240 struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
1242 struct hdac_ext_stream *sstream = get_hdac_ext_stream(substream);
1243 struct hdac_stream *hstr = hdac_stream(sstream);
1246 if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
1247 (audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
1249 snd_pcm_gettime(substream->runtime, system_ts);
1251 nsec = timecounter_read(&hstr->tc);
1252 if (audio_tstamp_config->report_delay)
1253 nsec = skl_adjust_codec_delay(substream, nsec);
1255 *audio_ts = ns_to_timespec64(nsec);
1257 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
1258 audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
1259 audio_tstamp_report->accuracy = 42; /* 24MHzWallClk == 42ns resolution */
1262 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
1268 #define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
1270 static int skl_platform_soc_new(struct snd_soc_component *component,
1271 struct snd_soc_pcm_runtime *rtd)
1273 struct snd_soc_dai *dai = snd_soc_rtd_to_cpu(rtd, 0);
1274 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1275 struct snd_pcm *pcm = rtd->pcm;
1277 struct skl_dev *skl = bus_to_skl(bus);
1279 if (dai->driver->playback.channels_min ||
1280 dai->driver->capture.channels_min) {
1281 /* buffer pre-allocation */
1282 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1283 if (size > MAX_PREALLOC_SIZE)
1284 size = MAX_PREALLOC_SIZE;
1285 snd_pcm_set_managed_buffer_all(pcm,
1286 SNDRV_DMA_TYPE_DEV_SG,
1288 size, MAX_PREALLOC_SIZE);
1294 static int skl_get_module_info(struct skl_dev *skl,
1295 struct skl_module_cfg *mconfig)
1297 struct skl_module_inst_id *pin_id;
1298 guid_t *uuid_mod, *uuid_tplg;
1299 struct skl_module *skl_module;
1300 struct uuid_module *module;
1303 uuid_mod = (guid_t *)mconfig->guid;
1305 if (list_empty(&skl->uuid_list)) {
1306 dev_err(skl->dev, "Module list is empty\n");
1310 for (i = 0; i < skl->nr_modules; i++) {
1311 skl_module = skl->modules[i];
1312 uuid_tplg = &skl_module->uuid;
1313 if (guid_equal(uuid_mod, uuid_tplg)) {
1314 mconfig->module = skl_module;
1320 if (skl->nr_modules && ret)
1324 list_for_each_entry(module, &skl->uuid_list, list) {
1325 if (guid_equal(uuid_mod, &module->uuid)) {
1326 mconfig->id.module_id = module->id;
1327 mconfig->module->loadable = module->is_loadable;
1331 for (i = 0; i < MAX_IN_QUEUE; i++) {
1332 pin_id = &mconfig->m_in_pin[i].id;
1333 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1334 pin_id->module_id = module->id;
1337 for (i = 0; i < MAX_OUT_QUEUE; i++) {
1338 pin_id = &mconfig->m_out_pin[i].id;
1339 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1340 pin_id->module_id = module->id;
1347 static int skl_populate_modules(struct skl_dev *skl)
1349 struct skl_pipeline *p;
1350 struct skl_pipe_module *m;
1351 struct snd_soc_dapm_widget *w;
1352 struct skl_module_cfg *mconfig;
1355 list_for_each_entry(p, &skl->ppl_list, node) {
1356 list_for_each_entry(m, &p->pipe->w_list, node) {
1360 ret = skl_get_module_info(skl, mconfig);
1363 "query module info failed\n");
1367 skl_tplg_add_moduleid_in_bind_params(skl, w);
1374 static int skl_platform_soc_probe(struct snd_soc_component *component)
1376 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1377 struct skl_dev *skl = bus_to_skl(bus);
1378 const struct skl_dsp_ops *ops;
1381 ret = pm_runtime_resume_and_get(component->dev);
1382 if (ret < 0 && ret != -EACCES)
1386 skl->component = component;
1389 skl->debugfs = skl_debugfs_init(skl);
1391 ret = skl_tplg_init(component, bus);
1393 dev_err(component->dev, "Failed to init topology!\n");
1397 /* load the firmwares, since all is set */
1398 ops = skl_get_dsp_ops(skl->pci->device);
1403 * Disable dynamic clock and power gating during firmware
1404 * and library download
1406 skl->enable_miscbdcge(component->dev, false);
1407 skl->clock_power_gating(component->dev, false);
1409 ret = ops->init_fw(component->dev, skl);
1410 skl->enable_miscbdcge(component->dev, true);
1411 skl->clock_power_gating(component->dev, true);
1413 dev_err(component->dev, "Failed to boot first fw: %d\n", ret);
1416 skl_populate_modules(skl);
1417 skl->update_d0i3c = skl_update_d0i3c;
1419 if (skl->cfg.astate_cfg != NULL) {
1420 skl_dsp_set_astate_cfg(skl,
1421 skl->cfg.astate_cfg->count,
1422 skl->cfg.astate_cfg);
1425 pm_runtime_mark_last_busy(component->dev);
1426 pm_runtime_put_autosuspend(component->dev);
1431 static void skl_platform_soc_remove(struct snd_soc_component *component)
1433 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1434 struct skl_dev *skl = bus_to_skl(bus);
1436 skl_tplg_exit(component, bus);
1438 skl_debugfs_exit(skl);
1441 static const struct snd_soc_component_driver skl_component = {
1443 .probe = skl_platform_soc_probe,
1444 .remove = skl_platform_soc_remove,
1445 .open = skl_platform_soc_open,
1446 .trigger = skl_platform_soc_trigger,
1447 .pointer = skl_platform_soc_pointer,
1448 .get_time_info = skl_platform_soc_get_time_info,
1449 .pcm_construct = skl_platform_soc_new,
1450 .module_get_upon_open = 1, /* increment refcount when a pcm is opened */
1453 int skl_platform_register(struct device *dev)
1456 struct snd_soc_dai_driver *dais;
1457 int num_dais = ARRAY_SIZE(skl_platform_dai);
1458 struct hdac_bus *bus = dev_get_drvdata(dev);
1459 struct skl_dev *skl = bus_to_skl(bus);
1461 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
1468 if (!skl->use_tplg_pcm) {
1469 dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
1470 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);
1487 dev_err(dev, "soc component registration failed %d\n", ret);
1493 int skl_platform_unregister(struct device *dev)
1495 struct hdac_bus *bus = dev_get_drvdata(dev);
1496 struct skl_dev *skl = bus_to_skl(bus);
1497 struct skl_module_deferred_bind *modules, *tmp;
1499 list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
1500 list_del(&modules->node);