From 6d8bda3545fdf2698af669761eb9c74a282eb027 Mon Sep 17 00:00:00 2001 From: Xiaoyu Ye Date: Sun, 16 Jun 2019 23:53:09 -0700 Subject: [PATCH] asoc: msm-lsm-client: reset app type configs at msm_lsm_close Currently lsm client driver doesn't reset app type configs at the end of a session, which causes the previous lsm session's acdb_dev_id to be cached and reused in the new lsm sessions. Fix this by resetting app type configs at msm_lsm_close to set acdb_dev_id to 0. Change-Id: I2c51201291beb1d4baa4d57c0d5c1ef9777a85ed Signed-off-by: Xiaoyu Ye --- asoc/msm-lsm-client.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/asoc/msm-lsm-client.c b/asoc/msm-lsm-client.c index f886b4b78872..5bc897d9e594 100644 --- a/asoc/msm-lsm-client.c +++ b/asoc/msm-lsm-client.c @@ -2624,7 +2624,10 @@ static int msm_lsm_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct lsm_priv *prtd = runtime->private_data; struct snd_soc_pcm_runtime *rtd; + struct msm_pcm_stream_app_type_cfg cfg_data = {0}; int ret = 0; + int be_id = 0; + int fe_id = 0; if (!substream->private_data) { pr_err("%s: Invalid private_data", __func__); @@ -2690,6 +2693,37 @@ static int msm_lsm_close(struct snd_pcm_substream *substream) q6lsm_close(prtd->lsm_client); prtd->lsm_client->opened = false; } + + fe_id = prtd->lsm_client->fe_id; + ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, SESSION_TYPE_TX, + &be_id, &cfg_data); + if (ret < 0) + dev_dbg(rtd->dev, + "%s: get stream app type cfg failed, err = %d\n", + __func__, ret); + /* + * be_id will be 0 in case of LSM directly connects to AFE due to + * last_be_id_configured[fedai_id][session_type] has not been updated. + * And then the cfg_data from wrong combination would be reset without + * this if check. We reset only if app_type, acdb_dev_id, and sample_rate + * are valid. + */ + if (!cfg_data.app_type && + !cfg_data.acdb_dev_id && !cfg_data.sample_rate) { + dev_dbg(rtd->dev, "%s: no need to reset app type configs\n", + __func__); + } else { + memset(&cfg_data, 0, sizeof(cfg_data)); + ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, + SESSION_TYPE_TX, + be_id, + &cfg_data); + if (ret < 0) + dev_dbg(rtd->dev, + "%s: set stream app type cfg failed, err = %d\n", + __func__, ret); + } + q6lsm_client_free(prtd->lsm_client); spin_lock_irqsave(&prtd->event_lock, flags);