Skip to content

Commit

Permalink
CHROMIUM: ALSA: ASoC: Get snow hp/mic detect GPIOs from device tree.
Browse files Browse the repository at this point in the history
Get the GPIOs used for hp and mic detect from the device tree.  Getting
them from device tree allows for the pull up/pull down to be properly
configured (it is disabled) and for mic detect to be inverted.

BUG=chrome-os-partner:10849
TEST=aplay/arecord on snow work.  evtest shows events for hp and mic
detection.

Signed-off-by: Dylan Reid <[email protected]>

Change-Id: I93d994a2ec5c22683c6eb5fd502f6a54c8e8d964
Reviewed-on: https://gerrit.chromium.org/gerrit/29626
Reviewed-by: Olof Johansson <[email protected]>
Tested-by: Dylan Reid <[email protected]>
Commit-Ready: Dylan Reid <[email protected]>
  • Loading branch information
dgreid authored and hsnaves committed Jun 30, 2014
1 parent 2ae375a commit ce029e0
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions sound/soc/samsung/daisy_max98095.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/of_gpio.h>

#include <sound/soc.h>
#include <sound/soc-dapm.h>
Expand Down Expand Up @@ -282,6 +283,11 @@ static struct snd_soc_jack_pin daisy_mic_jack_pins[] = {
},
};

static struct snd_soc_jack_gpio daisy_mic_jack_gpio = {
.name = "mic detect",
.report = SND_JACK_MICROPHONE,
};

static const struct snd_soc_dapm_route daisy_audio_map[] = {
{"Mic Jack", "NULL", "MICBIAS2"},
{"MIC2", "NULL", "Mic Jack"},
Expand All @@ -296,27 +302,39 @@ static int daisy_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_dapm_context *dapm = &codec->dapm;
struct snd_soc_card *card = codec->card;
struct device_node *dn = card->dev->of_node;

/* TODO(thutt): This must be hooked up to the headphone-switch
* & microphone-detect GPIOs on the Exynos and plumbed through
* to to /dev/input. These two GPIOs are presently done as a
* rework to existing boards.
*/
snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
&daisy_mic_jack);
snd_soc_jack_add_pins(&daisy_mic_jack,
ARRAY_SIZE(daisy_mic_jack_pins),
daisy_mic_jack_pins);

/* TODO: Move this to device tree */
if (of_machine_is_compatible("google,snow")) {
daisy_hp_jack_gpio.gpio = EXYNOS5_GPX2(2);
if (dn) {
enum of_gpio_flags flags;

daisy_mic_jack_gpio.gpio = of_get_named_gpio_flags(
dn, "samsung,mic-det-gpios", 0, &flags);
daisy_mic_jack_gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW);

daisy_hp_jack_gpio.gpio = of_get_named_gpio_flags(
dn, "samsung,hp-det-gpios", 0, &flags);
daisy_hp_jack_gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW);
}

if (gpio_is_valid(daisy_mic_jack_gpio.gpio)) {
snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
&daisy_mic_jack);
snd_soc_jack_add_pins(&daisy_mic_jack,
ARRAY_SIZE(daisy_mic_jack_pins),
daisy_mic_jack_pins);
snd_soc_jack_add_gpios(&daisy_mic_jack, 1,
&daisy_mic_jack_gpio);
}

if (gpio_is_valid(daisy_hp_jack_gpio.gpio)) {
snd_soc_jack_new(codec, "Headphone Jack",
SND_JACK_HEADPHONE, &daisy_hp_jack);
snd_soc_jack_add_pins(&daisy_hp_jack,
ARRAY_SIZE(daisy_hp_jack_pins),
daisy_hp_jack_pins);
snd_soc_jack_add_gpios(&daisy_hp_jack, 1, &daisy_hp_jack_gpio);
snd_soc_jack_add_gpios(&daisy_hp_jack, 1,
&daisy_hp_jack_gpio);
}

/* Microphone BIAS is needed to power the analog mic.
Expand Down

0 comments on commit ce029e0

Please sign in to comment.