xref: /openbmc/linux/sound/soc/sof/pcm.c (revision b243b437f4c46b09ec26fc02bea610ace4b45aa2)
1e149ca29SPierre-Louis Bossart // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2868bd00fSLiam Girdwood //
3868bd00fSLiam Girdwood // This file is provided under a dual BSD/GPLv2 license.  When using or
4868bd00fSLiam Girdwood // redistributing this file, you may do so under either license.
5868bd00fSLiam Girdwood //
6868bd00fSLiam Girdwood // Copyright(c) 2018 Intel Corporation. All rights reserved.
7868bd00fSLiam Girdwood //
8868bd00fSLiam Girdwood // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9868bd00fSLiam Girdwood //
10868bd00fSLiam Girdwood // PCM Layer, interface between ALSA and IPC.
11868bd00fSLiam Girdwood //
12868bd00fSLiam Girdwood 
13868bd00fSLiam Girdwood #include <linux/pm_runtime.h>
14868bd00fSLiam Girdwood #include <sound/pcm_params.h>
15868bd00fSLiam Girdwood #include <sound/sof.h>
16868bd00fSLiam Girdwood #include "sof-priv.h"
17ee1e79b7SRanjani Sridharan #include "sof-audio.h"
18ee844305SPeter Ujfalusi #include "sof-utils.h"
193dc0d709SPeter Ujfalusi #include "ops.h"
20868bd00fSLiam Girdwood 
21868bd00fSLiam Girdwood /* Create DMA buffer page table for DSP */
221c91d77eSKuninori Morimoto static int create_page_table(struct snd_soc_component *component,
231c91d77eSKuninori Morimoto 			     struct snd_pcm_substream *substream,
24868bd00fSLiam Girdwood 			     unsigned char *dma_area, size_t size)
25868bd00fSLiam Girdwood {
261205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
27868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
28868bd00fSLiam Girdwood 	struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream);
29868bd00fSLiam Girdwood 	int stream = substream->stream;
30868bd00fSLiam Girdwood 
31ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
32868bd00fSLiam Girdwood 	if (!spcm)
33868bd00fSLiam Girdwood 		return -EINVAL;
34868bd00fSLiam Girdwood 
35ee1e79b7SRanjani Sridharan 	return snd_sof_create_page_table(component->dev, dmab,
36868bd00fSLiam Girdwood 		spcm->stream[stream].page_table.area, size);
37868bd00fSLiam Girdwood }
38868bd00fSLiam Girdwood 
39e2803e61SKeyon Jie /*
40e2803e61SKeyon Jie  * sof pcm period elapse work
41e2803e61SKeyon Jie  */
42858f7a5cSDaniel Baluta static void snd_sof_pcm_period_elapsed_work(struct work_struct *work)
43e2803e61SKeyon Jie {
44e2803e61SKeyon Jie 	struct snd_sof_pcm_stream *sps =
45e2803e61SKeyon Jie 		container_of(work, struct snd_sof_pcm_stream,
46e2803e61SKeyon Jie 			     period_elapsed_work);
47e2803e61SKeyon Jie 
48e2803e61SKeyon Jie 	snd_pcm_period_elapsed(sps->substream);
49e2803e61SKeyon Jie }
50e2803e61SKeyon Jie 
51858f7a5cSDaniel Baluta void snd_sof_pcm_init_elapsed_work(struct work_struct *work)
52858f7a5cSDaniel Baluta {
53858f7a5cSDaniel Baluta 	 INIT_WORK(work, snd_sof_pcm_period_elapsed_work);
54858f7a5cSDaniel Baluta }
55858f7a5cSDaniel Baluta 
56e2803e61SKeyon Jie /*
57e2803e61SKeyon Jie  * sof pcm period elapse, this could be called at irq thread context.
58e2803e61SKeyon Jie  */
59e2803e61SKeyon Jie void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream)
60e2803e61SKeyon Jie {
611205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
62e2803e61SKeyon Jie 	struct snd_soc_component *component =
63ee1e79b7SRanjani Sridharan 		snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
64e2803e61SKeyon Jie 	struct snd_sof_pcm *spcm;
65e2803e61SKeyon Jie 
66ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
67e2803e61SKeyon Jie 	if (!spcm) {
68ee1e79b7SRanjani Sridharan 		dev_err(component->dev,
69e2803e61SKeyon Jie 			"error: period elapsed for unknown stream!\n");
70e2803e61SKeyon Jie 		return;
71e2803e61SKeyon Jie 	}
72e2803e61SKeyon Jie 
73e2803e61SKeyon Jie 	/*
74e2803e61SKeyon Jie 	 * snd_pcm_period_elapsed() can be called in interrupt context
75e2803e61SKeyon Jie 	 * before IRQ_HANDLED is returned. Inside snd_pcm_period_elapsed(),
76e2803e61SKeyon Jie 	 * when the PCM is done draining or xrun happened, a STOP IPC will
77e2803e61SKeyon Jie 	 * then be sent and this IPC will hit IPC timeout.
78e2803e61SKeyon Jie 	 * To avoid sending IPC before the previous IPC is handled, we
79e2803e61SKeyon Jie 	 * schedule delayed work here to call the snd_pcm_period_elapsed().
80e2803e61SKeyon Jie 	 */
81e2803e61SKeyon Jie 	schedule_work(&spcm->stream[substream->stream].period_elapsed_work);
82e2803e61SKeyon Jie }
83e2803e61SKeyon Jie EXPORT_SYMBOL(snd_sof_pcm_period_elapsed);
84e2803e61SKeyon Jie 
85442c7128SRanjani Sridharan int sof_pcm_setup_connected_widgets(struct snd_sof_dev *sdev, struct snd_soc_pcm_runtime *rtd,
865fcdbb2dSRanjani Sridharan 				    struct snd_sof_pcm *spcm, int dir)
875fcdbb2dSRanjani Sridharan {
885fcdbb2dSRanjani Sridharan 	struct snd_soc_dai *dai;
895fcdbb2dSRanjani Sridharan 	int ret, j;
905fcdbb2dSRanjani Sridharan 
915fcdbb2dSRanjani Sridharan 	/* query DAPM for list of connected widgets and set them up */
925fcdbb2dSRanjani Sridharan 	for_each_rtd_cpu_dais(rtd, j, dai) {
935fcdbb2dSRanjani Sridharan 		struct snd_soc_dapm_widget_list *list;
945fcdbb2dSRanjani Sridharan 
955fcdbb2dSRanjani Sridharan 		ret = snd_soc_dapm_dai_get_connected_widgets(dai, dir, &list,
965fcdbb2dSRanjani Sridharan 							     dpcm_end_walk_at_be);
975fcdbb2dSRanjani Sridharan 		if (ret < 0) {
985fcdbb2dSRanjani Sridharan 			dev_err(sdev->dev, "error: dai %s has no valid %s path\n", dai->name,
995fcdbb2dSRanjani Sridharan 				dir == SNDRV_PCM_STREAM_PLAYBACK ? "playback" : "capture");
1005fcdbb2dSRanjani Sridharan 			return ret;
1015fcdbb2dSRanjani Sridharan 		}
1025fcdbb2dSRanjani Sridharan 
1035fcdbb2dSRanjani Sridharan 		spcm->stream[dir].list = list;
1045fcdbb2dSRanjani Sridharan 
1055fcdbb2dSRanjani Sridharan 		ret = sof_widget_list_setup(sdev, spcm, dir);
1065fcdbb2dSRanjani Sridharan 		if (ret < 0) {
1075fcdbb2dSRanjani Sridharan 			dev_err(sdev->dev, "error: failed widget list set up for pcm %d dir %d\n",
1085fcdbb2dSRanjani Sridharan 				spcm->pcm.pcm_id, dir);
1095fcdbb2dSRanjani Sridharan 			spcm->stream[dir].list = NULL;
1105fcdbb2dSRanjani Sridharan 			snd_soc_dapm_dai_free_widgets(&list);
1115fcdbb2dSRanjani Sridharan 			return ret;
1125fcdbb2dSRanjani Sridharan 		}
1135fcdbb2dSRanjani Sridharan 	}
1145fcdbb2dSRanjani Sridharan 
1155fcdbb2dSRanjani Sridharan 	return 0;
1165fcdbb2dSRanjani Sridharan }
1175fcdbb2dSRanjani Sridharan 
1181c91d77eSKuninori Morimoto static int sof_pcm_hw_params(struct snd_soc_component *component,
1191c91d77eSKuninori Morimoto 			     struct snd_pcm_substream *substream,
120868bd00fSLiam Girdwood 			     struct snd_pcm_hw_params *params)
121868bd00fSLiam Girdwood {
122868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
123621fd48cSRanjani Sridharan 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
12431f60a0cSPeter Ujfalusi 	struct snd_sof_platform_stream_params platform_params = { 0 };
125621fd48cSRanjani Sridharan 	const struct sof_ipc_pcm_ops *pcm_ops = sdev->ipc->ops->pcm;
126621fd48cSRanjani Sridharan 	struct snd_pcm_runtime *runtime = substream->runtime;
127868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
128868bd00fSLiam Girdwood 	int ret;
129868bd00fSLiam Girdwood 
130868bd00fSLiam Girdwood 	/* nothing to do for BE */
131868bd00fSLiam Girdwood 	if (rtd->dai_link->no_pcm)
132868bd00fSLiam Girdwood 		return 0;
133868bd00fSLiam Girdwood 
134ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
135868bd00fSLiam Girdwood 	if (!spcm)
136868bd00fSLiam Girdwood 		return -EINVAL;
137868bd00fSLiam Girdwood 
138cfe8191bSKai Vehmanen 	/*
139cfe8191bSKai Vehmanen 	 * Handle repeated calls to hw_params() without free_pcm() in
140cfe8191bSKai Vehmanen 	 * between. At least ALSA OSS emulation depends on this.
141cfe8191bSKai Vehmanen 	 */
1424123c24bSRanjani Sridharan 	if (pcm_ops->hw_free && spcm->prepared[substream->stream]) {
1434123c24bSRanjani Sridharan 		ret = pcm_ops->hw_free(component, substream);
144cfe8191bSKai Vehmanen 		if (ret < 0)
145cfe8191bSKai Vehmanen 			return ret;
146cfe8191bSKai Vehmanen 
1474123c24bSRanjani Sridharan 		spcm->prepared[substream->stream] = false;
1484123c24bSRanjani Sridharan 	}
1494123c24bSRanjani Sridharan 
150ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "pcm: hw params stream %d dir %d\n",
151868bd00fSLiam Girdwood 		spcm->pcm.pcm_id, substream->stream);
152868bd00fSLiam Girdwood 
1535fcdbb2dSRanjani Sridharan 	/* if this is a repeated hw_params without hw_free, skip setting up widgets */
1545fcdbb2dSRanjani Sridharan 	if (!spcm->stream[substream->stream].list) {
1555fcdbb2dSRanjani Sridharan 		ret = sof_pcm_setup_connected_widgets(sdev, rtd, spcm, substream->stream);
1565fcdbb2dSRanjani Sridharan 		if (ret < 0)
1575fcdbb2dSRanjani Sridharan 			return ret;
1585fcdbb2dSRanjani Sridharan 	}
1595fcdbb2dSRanjani Sridharan 
160621fd48cSRanjani Sridharan 	/* create compressed page table for audio firmware */
161621fd48cSRanjani Sridharan 	if (runtime->buffer_changed) {
162621fd48cSRanjani Sridharan 		ret = create_page_table(component, substream, runtime->dma_area,
163621fd48cSRanjani Sridharan 					runtime->dma_bytes);
164621fd48cSRanjani Sridharan 
165621fd48cSRanjani Sridharan 		if (ret < 0)
166868bd00fSLiam Girdwood 			return ret;
167868bd00fSLiam Girdwood 	}
168868bd00fSLiam Girdwood 
169621fd48cSRanjani Sridharan 	ret = snd_sof_pcm_platform_hw_params(sdev, substream, params, &platform_params);
170757ce810SPeter Ujfalusi 	if (ret < 0) {
171621fd48cSRanjani Sridharan 		dev_err(component->dev, "platform hw params failed\n");
172621fd48cSRanjani Sridharan 		return ret;
173621fd48cSRanjani Sridharan 	}
174621fd48cSRanjani Sridharan 
175621fd48cSRanjani Sridharan 	if (pcm_ops->hw_params) {
176621fd48cSRanjani Sridharan 		ret = pcm_ops->hw_params(component, substream, params, &platform_params);
177621fd48cSRanjani Sridharan 		if (ret < 0)
178757ce810SPeter Ujfalusi 			return ret;
179757ce810SPeter Ujfalusi 	}
180757ce810SPeter Ujfalusi 
18104c80277SKai Vehmanen 	spcm->prepared[substream->stream] = true;
18204c80277SKai Vehmanen 
183868bd00fSLiam Girdwood 	/* save pcm hw_params */
184868bd00fSLiam Girdwood 	memcpy(&spcm->params[substream->stream], params, sizeof(*params));
185868bd00fSLiam Girdwood 
186621fd48cSRanjani Sridharan 	return 0;
187868bd00fSLiam Girdwood }
188868bd00fSLiam Girdwood 
1891c91d77eSKuninori Morimoto static int sof_pcm_hw_free(struct snd_soc_component *component,
1901c91d77eSKuninori Morimoto 			   struct snd_pcm_substream *substream)
191868bd00fSLiam Girdwood {
1921205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
193868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
1944123c24bSRanjani Sridharan 	const struct sof_ipc_pcm_ops *pcm_ops = sdev->ipc->ops->pcm;
195868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
196e66e52c5SKai Vehmanen 	int ret, err = 0;
197868bd00fSLiam Girdwood 
198868bd00fSLiam Girdwood 	/* nothing to do for BE */
199868bd00fSLiam Girdwood 	if (rtd->dai_link->no_pcm)
200868bd00fSLiam Girdwood 		return 0;
201868bd00fSLiam Girdwood 
202ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
203868bd00fSLiam Girdwood 	if (!spcm)
204868bd00fSLiam Girdwood 		return -EINVAL;
205868bd00fSLiam Girdwood 
206ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "pcm: free stream %d dir %d\n",
207ee1e79b7SRanjani Sridharan 		spcm->pcm.pcm_id, substream->stream);
208868bd00fSLiam Girdwood 
2090b639dcdSRanjani Sridharan 	/* free PCM in the DSP */
2104123c24bSRanjani Sridharan 	if (pcm_ops->hw_free && spcm->prepared[substream->stream]) {
2114123c24bSRanjani Sridharan 		ret = pcm_ops->hw_free(component, substream);
212e66e52c5SKai Vehmanen 		if (ret < 0)
213e66e52c5SKai Vehmanen 			err = ret;
214868bd00fSLiam Girdwood 
2154123c24bSRanjani Sridharan 		spcm->prepared[substream->stream] = false;
2164123c24bSRanjani Sridharan 	}
2175fcdbb2dSRanjani Sridharan 
2180b639dcdSRanjani Sridharan 	/* stop DMA */
21993146bc2SRanjani Sridharan 	ret = snd_sof_pcm_platform_hw_free(sdev, substream);
220e66e52c5SKai Vehmanen 	if (ret < 0) {
221ee1e79b7SRanjani Sridharan 		dev_err(component->dev, "error: platform hw free failed\n");
222e66e52c5SKai Vehmanen 		err = ret;
223e66e52c5SKai Vehmanen 	}
22493146bc2SRanjani Sridharan 
2250b639dcdSRanjani Sridharan 	/* free the DAPM widget list */
2260b639dcdSRanjani Sridharan 	ret = sof_widget_list_free(sdev, spcm, substream->stream);
2270b639dcdSRanjani Sridharan 	if (ret < 0)
2280b639dcdSRanjani Sridharan 		err = ret;
2290b639dcdSRanjani Sridharan 
2300b639dcdSRanjani Sridharan 	cancel_work_sync(&spcm->stream[substream->stream].period_elapsed_work);
2310b639dcdSRanjani Sridharan 
232e66e52c5SKai Vehmanen 	return err;
233868bd00fSLiam Girdwood }
234868bd00fSLiam Girdwood 
2351c91d77eSKuninori Morimoto static int sof_pcm_prepare(struct snd_soc_component *component,
2361c91d77eSKuninori Morimoto 			   struct snd_pcm_substream *substream)
237868bd00fSLiam Girdwood {
2381205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
239868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
240868bd00fSLiam Girdwood 	int ret;
241868bd00fSLiam Girdwood 
242868bd00fSLiam Girdwood 	/* nothing to do for BE */
243868bd00fSLiam Girdwood 	if (rtd->dai_link->no_pcm)
244868bd00fSLiam Girdwood 		return 0;
245868bd00fSLiam Girdwood 
246ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
247868bd00fSLiam Girdwood 	if (!spcm)
248868bd00fSLiam Girdwood 		return -EINVAL;
249868bd00fSLiam Girdwood 
25004c80277SKai Vehmanen 	if (spcm->prepared[substream->stream])
251868bd00fSLiam Girdwood 		return 0;
252868bd00fSLiam Girdwood 
253ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "pcm: prepare stream %d dir %d\n",
254ee1e79b7SRanjani Sridharan 		spcm->pcm.pcm_id, substream->stream);
255868bd00fSLiam Girdwood 
256868bd00fSLiam Girdwood 	/* set hw_params */
2571c91d77eSKuninori Morimoto 	ret = sof_pcm_hw_params(component,
2581c91d77eSKuninori Morimoto 				substream, &spcm->params[substream->stream]);
259868bd00fSLiam Girdwood 	if (ret < 0) {
260ee1e79b7SRanjani Sridharan 		dev_err(component->dev,
261ee1e79b7SRanjani Sridharan 			"error: set pcm hw_params after resume\n");
262868bd00fSLiam Girdwood 		return ret;
263868bd00fSLiam Girdwood 	}
264868bd00fSLiam Girdwood 
265868bd00fSLiam Girdwood 	return 0;
266868bd00fSLiam Girdwood }
267868bd00fSLiam Girdwood 
268868bd00fSLiam Girdwood /*
269868bd00fSLiam Girdwood  * FE dai link trigger actions are always executed in non-atomic context because
270868bd00fSLiam Girdwood  * they involve IPC's.
271868bd00fSLiam Girdwood  */
2721c91d77eSKuninori Morimoto static int sof_pcm_trigger(struct snd_soc_component *component,
2731c91d77eSKuninori Morimoto 			   struct snd_pcm_substream *substream, int cmd)
274868bd00fSLiam Girdwood {
2751205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
276868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
277beac3f4cSRanjani Sridharan 	const struct sof_ipc_pcm_ops *pcm_ops = sdev->ipc->ops->pcm;
278868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
27904c80277SKai Vehmanen 	bool reset_hw_params = false;
2805fcdbb2dSRanjani Sridharan 	bool free_widget_list = false;
2810a1b0834SPan Xiuli 	bool ipc_first = false;
282beac3f4cSRanjani Sridharan 	int ret = 0;
283868bd00fSLiam Girdwood 
284868bd00fSLiam Girdwood 	/* nothing to do for BE */
285868bd00fSLiam Girdwood 	if (rtd->dai_link->no_pcm)
286868bd00fSLiam Girdwood 		return 0;
287868bd00fSLiam Girdwood 
288ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
289868bd00fSLiam Girdwood 	if (!spcm)
290868bd00fSLiam Girdwood 		return -EINVAL;
291868bd00fSLiam Girdwood 
292ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "pcm: trigger stream %d dir %d cmd %d\n",
293868bd00fSLiam Girdwood 		spcm->pcm.pcm_id, substream->stream, cmd);
294868bd00fSLiam Girdwood 
295868bd00fSLiam Girdwood 	switch (cmd) {
296868bd00fSLiam Girdwood 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2970a1b0834SPan Xiuli 		ipc_first = true;
298868bd00fSLiam Girdwood 		break;
299868bd00fSLiam Girdwood 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
300868bd00fSLiam Girdwood 		break;
301868bd00fSLiam Girdwood 	case SNDRV_PCM_TRIGGER_START:
302ac8c046fSKeyon Jie 		if (spcm->stream[substream->stream].suspend_ignored) {
303ac8c046fSKeyon Jie 			/*
304ac8c046fSKeyon Jie 			 * This case will be triggered when INFO_RESUME is
305ac8c046fSKeyon Jie 			 * not supported, no need to re-start streams that
306ac8c046fSKeyon Jie 			 * remained enabled in D0ix.
307ac8c046fSKeyon Jie 			 */
308ac8c046fSKeyon Jie 			spcm->stream[substream->stream].suspend_ignored = false;
309ac8c046fSKeyon Jie 			return 0;
310ac8c046fSKeyon Jie 		}
311868bd00fSLiam Girdwood 		break;
312868bd00fSLiam Girdwood 	case SNDRV_PCM_TRIGGER_SUSPEND:
313043ae13bSRanjani Sridharan 		if (sdev->system_suspend_target == SOF_SUSPEND_S0IX &&
314ac8c046fSKeyon Jie 		    spcm->stream[substream->stream].d0i3_compatible) {
315ac8c046fSKeyon Jie 			/*
316ac8c046fSKeyon Jie 			 * trap the event, not sending trigger stop to
317ac8c046fSKeyon Jie 			 * prevent the FW pipelines from being stopped,
318ac8c046fSKeyon Jie 			 * and mark the flag to ignore the upcoming DAPM
319ac8c046fSKeyon Jie 			 * PM events.
320ac8c046fSKeyon Jie 			 */
321ac8c046fSKeyon Jie 			spcm->stream[substream->stream].suspend_ignored = true;
322ac8c046fSKeyon Jie 			return 0;
323ac8c046fSKeyon Jie 		}
3245fcdbb2dSRanjani Sridharan 		free_widget_list = true;
325df561f66SGustavo A. R. Silva 		fallthrough;
326868bd00fSLiam Girdwood 	case SNDRV_PCM_TRIGGER_STOP:
3270a1b0834SPan Xiuli 		ipc_first = true;
32804c80277SKai Vehmanen 		reset_hw_params = true;
329868bd00fSLiam Girdwood 		break;
330868bd00fSLiam Girdwood 	default:
331beac3f4cSRanjani Sridharan 		dev_err(component->dev, "Unhandled trigger cmd %d\n", cmd);
332868bd00fSLiam Girdwood 		return -EINVAL;
333868bd00fSLiam Girdwood 	}
334868bd00fSLiam Girdwood 
3350a1b0834SPan Xiuli 	/*
3360a1b0834SPan Xiuli 	 * DMA and IPC sequence is different for start and stop. Need to send
3370a1b0834SPan Xiuli 	 * STOP IPC before stop DMA
3380a1b0834SPan Xiuli 	 */
3390a1b0834SPan Xiuli 	if (!ipc_first)
340868bd00fSLiam Girdwood 		snd_sof_pcm_platform_trigger(sdev, substream, cmd);
341868bd00fSLiam Girdwood 
342beac3f4cSRanjani Sridharan 	if (pcm_ops->trigger)
343beac3f4cSRanjani Sridharan 		ret = pcm_ops->trigger(component, substream, cmd);
344868bd00fSLiam Girdwood 
345beac3f4cSRanjani Sridharan 	/* need to STOP DMA even if trigger IPC failed */
3460a1b0834SPan Xiuli 	if (ipc_first)
3470a1b0834SPan Xiuli 		snd_sof_pcm_platform_trigger(sdev, substream, cmd);
3480a1b0834SPan Xiuli 
3490a1b0834SPan Xiuli 	/* free PCM if reset_hw_params is set and the STOP IPC is successful */
3505fcdbb2dSRanjani Sridharan 	if (!ret && reset_hw_params) {
351d9a72465SRanjani Sridharan 		ret = sof_pcm_stream_free(sdev, substream, spcm, substream->stream,
352d9a72465SRanjani Sridharan 					  free_widget_list);
3535fcdbb2dSRanjani Sridharan 		if (ret < 0)
3545fcdbb2dSRanjani Sridharan 			return ret;
3555fcdbb2dSRanjani Sridharan 	}
356a49b6871SKai Vehmanen 
357868bd00fSLiam Girdwood 	return ret;
358868bd00fSLiam Girdwood }
359868bd00fSLiam Girdwood 
3601c91d77eSKuninori Morimoto static snd_pcm_uframes_t sof_pcm_pointer(struct snd_soc_component *component,
3611c91d77eSKuninori Morimoto 					 struct snd_pcm_substream *substream)
362868bd00fSLiam Girdwood {
3631205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
364868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
365868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
366868bd00fSLiam Girdwood 	snd_pcm_uframes_t host, dai;
367868bd00fSLiam Girdwood 
368868bd00fSLiam Girdwood 	/* nothing to do for BE */
369868bd00fSLiam Girdwood 	if (rtd->dai_link->no_pcm)
370868bd00fSLiam Girdwood 		return 0;
371868bd00fSLiam Girdwood 
372868bd00fSLiam Girdwood 	/* use dsp ops pointer callback directly if set */
373868bd00fSLiam Girdwood 	if (sof_ops(sdev)->pcm_pointer)
374868bd00fSLiam Girdwood 		return sof_ops(sdev)->pcm_pointer(sdev, substream);
375868bd00fSLiam Girdwood 
376ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
377868bd00fSLiam Girdwood 	if (!spcm)
378868bd00fSLiam Girdwood 		return -EINVAL;
379868bd00fSLiam Girdwood 
380868bd00fSLiam Girdwood 	/* read position from DSP */
381868bd00fSLiam Girdwood 	host = bytes_to_frames(substream->runtime,
382868bd00fSLiam Girdwood 			       spcm->stream[substream->stream].posn.host_posn);
383868bd00fSLiam Girdwood 	dai = bytes_to_frames(substream->runtime,
384868bd00fSLiam Girdwood 			      spcm->stream[substream->stream].posn.dai_posn);
385868bd00fSLiam Girdwood 
386277ff236SPierre-Louis Bossart 	dev_vdbg(component->dev,
387ee1e79b7SRanjani Sridharan 		 "PCM: stream %d dir %d DMA position %lu DAI position %lu\n",
388868bd00fSLiam Girdwood 		 spcm->pcm.pcm_id, substream->stream, host, dai);
389868bd00fSLiam Girdwood 
390868bd00fSLiam Girdwood 	return host;
391868bd00fSLiam Girdwood }
392868bd00fSLiam Girdwood 
3931c91d77eSKuninori Morimoto static int sof_pcm_open(struct snd_soc_component *component,
3941c91d77eSKuninori Morimoto 			struct snd_pcm_substream *substream)
395868bd00fSLiam Girdwood {
3961205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
397868bd00fSLiam Girdwood 	struct snd_pcm_runtime *runtime = substream->runtime;
398868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
39927e322faSPierre-Louis Bossart 	const struct snd_sof_dsp_ops *ops = sof_ops(sdev);
400868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
401868bd00fSLiam Girdwood 	struct snd_soc_tplg_stream_caps *caps;
402868bd00fSLiam Girdwood 	int ret;
403868bd00fSLiam Girdwood 
404868bd00fSLiam Girdwood 	/* nothing to do for BE */
405868bd00fSLiam Girdwood 	if (rtd->dai_link->no_pcm)
406868bd00fSLiam Girdwood 		return 0;
407868bd00fSLiam Girdwood 
408ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
409868bd00fSLiam Girdwood 	if (!spcm)
410868bd00fSLiam Girdwood 		return -EINVAL;
411868bd00fSLiam Girdwood 
412ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "pcm: open stream %d dir %d\n",
413ee1e79b7SRanjani Sridharan 		spcm->pcm.pcm_id, substream->stream);
414868bd00fSLiam Girdwood 
415868bd00fSLiam Girdwood 
416868bd00fSLiam Girdwood 	caps = &spcm->pcm.caps[substream->stream];
417868bd00fSLiam Girdwood 
418868bd00fSLiam Girdwood 	/* set runtime config */
41927e322faSPierre-Louis Bossart 	runtime->hw.info = ops->hw_info; /* platform-specific */
42027e322faSPierre-Louis Bossart 
4219983ac49SKai Vehmanen 	/* set any runtime constraints based on topology */
422868bd00fSLiam Girdwood 	runtime->hw.formats = le64_to_cpu(caps->formats);
423868bd00fSLiam Girdwood 	runtime->hw.period_bytes_min = le32_to_cpu(caps->period_size_min);
424868bd00fSLiam Girdwood 	runtime->hw.period_bytes_max = le32_to_cpu(caps->period_size_max);
425868bd00fSLiam Girdwood 	runtime->hw.periods_min = le32_to_cpu(caps->periods_min);
426868bd00fSLiam Girdwood 	runtime->hw.periods_max = le32_to_cpu(caps->periods_max);
427868bd00fSLiam Girdwood 
428868bd00fSLiam Girdwood 	/*
429868bd00fSLiam Girdwood 	 * caps->buffer_size_min is not used since the
430868bd00fSLiam Girdwood 	 * snd_pcm_hardware structure only defines buffer_bytes_max
431868bd00fSLiam Girdwood 	 */
432868bd00fSLiam Girdwood 	runtime->hw.buffer_bytes_max = le32_to_cpu(caps->buffer_size_max);
433868bd00fSLiam Girdwood 
434ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "period min %zd max %zd bytes\n",
435868bd00fSLiam Girdwood 		runtime->hw.period_bytes_min,
436868bd00fSLiam Girdwood 		runtime->hw.period_bytes_max);
437ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "period count %d max %d\n",
438868bd00fSLiam Girdwood 		runtime->hw.periods_min,
439868bd00fSLiam Girdwood 		runtime->hw.periods_max);
440ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "buffer max %zd bytes\n",
441868bd00fSLiam Girdwood 		runtime->hw.buffer_bytes_max);
442868bd00fSLiam Girdwood 
443868bd00fSLiam Girdwood 	/* set wait time - TODO: come from topology */
444868bd00fSLiam Girdwood 	substream->wait_time = 500;
445868bd00fSLiam Girdwood 
446868bd00fSLiam Girdwood 	spcm->stream[substream->stream].posn.host_posn = 0;
447868bd00fSLiam Girdwood 	spcm->stream[substream->stream].posn.dai_posn = 0;
448868bd00fSLiam Girdwood 	spcm->stream[substream->stream].substream = substream;
44904c80277SKai Vehmanen 	spcm->prepared[substream->stream] = false;
450868bd00fSLiam Girdwood 
451868bd00fSLiam Girdwood 	ret = snd_sof_pcm_platform_open(sdev, substream);
45214a2212dSRanjani Sridharan 	if (ret < 0)
453ee1e79b7SRanjani Sridharan 		dev_err(component->dev, "error: pcm open failed %d\n", ret);
454868bd00fSLiam Girdwood 
455868bd00fSLiam Girdwood 	return ret;
456868bd00fSLiam Girdwood }
457868bd00fSLiam Girdwood 
4581c91d77eSKuninori Morimoto static int sof_pcm_close(struct snd_soc_component *component,
4591c91d77eSKuninori Morimoto 			 struct snd_pcm_substream *substream)
460868bd00fSLiam Girdwood {
4611205300aSKuninori Morimoto 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
462868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
463868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
464868bd00fSLiam Girdwood 	int err;
465868bd00fSLiam Girdwood 
466868bd00fSLiam Girdwood 	/* nothing to do for BE */
467868bd00fSLiam Girdwood 	if (rtd->dai_link->no_pcm)
468868bd00fSLiam Girdwood 		return 0;
469868bd00fSLiam Girdwood 
470ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
471868bd00fSLiam Girdwood 	if (!spcm)
472868bd00fSLiam Girdwood 		return -EINVAL;
473868bd00fSLiam Girdwood 
474ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "pcm: close stream %d dir %d\n",
475ee1e79b7SRanjani Sridharan 		spcm->pcm.pcm_id, substream->stream);
476868bd00fSLiam Girdwood 
477868bd00fSLiam Girdwood 	err = snd_sof_pcm_platform_close(sdev, substream);
478868bd00fSLiam Girdwood 	if (err < 0) {
479ee1e79b7SRanjani Sridharan 		dev_err(component->dev, "error: pcm close failed %d\n",
480868bd00fSLiam Girdwood 			err);
481868bd00fSLiam Girdwood 		/*
482868bd00fSLiam Girdwood 		 * keep going, no point in preventing the close
483868bd00fSLiam Girdwood 		 * from happening
484868bd00fSLiam Girdwood 		 */
485868bd00fSLiam Girdwood 	}
486868bd00fSLiam Girdwood 
487868bd00fSLiam Girdwood 	return 0;
488868bd00fSLiam Girdwood }
489868bd00fSLiam Girdwood 
490868bd00fSLiam Girdwood /*
491868bd00fSLiam Girdwood  * Pre-allocate playback/capture audio buffer pages.
492868bd00fSLiam Girdwood  * no need to explicitly release memory preallocated by sof_pcm_new in pcm_free
493868bd00fSLiam Girdwood  * snd_pcm_lib_preallocate_free_for_all() is called by the core.
494868bd00fSLiam Girdwood  */
4951c91d77eSKuninori Morimoto static int sof_pcm_new(struct snd_soc_component *component,
4961c91d77eSKuninori Morimoto 		       struct snd_soc_pcm_runtime *rtd)
497868bd00fSLiam Girdwood {
498868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
499868bd00fSLiam Girdwood 	struct snd_sof_pcm *spcm;
500868bd00fSLiam Girdwood 	struct snd_pcm *pcm = rtd->pcm;
501868bd00fSLiam Girdwood 	struct snd_soc_tplg_stream_caps *caps;
502868bd00fSLiam Girdwood 	int stream = SNDRV_PCM_STREAM_PLAYBACK;
503868bd00fSLiam Girdwood 
504868bd00fSLiam Girdwood 	/* find SOF PCM for this RTD */
505ee1e79b7SRanjani Sridharan 	spcm = snd_sof_find_spcm_dai(component, rtd);
506868bd00fSLiam Girdwood 	if (!spcm) {
507ee1e79b7SRanjani Sridharan 		dev_warn(component->dev, "warn: can't find PCM with DAI ID %d\n",
508868bd00fSLiam Girdwood 			 rtd->dai_link->id);
509868bd00fSLiam Girdwood 		return 0;
510868bd00fSLiam Girdwood 	}
511868bd00fSLiam Girdwood 
512ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev, "creating new PCM %s\n", spcm->pcm.pcm_name);
513868bd00fSLiam Girdwood 
514868bd00fSLiam Girdwood 	/* do we need to pre-allocate playback audio buffer pages */
515868bd00fSLiam Girdwood 	if (!spcm->pcm.playback)
516868bd00fSLiam Girdwood 		goto capture;
517868bd00fSLiam Girdwood 
518868bd00fSLiam Girdwood 	caps = &spcm->pcm.caps[stream];
519868bd00fSLiam Girdwood 
520868bd00fSLiam Girdwood 	/* pre-allocate playback audio buffer pages */
521ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev,
522ee1e79b7SRanjani Sridharan 		"spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n",
523868bd00fSLiam Girdwood 		caps->name, caps->buffer_size_min, caps->buffer_size_max);
524868bd00fSLiam Girdwood 
5254f7f9564SGuennadi Liakhovetski 	if (!pcm->streams[stream].substream) {
5264f7f9564SGuennadi Liakhovetski 		dev_err(component->dev, "error: NULL playback substream!\n");
5274f7f9564SGuennadi Liakhovetski 		return -EINVAL;
5284f7f9564SGuennadi Liakhovetski 	}
5294f7f9564SGuennadi Liakhovetski 
53057e960f0STakashi Iwai 	snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
531868bd00fSLiam Girdwood 				   SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
532e582f483SKeyon Jie 				   0, le32_to_cpu(caps->buffer_size_max));
533868bd00fSLiam Girdwood capture:
534868bd00fSLiam Girdwood 	stream = SNDRV_PCM_STREAM_CAPTURE;
535868bd00fSLiam Girdwood 
536868bd00fSLiam Girdwood 	/* do we need to pre-allocate capture audio buffer pages */
537868bd00fSLiam Girdwood 	if (!spcm->pcm.capture)
538868bd00fSLiam Girdwood 		return 0;
539868bd00fSLiam Girdwood 
540868bd00fSLiam Girdwood 	caps = &spcm->pcm.caps[stream];
541868bd00fSLiam Girdwood 
542868bd00fSLiam Girdwood 	/* pre-allocate capture audio buffer pages */
543ee1e79b7SRanjani Sridharan 	dev_dbg(component->dev,
544ee1e79b7SRanjani Sridharan 		"spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n",
545868bd00fSLiam Girdwood 		caps->name, caps->buffer_size_min, caps->buffer_size_max);
546868bd00fSLiam Girdwood 
5474f7f9564SGuennadi Liakhovetski 	if (!pcm->streams[stream].substream) {
5484f7f9564SGuennadi Liakhovetski 		dev_err(component->dev, "error: NULL capture substream!\n");
5494f7f9564SGuennadi Liakhovetski 		return -EINVAL;
5504f7f9564SGuennadi Liakhovetski 	}
5514f7f9564SGuennadi Liakhovetski 
55257e960f0STakashi Iwai 	snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
553868bd00fSLiam Girdwood 				   SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
554e582f483SKeyon Jie 				   0, le32_to_cpu(caps->buffer_size_max));
555868bd00fSLiam Girdwood 
556868bd00fSLiam Girdwood 	return 0;
557868bd00fSLiam Girdwood }
558868bd00fSLiam Girdwood 
559868bd00fSLiam Girdwood /* fixup the BE DAI link to match any values from topology */
560f805e7e0SRanjani Sridharan int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params)
561868bd00fSLiam Girdwood {
562868bd00fSLiam Girdwood 	struct snd_interval *rate = hw_param_interval(params,
563868bd00fSLiam Girdwood 			SNDRV_PCM_HW_PARAM_RATE);
564868bd00fSLiam Girdwood 	struct snd_interval *channels = hw_param_interval(params,
565868bd00fSLiam Girdwood 						SNDRV_PCM_HW_PARAM_CHANNELS);
566868bd00fSLiam Girdwood 	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
567868bd00fSLiam Girdwood 	struct snd_soc_component *component =
568ee1e79b7SRanjani Sridharan 		snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
569868bd00fSLiam Girdwood 	struct snd_sof_dai *dai =
570ee1e79b7SRanjani Sridharan 		snd_sof_find_dai(component, (char *)rtd->dai_link->name);
571c943a586SJaska Uimonen 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
572*b243b437SRanjani Sridharan 	const struct sof_ipc_pcm_ops *pcm_ops = sdev->ipc->ops->pcm;
573868bd00fSLiam Girdwood 
574868bd00fSLiam Girdwood 	/* no topology exists for this BE, try a common configuration */
575868bd00fSLiam Girdwood 	if (!dai) {
576ee1e79b7SRanjani Sridharan 		dev_warn(component->dev,
577ee1e79b7SRanjani Sridharan 			 "warning: no topology found for BE DAI %s config\n",
578868bd00fSLiam Girdwood 			 rtd->dai_link->name);
579868bd00fSLiam Girdwood 
580868bd00fSLiam Girdwood 		/*  set 48k, stereo, 16bits by default */
581868bd00fSLiam Girdwood 		rate->min = 48000;
582868bd00fSLiam Girdwood 		rate->max = 48000;
583868bd00fSLiam Girdwood 
584868bd00fSLiam Girdwood 		channels->min = 2;
585868bd00fSLiam Girdwood 		channels->max = 2;
586868bd00fSLiam Girdwood 
587868bd00fSLiam Girdwood 		snd_mask_none(fmt);
588868bd00fSLiam Girdwood 		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
589868bd00fSLiam Girdwood 
590868bd00fSLiam Girdwood 		return 0;
591868bd00fSLiam Girdwood 	}
592868bd00fSLiam Girdwood 
593*b243b437SRanjani Sridharan 	if (pcm_ops->dai_link_fixup)
594*b243b437SRanjani Sridharan 		return pcm_ops->dai_link_fixup(rtd, params);
595868bd00fSLiam Girdwood 
596868bd00fSLiam Girdwood 	return 0;
597868bd00fSLiam Girdwood }
598f3f3af17SPierre-Louis Bossart EXPORT_SYMBOL(sof_pcm_dai_link_fixup);
599868bd00fSLiam Girdwood 
600868bd00fSLiam Girdwood static int sof_pcm_probe(struct snd_soc_component *component)
601868bd00fSLiam Girdwood {
602868bd00fSLiam Girdwood 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
603868bd00fSLiam Girdwood 	struct snd_sof_pdata *plat_data = sdev->pdata;
604868bd00fSLiam Girdwood 	const char *tplg_filename;
605868bd00fSLiam Girdwood 	int ret;
606868bd00fSLiam Girdwood 
607868bd00fSLiam Girdwood 	/* load the default topology */
608868bd00fSLiam Girdwood 	sdev->component = component;
609868bd00fSLiam Girdwood 
610868bd00fSLiam Girdwood 	tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
611868bd00fSLiam Girdwood 				       "%s/%s",
612868bd00fSLiam Girdwood 				       plat_data->tplg_filename_prefix,
613868bd00fSLiam Girdwood 				       plat_data->tplg_filename);
614868bd00fSLiam Girdwood 	if (!tplg_filename)
615868bd00fSLiam Girdwood 		return -ENOMEM;
616868bd00fSLiam Girdwood 
617ee1e79b7SRanjani Sridharan 	ret = snd_sof_load_topology(component, tplg_filename);
618868bd00fSLiam Girdwood 	if (ret < 0) {
619ee1e79b7SRanjani Sridharan 		dev_err(component->dev, "error: failed to load DSP topology %d\n",
620868bd00fSLiam Girdwood 			ret);
621868bd00fSLiam Girdwood 		return ret;
622868bd00fSLiam Girdwood 	}
623868bd00fSLiam Girdwood 
624868bd00fSLiam Girdwood 	return ret;
625868bd00fSLiam Girdwood }
626868bd00fSLiam Girdwood 
627868bd00fSLiam Girdwood static void sof_pcm_remove(struct snd_soc_component *component)
628868bd00fSLiam Girdwood {
629868bd00fSLiam Girdwood 	/* remove topology */
630a5b8f71cSAmadeusz Sławiński 	snd_soc_tplg_component_remove(component);
631868bd00fSLiam Girdwood }
632868bd00fSLiam Girdwood 
6334a39ea3fSRanjani Sridharan static int sof_pcm_ack(struct snd_soc_component *component,
6344a39ea3fSRanjani Sridharan 		       struct snd_pcm_substream *substream)
6354a39ea3fSRanjani Sridharan {
6364a39ea3fSRanjani Sridharan 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
6374a39ea3fSRanjani Sridharan 
6384a39ea3fSRanjani Sridharan 	return snd_sof_pcm_platform_ack(sdev, substream);
6394a39ea3fSRanjani Sridharan }
6404a39ea3fSRanjani Sridharan 
641868bd00fSLiam Girdwood void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
642868bd00fSLiam Girdwood {
643868bd00fSLiam Girdwood 	struct snd_soc_component_driver *pd = &sdev->plat_drv;
644868bd00fSLiam Girdwood 	struct snd_sof_pdata *plat_data = sdev->pdata;
645868bd00fSLiam Girdwood 	const char *drv_name;
646868bd00fSLiam Girdwood 
647868bd00fSLiam Girdwood 	drv_name = plat_data->machine->drv_name;
648868bd00fSLiam Girdwood 
649868bd00fSLiam Girdwood 	pd->name = "sof-audio-component";
650868bd00fSLiam Girdwood 	pd->probe = sof_pcm_probe;
651868bd00fSLiam Girdwood 	pd->remove = sof_pcm_remove;
6521c91d77eSKuninori Morimoto 	pd->open = sof_pcm_open;
6531c91d77eSKuninori Morimoto 	pd->close = sof_pcm_close;
6541c91d77eSKuninori Morimoto 	pd->hw_params = sof_pcm_hw_params;
6551c91d77eSKuninori Morimoto 	pd->prepare = sof_pcm_prepare;
6561c91d77eSKuninori Morimoto 	pd->hw_free = sof_pcm_hw_free;
6571c91d77eSKuninori Morimoto 	pd->trigger = sof_pcm_trigger;
6581c91d77eSKuninori Morimoto 	pd->pointer = sof_pcm_pointer;
6594a39ea3fSRanjani Sridharan 	pd->ack = sof_pcm_ack;
6601c91d77eSKuninori Morimoto 
66176cdd90bSDaniel Baluta #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
66276cdd90bSDaniel Baluta 	pd->compress_ops = &sof_compressed_ops;
66376cdd90bSDaniel Baluta #endif
66476cdd90bSDaniel Baluta 
6651c91d77eSKuninori Morimoto 	pd->pcm_construct = sof_pcm_new;
666868bd00fSLiam Girdwood 	pd->ignore_machine = drv_name;
667868bd00fSLiam Girdwood 	pd->be_hw_params_fixup = sof_pcm_dai_link_fixup;
668868bd00fSLiam Girdwood 	pd->be_pcm_base = SOF_BE_PCM_BASE;
669868bd00fSLiam Girdwood 	pd->use_dai_pcm_id = true;
670868bd00fSLiam Girdwood 	pd->topology_name_prefix = "sof";
671868bd00fSLiam Girdwood 
672868bd00fSLiam Girdwood 	 /* increment module refcount when a pcm is opened */
673868bd00fSLiam Girdwood 	pd->module_get_upon_open = 1;
674868bd00fSLiam Girdwood }
675