Commit 4be8dc7f authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Linus Torvalds

[PATCH] ppc64: improve g5 sound headphone mute

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: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1bdacf88
...@@ -177,11 +177,22 @@ static void write_audio_gpio(pmac_gpio_t *gp, int active) ...@@ -177,11 +177,22 @@ static void write_audio_gpio(pmac_gpio_t *gp, int active)
if (! gp->addr) if (! gp->addr)
return; return;
active = active ? gp->active_val : gp->inactive_val; active = active ? gp->active_val : gp->inactive_val;
do_gpio_write(gp, active); do_gpio_write(gp, active);
DBG("(I) gpio %x write %d\n", gp->addr, 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) static int read_audio_gpio(pmac_gpio_t *gp)
{ {
int ret; int ret;
...@@ -683,7 +694,7 @@ static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ ...@@ -683,7 +694,7 @@ static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
} }
if (gp == NULL) if (gp == NULL)
return -EINVAL; return -EINVAL;
ucontrol->value.integer.value[0] = ! read_audio_gpio(gp); ucontrol->value.integer.value[0] = !check_audio_gpio(gp);
return 0; return 0;
} }
...@@ -711,7 +722,7 @@ static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ ...@@ -711,7 +722,7 @@ static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
} }
if (gp == NULL) if (gp == NULL)
return -EINVAL; return -EINVAL;
val = ! read_audio_gpio(gp); val = ! check_audio_gpio(gp);
if (val != ucontrol->value.integer.value[0]) { if (val != ucontrol->value.integer.value[0]) {
write_audio_gpio(gp, ! ucontrol->value.integer.value[0]); write_audio_gpio(gp, ! ucontrol->value.integer.value[0]);
return 1; return 1;
...@@ -897,11 +908,11 @@ static int tumbler_detect_lineout(pmac_t *chip) ...@@ -897,11 +908,11 @@ static int tumbler_detect_lineout(pmac_t *chip)
static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw) 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 (check_audio_gpio(gp) != val) {
if (val != read_audio_gpio(gp)) {
write_audio_gpio(gp, val); write_audio_gpio(gp, val);
if (do_notify) 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);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment