]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ASoC: Add helper function to check whether a CODEC is active
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 5 Mar 2014 12:17:45 +0000 (13:17 +0100)
committerMark Brown <broonie@linaro.org>
Thu, 6 Mar 2014 09:04:55 +0000 (17:04 +0800)
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: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/sound/soc.h
sound/soc/codecs/adav80x.c
sound/soc/codecs/tlv320aic23.c
sound/soc/codecs/tlv320dac33.c
sound/soc/codecs/uda1380.c
sound/soc/codecs/wl1273.c
sound/soc/codecs/wm8711.c
sound/soc/codecs/wm8753.c

index 53d15e0e6e89bb6e64d77f9cd4cdbd0bf4054659..5c2b4f4b5cfaa9a87e23832de8ce31fe7ede91cd 100644 (file)
@@ -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);
 
index f78b27a7c461d3e5580dad311fd583f30755a3b4..d50cf5b29a2717ea2f6145738055e0d0bef4097f 100644 (file)
@@ -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;
 }
 
index 5d430cc56f51d42397c3190bf3bfb55b7f850dae..458a6aed203eda6641a46c4e85929a063b8b91ea 100644 (file)
@@ -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);
        }
index 4f358393d6d63b721495ccc8330da431a9c38a20..35b2d244e42e7199c011132d099f725212092e9b 100644 (file)
@@ -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 ||
index 726df6d43c2b69227adc503e38397f977db4f220..8e3940dcff20287e074c5175effa541df05162e1 100644 (file)
@@ -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) {
index b7ab2ef567c889ad7969c9bae6e2a4ca640b7de4..47e96ff30064a5035a804963225ba0e6cbe3a81f 100644 (file)
@@ -197,7 +197,7 @@ static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol,
                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 ||
index d99f948c513cd80bf56f96f6657ce20224f2fb0d..6efcc40a7cb3c3ef82499283a2abcd29a0c55dad 100644 (file)
@@ -201,7 +201,7 @@ static void wm8711_shutdown(struct snd_pcm_substream *substream,
        struct snd_soc_codec *codec = dai->codec;
 
        /* deactivate */
-       if (!codec->active) {
+       if (!snd_soc_codec_is_active(codec)) {
                udelay(50);
                snd_soc_write(codec, WM8711_ACTIVE, 0x0);
        }
index be85da93a2682fb89c7c668042f772fc08ca7452..5cf4bebc5d8954c59959dbdb9b54b26289d9d00a 100644 (file)
@@ -251,7 +251,7 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
        if (wm8753->dai_func == ucontrol->value.integer.value[0])
                return 0;
 
-       if (codec->active)
+       if (snd_soc_codec_is_active(codec))
                return -EBUSY;
 
        ioctl = snd_soc_read(codec, WM8753_IOCTL);
@@ -1314,7 +1314,7 @@ static int wm8753_mute(struct snd_soc_dai *dai, int mute)
        /* the digital mute covers the HiFi and Voice DAC's on the WM8753.
         * make sure we check if they are not both active when we mute */
        if (mute && wm8753->dai_func == 1) {
-               if (!codec->active)
+               if (!snd_soc_codec_is_active(codec))
                        snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8);
        } else {
                if (mute)