aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2014-10-02 12:42:44 -0400
committerMark Brown <broonie@kernel.org>2014-10-03 06:22:02 -0400
commit9766a1cfe5ef2042d1e604e2223629dc43307a21 (patch)
tree5441936629e0f4b72e4e21b5daf33b9fb01ca0a5 /sound
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff)
ASoC: tegra: add mic detect gpio to tegra_max98090
Add an optional mic detect gpio property. If specified in device tree there will be a mic jack created for the given gpio. This will be used by the Tegra-based Chromebooks. Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/tegra/tegra_max98090.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c
index b86cd9936ef1..01921d7e73fa 100644
--- a/sound/soc/tegra/tegra_max98090.c
+++ b/sound/soc/tegra/tegra_max98090.c
@@ -42,6 +42,7 @@
42struct tegra_max98090 { 42struct tegra_max98090 {
43 struct tegra_asoc_utils_data util_data; 43 struct tegra_asoc_utils_data util_data;
44 int gpio_hp_det; 44 int gpio_hp_det;
45 int gpio_mic_det;
45}; 46};
46 47
47static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream, 48static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream,
@@ -112,6 +113,22 @@ static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio = {
112 .invert = 1, 113 .invert = 1,
113}; 114};
114 115
116static struct snd_soc_jack tegra_max98090_mic_jack;
117
118static struct snd_soc_jack_pin tegra_max98090_mic_jack_pins[] = {
119 {
120 .pin = "Mic Jack",
121 .mask = SND_JACK_MICROPHONE,
122 },
123};
124
125static struct snd_soc_jack_gpio tegra_max98090_mic_jack_gpio = {
126 .name = "Mic detection",
127 .report = SND_JACK_MICROPHONE,
128 .debounce_time = 150,
129 .invert = 1,
130};
131
115static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = { 132static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = {
116 SND_SOC_DAPM_HP("Headphones", NULL), 133 SND_SOC_DAPM_HP("Headphones", NULL),
117 SND_SOC_DAPM_SPK("Speakers", NULL), 134 SND_SOC_DAPM_SPK("Speakers", NULL),
@@ -141,6 +158,19 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
141 &tegra_max98090_hp_jack_gpio); 158 &tegra_max98090_hp_jack_gpio);
142 } 159 }
143 160
161 if (gpio_is_valid(machine->gpio_mic_det)) {
162 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
163 &tegra_max98090_mic_jack);
164 snd_soc_jack_add_pins(&tegra_max98090_mic_jack,
165 ARRAY_SIZE(tegra_max98090_mic_jack_pins),
166 tegra_max98090_mic_jack_pins);
167
168 tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det;
169 snd_soc_jack_add_gpios(&tegra_max98090_mic_jack,
170 1,
171 &tegra_max98090_mic_jack_gpio);
172 }
173
144 return 0; 174 return 0;
145} 175}
146 176
@@ -153,6 +183,11 @@ static int tegra_max98090_card_remove(struct snd_soc_card *card)
153 &tegra_max98090_hp_jack_gpio); 183 &tegra_max98090_hp_jack_gpio);
154 } 184 }
155 185
186 if (gpio_is_valid(machine->gpio_mic_det)) {
187 snd_soc_jack_free_gpios(&tegra_max98090_mic_jack, 1,
188 &tegra_max98090_mic_jack_gpio);
189 }
190
156 return 0; 191 return 0;
157} 192}
158 193
@@ -201,6 +236,11 @@ static int tegra_max98090_probe(struct platform_device *pdev)
201 if (machine->gpio_hp_det == -EPROBE_DEFER) 236 if (machine->gpio_hp_det == -EPROBE_DEFER)
202 return -EPROBE_DEFER; 237 return -EPROBE_DEFER;
203 238
239 machine->gpio_mic_det =
240 of_get_named_gpio(np, "nvidia,mic-det-gpios", 0);
241 if (machine->gpio_mic_det == -EPROBE_DEFER)
242 return -EPROBE_DEFER;
243
204 ret = snd_soc_of_parse_card_name(card, "nvidia,model"); 244 ret = snd_soc_of_parse_card_name(card, "nvidia,model");
205 if (ret) 245 if (ret)
206 goto err; 246 goto err;