ASoC: msm: Loopback Driver Reg Stream in Prepare Stage

Move the msm_pcm_routing_reg_phy_stream() to prepare stage.
Then it allows to set channel mixer configuration pre usecase start.

Change-Id: I1811c4d9bcbdd2bb1ee425044407a2c61e794a9a
Signed-off-by: Cong Tang <congt@codeaurora.org>
Signed-off-by: Viraja Kommaraju <virajak@codeaurora.org>
This commit is contained in:
Cong Tang 2019-08-27 16:21:06 +05:30 • committed by Viraja Kommaraju
commit d083a83b6e

View file

@ -252,7 +252,6 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
struct msm_pcm_loopback *pcm = NULL;
int ret = 0;
uint16_t bits_per_sample = 16;
struct msm_pcm_routing_evt event;
struct asm_session_mtmx_strtr_param_window_v2_t asm_mtmx_strtr_window;
uint32_t param_id;
struct msm_pcm_pdata *pdata;
@ -279,10 +278,6 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
dev_dbg(component->dev, "%s: pcm out open: %d,%d\n", __func__,
pcm->instance, substream->stream);
if (pcm->instance == 2) {
struct snd_soc_pcm_runtime *soc_pcm_rx =
pcm->playback_substream->private_data;
struct snd_soc_pcm_runtime *soc_pcm_tx =
pcm->capture_substream->private_data;
if (pcm->audio_client != NULL)
stop_pcm(pcm);
@ -314,15 +309,6 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
mutex_unlock(&pcm->lock);
return -ENOMEM;
}
event.event_func = msm_pcm_route_event_handler;
event.priv_data = (void *) pcm;
msm_pcm_routing_reg_phy_stream(soc_pcm_tx->dai_link->id,
pcm->audio_client->perf_mode,
pcm->session_id, pcm->capture_substream->stream);
msm_pcm_routing_reg_phy_stream_v2(soc_pcm_rx->dai_link->id,
pcm->audio_client->perf_mode,
pcm->session_id, pcm->playback_substream->stream,
event);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
pcm->playback_substream = substream;
ret = pcm_loopback_set_volume(pcm, pcm->volume);
@ -442,7 +428,9 @@ static int msm_pcm_prepare(struct snd_pcm_substream *substream)
struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct msm_pcm_routing_evt event;
memset(&event, 0, sizeof(event));
if (!component) {
pr_err("%s: component is NULL\n", __func__);
return -EINVAL;
@ -452,6 +440,12 @@ static int msm_pcm_prepare(struct snd_pcm_substream *substream)
dev_dbg(component->dev, "%s: ASM loopback stream:%d\n",
__func__, substream->stream);
if (pcm->playback_start && pcm->capture_start) {
mutex_unlock(&pcm->lock);
return ret;
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
if (!pcm->playback_start)
pcm->playback_start = 1;
@ -459,6 +453,23 @@ static int msm_pcm_prepare(struct snd_pcm_substream *substream)
if (!pcm->capture_start)
pcm->capture_start = 1;
}
if (pcm->playback_start && pcm->capture_start) {
struct snd_soc_pcm_runtime *soc_pcm_rx =
pcm->playback_substream->private_data;
struct snd_soc_pcm_runtime *soc_pcm_tx =
pcm->capture_substream->private_data;
event.event_func = msm_pcm_route_event_handler;
event.priv_data = (void *) pcm;
msm_pcm_routing_reg_phy_stream(soc_pcm_tx->dai_link->id,
pcm->audio_client->perf_mode,
pcm->session_id, pcm->capture_substream->stream);
msm_pcm_routing_reg_phy_stream_v2(soc_pcm_rx->dai_link->id,
pcm->audio_client->perf_mode,
pcm->session_id, pcm->playback_substream->stream,
event);
}
mutex_unlock(&pcm->lock);
return ret;