Skip to content

Commit 787fa0e

Browse files
committed
ASoC: SOF: Intel: hda: Remove hda_dai_hw_free_ipc()
And replace with the post_trigger() DAI DMA op during hda_dai_suspend() and the dai_config() DAI op during hda_dai_hw_free(). Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent bff6d2d commit 787fa0e

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

sound/soc/sof/intel/hda-dai.c

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,6 @@ static int hda_link_dma_hw_free(struct snd_pcm_substream *substream, struct snd_
134134
return hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai);
135135
}
136136

137-
static int hda_dai_widget_update(struct snd_soc_dapm_widget *w,
138-
int channel, bool widget_setup)
139-
{
140-
struct snd_sof_dai_config_data data;
141-
142-
data.dai_data = channel;
143-
144-
/* set up/free DAI widget and send DAI_CONFIG IPC */
145-
if (widget_setup)
146-
return hda_ctrl_dai_widget_setup(w, SOF_DAI_CONFIG_FLAGS_2_STEP_STOP, &data);
147-
148-
return hda_ctrl_dai_widget_free(w, SOF_DAI_CONFIG_FLAGS_NONE, &data);
149-
}
150-
151137
static int hda_dai_hw_params(struct snd_pcm_substream *substream,
152138
struct snd_pcm_hw_params *params,
153139
struct snd_soc_dai *dai)
@@ -210,17 +196,6 @@ static int hda_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_d
210196
return 0;
211197
}
212198

213-
static int hda_dai_hw_free_ipc(int stream, /* direction */
214-
struct snd_soc_dai *dai)
215-
{
216-
struct snd_soc_dapm_widget *w;
217-
218-
w = snd_soc_dai_get_widget(dai, stream);
219-
220-
/* free the link DMA channel in the FW and the DAI widget */
221-
return hda_dai_widget_update(w, DMA_CHAN_INVALID, false);
222-
}
223-
224199
/*
225200
* In contrast to IPC3, the dai trigger in IPC4 mixes pipeline state changes
226201
* (over IPC channel) and DMA state change (direct host register changes).
@@ -284,13 +259,21 @@ static int hda_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct
284259
static int hda_dai_hw_free(struct snd_pcm_substream *substream,
285260
struct snd_soc_dai *dai)
286261
{
262+
struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, substream->stream);
263+
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(dai->component);
264+
struct snd_sof_widget *swidget = w->dobj.private;
265+
struct snd_sof_dai *sdai = swidget->private;
266+
const struct snd_sof_dai_ops *ops = sdai->ops;
287267
int ret;
288268

289269
ret = hda_link_dma_hw_free(substream, dai);
290270
if (ret < 0)
291271
return ret;
292272

293-
return hda_dai_hw_free_ipc(substream->stream, dai);
273+
if (ops && ops->dai_config)
274+
return ops->dai_config(sdev, w, DMA_CHAN_INVALID, SOF_DAI_CONFIG_FLAGS_NONE);
275+
276+
return 0;
294277
}
295278

296279
static const struct snd_soc_dai_ops hda_dai_ops = {
@@ -319,23 +302,37 @@ static int hda_dai_suspend(struct hdac_bus *bus)
319302
* explicitly during suspend.
320303
*/
321304
if (hext_stream->link_substream) {
322-
struct snd_soc_dai *cpu_dai;
305+
const struct snd_sof_dai_ops *ops;
306+
struct snd_sof_widget *swidget;
307+
struct snd_soc_dapm_widget *w;
323308
struct snd_soc_dai *codec_dai;
309+
struct snd_soc_dai *cpu_dai;
310+
struct snd_sof_dev *sdev;
311+
struct snd_sof_dai *sdai;
324312

325313
rtd = asoc_substream_to_rtd(hext_stream->link_substream);
326314
cpu_dai = asoc_rtd_to_cpu(rtd, 0);
327315
codec_dai = asoc_rtd_to_codec(rtd, 0);
316+
w = snd_soc_dai_get_widget(cpu_dai, hdac_stream(hext_stream)->direction);
317+
swidget = w->dobj.private;
318+
sdev = snd_soc_component_get_drvdata(swidget->scomp);
319+
sdai = swidget->private;
320+
ops = sdai->ops;
328321

329322
ret = hda_link_dma_cleanup(hext_stream->link_substream,
330323
hext_stream,
331324
cpu_dai, codec_dai);
332325
if (ret < 0)
333326
return ret;
334327

335-
/* for consistency with TRIGGER_SUSPEND we free DAI resources */
336-
ret = hda_dai_hw_free_ipc(hdac_stream(hext_stream)->direction, cpu_dai);
337-
if (ret < 0)
338-
return ret;
328+
/* for consistency with TRIGGER_SUSPEND */
329+
if (ops && ops->dma_ops && ops->dma_ops->post_trigger) {
330+
ret = ops->dma_ops->post_trigger(sdev, cpu_dai,
331+
hext_stream->link_substream,
332+
SNDRV_PCM_TRIGGER_SUSPEND);
333+
if (ret < 0)
334+
return ret;
335+
}
339336
}
340337
}
341338

0 commit comments

Comments
 (0)