aboutsummaryrefslogtreecommitdiffstats
path: root/sound/ppc/tumbler.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/ppc/tumbler.c')
-rw-r--r--sound/ppc/tumbler.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index c71807e069ee..9332237cb6a4 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -99,6 +99,7 @@ typedef struct pmac_tumbler_t {
99 pmac_gpio_t hp_detect; 99 pmac_gpio_t hp_detect;
100 int headphone_irq; 100 int headphone_irq;
101 int lineout_irq; 101 int lineout_irq;
102 unsigned int save_master_vol[2];
102 unsigned int master_vol[2]; 103 unsigned int master_vol[2];
103 unsigned int save_master_switch[2]; 104 unsigned int save_master_switch[2];
104 unsigned int master_switch[2]; 105 unsigned int master_switch[2];
@@ -177,11 +178,22 @@ static void write_audio_gpio(pmac_gpio_t *gp, int active)
177 if (! gp->addr) 178 if (! gp->addr)
178 return; 179 return;
179 active = active ? gp->active_val : gp->inactive_val; 180 active = active ? gp->active_val : gp->inactive_val;
180
181 do_gpio_write(gp, active); 181 do_gpio_write(gp, active);
182 DBG("(I) gpio %x write %d\n", gp->addr, active); 182 DBG("(I) gpio %x write %d\n", gp->addr, active);
183} 183}
184 184
185static int check_audio_gpio(pmac_gpio_t *gp)
186{
187 int ret;
188
189 if (! gp->addr)
190 return 0;
191
192 ret = do_gpio_read(gp);
193
194 return (ret & 0xd) == (gp->active_val & 0xd);
195}
196
185static int read_audio_gpio(pmac_gpio_t *gp) 197static int read_audio_gpio(pmac_gpio_t *gp)
186{ 198{
187 int ret; 199 int ret;
@@ -683,7 +695,7 @@ static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
683 } 695 }
684 if (gp == NULL) 696 if (gp == NULL)
685 return -EINVAL; 697 return -EINVAL;
686 ucontrol->value.integer.value[0] = ! read_audio_gpio(gp); 698 ucontrol->value.integer.value[0] = !check_audio_gpio(gp);
687 return 0; 699 return 0;
688} 700}
689 701
@@ -711,7 +723,7 @@ static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
711 } 723 }
712 if (gp == NULL) 724 if (gp == NULL)
713 return -EINVAL; 725 return -EINVAL;
714 val = ! read_audio_gpio(gp); 726 val = ! check_audio_gpio(gp);
715 if (val != ucontrol->value.integer.value[0]) { 727 if (val != ucontrol->value.integer.value[0]) {
716 write_audio_gpio(gp, ! ucontrol->value.integer.value[0]); 728 write_audio_gpio(gp, ! ucontrol->value.integer.value[0]);
717 return 1; 729 return 1;
@@ -897,11 +909,11 @@ static int tumbler_detect_lineout(pmac_t *chip)
897 909
898static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw) 910static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw)
899{ 911{
900 //pmac_tumbler_t *mix = chip->mixer_data; 912 if (check_audio_gpio(gp) != val) {
901 if (val != read_audio_gpio(gp)) {
902 write_audio_gpio(gp, val); 913 write_audio_gpio(gp, val);
903 if (do_notify) 914 if (do_notify)
904 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &sw->id); 915 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
916 &sw->id);
905 } 917 }
906} 918}
907 919
@@ -1128,6 +1140,8 @@ static void tumbler_suspend(pmac_t *chip)
1128 disable_irq(mix->lineout_irq); 1140 disable_irq(mix->lineout_irq);
1129 mix->save_master_switch[0] = mix->master_switch[0]; 1141 mix->save_master_switch[0] = mix->master_switch[0];
1130 mix->save_master_switch[1] = mix->master_switch[1]; 1142 mix->save_master_switch[1] = mix->master_switch[1];
1143 mix->save_master_vol[0] = mix->master_vol[0];
1144 mix->save_master_vol[1] = mix->master_vol[1];
1131 mix->master_switch[0] = mix->master_switch[1] = 0; 1145 mix->master_switch[0] = mix->master_switch[1] = 0;
1132 tumbler_set_master_volume(mix); 1146 tumbler_set_master_volume(mix);
1133 if (!mix->anded_reset) { 1147 if (!mix->anded_reset) {
@@ -1155,6 +1169,8 @@ static void tumbler_resume(pmac_t *chip)
1155 mix->acs &= ~1; 1169 mix->acs &= ~1;
1156 mix->master_switch[0] = mix->save_master_switch[0]; 1170 mix->master_switch[0] = mix->save_master_switch[0];
1157 mix->master_switch[1] = mix->save_master_switch[1]; 1171 mix->master_switch[1] = mix->save_master_switch[1];
1172 mix->master_vol[0] = mix->save_master_vol[0];
1173 mix->master_vol[1] = mix->save_master_vol[1];
1158 tumbler_reset_audio(chip); 1174 tumbler_reset_audio(chip);
1159 if (mix->i2c.client && mix->i2c.init_client) { 1175 if (mix->i2c.client && mix->i2c.init_client) {
1160 if (mix->i2c.init_client(&mix->i2c) < 0) 1176 if (mix->i2c.init_client(&mix->i2c) < 0)