Skip to content

Commit ae3a391

Browse files
plbossartbroonie
authored andcommitted
ASoC: Intel: sof_sdw: add dailink .trigger callback
Add trigger functionality to dailink, so far only .startup() and .shutdown() were implemented at the machine driver level. The companion patch for this patch is the removal of the trigger callback 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-3-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d20e834 commit ae3a391

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

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

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

228+
static int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
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+
int ret;
234+
235+
/* Find stream from first CPU DAI */
236+
dai = asoc_rtd_to_cpu(rtd, 0);
237+
238+
sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream);
239+
240+
if (IS_ERR(sdw_stream)) {
241+
dev_err(rtd->dev, "no stream found for DAI %s", dai->name);
242+
return PTR_ERR(sdw_stream);
243+
}
244+
245+
switch (cmd) {
246+
case SNDRV_PCM_TRIGGER_START:
247+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
248+
case SNDRV_PCM_TRIGGER_RESUME:
249+
ret = sdw_enable_stream(sdw_stream);
250+
break;
251+
252+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
253+
case SNDRV_PCM_TRIGGER_SUSPEND:
254+
case SNDRV_PCM_TRIGGER_STOP:
255+
ret = sdw_disable_stream(sdw_stream);
256+
break;
257+
default:
258+
ret = -EINVAL;
259+
break;
260+
}
261+
262+
if (ret)
263+
dev_err(rtd->dev, "%s trigger %d failed: %d", __func__, cmd, ret);
264+
265+
return ret;
266+
}
267+
228268
void sdw_shutdown(struct snd_pcm_substream *substream)
229269
{
230270
sdw_shutdown_stream(substream);
231271
}
232272

233273
static const struct snd_soc_ops sdw_ops = {
234274
.startup = sdw_startup,
275+
.trigger = sdw_trigger,
235276
.shutdown = sdw_shutdown,
236277
};
237278

0 commit comments

Comments
 (0)