diff options
author | Sumit Bhattacharya <sumitb@nvidia.com> | 2011-04-08 15:28:21 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-04-12 18:54:37 -0700 |
commit | a52b6fbd3e06242edae1ea84368b4291407a91a1 (patch) | |
tree | a09db5f3e3f6b4c849fd17e741269fa4c798764f /sound | |
parent | aa6214d5c4f9e0e2aea9a3f923255bda29c2f447 (diff) |
ASOC: tegra: Check HP and mic jack status at init
Adding code to scan headphone and mix gpios during alsa init to check
if headphone/mic jacks are connected during bootup or not.
Also removing registering of headphone/mic DAPM pins with jack
detection mechanism. We should not enable DAPM paths just depending
on which jacks are connected. DAPM paths should be enabled/disabled
only when libaudio change alsa routing paths.
Change-Id: I2176176f71b35eaa0ad5405052a83b834cdca17e
Reviewed-on: http://git-master/r/27176
Tested-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/tegra/tegra_wired_jack.c | 86 |
1 files changed, 32 insertions, 54 deletions
diff --git a/sound/soc/tegra/tegra_wired_jack.c b/sound/soc/tegra/tegra_wired_jack.c index 211d69e45818..9a434fe57715 100644 --- a/sound/soc/tegra/tegra_wired_jack.c +++ b/sound/soc/tegra/tegra_wired_jack.c @@ -46,24 +46,16 @@ enum { MIC = 0x11, }; +/* These values are copied from WiredAccessoryObserver */ +enum headset_state { + BIT_NO_HEADSET = 0, + BIT_HEADSET = (1 << 0), + BIT_HEADSET_NO_MIC = (1 << 1), +}; + /* jack */ static struct snd_soc_jack *tegra_wired_jack; -static struct snd_soc_jack_pin wired_jack_pins[] = { - { - .pin = "Headset Jack", - .mask = SND_JACK_HEADSET, - }, - { - .pin = "Headphone Jack", - .mask = SND_JACK_HEADPHONE, - }, - { - .pin = "Mic Jack", - .mask = SND_JACK_MICROPHONE, - }, -}; - static struct snd_soc_jack_gpio wired_jack_gpios[] = { { /* gpio pin depends on board traits */ @@ -91,13 +83,12 @@ void tegra_switch_set_state(int state) switch_set_state(&wired_switch_dev, state); } -static int wired_switch_notify(struct notifier_block *self, - unsigned long action, void* dev) +static enum headset_state get_headset_state(void) { - int state = 0; + enum headset_state state = BIT_NO_HEADSET; int flag = 0; int hp_gpio = -1; - int mic_gpio = -1;; + int mic_gpio = -1; /* hp_det_n is low active pin */ if (tegra_wired_jack_conf.hp_det_n != -1) @@ -109,40 +100,30 @@ static int wired_switch_notify(struct notifier_block *self, flag = (hp_gpio << 4) | mic_gpio; - switch (action) { - case SND_JACK_HEADSET: - state = 1; + switch (flag) { + case NO_DEVICE: + state = BIT_NO_HEADSET; + break; + case HEADSET_WITH_MIC: + state = BIT_HEADSET; break; - case SND_JACK_HEADPHONE: - if (mic_gpio) - state = 1; - else - state = 2; + case MIC: + /* mic: would not report */ break; - case SND_JACK_MICROPHONE: - if (!hp_gpio) /* low = hp */ - state = 1; + case HEADSET_WITHOUT_MIC: + state = BIT_HEADSET_NO_MIC; break; default: - switch (flag) { - case NO_DEVICE: - state = 0; - break; - case HEADSET_WITH_MIC: - state = 1; - break; - case MIC: - /* mic: would not report */ - break; - case HEADSET_WITHOUT_MIC: - state = 2; - break; - default: - state = 0; - } + state = BIT_NO_HEADSET; } - tegra_switch_set_state(state); + return state; +} + +static int wired_switch_notify(struct notifier_block *self, + unsigned long action, void* dev) +{ + tegra_switch_set_state(get_headset_state()); return NOTIFY_OK; } @@ -150,7 +131,7 @@ static int wired_switch_notify(struct notifier_block *self, void tegra_jack_resume(void) { - wired_switch_notify(NULL, SND_JACK_NO_TYPE_SPECIFIED, NULL); + tegra_switch_set_state(get_headset_state()); } static struct notifier_block wired_switch_nb = { @@ -232,6 +213,9 @@ static int tegra_wired_jack_probe(struct platform_device *pdev) tegra_wired_jack_conf.cdc_irq = cdc_irq; tegra_wired_jack_conf.en_spkr = en_spkr; + // Communicate the jack connection state at device bootup + tegra_switch_set_state(get_headset_state()); + #ifdef CONFIG_SWITCH snd_soc_jack_notifier_register(tegra_wired_jack, &wired_switch_nb); @@ -287,12 +271,6 @@ int tegra_jack_init(struct snd_soc_codec *codec) if (ret < 0) goto failed; - ret = snd_soc_jack_add_pins(tegra_wired_jack, - ARRAY_SIZE(wired_jack_pins), - wired_jack_pins); - if (ret < 0) - goto failed; - #ifdef CONFIG_SWITCH /* Addd h2w swith class support */ ret = switch_dev_register(&wired_switch_dev); |