Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c898e74 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown
Browse files

ASoC: Add helper function to check whether a CODEC is active



Instead of directly checking the 'active' field of the CODEC struct add a new
helper function that will return either true or false depending on whether the
CODEC is active. This will make the migration to the component level easier.

The patch also updates all CODEC drivers that check the active attribute to use
the new helper function.

Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent a1a0cc06
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1172,6 +1172,11 @@ static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
	return 1;
}

static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec)
{
	return codec->active != 0;
}

int snd_soc_util_init(void);
void snd_soc_util_exit(void);

+2 −2
Original line number Diff line number Diff line
@@ -722,7 +722,7 @@ static int adav80x_dai_startup(struct snd_pcm_substream *substream,
	struct snd_soc_codec *codec = dai->codec;
	struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);

	if (!codec->active || !adav80x->rate)
	if (!snd_soc_codec_is_active(codec) || !adav80x->rate)
		return 0;

	return snd_pcm_hw_constraint_minmax(substream->runtime,
@@ -735,7 +735,7 @@ static void adav80x_dai_shutdown(struct snd_pcm_substream *substream,
	struct snd_soc_codec *codec = dai->codec;
	struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);

	if (!codec->active)
	if (!snd_soc_codec_is_active(codec))
		adav80x->rate = 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ static void tlv320aic23_shutdown(struct snd_pcm_substream *substream,
	struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec);

	/* deactivate */
	if (!codec->active) {
	if (!snd_soc_codec_is_active(codec)) {
		udelay(50);
		snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0);
	}
+1 −1
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol,
	if (dac33->fifo_mode == ucontrol->value.integer.value[0])
		return 0;
	/* Do not allow changes while stream is running*/
	if (codec->active)
	if (snd_soc_codec_is_active(codec))
		return -EPERM;

	if (ucontrol->value.integer.value[0] < 0 ||
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg,
	/* the interpolator & decimator regs must only be written when the
	 * codec DAI is active.
	 */
	if (!codec->active && (reg >= UDA1380_MVOL))
	if (!snd_soc_codec_is_active(codec) && (reg >= UDA1380_MVOL))
		return 0;
	pr_debug("uda1380: hw write %x val %x\n", reg, value);
	if (codec->hw_write(codec->control_data, data, 3) == 3) {
Loading