Skip to content

Commit

Permalink
techpack: audio: Merge tag 'LA.UM.8.3.r1-06300-sdm845.0' into canting…
Browse files Browse the repository at this point in the history
…-4.9-q

Change-Id: I3b8fdecb1fd191a2a35a0b69efc03720c12cb8e4
Signed-off-by: Khusika Dhamar Gusti <mail@khusika.com>
  • Loading branch information
Khusika Dhamar Gusti committed Oct 23, 2019
2 parents d6965f3 + 6d70467 commit 26dc02a
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 16 deletions.
12 changes: 11 additions & 1 deletion techpack/audio/asoc/msm-pcm-loopback-v2.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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++) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
55 changes: 50 additions & 5 deletions techpack/audio/asoc/msm-pcm-q6-noirq.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -643,22 +660,35 @@ 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__);
if (!substream) {
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;
}

Expand All @@ -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[SNDRV_PCM_STREAM_PLAYBACK].substream;
struct snd_soc_pcm_runtime *soc_prtd = NULL;
struct msm_audio *prtd;
int volume = ucontrol->value.integer.value[0];

Expand All @@ -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;
}

Expand Down Expand Up @@ -1228,6 +1270,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",
Expand All @@ -1248,6 +1292,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;
Expand Down

0 comments on commit 26dc02a

Please sign in to comment.