2005-04-13 11:23:38

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: [PATCH] ppc64: improve g5 sound headphone mute

Hi !

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 <[email protected]>

Index: linux-work/sound/ppc/tumbler.c
===================================================================
--- linux-work.orig/sound/ppc/tumbler.c 2005-04-12 18:07:50.000000000 +1000
+++ linux-work/sound/ppc/tumbler.c 2005-04-13 18:02:26.000000000 +1000
@@ -177,11 +177,22 @@
if (! gp->addr)
return;
active = active ? gp->active_val : gp->inactive_val;
-
do_gpio_write(gp, active);
DBG("(I) gpio %x write %d\n", gp->addr, active);
}

+static int check_audio_gpio(pmac_gpio_t *gp)
+{
+ int ret;
+
+ if (! gp->addr)
+ return 0;
+
+ ret = do_gpio_read(gp);
+
+ return (ret & 0xd) == (gp->active_val & 0xd);
+}
+
static int read_audio_gpio(pmac_gpio_t *gp)
{
int ret;
@@ -683,7 +694,7 @@
}
if (gp == NULL)
return -EINVAL;
- ucontrol->value.integer.value[0] = ! read_audio_gpio(gp);
+ ucontrol->value.integer.value[0] = !check_audio_gpio(gp);
return 0;
}

@@ -711,7 +722,7 @@
}
if (gp == NULL)
return -EINVAL;
- val = ! read_audio_gpio(gp);
+ val = ! check_audio_gpio(gp);
if (val != ucontrol->value.integer.value[0]) {
write_audio_gpio(gp, ! ucontrol->value.integer.value[0]);
return 1;
@@ -897,11 +908,11 @@

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->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->card, SNDRV_CTL_EVENT_MASK_VALUE, &sw->id);
+ snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
+ &sw->id);
}
}




2005-04-14 00:30:12

by Andrea Arcangeli

[permalink] [raw]
Subject: Re: [PATCH] ppc64: improve g5 sound headphone mute

On Wed, Apr 13, 2005 at 09:23:02PM +1000, Benjamin Herrenschmidt wrote:
> Hi !
>
> 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.

It works great here with all patches applied, thanks!

2005-04-16 12:56:13

by Andreas Schwab

[permalink] [raw]
Subject: Re: [PATCH] ppc64: improve g5 sound headphone mute

Benjamin Herrenschmidt <[email protected]> writes:

> 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.

There's still a minor problem: when booting with line-out plugged (didn't
try headphone yet) the initial volume settings are still not right.
Unplugging and plugging again fixes this.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstra?e 5, 90409 N?rnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2005-04-16 14:28:35

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH] ppc64: improve g5 sound headphone mute

On Sat, 2005-04-16 at 14:56 +0200, Andreas Schwab wrote:
> Benjamin Herrenschmidt <[email protected]> writes:
>
> > 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.
>
> There's still a minor problem: when booting with line-out plugged (didn't
> try headphone yet) the initial volume settings are still not right.
> Unplugging and plugging again fixes this.

It can be either alsa not restoring the setup properly, or a bug in the
driver I'm still chasing where the headphone detection happens before
propoer initialisation of the rest of the driver ...