Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 61fc060c authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown
Browse files

ASoC: wm_adsp: Support streams which can start/stop with DSP active



Clear the buffer data structure on each trigger start such that the
buffer is in a sensible state even if the DSP itself didn't restart.
This is necessary to support voice control streams which can trigger
multiple times without reloading the firmware.

Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent e21a5acf
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -3258,6 +3258,13 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
	return 0;
}

static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf)
{
	buf->irq_count = 0xFFFFFFFF;
	buf->read_index = -1;
	buf->avail = 0;
}

static int wm_adsp_buffer_init(struct wm_adsp *dsp)
{
	struct wm_adsp_compr_buf *buf;
@@ -3268,8 +3275,8 @@ static int wm_adsp_buffer_init(struct wm_adsp *dsp)
		return -ENOMEM;

	buf->dsp = dsp;
	buf->read_index = -1;
	buf->irq_count = 0xFFFFFFFF;

	wm_adsp_buffer_clear(buf);

	ret = wm_adsp_buffer_locate(buf);
	if (ret < 0) {
@@ -3327,15 +3334,16 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
		if (wm_adsp_compr_attached(compr))
			break;

		if (!wm_adsp_compr_attached(compr)) {
			ret = wm_adsp_compr_attach(compr);
			if (ret < 0) {
				adsp_err(dsp, "Failed to link buffer and stream: %d\n",
					 ret);
				break;
			}
		}

		wm_adsp_buffer_clear(compr->buf);

		/* Trigger the IRQ at one fragment of data */
		ret = wm_adsp_buffer_write(compr->buf,