<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;

This patch fixes a couple more issues with the management of the GPIOs
dealing with headphone and line out mute on the G5.  It should fix the
remaining problems of people not getting any sound out of the headphone
jack.

Signed-off-by: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
---

 sound/ppc/tumbler.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff -puN sound/ppc/tumbler.c~ppc64-improve-g5-sound-headphone-mute sound/ppc/tumbler.c
--- 25/sound/ppc/tumbler.c~ppc64-improve-g5-sound-headphone-mute	2005-04-25 18:27:21.680510480 -0700
+++ 25-akpm/sound/ppc/tumbler.c	2005-04-25 18:28:14.362501600 -0700
@@ -177,11 +177,22 @@ static void write_audio_gpio(pmac_gpio_t
 	if (! gp-&gt;addr)
 		return;
 	active = active ? gp-&gt;active_val : gp-&gt;inactive_val;
-
 	do_gpio_write(gp, active);
 	DBG("(I) gpio %x write %d\n", gp-&gt;addr, active);
 }
 
+static int check_audio_gpio(pmac_gpio_t *gp)
+{
+	int ret;
+
+	if (! gp-&gt;addr)
+		return 0;
+
+	ret = do_gpio_read(gp);
+
+	return (ret &amp; 0xd) == (gp-&gt;active_val &amp; 0xd);
+}
+
 static int read_audio_gpio(pmac_gpio_t *gp)
 {
 	int ret;
@@ -683,7 +694,7 @@ static int tumbler_get_mute_switch(snd_k
 	}
 	if (gp == NULL)
 		return -EINVAL;
-	ucontrol-&gt;value.integer.value[0] = ! read_audio_gpio(gp);
+	ucontrol-&gt;value.integer.value[0] = !check_audio_gpio(gp);
 	return 0;
 }
 
@@ -711,7 +722,7 @@ static int tumbler_put_mute_switch(snd_k
 	}
 	if (gp == NULL)
 		return -EINVAL;
-	val = ! read_audio_gpio(gp);
+	val = ! check_audio_gpio(gp);
 	if (val != ucontrol-&gt;value.integer.value[0]) {
 		write_audio_gpio(gp, ! ucontrol-&gt;value.integer.value[0]);
 		return 1;
@@ -897,11 +908,11 @@ static int tumbler_detect_lineout(pmac_t
 
 static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw)
 {
-	//pmac_tumbler_t *mix = chip-&gt;mixer_data;
-	if (val != read_audio_gpio(gp)) {
+	if (check_audio_gpio(gp) != val) {
 		write_audio_gpio(gp, val);
 		if (do_notify)
-			snd_ctl_notify(chip-&gt;card, SNDRV_CTL_EVENT_MASK_VALUE, &amp;sw-&gt;id);
+			snd_ctl_notify(chip-&gt;card, SNDRV_CTL_EVENT_MASK_VALUE,
+				       &amp;sw-&gt;id);
 	}
 }
 
_
</pre></body></html>