]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ASoC: sn95031: Pass CODEC to sn95031_jack_detection()
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 4 Mar 2015 09:33:16 +0000 (10:33 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 4 Mar 2015 17:09:51 +0000 (17:09 +0000)
The sn95031 driver currently gets the CODEC implicitly from the jack that is
passed to sn95031_jack_detection(). But the codec field is going to be
removed from the snd_soc_jack struct, so refactor things to pass the CODEC
explicitly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/sn95031.c
sound/soc/codecs/sn95031.h
sound/soc/intel/mfld_machine.c

index 47b257e4180965f38be5c393cab204945f444b7f..1e5d2643c28606c88703f69ccb6fa5f4fc661c0f 100644 (file)
@@ -783,19 +783,21 @@ static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec)
        snd_soc_write(codec, SN95031_BTNCTRL2, 0x01);
 }
 
-static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack)
+static int sn95031_get_headset_state(struct snd_soc_codec *codec,
+       struct snd_soc_jack *mfld_jack)
 {
-       int micbias = sn95031_get_mic_bias(mfld_jack->codec);
+       int micbias = sn95031_get_mic_bias(codec);
 
        int jack_type = snd_soc_jack_get_type(mfld_jack, micbias);
 
        pr_debug("jack type detected = %d\n", jack_type);
        if (jack_type == SND_JACK_HEADSET)
-               sn95031_enable_jack_btn(mfld_jack->codec);
+               sn95031_enable_jack_btn(codec);
        return jack_type;
 }
 
-void sn95031_jack_detection(struct mfld_jack_data *jack_data)
+void sn95031_jack_detection(struct snd_soc_codec *codec,
+       struct mfld_jack_data *jack_data)
 {
        unsigned int status;
        unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET;
@@ -809,11 +811,11 @@ void sn95031_jack_detection(struct mfld_jack_data *jack_data)
                status = SND_JACK_HEADSET | SND_JACK_BTN_1;
        } else if (jack_data->intr_id & 0x4) {
                pr_debug("headset or headphones inserted\n");
-               status = sn95031_get_headset_state(jack_data->mfld_jack);
+               status = sn95031_get_headset_state(codec, jack_data->mfld_jack);
        } else if (jack_data->intr_id & 0x8) {
                pr_debug("headset or headphones removed\n");
                status = 0;
-               sn95031_disable_jack_btn(jack_data->mfld_jack->codec);
+               sn95031_disable_jack_btn(codec);
        } else {
                pr_err("unidentified interrupt\n");
                return;
index 20376d234fb83eb26c3bb5eac6c31bc21d5ab24d..7651fe4e6a458907d468675031b7685be4cdf945 100644 (file)
@@ -127,6 +127,7 @@ struct mfld_jack_data {
        struct snd_soc_jack *mfld_jack;
 };
 
-extern void sn95031_jack_detection(struct mfld_jack_data *jack_data);
+extern void sn95031_jack_detection(struct snd_soc_codec *codec,
+       struct mfld_jack_data *jack_data);
 
 #endif
index 90b7a57713a0234bb6aebfb9ae343c2a65c495ae..d22b44db824ee88c16d90350ebbeaf87931f3986 100644 (file)
@@ -228,10 +228,13 @@ static void mfld_jack_check(unsigned int intr_status)
 {
        struct mfld_jack_data jack_data;
 
+       if (!mfld_codec)
+               return;
+
        jack_data.mfld_jack = &mfld_jack;
        jack_data.intr_id = intr_status;
 
-       sn95031_jack_detection(&jack_data);
+       sn95031_jack_detection(mfld_codec, &jack_data);
        /* TODO: add american headset detection post gpiolib support */
 }
 
@@ -240,8 +243,6 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
        struct snd_soc_dapm_context *dapm = &runtime->card->dapm;
        int ret_val;
 
-       mfld_codec = runtime->codec;
-
        /* default is earpiece pin, userspace sets it explcitly */
        snd_soc_dapm_disable_pin(dapm, "Headphones");
        /* default is lineout NC, userspace sets it explcitly */
@@ -254,7 +255,7 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
        snd_soc_dapm_disable_pin(dapm, "LINEINR");
 
        /* Headset and button jack detection */
-       ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack",
+       ret_val = snd_soc_jack_new(runtime->codec, "Intel(R) MID Audio Jack",
                        SND_JACK_HEADSET | SND_JACK_BTN_0 |
                        SND_JACK_BTN_1, &mfld_jack);
        if (ret_val) {
@@ -275,6 +276,8 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
                return ret_val;
        }
 
+       mfld_codec = runtime->codec;
+
        /* we want to check if anything is inserted at boot,
         * so send a fake event to codec and it will read adc
         * to find if anything is there or not */
@@ -359,8 +362,6 @@ static irqreturn_t snd_mfld_jack_detection(int irq, void *data)
 {
        struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data;
 
-       if (mfld_jack.codec == NULL)
-               return IRQ_HANDLED;
        mfld_jack_check(mc_drv_ctx->interrupt_status);
 
        return IRQ_HANDLED;