BACKPORT: ASoC: add snd_soc_card_mutex_lock/unlock()
ASoC need to use card->mutex with _INIT or _RUNTIME, but there is no helper function for it. This patch adds its helper function and use it. Because people might misunderstand that _init() is mutex initialization, this patch renames _INIT to _ROOT and adds new snd_soc_card_mutex_lock_root() for it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87a5zlx3tw.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org> Bug: 303236405 (cherry picked from commit 0f3b818486796ec8895fa4ccdf15edb759bff40a) [ Yixuan Jiang: Fix minor conflict ] Change-Id: Ie8cd7aeeea759576423760d25b5fb5b2c9ae0d12 Signed-off-by: Yixuan Jiang <yixuanjiang@google.com>
This commit is contained in:
parent
edfef8fdc9
commit
6cb2109589
3 changed files with 27 additions and 12 deletions
|
|
@ -9,10 +9,25 @@
|
||||||
#define __SOC_CARD_H
|
#define __SOC_CARD_H
|
||||||
|
|
||||||
enum snd_soc_card_subclass {
|
enum snd_soc_card_subclass {
|
||||||
SND_SOC_CARD_CLASS_INIT = 0,
|
SND_SOC_CARD_CLASS_ROOT = 0,
|
||||||
SND_SOC_CARD_CLASS_RUNTIME = 1,
|
SND_SOC_CARD_CLASS_RUNTIME = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline void snd_soc_card_mutex_lock_root(struct snd_soc_card *card)
|
||||||
|
{
|
||||||
|
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void snd_soc_card_mutex_lock(struct snd_soc_card *card)
|
||||||
|
{
|
||||||
|
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void snd_soc_card_mutex_unlock(struct snd_soc_card *card)
|
||||||
|
{
|
||||||
|
mutex_unlock(&card->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
|
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
|
||||||
const char *name);
|
const char *name);
|
||||||
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
|
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
|
||||||
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
|
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
|
snd_soc_card_mutex_lock(fe->card);
|
||||||
fe->dpcm[stream].runtime = fe_substream->runtime;
|
fe->dpcm[stream].runtime = fe_substream->runtime;
|
||||||
|
|
||||||
ret = dpcm_path_get(fe, stream, &list);
|
ret = dpcm_path_get(fe, stream, &list);
|
||||||
|
|
@ -189,7 +189,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
|
||||||
snd_soc_runtime_activate(fe, stream);
|
snd_soc_runtime_activate(fe, stream);
|
||||||
snd_soc_dpcm_mutex_unlock(fe);
|
snd_soc_dpcm_mutex_unlock(fe);
|
||||||
|
|
||||||
mutex_unlock(&fe->card->mutex);
|
snd_soc_card_mutex_unlock(fe->card);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -201,7 +201,7 @@ out:
|
||||||
dpcm_path_put(&list);
|
dpcm_path_put(&list);
|
||||||
be_err:
|
be_err:
|
||||||
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
|
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
|
||||||
mutex_unlock(&fe->card->mutex);
|
snd_soc_card_mutex_unlock(fe->card);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,7 +212,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
|
||||||
struct snd_soc_dpcm *dpcm;
|
struct snd_soc_dpcm *dpcm;
|
||||||
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
|
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
|
||||||
|
|
||||||
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
|
snd_soc_card_mutex_lock(fe->card);
|
||||||
|
|
||||||
snd_soc_dpcm_mutex_lock(fe);
|
snd_soc_dpcm_mutex_lock(fe);
|
||||||
snd_soc_runtime_deactivate(fe, stream);
|
snd_soc_runtime_deactivate(fe, stream);
|
||||||
|
|
@ -244,7 +244,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
|
||||||
|
|
||||||
snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0);
|
snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0);
|
||||||
|
|
||||||
mutex_unlock(&fe->card->mutex);
|
snd_soc_card_mutex_unlock(fe->card);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -291,7 +291,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
|
||||||
cmd == SND_COMPR_TRIGGER_DRAIN)
|
cmd == SND_COMPR_TRIGGER_DRAIN)
|
||||||
return snd_soc_component_compr_trigger(cstream, cmd);
|
return snd_soc_component_compr_trigger(cstream, cmd);
|
||||||
|
|
||||||
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
|
snd_soc_card_mutex_lock(fe->card);
|
||||||
|
|
||||||
ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
|
ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
@ -322,7 +322,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
|
||||||
|
|
||||||
out:
|
out:
|
||||||
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
|
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
|
||||||
mutex_unlock(&fe->card->mutex);
|
snd_soc_card_mutex_unlock(fe->card);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -380,7 +380,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
|
||||||
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
|
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
|
snd_soc_card_mutex_lock(fe->card);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create an empty hw_params for the BE as the machine driver must
|
* Create an empty hw_params for the BE as the machine driver must
|
||||||
|
|
@ -418,7 +418,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
|
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
|
||||||
mutex_unlock(&fe->card->mutex);
|
snd_soc_card_mutex_unlock(fe->card);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1936,7 +1936,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
mutex_lock(&client_mutex);
|
mutex_lock(&client_mutex);
|
||||||
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
|
snd_soc_card_mutex_lock_root(card);
|
||||||
|
|
||||||
snd_soc_dapm_init(&card->dapm, card, NULL);
|
snd_soc_dapm_init(&card->dapm, card, NULL);
|
||||||
|
|
||||||
|
|
@ -2093,7 +2093,7 @@ probe_end:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
soc_cleanup_card_resources(card);
|
soc_cleanup_card_resources(card);
|
||||||
|
|
||||||
mutex_unlock(&card->mutex);
|
snd_soc_card_mutex_unlock(card);
|
||||||
mutex_unlock(&client_mutex);
|
mutex_unlock(&client_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue