Skip to content

Commit 06998d4

Browse files
plbossartbroonie
authored andcommitted
ASoC: Intel: sof_sdw: add dailink .prepare and .hw_free callback
Add .prepare and .hw_free callback to dailink. The companion patch for this patch is the removal of stream operations in the .prepare and .hw_free callbacks at the DAI level in drivers/soundwire/intel.c Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20200904182854.3944-4-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ae3a391 commit 06998d4

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎sound/soc/intel/boards/sof_sdw.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,25 @@ int sdw_startup(struct snd_pcm_substream *substream)
225225
return sdw_startup_stream(substream);
226226
}
227227

228+
static int sdw_prepare(struct snd_pcm_substream *substream)
229+
{
230+
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
231+
struct sdw_stream_runtime *sdw_stream;
232+
struct snd_soc_dai *dai;
233+
234+
/* Find stream from first CPU DAI */
235+
dai = asoc_rtd_to_cpu(rtd, 0);
236+
237+
sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream);
238+
239+
if (IS_ERR(sdw_stream)) {
240+
dev_err(rtd->dev, "no stream found for DAI %s", dai->name);
241+
return PTR_ERR(sdw_stream);
242+
}
243+
244+
return sdw_prepare_stream(sdw_stream);
245+
}
246+
228247
static int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
229248
{
230249
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
@@ -265,14 +284,35 @@ static int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
265284
return ret;
266285
}
267286

287+
static int sdw_hw_free(struct snd_pcm_substream *substream)
288+
{
289+
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
290+
struct sdw_stream_runtime *sdw_stream;
291+
struct snd_soc_dai *dai;
292+
293+
/* Find stream from first CPU DAI */
294+
dai = asoc_rtd_to_cpu(rtd, 0);
295+
296+
sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream);
297+
298+
if (IS_ERR(sdw_stream)) {
299+
dev_err(rtd->dev, "no stream found for DAI %s", dai->name);
300+
return PTR_ERR(sdw_stream);
301+
}
302+
303+
return sdw_deprepare_stream(sdw_stream);
304+
}
305+
268306
void sdw_shutdown(struct snd_pcm_substream *substream)
269307
{
270308
sdw_shutdown_stream(substream);
271309
}
272310

273311
static const struct snd_soc_ops sdw_ops = {
274312
.startup = sdw_startup,
313+
.prepare = sdw_prepare,
275314
.trigger = sdw_trigger,
315+
.hw_free = sdw_hw_free,
276316
.shutdown = sdw_shutdown,
277317
};
278318

0 commit comments

Comments
 (0)