summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSecurityBot AutoMerger <android-nexus-securitybot@system.gserviceaccount.com>2020-02-07 14:21:05 -0800
committerSecurityBot <android-nexus-securitybot@system.gserviceaccount.com>2020-02-07 14:21:05 -0800
commit2db65fb85a61c57b348a3ab1a71e99bd6ab8f8d5 (patch)
tree806587c34331fc7bf6c71bc2e08bb75905e66221
parent966bda4849e5453b44e69341217ee0706dafa27d (diff)
parentfd6c120fb118db17c9fb9c08d3667ced9a9aa134 (diff)
downloadmsm-extra-android-msm-bonito-4.9-android10-qpr2.tar.gz
SBMerger: 284775313 Change-Id: Ifc862d5537e23e5b5235f20f4246bbfc195f4c12 Signed-off-by: SecurityBot <android-nexus-securitybot@system.gserviceaccount.com>
-rw-r--r--asoc/msm-pcm-loopback-v2.c12
-rw-r--r--asoc/msm-pcm-q6-noirq.c55
-rw-r--r--asoc/msm-pcm-q6-v2.c106
-rw-r--r--asoc/msm-pcm-q6-v2.h1
4 files changed, 161 insertions, 13 deletions
diff --git a/asoc/msm-pcm-loopback-v2.c b/asoc/msm-pcm-loopback-v2.c
index 3b6b3a84..61318050 100644
--- a/asoc/msm-pcm-loopback-v2.c
+++ b/asoc/msm-pcm-loopback-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2019, 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
@@ -137,6 +137,7 @@ static int msm_loopback_session_mute_put(struct snd_kcontrol *kcontrol,
goto done;
}
+ mutex_lock(&loopback_session_lock);
pr_debug("%s: mute=%d\n", __func__, mute);
hfp_tx_mute = mute;
for (n = 0; n < LOOPBACK_SESSION_MAX; n++) {
@@ -149,6 +150,7 @@ static int msm_loopback_session_mute_put(struct snd_kcontrol *kcontrol,
pr_err("%s: Send mute command failed rc=%d\n",
__func__, ret);
}
+ mutex_unlock(&loopback_session_lock);
done:
return ret;
}
@@ -351,6 +353,7 @@ static void stop_pcm(struct msm_pcm_loopback *pcm)
if (pcm->audio_client == NULL)
return;
+ mutex_lock(&loopback_session_lock);
q6asm_cmd(pcm->audio_client, CMD_CLOSE);
if (pcm->playback_substream != NULL) {
@@ -365,6 +368,7 @@ static void stop_pcm(struct msm_pcm_loopback *pcm)
}
q6asm_audio_client_free(pcm->audio_client);
pcm->audio_client = NULL;
+ mutex_unlock(&loopback_session_lock);
}
static int msm_pcm_close(struct snd_pcm_substream *substream)
@@ -495,12 +499,15 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
rc = -ENODEV;
goto exit;
}
+ mutex_lock(&loopback_session_lock);
prtd = substream->runtime->private_data;
if (!prtd) {
rc = -ENODEV;
+ mutex_unlock(&loopback_session_lock);
goto exit;
}
rc = pcm_loopback_set_volume(prtd, volume);
+ mutex_unlock(&loopback_session_lock);
exit:
return rc;
@@ -521,12 +528,15 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
rc = -ENODEV;
goto exit;
}
+ mutex_lock(&loopback_session_lock);
prtd = substream->runtime->private_data;
if (!prtd) {
rc = -ENODEV;
+ mutex_unlock(&loopback_session_lock);
goto exit;
}
ucontrol->value.integer.value[0] = prtd->volume;
+ mutex_unlock(&loopback_session_lock);
exit:
return rc;
diff --git a/asoc/msm-pcm-q6-noirq.c b/asoc/msm-pcm-q6-noirq.c
index 46050715..c3835da9 100644
--- a/asoc/msm-pcm-q6-noirq.c
+++ b/asoc/msm-pcm-q6-noirq.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2019, 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
@@ -577,6 +577,7 @@ static int msm_pcm_prepare(struct snd_pcm_substream *substream)
static int msm_pcm_close(struct snd_pcm_substream *substream)
{
+ struct msm_plat_data *pdata = NULL;
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
struct msm_audio *prtd = runtime->private_data;
@@ -585,6 +586,21 @@ static int msm_pcm_close(struct snd_pcm_substream *substream)
int dir = 0;
int ret = 0;
+ if (!soc_prtd) {
+ pr_debug("%s private_data not found\n",
+ __func__);
+ return 0;
+ }
+
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: pdata not found\n", __func__);
+ return -ENODEV;
+ }
+
+ mutex_lock(&pdata->lock);
+
if (ac) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
dir = IN;
@@ -619,6 +635,7 @@ static int msm_pcm_close(struct snd_pcm_substream *substream)
SNDRV_PCM_STREAM_CAPTURE);
kfree(prtd);
runtime->private_data = NULL;
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -643,8 +660,10 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
+ struct msm_plat_data *pdata = NULL;
struct snd_pcm_substream *substream =
vol->pcm->streams[vol->stream].substream;
+ struct snd_soc_pcm_runtime *soc_prtd = NULL;
struct msm_audio *prtd;
pr_debug("%s\n", __func__);
@@ -652,13 +671,24 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
pr_err("%s substream not found\n", __func__);
return -ENODEV;
}
- if (!substream->runtime) {
- pr_debug("%s substream runtime not found\n", __func__);
+ soc_prtd = substream->private_data;
+ if (!substream->runtime || !soc_prtd) {
+ pr_debug("%s substream runtime or private_data not found\n",
+ __func__);
return 0;
}
+
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: pdata not found\n", __func__);
+ return -ENODEV;
+ }
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd)
ucontrol->value.integer.value[0] = prtd->volume;
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -667,8 +697,10 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
{
int rc = 0;
struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
+ struct msm_plat_data *pdata = NULL;
struct snd_pcm_substream *substream =
vol->pcm->streams[vol->stream].substream;
+ struct snd_soc_pcm_runtime *soc_prtd = NULL;
struct msm_audio *prtd;
int volume = ucontrol->value.integer.value[0];
@@ -677,15 +709,25 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
pr_err("%s substream not found\n", __func__);
return -ENODEV;
}
- if (!substream->runtime) {
- pr_err("%s substream runtime not found\n", __func__);
+ soc_prtd = substream->private_data;
+ if (!substream->runtime || !soc_prtd) {
+ pr_debug("%s substream runtime or private_data not found\n",
+ __func__);
return 0;
}
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: pdata not found\n", __func__);
+ return -ENODEV;
+ }
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd) {
rc = msm_pcm_set_volume(prtd, volume);
prtd->volume = volume;
}
+ mutex_unlock(&pdata->lock);
return rc;
}
@@ -1231,6 +1273,8 @@ static int msm_pcm_probe(struct platform_device *pdev)
pdata->perf_mode = perf_mode;
+ mutex_init(&pdata->lock);
+
dev_set_drvdata(&pdev->dev, pdata);
dev_dbg(&pdev->dev, "%s: dev name %s\n",
@@ -1251,6 +1295,7 @@ static int msm_pcm_remove(struct platform_device *pdev)
dev_dbg(&pdev->dev, "Pull mode remove\n");
pdata = dev_get_drvdata(&pdev->dev);
+ mutex_destroy(&pdata->lock);
devm_kfree(&pdev->dev, pdata);
snd_soc_unregister_platform(&pdev->dev);
return 0;
diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c
index 5be2cb43..c672608b 100644
--- a/asoc/msm-pcm-q6-v2.c
+++ b/asoc/msm-pcm-q6-v2.c
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/time.h>
+#include <linux/mutex.h>
#include <linux/wait.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -827,6 +828,14 @@ static int msm_pcm_playback_close(struct snd_pcm_substream *substream)
pr_debug("%s: cmd_pending 0x%lx\n", __func__, prtd->cmd_pending);
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: platform data is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ mutex_lock(&pdata->lock);
if (prtd->audio_client) {
dir = IN;
@@ -834,8 +843,6 @@ static int msm_pcm_playback_close(struct snd_pcm_substream *substream)
* Unvote to downgrade the Rx thread priority from
* RT Thread for Low-Latency use case.
*/
- pdata = (struct msm_plat_data *)
- dev_get_drvdata(soc_prtd->platform->dev);
if (pdata) {
if (pdata->perf_mode == LOW_LATENCY_PCM_MODE)
apr_end_rx_rt(prtd->audio_client->apr);
@@ -869,6 +876,7 @@ static int msm_pcm_playback_close(struct snd_pcm_substream *substream)
msm_adsp_clean_mixer_ctl_pp_event_queue(soc_prtd);
kfree(prtd);
runtime->private_data = NULL;
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -962,9 +970,20 @@ static int msm_pcm_capture_close(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
struct msm_audio *prtd = runtime->private_data;
+ struct msm_plat_data *pdata;
int dir = OUT;
pr_debug("%s\n", __func__);
+
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: platform data is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ mutex_lock(&pdata->lock);
+
if (prtd->audio_client) {
q6asm_cmd(prtd->audio_client, CMD_CLOSE);
q6asm_audio_client_buf_free_contiguous(dir,
@@ -976,6 +995,7 @@ static int msm_pcm_capture_close(struct snd_pcm_substream *substream)
SNDRV_PCM_STREAM_CAPTURE);
kfree(prtd);
runtime->private_data = NULL;
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -1114,10 +1134,10 @@ static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
if (!pdata) {
pr_err("%s pdata is NULL\n", __func__);
- ret = -ENODEV;
- goto done;
+ return -ENODEV;
}
+ mutex_lock(&pdata->lock);
substream = pdata->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
if (!substream) {
pr_err("%s substream not found\n", __func__);
@@ -1175,6 +1195,7 @@ static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
pr_err("%s: failed to send stream event cmd, err = %d\n",
__func__, ret);
done:
+ mutex_unlock(&pdata->lock);
return ret;
}
@@ -1312,8 +1333,10 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
+ struct msm_plat_data *pdata = NULL;
struct snd_pcm_substream *substream =
vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
+ struct snd_soc_pcm_runtime *soc_prtd = NULL;
struct msm_audio *prtd;
pr_debug("%s\n", __func__);
@@ -1321,13 +1344,23 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
pr_err("%s substream not found\n", __func__);
return -ENODEV;
}
- if (!substream->runtime) {
- pr_debug("%s substream runtime not found\n", __func__);
+ soc_prtd = substream->private_data;
+ if (!substream->runtime || !soc_prtd) {
+ pr_debug("%s substream runtime or private_data not found\n",
+ __func__);
return 0;
}
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: pdata not found\n", __func__);
+ return -ENODEV;
+ }
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd)
ucontrol->value.integer.value[0] = prtd->volume;
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -1338,6 +1371,8 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
struct snd_pcm_substream *substream =
vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
+ struct snd_soc_pcm_runtime *soc_prtd = NULL;
+ struct msm_plat_data *pdata = NULL;
struct msm_audio *prtd;
int volume = ucontrol->value.integer.value[0];
@@ -1350,11 +1385,27 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
pr_err("%s substream runtime not found\n", __func__);
return 0;
}
+
+ soc_prtd = substream->private_data;
+ if (!soc_prtd) {
+ pr_err("%s: soc_prtd is NULL\n", __func__);
+ return -ENODEV;
+ }
+
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: platform data is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd) {
rc = msm_pcm_set_volume(prtd, volume);
prtd->volume = volume;
}
+ mutex_unlock(&pdata->lock);
return rc;
}
@@ -1412,9 +1463,11 @@ static int msm_pcm_compress_ctl_get(struct snd_kcontrol *kcontrol,
pr_debug("%s substream runtime not found\n", __func__);
return 0;
}
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd)
ucontrol->value.integer.value[0] = prtd->compress_enable;
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -1443,12 +1496,14 @@ static int msm_pcm_compress_ctl_put(struct snd_kcontrol *kcontrol,
pr_err("%s substream runtime not found\n", __func__);
return 0;
}
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd) {
pr_debug("%s: setting compress flag to 0x%x\n",
__func__, compress);
prtd->compress_enable = compress;
}
+ mutex_unlock(&pdata->lock);
return rc;
}
@@ -1517,15 +1572,32 @@ static int msm_pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol,
struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
struct snd_pcm_substream *substream;
+ struct snd_soc_pcm_runtime *soc_prtd = NULL;
+ struct msm_plat_data *pdata = NULL;
struct msm_audio *prtd;
pr_debug("%s", __func__);
substream = snd_pcm_chmap_substream(info, idx);
if (!substream)
return -ENODEV;
+
if (!substream->runtime)
return 0;
+ soc_prtd = substream->private_data;
+ if (!soc_prtd) {
+ pr_err("%s: soc_prtd is NULL\n", __func__);
+ return -ENODEV;
+ }
+
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: platform data is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd) {
prtd->set_channel_map = true;
@@ -1533,6 +1605,7 @@ static int msm_pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol,
prtd->channel_map[i] =
(char)(ucontrol->value.integer.value[i]);
}
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -1543,17 +1616,34 @@ static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,
struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
struct snd_pcm_substream *substream;
+ struct snd_soc_pcm_runtime *soc_prtd = NULL;
+ struct msm_plat_data *pdata = NULL;
struct msm_audio *prtd;
pr_debug("%s", __func__);
substream = snd_pcm_chmap_substream(info, idx);
if (!substream)
return -ENODEV;
+
memset(ucontrol->value.integer.value, 0,
sizeof(ucontrol->value.integer.value));
if (!substream->runtime)
return 0; /* no channels set */
+ soc_prtd = substream->private_data;
+ if (!soc_prtd) {
+ pr_err("%s: soc_prtd is NULL\n", __func__);
+ return -ENODEV;
+ }
+
+ pdata = (struct msm_plat_data *)
+ dev_get_drvdata(soc_prtd->platform->dev);
+ if (!pdata) {
+ pr_err("%s: platform data is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ mutex_lock(&pdata->lock);
prtd = substream->runtime->private_data;
if (prtd && prtd->set_channel_map == true) {
@@ -1565,6 +1655,7 @@ static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[i] = 0;
}
+ mutex_unlock(&pdata->lock);
return 0;
}
@@ -1875,7 +1966,7 @@ static int msm_pcm_probe(struct platform_device *pdev)
} else {
pdata->perf_mode = LEGACY_PCM_MODE;
}
-
+ mutex_init(&pdata->lock);
dev_set_drvdata(&pdev->dev, pdata);
@@ -1890,6 +1981,7 @@ static int msm_pcm_remove(struct platform_device *pdev)
struct msm_plat_data *pdata;
pdata = dev_get_drvdata(&pdev->dev);
+ mutex_destroy(&pdata->lock);
kfree(pdata);
snd_soc_unregister_platform(&pdev->dev);
return 0;
diff --git a/asoc/msm-pcm-q6-v2.h b/asoc/msm-pcm-q6-v2.h
index 0177b2d6..57dc07d8 100644
--- a/asoc/msm-pcm-q6-v2.h
+++ b/asoc/msm-pcm-q6-v2.h
@@ -125,6 +125,7 @@ struct output_meta_data_st {
struct msm_plat_data {
int perf_mode;
struct snd_pcm *pcm;
+ struct mutex lock;
};
#endif /*_MSM_PCM_H*/