asoc: msm_common: call spf_apm_close_all only once
Add lock to avoid calling spf_apm_close_all twice from machine driver. Change-Id: Id5f40b0a5f7c336aa900db5657f5fab198c6e359
This commit is contained in:
@@ -113,8 +113,6 @@ static ssize_t aud_dev_sysfs_store(struct kobject *kobj,
|
|||||||
pr_debug("%s: pcm_id %d state %d \n", __func__, pcm_id, state);
|
pr_debug("%s: pcm_id %d state %d \n", __func__, pcm_id, state);
|
||||||
|
|
||||||
pdata->aud_dev_state[pcm_id] = state;
|
pdata->aud_dev_state[pcm_id] = state;
|
||||||
if ( state == DEVICE_ENABLE && (pdata->dsp_sessions_closed != 0))
|
|
||||||
pdata->dsp_sessions_closed = 0;
|
|
||||||
|
|
||||||
ret = count;
|
ret = count;
|
||||||
done:
|
done:
|
||||||
@@ -225,22 +223,29 @@ done:
|
|||||||
static void check_userspace_service_state(struct snd_soc_pcm_runtime *rtd,
|
static void check_userspace_service_state(struct snd_soc_pcm_runtime *rtd,
|
||||||
struct msm_common_pdata *pdata)
|
struct msm_common_pdata *pdata)
|
||||||
{
|
{
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
dev_info(rtd->card->dev,"%s: pcm_id %d state %d\n", __func__,
|
dev_info(rtd->card->dev,"%s: pcm_id %d state %d\n", __func__,
|
||||||
rtd->num, pdata->aud_dev_state[rtd->num]);
|
rtd->num, pdata->aud_dev_state[rtd->num]);
|
||||||
|
|
||||||
|
mutex_lock(&pdata->aud_dev_lock);
|
||||||
if (pdata->aud_dev_state[rtd->num] == DEVICE_ENABLE) {
|
if (pdata->aud_dev_state[rtd->num] == DEVICE_ENABLE) {
|
||||||
dev_info(rtd->card->dev, "%s userspace service crashed\n",
|
dev_info(rtd->card->dev, "%s userspace service crashed\n",
|
||||||
__func__);
|
__func__);
|
||||||
if (pdata->dsp_sessions_closed == 0) {
|
/*Reset the state as sysfs node wont be triggred*/
|
||||||
|
pdata->aud_dev_state[rtd->num] = DEVICE_DISABLE;
|
||||||
|
for (i = 0; i < pdata->num_aud_devs; i++) {
|
||||||
|
if (pdata->aud_dev_state[i] == DEVICE_ENABLE)
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
/*Issue close all graph cmd to DSP*/
|
/*Issue close all graph cmd to DSP*/
|
||||||
spf_core_apm_close_all();
|
spf_core_apm_close_all();
|
||||||
/*unmap all dma mapped buffers*/
|
/*unmap all dma mapped buffers*/
|
||||||
msm_audio_ion_crash_handler();
|
msm_audio_ion_crash_handler();
|
||||||
pdata->dsp_sessions_closed = 1;
|
|
||||||
}
|
|
||||||
/*Reset the state as sysfs node wont be triggred*/
|
|
||||||
pdata->aud_dev_state[rtd->num] = 0;
|
|
||||||
}
|
}
|
||||||
|
exit:
|
||||||
|
mutex_unlock(&pdata->aud_dev_lock);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_mi2s_tdm_auxpcm_intf_index(const char *stream_name)
|
static int get_mi2s_tdm_auxpcm_intf_index(const char *stream_name)
|
||||||
@@ -763,6 +768,7 @@ int msm_common_snd_init(struct platform_device *pdev, struct snd_soc_card *card)
|
|||||||
sizeof(uint8_t), GFP_KERNEL);
|
sizeof(uint8_t), GFP_KERNEL);
|
||||||
dev_info(&pdev->dev, "num_links %d \n", card->num_links);
|
dev_info(&pdev->dev, "num_links %d \n", card->num_links);
|
||||||
common_pdata->num_aud_devs = card->num_links;
|
common_pdata->num_aud_devs = card->num_links;
|
||||||
|
mutex_init(&common_pdata->aud_dev_lock);
|
||||||
|
|
||||||
aud_dev_sysfs_init(common_pdata);
|
aud_dev_sysfs_init(common_pdata);
|
||||||
|
|
||||||
@@ -783,6 +789,7 @@ void msm_common_snd_deinit(struct msm_common_pdata *common_pdata)
|
|||||||
|
|
||||||
msm_audio_remove_qos_request();
|
msm_audio_remove_qos_request();
|
||||||
|
|
||||||
|
mutex_destroy(&common_pdata->aud_dev_lock);
|
||||||
for (count = 0; count < MI2S_TDM_AUXPCM_MAX; count++) {
|
for (count = 0; count < MI2S_TDM_AUXPCM_MAX; count++) {
|
||||||
mutex_destroy(&common_pdata->lock[count]);
|
mutex_destroy(&common_pdata->lock[count]);
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,7 @@
|
|||||||
/* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
|
||||||
* it under the terms of the GNU General Public License version 2 and
|
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||||
* only version 2 as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
#ifndef _MSM_COMMON_H_
|
#ifndef _MSM_COMMON_H_
|
||||||
#define _MSM_COMMON_H_
|
#define _MSM_COMMON_H_
|
||||||
@@ -40,7 +34,7 @@ typedef enum snd_card_status_t {
|
|||||||
struct msm_common_pdata {
|
struct msm_common_pdata {
|
||||||
uint8_t *aud_dev_state;
|
uint8_t *aud_dev_state;
|
||||||
struct kobject aud_dev_kobj;
|
struct kobject aud_dev_kobj;
|
||||||
uint8_t dsp_sessions_closed;
|
struct mutex aud_dev_lock;
|
||||||
uint32_t num_aud_devs;
|
uint32_t num_aud_devs;
|
||||||
struct device_node *mi2s_gpio_p[MI2S_TDM_AUXPCM_MAX];
|
struct device_node *mi2s_gpio_p[MI2S_TDM_AUXPCM_MAX];
|
||||||
struct mutex lock[MI2S_TDM_AUXPCM_MAX];
|
struct mutex lock[MI2S_TDM_AUXPCM_MAX];
|
||||||
|
Reference in New Issue
Block a user