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

Commit f531c9d4 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: msm-cpe-lsm: Skip prepare if stream is already prepared



It is possible that userspace may prepare the stream multiple times
without closing the stream. In such cases, preparing the CPE multiple
times can result into an error and eventually leading the userspace to
fail the stream setup. Fix this issue by skipping the stream prepare if
the stream is already prepared once.

Change-Id: Ia5cc3494812497dec46ff84a54711f7b7da6dcab
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent 727853d1
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ struct cpe_lsm_data {
	u8 ev_det_status;
	u8 ev_det_pld_size;
	u8 *ev_det_payload;

	bool cpe_prepared;
};

/*
@@ -760,6 +762,7 @@ static int msm_cpe_lsm_open(struct snd_pcm_substream *substream)
	lsm_d->lsm_session->started = false;
	lsm_d->substream = substream;
	init_waitqueue_head(&lsm_d->lab.period_wait);
	lsm_d->cpe_prepared = false;

	dev_dbg(rtd->dev, "%s: allocated session with id = %d\n",
		__func__, lsm_d->lsm_session->id);
@@ -848,6 +851,8 @@ static int msm_cpe_lsm_close(struct snd_pcm_substream *substream)
				   afe_ops, afe_cfg,
				   AFE_CMD_PORT_STOP);

	lsm_d->cpe_prepared = false;

	rc = lsm_ops->lsm_close_tx(cpe->core_handle, session);
	if (rc != 0) {
		dev_err(rtd->dev,
@@ -1983,6 +1988,13 @@ static int msm_cpe_lsm_prepare(struct snd_pcm_substream *substream)

	dev_dbg(rtd->dev,
		"%s: pcm_size 0x%x", __func__, lab_d->pcm_size);

	if (lsm_d->cpe_prepared) {
		dev_dbg(rtd->dev, "%s: CPE is alredy prepared\n",
			__func__);
		return 0;
	}

	afe_ops = &cpe->afe_ops;
	afe_cfg = &(lsm_d->lsm_session->afe_port_cfg);

@@ -2004,6 +2016,12 @@ static int msm_cpe_lsm_prepare(struct snd_pcm_substream *substream)
				   cpe->core_handle,
				   afe_ops, afe_cfg,
				   AFE_CMD_PORT_START);
	if (rc)
		dev_err(rtd->dev,
			"%s: cpe_afe_port start failed, err = %d\n",
			__func__, rc);
	else
		lsm_d->cpe_prepared = true;

	return rc;
}