Merge "ASoC: msm: Loopback Driver Reg Stream in Prepare Stage"

This commit is contained in:
qctecmdr
2019-09-06 11:21:14 -07:00
committed by Gerrit - the friendly Code Review server

Fájl megtekintése

@@ -252,7 +252,6 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
struct msm_pcm_loopback *pcm = NULL; struct msm_pcm_loopback *pcm = NULL;
int ret = 0; int ret = 0;
uint16_t bits_per_sample = 16; 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; struct asm_session_mtmx_strtr_param_window_v2_t asm_mtmx_strtr_window;
uint32_t param_id; uint32_t param_id;
struct msm_pcm_pdata *pdata; 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__, dev_dbg(component->dev, "%s: pcm out open: %d,%d\n", __func__,
pcm->instance, substream->stream); pcm->instance, substream->stream);
if (pcm->instance == 2) { 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) if (pcm->audio_client != NULL)
stop_pcm(pcm); stop_pcm(pcm);
@@ -314,15 +309,6 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
mutex_unlock(&pcm->lock); mutex_unlock(&pcm->lock);
return -ENOMEM; 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) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
pcm->playback_substream = substream; pcm->playback_substream = substream;
ret = pcm_loopback_set_volume(pcm, pcm->volume); 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_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
struct snd_soc_component *component = struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME); snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct msm_pcm_routing_evt event;
memset(&event, 0, sizeof(event));
if (!component) { if (!component) {
pr_err("%s: component is NULL\n", __func__); pr_err("%s: component is NULL\n", __func__);
return -EINVAL; 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", dev_dbg(component->dev, "%s: ASM loopback stream:%d\n",
__func__, substream->stream); __func__, substream->stream);
if (pcm->playback_start && pcm->capture_start) {
mutex_unlock(&pcm->lock);
return ret;
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
if (!pcm->playback_start) if (!pcm->playback_start)
pcm->playback_start = 1; pcm->playback_start = 1;
@@ -459,6 +453,23 @@ static int msm_pcm_prepare(struct snd_pcm_substream *substream)
if (!pcm->capture_start) if (!pcm->capture_start)
pcm->capture_start = 1; 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); mutex_unlock(&pcm->lock);
return ret; return ret;