From 2985dc735db23d5bb74ba8f4277dbb3f19e12022 Mon Sep 17 00:00:00 2001
From: Banajit Goswami <bgoswami@codeaurora.org>
Date: Mon, 7 Jul 2014 18:16:02 -0700
Subject: [PATCH] ASoC: qdsp6v2: update perf mode flag for LL capture cases

Read perf mode flag from platform data and update to the
audio client structure, so that the right settings can be
applied to ADM for Low-latency capture use-case.
Also, update the correct bit value for ASM perf mode flag
sent to DSP.

Bug: 18869497
Change-Id: If1f8b9e657a409fd9d2af19ff004a797fd987788
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
Signed-off-by: Glenn Kasten <gkasten@google.com>
---
 include/sound/apr_audio-v2.h          |  3 +++
 sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c | 11 +++++++++++
 sound/soc/msm/qdsp6v2/q6asm.c         |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h
index ed1f80c501f6..37d44914140e 100644
--- a/include/sound/apr_audio-v2.h
+++ b/include/sound/apr_audio-v2.h
@@ -4145,6 +4145,9 @@ struct asm_stream_cmd_open_write_v3 {
 /* Absolute timestamp is identified by this value.*/
 #define ASM_ABSOLUTEIMESTAMP      1
 
+/* Bit value for Low Latency Tx stream subfield */
+#define ASM_LOW_LATENCY_TX_STREAM_SESSION			1
+
 /* Bit shift for the stream_perf_mode subfield. */
 #define ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ              29
 
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
index ab5a0f330ae1..0855ae2016a8 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
@@ -323,17 +323,28 @@ static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct msm_audio *prtd = runtime->private_data;
 	struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
+	struct msm_plat_data *pdata;
 	struct snd_pcm_hw_params *params;
 	struct msm_pcm_routing_evt event;
 	int ret = 0;
 	int i = 0;
 	uint16_t bits_per_sample = 16;
 
+	pdata = (struct msm_plat_data *)
+		dev_get_drvdata(soc_prtd->platform->dev);
+	if (!pdata) {
+		pr_err("%s: platform data not populated\n", __func__);
+		return -EINVAL;
+	}
+
 	pr_debug("%s\n", __func__);
 	params = &soc_prtd->dpcm[substream->stream].hw_params;
 	if (params_format(params) == SNDRV_PCM_FORMAT_S24_LE)
 		bits_per_sample = 24;
 
+	prtd->audio_client->perf_mode = pdata->perf_mode;
+	pr_debug("%s: perf_mode: 0x%x\n", __func__, pdata->perf_mode);
+
 	pr_debug("%s Opening %d-ch PCM read stream\n",
 			__func__, params_channels(params));
 	ret = q6asm_open_read_v2(prtd->audio_client, FORMAT_LINEAR_PCM,
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
index eaf644eac2e9..cbc88b7f118d 100644
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ b/sound/soc/msm/qdsp6v2/q6asm.c
@@ -1768,7 +1768,7 @@ static int __q6asm_open_read(struct audio_client *ac,
 	open.mode_flags = 0x0;
 
 	if (ac->perf_mode == LOW_LATENCY_PCM_MODE) {
-		open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION <<
+		open.mode_flags |= ASM_LOW_LATENCY_TX_STREAM_SESSION <<
 				ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ;
 	} else {
 		open.mode_flags |= ASM_LEGACY_STREAM_SESSION <<
-- 
GitLab