All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Jack handling enhancements as suggested by subsystem maintainer
@ 2009-07-24  0:48 Janusz Krzysztofik
  2009-07-24 10:27 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Janusz Krzysztofik @ 2009-07-24  0:48 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel

The patch adds a few small enhancements to the ASoC jack handling, as 
suggested by Mark in his comments to my Amstrad Delta driver, and a few fixes 
for related bugs found while learning Mark's code and testing results.

Enhancements:
1. Update status of an ASoC jack while associating it with new gpios.
2. Really update DAPM pins while associating them with an ASoC jack.
3. Export ASoC jack gpios over gpiolib sysfs for diagnostic purposes.

Fixes:
1. Apply mask on jack status report before using it, just for case.
2. While updating jack associated DAPM pins, use full resulting jack status,
   not the status report passed as an argument.

Created and tested on linux-2.6.31-rc3

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
--- linux-2.6.31-rc3/sound/soc/soc-jack.c.orig	2009-07-14 03:18:52.000000000 +0200
+++ linux-2.6.31-rc3/sound/soc/soc-jack.c	2009-07-24 02:47:06.000000000 +0200
@@ -73,14 +73,15 @@ void snd_soc_jack_report(struct snd_soc_
 	oldstatus = jack->status;
 
 	jack->status &= ~mask;
-	jack->status |= status;
+	jack->status |= status & mask;
 
-	/* The DAPM sync is expensive enough to be worth skipping */
-	if (jack->status == oldstatus)
+	/* The DAPM sync is expensive enough to be worth skipping.
+	 * However, empty mask means pin synchronization is desired. */
+	if (mask && (jack->status == oldstatus))
 		goto out;
 
 	list_for_each_entry(pin, &jack->pins, list) {
-		enable = pin->mask & status;
+		enable = pin->mask & jack->status;
 
 		if (pin->invert)
 			enable = !enable;
@@ -228,8 +229,16 @@ int snd_soc_jack_add_gpios(struct snd_so
 		if (ret)
 			goto err;
 
+#ifdef CONFIG_GPIO_SYSFS
+		/* Expose GPIO value over sysfs for diagnostic purposes */
+		gpio_export(gpios[i].gpio, false);
+#endif
+
 		INIT_WORK(&gpios[i].work, gpio_work);
 		gpios[i].jack = jack;
+
+		/* Update initial jack status */
+		snd_soc_jack_gpio_detect(&gpios[i]);
 	}
 
 	return 0;
@@ -258,6 +267,9 @@ void snd_soc_jack_free_gpios(struct snd_
 	int i;
 
 	for (i = 0; i < count; i++) {
+#ifdef CONFIG_GPIO_SYSFS
+		gpio_unexport(gpios[i].gpio);
+#endif
 		free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]);
 		gpio_free(gpios[i].gpio);
 		gpios[i].jack = NULL;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-24 10:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-24  0:48 [PATCH] ASoC: Jack handling enhancements as suggested by subsystem maintainer Janusz Krzysztofik
2009-07-24 10:27 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.