asoc: lpass-cdc: add enable check before tx mixer put

Check whether tx channel had been enabled or disabled before
tx channel set.

Change-Id: I1f2e0132f0905a53df989b5d52370c4dfdf7d99b
This commit is contained in:
Yuhui Zhao
2023-04-03 14:38:16 +08:00
committed by Gerrit - the friendly Code Review server
parent a8496e9bf4
commit 5990a54d8e
2 changed files with 30 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
*/ */
#include <linux/module.h> #include <linux/module.h>
@@ -612,11 +612,21 @@ static int lpass_cdc_tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
return -EINVAL; return -EINVAL;
if (enable) { if (enable) {
set_bit(dec_id, &tx_priv->active_ch_mask[dai_id]); if (test_bit(dec_id, &tx_priv->active_ch_mask[dai_id])) {
tx_priv->active_ch_cnt[dai_id]++; dev_err(component->dev, "%s: channel is already enabled, dec_id = %d, dai_id = %d\n",
__func__, dec_id, dai_id);
} else {
set_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
tx_priv->active_ch_cnt[dai_id]++;
}
} else { } else {
tx_priv->active_ch_cnt[dai_id]--; if (!test_bit(dec_id, &tx_priv->active_ch_mask[dai_id])) {
clear_bit(dec_id, &tx_priv->active_ch_mask[dai_id]); dev_err(component->dev, "%s: channel is already disabled, dec_id = %d, dai_id = %d\n",
__func__, dec_id, dai_id);
} else {
tx_priv->active_ch_cnt[dai_id]--;
clear_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
}
} }
snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update); snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);

View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
*/ */
#include <linux/module.h> #include <linux/module.h>
@@ -1186,11 +1186,21 @@ static int lpass_cdc_va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
return -EINVAL; return -EINVAL;
if (enable) { if (enable) {
set_bit(dec_id, &va_priv->active_ch_mask[dai_id]); if (test_bit(dec_id, &va_priv->active_ch_mask[dai_id])) {
va_priv->active_ch_cnt[dai_id]++; dev_err_ratelimited(component->dev, "%s: channel is already enabled, dec_id = %d, dai_id = %d\n",
__func__, dec_id, dai_id);
} else {
set_bit(dec_id, &va_priv->active_ch_mask[dai_id]);
va_priv->active_ch_cnt[dai_id]++;
}
} else { } else {
clear_bit(dec_id, &va_priv->active_ch_mask[dai_id]); if (!test_bit(dec_id, &va_priv->active_ch_mask[dai_id])) {
va_priv->active_ch_cnt[dai_id]--; dev_err_ratelimited(component->dev, "%s: channel is already disabled, dec_id = %d, dai_id = %d\n",
__func__, dec_id, dai_id);
} else {
va_priv->active_ch_mask[dai_id]--;
clear_bit(dec_id, &va_priv->active_ch_mask[dai_id]);
}
} }
snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update); snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);