ASoC: Tegra wm8903 machine: suspend/resume code for HP detection
Ankit Gupta [Wed, 14 Mar 2012 07:00:08 +0000 (12:00 +0530)]
Suspend and resume code included for headphone detection. Earlier,
it was causing problem in HP detection when device enters into LP0
state and headphone is plugged in. (Bug 937153)

Change-Id: If625f0e7b857b40b0535f8bc8d1c262650886fa7
Signed-off-by: Ankit Gupta <ankitgupta@nvidia.com>
Reviewed-on: http://git-master/r/89975
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/soc/tegra/tegra_wm8903.c

index 55187f8..a75d67b 100644 (file)
@@ -747,10 +747,33 @@ static struct snd_soc_dai_link tegra_wm8903_dai[] = {
        },
 };
 
+void tegra_wm8903_suspend_post(struct snd_soc_card *card)
+{
+       struct snd_soc_jack_gpio *gpio = &tegra_wm8903_hp_jack_gpio;
+
+       if (gpio_is_valid(gpio->gpio))
+               disable_irq(gpio_to_irq(gpio->gpio));
+}
+
+void tegra_wm8903_resume_pre(struct snd_soc_card *card)
+{
+       int val;
+       struct snd_soc_jack_gpio *gpio = &tegra_wm8903_hp_jack_gpio;
+
+       if (gpio_is_valid(gpio->gpio)) {
+               val = gpio_get_value(gpio->gpio);
+               val = gpio->invert ? !val : val;
+               snd_soc_jack_report(gpio->jack, val, gpio->report);
+               enable_irq(gpio_to_irq(gpio->gpio));
+       }
+}
+
 static struct snd_soc_card snd_soc_tegra_wm8903 = {
        .name = "tegra-wm8903",
        .dai_link = tegra_wm8903_dai,
        .num_links = ARRAY_SIZE(tegra_wm8903_dai),
+       .suspend_post = tegra_wm8903_suspend_post,
+       .resume_pre = tegra_wm8903_resume_pre,
        //.set_bias_level = tegra30_soc_set_bias_level,
        //.set_bias_level_post = tegra30_soc_set_bias_level_post,
 };