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

Commit 6a2b0cec authored by Vidyakumar Athota's avatar Vidyakumar Athota
Browse files

ASoC: msm-cpe-lsm: Queue 2 buffers with slimbus before afe start



When userspace requests small duration of buffer then it is possible
that the buffer can overflow if only one buffer is queued at a time.
This is because of more channel setup time than buffer size duration.
Queue two buffers with slimbus before starting AFE port to avoid
data loss.

Change-Id: Iabb6f6b1d0e3ee8227ed8be26a64e7eb025e7018
Signed-off-by: default avatarVidyakumar Athota <vathota@codeaurora.org>
parent 031e28bb
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -538,7 +538,8 @@ static int msm_cpe_lab_thread(void *data)
	bool wait_timedout = false;
	int rc = 0;
	u32 done_len = 0;
	u32 buf_count = 1;
	u32 buf_count = 0;
	u32 prd_cnt;

	allow_signal(SIGKILL);
	set_current_state(TASK_INTERRUPTIBLE);
@@ -604,8 +605,19 @@ static int msm_cpe_lab_thread(void *data)
			goto done;
		}

		rc = slim_port_xfer(dma_data->sdev, dma_data->ph,
				    lab_d->pcm_buf[1].phys,
				    hw_params->buf_sz, &lab_d->comp);
		if (rc) {
			dev_err(rtd->dev,
				"%s: buf[0] slim_port_xfer failed, err = %d\n",
				__func__, rc);
			goto done;
		}

		cur_buf = &lab_d->pcm_buf[0];
		next_buf = &lab_d->pcm_buf[1];
		next_buf = &lab_d->pcm_buf[2];
		prd_cnt = hw_params->period_count;
		rc = lsm_ops->lab_ch_setup(cpe->core_handle,
					   session,
					   WCD_CPE_POST_ENABLE);
@@ -674,14 +686,10 @@ static int msm_cpe_lab_thread(void *data)
			lab_d->dma_write += snd_pcm_lib_period_bytes(substream);
			snd_pcm_period_elapsed(substream);
			wake_up(&lab_d->period_wait);
			cur_buf = next_buf;
			if (buf_count >= (hw_params->period_count - 1)) {
				buf_count = 0;
				next_buf = &lab_d->pcm_buf[0];
			} else {
				next_buf = &lab_d->pcm_buf[buf_count + 1];
			buf_count++;
			}

			cur_buf = &lab_d->pcm_buf[buf_count % prd_cnt];
			next_buf = &lab_d->pcm_buf[(buf_count + 2) % prd_cnt];
			dev_dbg(rtd->dev,
				"%s: Cur buf.mem = %p Next Buf.mem = %p\n"
				" buf count = 0x%x\n", __func__,