Loading asoc/msm-pcm-q6-v2.c +74 −5 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; Loading Loading @@ -869,6 +878,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; } Loading Loading @@ -963,8 +973,18 @@ static int msm_pcm_capture_close(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; struct msm_audio *prtd = runtime->private_data; int dir = OUT; struct msm_plat_data *pdata; 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, Loading @@ -976,6 +996,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; } Loading Loading @@ -1144,6 +1165,7 @@ static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol, goto done; } mutex_lock(&pdata->lock); event_data = (struct msm_adsp_event_data *)ucontrol->value.bytes.data; if ((event_data->event_type < ADSP_STREAM_PP_EVENT) || (event_data->event_type >= ADSP_STREAM_EVENT_MAX)) { Loading Loading @@ -1175,6 +1197,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; } Loading Loading @@ -1340,21 +1363,35 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, vol->pcm->streams[vol->stream].substream; struct msm_audio *prtd; int volume = ucontrol->value.integer.value[0]; struct msm_plat_data *pdata = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; pr_debug("%s: volume : 0x%x\n", __func__, volume); if (!substream) { pr_err("%s substream not found\n", __func__); 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_err("%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; } Loading Loading @@ -1519,14 +1556,28 @@ static int msm_pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol, unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); struct snd_pcm_substream *substream; struct msm_audio *prtd; struct snd_soc_pcm_runtime *rtd = NULL; struct msm_plat_data *pdata = NULL; pr_debug("%s", __func__); substream = snd_pcm_chmap_substream(info, idx); if (!substream) return -ENODEV; if (!substream->runtime) rtd = substream->private_data; if (rtd) { pdata = (struct msm_plat_data *) dev_get_drvdata(rtd->platform->dev); if (!pdata) { pr_err("%s: pdata not found\n", __func__); return -ENODEV; } } if (!substream->runtime || !rtd) return 0; mutex_lock(&pdata->lock); prtd = substream->runtime->private_data; if (prtd) { prtd->set_channel_map = true; Loading @@ -1534,6 +1585,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; } Loading @@ -1545,16 +1597,30 @@ static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); struct snd_pcm_substream *substream; struct msm_audio *prtd; struct snd_soc_pcm_runtime *rtd = NULL; struct msm_plat_data *pdata = NULL; pr_debug("%s", __func__); substream = snd_pcm_chmap_substream(info, idx); if (!substream) return -ENODEV; rtd = substream->private_data; if (rtd) { pdata = (struct msm_plat_data *) dev_get_drvdata(rtd->platform->dev); if (!pdata) { pr_err("%s: pdata not found\n", __func__); return -ENODEV; } } memset(ucontrol->value.integer.value, 0, sizeof(ucontrol->value.integer.value)); if (!substream->runtime) if (!substream->runtime || !rtd) return 0; /* no channels set */ mutex_lock(&pdata->lock); prtd = substream->runtime->private_data; if (prtd && prtd->set_channel_map == true) { Loading @@ -1566,6 +1632,7 @@ static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[i] = 0; } mutex_unlock(&pdata->lock); return 0; } Loading Loading @@ -2027,6 +2094,7 @@ static int msm_pcm_probe(struct platform_device *pdev) pdata->perf_mode = LEGACY_PCM_MODE; } mutex_init(&pdata->lock); dev_set_drvdata(&pdev->dev, pdata); Loading @@ -2041,6 +2109,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; Loading asoc/msm-pcm-q6-v2.h +2 −1 Original line number Diff line number Diff line /* * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and Loading Loading @@ -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*/ Loading
asoc/msm-pcm-q6-v2.c +74 −5 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; Loading Loading @@ -869,6 +878,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; } Loading Loading @@ -963,8 +973,18 @@ static int msm_pcm_capture_close(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; struct msm_audio *prtd = runtime->private_data; int dir = OUT; struct msm_plat_data *pdata; 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, Loading @@ -976,6 +996,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; } Loading Loading @@ -1144,6 +1165,7 @@ static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol, goto done; } mutex_lock(&pdata->lock); event_data = (struct msm_adsp_event_data *)ucontrol->value.bytes.data; if ((event_data->event_type < ADSP_STREAM_PP_EVENT) || (event_data->event_type >= ADSP_STREAM_EVENT_MAX)) { Loading Loading @@ -1175,6 +1197,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; } Loading Loading @@ -1340,21 +1363,35 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, vol->pcm->streams[vol->stream].substream; struct msm_audio *prtd; int volume = ucontrol->value.integer.value[0]; struct msm_plat_data *pdata = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; pr_debug("%s: volume : 0x%x\n", __func__, volume); if (!substream) { pr_err("%s substream not found\n", __func__); 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_err("%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; } Loading Loading @@ -1519,14 +1556,28 @@ static int msm_pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol, unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); struct snd_pcm_substream *substream; struct msm_audio *prtd; struct snd_soc_pcm_runtime *rtd = NULL; struct msm_plat_data *pdata = NULL; pr_debug("%s", __func__); substream = snd_pcm_chmap_substream(info, idx); if (!substream) return -ENODEV; if (!substream->runtime) rtd = substream->private_data; if (rtd) { pdata = (struct msm_plat_data *) dev_get_drvdata(rtd->platform->dev); if (!pdata) { pr_err("%s: pdata not found\n", __func__); return -ENODEV; } } if (!substream->runtime || !rtd) return 0; mutex_lock(&pdata->lock); prtd = substream->runtime->private_data; if (prtd) { prtd->set_channel_map = true; Loading @@ -1534,6 +1585,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; } Loading @@ -1545,16 +1597,30 @@ static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); struct snd_pcm_substream *substream; struct msm_audio *prtd; struct snd_soc_pcm_runtime *rtd = NULL; struct msm_plat_data *pdata = NULL; pr_debug("%s", __func__); substream = snd_pcm_chmap_substream(info, idx); if (!substream) return -ENODEV; rtd = substream->private_data; if (rtd) { pdata = (struct msm_plat_data *) dev_get_drvdata(rtd->platform->dev); if (!pdata) { pr_err("%s: pdata not found\n", __func__); return -ENODEV; } } memset(ucontrol->value.integer.value, 0, sizeof(ucontrol->value.integer.value)); if (!substream->runtime) if (!substream->runtime || !rtd) return 0; /* no channels set */ mutex_lock(&pdata->lock); prtd = substream->runtime->private_data; if (prtd && prtd->set_channel_map == true) { Loading @@ -1566,6 +1632,7 @@ static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[i] = 0; } mutex_unlock(&pdata->lock); return 0; } Loading Loading @@ -2027,6 +2094,7 @@ static int msm_pcm_probe(struct platform_device *pdev) pdata->perf_mode = LEGACY_PCM_MODE; } mutex_init(&pdata->lock); dev_set_drvdata(&pdev->dev, pdata); Loading @@ -2041,6 +2109,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; Loading
asoc/msm-pcm-q6-v2.h +2 −1 Original line number Diff line number Diff line /* * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and Loading Loading @@ -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*/