Audio: Extend GPIO jack detection support for all medfield based devices
authorNamarta Kohli <namartax.kohli@intel.com>
Mon, 21 May 2012 09:38:44 +0000 (15:08 +0530)
committerbuildbot <buildbot@intel.com>
Wed, 23 May 2012 10:52:15 +0000 (03:52 -0700)
BZ: 37120

Redridge device has a GPIO pin which can be used to detect high impedance
headsets.

With this GPIO support, whenever an insert interrupt is received and the
micbias value is out of range, it checks the GPIO pin and reports the jack as
a HEADSET if the GPIO pin says that there is a headset.

Change-Id: I6ea08050b1c965a23937ab9a5e6d36e9a66486d2
Signed-off-by: Namarta Kohli <namartax.kohli@intel.com>
Reviewed-on: http://android.intel.com:8080/49514
Reviewed-by: Babu, Ramesh <ramesh.babu@intel.com>
Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
Reviewed-by: Gupta, ArvindX K <arvindx.k.gupta@intel.com>
Reviewed-by: Hibare, PramodX <pramodx.hibare@intel.com>
Tested-by: Hibare, PramodX <pramodx.hibare@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
sound/soc/mid-x86/mfld_machine.c

index 79eb59d..cc6b527 100644 (file)
@@ -81,14 +81,11 @@ static int mfld_get_headset_state(struct snd_soc_jack *jack)
        jack_type = snd_soc_jack_get_type(jack, micbias);
        pr_debug("jack type detected = %d, micbias = %d\n", jack_type, micbias);
 
-       if (mfld_board_id() == MFLD_BID_PR3) {
-               if ((jack_type != SND_JACK_HEADSET) &&
-                   (jack_type != SND_JACK_HEADPHONE))
-                       hs_gpio = gpio_get_value(MFLD_GPIO_HEADSET_DET_PIN);
-               if (!hs_gpio) {
-                       jack_type = SND_JACK_HEADPHONE;
-                       pr_debug("GPIO says there is a headphone, reporting it\n");
-               }
+       if ((jack_type != SND_JACK_HEADSET) && (jack_type != SND_JACK_HEADPHONE))
+               hs_gpio = gpio_get_value(MFLD_GPIO_HEADSET_DET_PIN);
+       if (!hs_gpio) {
+               jack_type = SND_JACK_HEADPHONE;
+               pr_debug("GPIO says there is a headphone, reporting it\n");
        }
 
        if (jack_type == SND_JACK_HEADSET)
@@ -144,12 +141,10 @@ void mfld_jack_wq(struct work_struct *work)
                        snd_soc_update_bits(jack->codec, SN95031_ACCDETMASK,
                                                        BIT(1)|BIT(0), 0);
        } else if (intr_id & SN95031_JACK_REMOVED) {
-               if (mfld_board_id() == MFLD_BID_PR3) {
-                       if (!gpio_get_value(MFLD_GPIO_HEADSET_DET_PIN)) {
-                               pr_debug("remove interrupt, "
-                                       "but GPIO says inserted\n");
-                               return;
-                       }
+               if (!gpio_get_value(MFLD_GPIO_HEADSET_DET_PIN)) {
+                       pr_debug("remove interrupt, "
+                               "but GPIO says inserted\n");
+                       return;
                }
                pr_debug("reporting jack as removed\n");
                snd_soc_update_bits(jack->codec, SN95031_BTNCTRL2, BIT(0), 0);
@@ -717,13 +712,11 @@ static int __devinit snd_mfld_mc_probe(struct ipc_device *ipcdev)
        }
        INIT_DELAYED_WORK(&ctx->jack_work.work, mfld_jack_wq);
 
-       if (mfld_board_id() == MFLD_BID_PR3) {
-               ret_val = gpio_request_one(MFLD_GPIO_HEADSET_DET_PIN,
-                                          GPIOF_DIR_IN, "headset_detect_gpio");
-               if (ret_val) {
-                       pr_err("Headset detect GPIO alloc fail:%d\n", ret_val);
-                       goto unalloc;
-               }
+       ret_val = gpio_request_one(MFLD_GPIO_HEADSET_DET_PIN, GPIOF_DIR_IN,
+                                  "headset_detect_gpio");
+       if (ret_val) {
+               pr_err("Headset detect GPIO alloc fail:%d\n", ret_val);
+               goto unalloc;
        }
 
        ctx->int_base = ioremap_nocache(irq_mem->start, resource_size(irq_mem));
@@ -776,8 +769,7 @@ static int __devexit snd_mfld_mc_remove(struct ipc_device *ipcdev)
        cancel_delayed_work(&ctx->jack_work.work);
        intel_mid_gpadc_free(ctx->audio_adc_handle);
        kfree(ctx);
-       if (mfld_board_id() == MFLD_BID_PR3)
-               gpio_free(MFLD_GPIO_HEADSET_DET_PIN);
+       gpio_free(MFLD_GPIO_HEADSET_DET_PIN);
        snd_soc_card_set_drvdata(soc_card, NULL);
        snd_soc_unregister_card(soc_card);
        ipc_set_drvdata(ipcdev, NULL);