aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut@gmail.com>2011-04-01 21:43:15 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-04-03 09:11:09 -0400
commit04368d051a6aa90c14a3ca5a48f60aca2f6ecdd1 (patch)
tree8be790055a82ce4c7c7c99e8defbfbd8962506a4
parent363618f013f2f11a1089b610748beb5de93b8630 (diff)
ASoC: Properly handle spitz MIC GPIO
This patch firstly restructurizes the code a bit by getting rid of continuous checking for machine type in spitz_mic_bias(). Then the patch properly requests the MIC GPIO in the spitz_init() and frees it in spitz_exit(). Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/pxa/spitz.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index 8e1571350630..b253d864868a 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -42,6 +42,7 @@
42 42
43static int spitz_jack_func; 43static int spitz_jack_func;
44static int spitz_spk_func; 44static int spitz_spk_func;
45static int spitz_mic_gpio;
45 46
46static void spitz_ext_control(struct snd_soc_codec *codec) 47static void spitz_ext_control(struct snd_soc_codec *codec)
47{ 48{
@@ -217,14 +218,7 @@ static int spitz_set_spk(struct snd_kcontrol *kcontrol,
217static int spitz_mic_bias(struct snd_soc_dapm_widget *w, 218static int spitz_mic_bias(struct snd_soc_dapm_widget *w,
218 struct snd_kcontrol *k, int event) 219 struct snd_kcontrol *k, int event)
219{ 220{
220 if (machine_is_borzoi() || machine_is_spitz()) 221 gpio_set_value_cansleep(spitz_mic_gpio, SND_SOC_DAPM_EVENT_ON(event));
221 gpio_set_value(SPITZ_GPIO_MIC_BIAS,
222 SND_SOC_DAPM_EVENT_ON(event));
223
224 if (machine_is_akita())
225 gpio_set_value(AKITA_GPIO_MIC_BIAS,
226 SND_SOC_DAPM_EVENT_ON(event));
227
228 return 0; 222 return 0;
229} 223}
230 224
@@ -339,22 +333,45 @@ static int __init spitz_init(void)
339 if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) 333 if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita()))
340 return -ENODEV; 334 return -ENODEV;
341 335
336 if (machine_is_borzoi() || machine_is_spitz())
337 spitz_mic_gpio = SPITZ_GPIO_MIC_BIAS;
338 else
339 spitz_mic_gpio = AKITA_GPIO_MIC_BIAS;
340
341 ret = gpio_request(spitz_mic_gpio, "MIC GPIO");
342 if (ret)
343 goto err1;
344
345 ret = gpio_direction_output(spitz_mic_gpio, 0);
346 if (ret)
347 goto err2;
348
342 spitz_snd_device = platform_device_alloc("soc-audio", -1); 349 spitz_snd_device = platform_device_alloc("soc-audio", -1);
343 if (!spitz_snd_device) 350 if (!spitz_snd_device) {
344 return -ENOMEM; 351 ret = -ENOMEM;
352 goto err2;
353 }
345 354
346 platform_set_drvdata(spitz_snd_device, &snd_soc_spitz); 355 platform_set_drvdata(spitz_snd_device, &snd_soc_spitz);
347 ret = platform_device_add(spitz_snd_device);
348 356
357 ret = platform_device_add(spitz_snd_device);
349 if (ret) 358 if (ret)
350 platform_device_put(spitz_snd_device); 359 goto err3;
360
361 return 0;
351 362
363err3:
364 platform_device_put(spitz_snd_device);
365err2:
366 gpio_free(spitz_mic_gpio);
367err1:
352 return ret; 368 return ret;
353} 369}
354 370
355static void __exit spitz_exit(void) 371static void __exit spitz_exit(void)
356{ 372{
357 platform_device_unregister(spitz_snd_device); 373 platform_device_unregister(spitz_snd_device);
374 gpio_free(spitz_mic_gpio);
358} 375}
359 376
360module_init(spitz_init); 377module_init(spitz_init);