summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Jain <ashishj@codeaurora.org>2016-02-16 21:04:07 +0530
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 21:21:16 -0700
commit9d07dff310542464dbd1d32ad89e6d5657d9ff55 (patch)
treefbb59228839434b49bd181662e2bd4a1c3f148a9
parent705109f05d240c875989b59101b8d203e45bbeb4 (diff)
ASoC: msm: Use legacy ASM APIs for older targets
With 3.18 kernel, get_session_time command to DSP is updated to new command. This command is not supported on older targets as they have an older DSP version. To have backwards compatibility, based on DSP version choose which command to use. CRs-Fixed: 978676 Change-Id: I76b0cfcd84df90d7a206690cb8aa1eb773fdc53d Signed-off-by: Ashish Jain <ashishj@codeaurora.org>
-rwxr-xr-xDocumentation/devicetree/bindings/sound/qcom-audio-dev.txt8
-rw-r--r--include/sound/q6asm-v2.h4
-rwxr-xr-xsound/soc/msm/qdsp6v2/msm-compress-q6-v2.c35
-rw-r--r--sound/soc/msm/qdsp6v2/q6asm.c47
4 files changed, 89 insertions, 5 deletions
diff --git a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
index f3bb265da565..d34bc841863d 100755
--- a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
+++ b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
@@ -51,6 +51,14 @@ Required properties:
- compatible : "qcom,msm-compress-dsp"
+Optional properties
+ - qcom,adsp-version:
+ This property can be used to specify the ADSP version/name.
+ Based on ADSP version, we decide if we have to use older
+ ADSP APIs or newer. Right now we are adding "MDSP 1.2" for
+ 8909 purpose.If the ADSP version is anything other than this
+ we use new ADSP APIs.
+
* msm-voip-dsp
Required properties:
diff --git a/include/sound/q6asm-v2.h b/include/sound/q6asm-v2.h
index 44c216907006..1a0471dac0b3 100644
--- a/include/sound/q6asm-v2.h
+++ b/include/sound/q6asm-v2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -456,6 +456,8 @@ int q6asm_set_mute(struct audio_client *ac, int muteflag);
int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
+int q6asm_get_session_time_legacy(struct audio_client *ac, uint64_t *tstamp);
+
int q6asm_send_audio_effects_params(struct audio_client *ac, char *params,
uint32_t params_length);
diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
index 796fbe6d1e8a..f8144340a1dd 100755
--- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
@@ -110,6 +110,7 @@ struct msm_compr_pdata {
uint32_t volume[MSM_FRONTEND_DAI_MAX][2]; /* For both L & R */
struct msm_compr_audio_effects *audio_effects[MSM_FRONTEND_DAI_MAX];
bool use_dsp_gapless_mode;
+ bool use_legacy_api; /* indicates use older asm apis*/
struct msm_compr_dec_params *dec_params[MSM_FRONTEND_DAI_MAX];
struct msm_compr_ch_map *ch_map[MSM_FRONTEND_DAI_MAX];
};
@@ -1748,8 +1749,14 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
/*
* Cache this time as last known time
*/
- q6asm_get_session_time(prtd->audio_client,
- &prtd->marker_timestamp);
+ if (pdata->use_legacy_api)
+ q6asm_get_session_time_legacy(
+ prtd->audio_client,
+ &prtd->marker_timestamp);
+ else
+ q6asm_get_session_time(prtd->audio_client,
+ &prtd->marker_timestamp);
+
spin_lock_irqsave(&prtd->lock, flags);
/*
* Don't reset these as these vars map to
@@ -1879,13 +1886,16 @@ static int msm_compr_pointer(struct snd_compr_stream *cstream,
struct snd_compr_tstamp *arg)
{
struct snd_compr_runtime *runtime = cstream->runtime;
+ struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct msm_compr_audio *prtd = runtime->private_data;
+ struct msm_compr_pdata *pdata = NULL;
struct snd_compr_tstamp tstamp;
uint64_t timestamp = 0;
int rc = 0, first_buffer;
unsigned long flags;
uint32_t gapless_transition;
+ pdata = snd_soc_platform_get_drvdata(rtd->platform);
pr_debug("%s\n", __func__);
memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp));
@@ -1918,8 +1928,12 @@ static int msm_compr_pointer(struct snd_compr_stream *cstream,
if (gapless_transition)
pr_debug("%s session time in gapless transition",
__func__);
-
- rc = q6asm_get_session_time(prtd->audio_client, &timestamp);
+ if (pdata->use_legacy_api)
+ rc = q6asm_get_session_time_legacy(prtd->audio_client,
+ &timestamp);
+ else
+ rc = q6asm_get_session_time(prtd->audio_client,
+ &timestamp);
if (rc < 0) {
pr_err("%s: Get Session Time return value =%lld\n",
__func__, timestamp);
@@ -2767,6 +2781,8 @@ static int msm_compr_probe(struct snd_soc_platform *platform)
{
struct msm_compr_pdata *pdata;
int i;
+ int rc;
+ const char *qdsp_version;
pr_debug("%s\n", __func__);
pdata = (struct msm_compr_pdata *)
@@ -2788,6 +2804,17 @@ static int msm_compr_probe(struct snd_soc_platform *platform)
snd_soc_add_platform_controls(platform, msm_compr_gapless_controls,
ARRAY_SIZE(msm_compr_gapless_controls));
+ rc = of_property_read_string(platform->dev->of_node,
+ "qcom,adsp-version", &qdsp_version);
+ if (!rc) {
+ if (!strcmp(qdsp_version, "MDSP 1.2"))
+ pdata->use_legacy_api = true;
+ else
+ pdata->use_legacy_api = false;
+ } else
+ pdata->use_legacy_api = false;
+
+ pr_debug("%s: use legacy api %d\n", __func__, pdata->use_legacy_api);
/*
* use_dsp_gapless_mode part of platform data(pdata) is updated from HAL
* through a mixer control before compress driver is opened. The mixer
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
index 7af684ea30b2..df310b81c8e3 100644
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ b/sound/soc/msm/qdsp6v2/q6asm.c
@@ -5979,6 +5979,53 @@ fail_cmd:
return -EINVAL;
}
+int q6asm_get_session_time_legacy(struct audio_client *ac, uint64_t *tstamp)
+{
+ struct apr_hdr hdr;
+ int rc;
+
+ if (ac == NULL) {
+ pr_err("%s: APR handle NULL\n", __func__);
+ return -EINVAL;
+ }
+ if (ac->apr == NULL) {
+ pr_err("%s: AC APR handle NULL\n", __func__);
+ return -EINVAL;
+ }
+ if (tstamp == NULL) {
+ pr_err("%s: tstamp NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ q6asm_add_hdr(ac, &hdr, sizeof(hdr), TRUE);
+ hdr.opcode = ASM_SESSION_CMD_GET_SESSIONTIME_V3;
+ atomic_set(&ac->time_flag, 1);
+
+ dev_vdbg(ac->dev, "%s: session[%d]opcode[0x%x]\n", __func__,
+ ac->session,
+ hdr.opcode);
+ rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr);
+ if (rc < 0) {
+ pr_err("%s: Commmand 0x%x failed %d\n",
+ __func__, hdr.opcode, rc);
+ goto fail_cmd;
+ }
+ rc = wait_event_timeout(ac->time_wait,
+ (atomic_read(&ac->time_flag) == 0), 5*HZ);
+ if (!rc) {
+ pr_err("%s: timeout in getting session time from DSP\n",
+ __func__);
+ goto fail_cmd;
+ }
+
+ *tstamp = ac->time_stamp;
+ return 0;
+
+fail_cmd:
+ return -EINVAL;
+}
+
+
int q6asm_send_audio_effects_params(struct audio_client *ac, char *params,
uint32_t params_length)
{