ASoC: soc-pcm: cleanup soc_pcm_apply_symmetry()
soc_pcm_apply_symmetry() want to call snd_pcm_hw_constraint_single() for rate/channel/sample_bits, but, it needs many condition checks. These are very similar but different, thus, it needs to have very verbose code. This patch use macro for it and make code more simple. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87a6tan6sm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
fa31a2c787
Коммит
fac110cbcd
|
@ -349,53 +349,26 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
|
||||||
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (soc_dai->rate && (soc_dai->driver->symmetric_rate ||
|
#define __soc_pcm_apply_symmetry(name, NAME) \
|
||||||
rtd->dai_link->symmetric_rate)) {
|
if (soc_dai->name && (soc_dai->driver->symmetric_##name || \
|
||||||
dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %dHz rate\n",
|
rtd->dai_link->symmetric_##name)) { \
|
||||||
soc_dai->rate);
|
dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %s to %d\n",\
|
||||||
|
#name, soc_dai->name); \
|
||||||
ret = snd_pcm_hw_constraint_single(substream->runtime,
|
\
|
||||||
SNDRV_PCM_HW_PARAM_RATE,
|
ret = snd_pcm_hw_constraint_single(substream->runtime, \
|
||||||
soc_dai->rate);
|
SNDRV_PCM_HW_PARAM_##NAME,\
|
||||||
if (ret < 0) {
|
soc_dai->name); \
|
||||||
dev_err(soc_dai->dev,
|
if (ret < 0) { \
|
||||||
"ASoC: Unable to apply rate constraint: %d\n",
|
dev_err(soc_dai->dev, \
|
||||||
ret);
|
"ASoC: Unable to apply %s constraint: %d\n",\
|
||||||
return ret;
|
#name, ret); \
|
||||||
}
|
return ret; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
if (soc_dai->channels && (soc_dai->driver->symmetric_channels ||
|
__soc_pcm_apply_symmetry(rate, RATE);
|
||||||
rtd->dai_link->symmetric_channels)) {
|
__soc_pcm_apply_symmetry(channels, CHANNELS);
|
||||||
dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %d channel(s)\n",
|
__soc_pcm_apply_symmetry(sample_bits, SAMPLE_BITS);
|
||||||
soc_dai->channels);
|
|
||||||
|
|
||||||
ret = snd_pcm_hw_constraint_single(substream->runtime,
|
|
||||||
SNDRV_PCM_HW_PARAM_CHANNELS,
|
|
||||||
soc_dai->channels);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(soc_dai->dev,
|
|
||||||
"ASoC: Unable to apply channel symmetry constraint: %d\n",
|
|
||||||
ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (soc_dai->sample_bits && (soc_dai->driver->symmetric_sample_bits ||
|
|
||||||
rtd->dai_link->symmetric_sample_bits)) {
|
|
||||||
dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %d sample bits\n",
|
|
||||||
soc_dai->sample_bits);
|
|
||||||
|
|
||||||
ret = snd_pcm_hw_constraint_single(substream->runtime,
|
|
||||||
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
|
|
||||||
soc_dai->sample_bits);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(soc_dai->dev,
|
|
||||||
"ASoC: Unable to apply sample bits symmetry constraint: %d\n",
|
|
||||||
ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче