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

Commit 0be40a35 authored by Damir Didjusto's avatar Damir Didjusto Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: msm: Handle data loss at device switch for FM



- When device switch happens there are underflow errors
in LPASS. And there is some break in audio observed for
around 2 sec.
- To handle this, ASM run command needs to be sent again
to DSP at device switch.

Change-Id: I7d5e279796db190c454b3d1b39ad9add8f933319
Signed-off-by: default avatarDamir Didjusto <damird@codeaurora.org>
Signed-off-by: default avatarVimal Puthanveed <vimalp@codeaurora.org>
parent 444ef0c3
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -68,6 +68,25 @@ static const struct snd_pcm_hardware dummy_pcm_hardware = {
	.periods_max            = 128,
};

static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event,
					void *priv_data)
{
	struct msm_pcm_loopback *pcm = priv_data;

	BUG_ON(!pcm);

	pr_debug("%s: event %x\n", __func__, event);

	switch (event) {
	case MSM_PCM_RT_EVT_DEVSWITCH:
		q6asm_cmd(pcm->audio_client, CMD_PAUSE);
		q6asm_cmd(pcm->audio_client, CMD_FLUSH);
		q6asm_run(pcm->audio_client, 0, 0, 0);
	default:
		break;
	}
}

static void msm_pcm_loopback_event_handler(uint32_t opcode, uint32_t token,
					   uint32_t *payload, void *priv)
{
@@ -112,6 +131,7 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
	struct msm_pcm_loopback *pcm;
	int ret = 0;
	uint16_t bits_per_sample = 16;
	struct msm_pcm_routing_evt event;

	pcm = dev_get_drvdata(rtd->platform->dev);
	mutex_lock(&pcm->lock);
@@ -154,12 +174,15 @@ 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->be_id,
			pcm->audio_client->perf_mode,
			pcm->session_id, pcm->capture_substream->stream);
		msm_pcm_routing_reg_phy_stream(soc_pcm_rx->dai_link->be_id,
		msm_pcm_routing_reg_phy_stream_v2(soc_pcm_rx->dai_link->be_id,
			pcm->audio_client->perf_mode,
			pcm->session_id, pcm->playback_substream->stream);
			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);
+6 −0
Original line number Diff line number Diff line
@@ -682,6 +682,12 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
				topology, fe_dai_perf_mode[val][session_type],
				bits_per_sample);

			if (session_type == SESSION_TYPE_RX &&
			    fdai->event_info.event_func)
				fdai->event_info.event_func(
					MSM_PCM_RT_EVT_DEVSWITCH,
					fdai->event_info.priv_data);

			msm_pcm_routing_build_matrix(val,
				fdai->strm_id, path_type,
				fe_dai_perf_mode[val][session_type]);
+1 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ enum {

enum msm_pcm_routing_event {
	MSM_PCM_RT_EVT_BUF_RECFG,
	MSM_PCM_RT_EVT_DEVSWITCH,
	MSM_PCM_RT_EVT_MAX,
};