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

Commit fb8ccbe1 authored by Haynes Mathew George's avatar Haynes Mathew George
Browse files

ASoC: msm: compr: Ensure drain sequence is executed



This change ensures drain sequence is executed even if
a pause/resume commands are sent from userspace while
the control thread is waiting for all buffers to be consumed
by DSP.
CRs-Fixed: 711920

Change-Id: I6ffcc072e00fa1865b0484f54fa6b070c1a73cf2
Signed-off-by: default avatarHaynes Mathew George <hgeorge@codeaurora.org>
parent 3c4a9994
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -441,6 +441,28 @@ static void compr_event_handler(uint32_t opcode,
				} else
					msm_compr_send_buffer(prtd);
			}

			/*
			 * The condition below ensures playback finishes in the
			 * follow cornercase
			 * WRITE(last buffer)
			 * WAIT_FOR_DRAIN
			 * PAUSE
			 * WRITE_DONE(X)
			 * RESUME
			 */
			if ((prtd->copied_total == prtd->bytes_sent) &&
			    atomic_read(&prtd->drain)) {
				pr_debug("RUN ack, wake up & continue pending drain\n");

				if (prtd->last_buffer)
					prtd->last_buffer = 0;

				prtd->drain_ready = 1;
				wake_up(&prtd->drain_wait);
				atomic_set(&prtd->drain, 0);
			}

			spin_unlock_irqrestore(&prtd->lock, flags);
			break;
		case ASM_STREAM_CMD_FLUSH:
@@ -1109,7 +1131,7 @@ static int msm_compr_drain_buffer(struct msm_compr_audio *prtd,
					prtd->drain_ready ||
					prtd->cmd_interrupt ||
					atomic_read(&prtd->xrun));
	pr_debug("%s: out of buffer drain wait\n", __func__);
	pr_debug("%s: out of buffer drain wait with ret %d\n", __func__, rc);
	spin_lock_irqsave(&prtd->lock, *flags);
	if (prtd->cmd_interrupt) {
		pr_debug("%s: buffer drain interrupted by flush)\n", __func__);