]> err.no Git - linux-2.6/blobdiff - sound/ppc/tumbler.c
[PATCH] Consolidate the asm-ppc*/fcntl.h files into asm-powerpc
[linux-2.6] / sound / ppc / tumbler.c
index c71807e069ee6a22cf316d438d55695a2350e18c..b94437c024b1dfce38f39279b3876f935589c838 100644 (file)
@@ -99,6 +99,7 @@ typedef struct pmac_tumbler_t {
        pmac_gpio_t hp_detect;
        int headphone_irq;
        int lineout_irq;
+       unsigned int save_master_vol[2];
        unsigned int master_vol[2];
        unsigned int save_master_switch[2];
        unsigned int master_switch[2];
@@ -177,11 +178,22 @@ static void write_audio_gpio(pmac_gpio_t *gp, int active)
        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 +695,7 @@ static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
        }
        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 +723,7 @@ static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
        }
        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 +909,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)
 {
-       //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);
        }
 }
 
@@ -933,7 +945,7 @@ static void device_change_handler(void *self)
                        check_mute(chip, &mix->line_mute, 0, mix->auto_mute_notify,
                                   chip->lineout_sw_ctl);
                if (mix->anded_reset)
-                       big_mdelay(10);
+                       msleep(10);
                check_mute(chip, &mix->amp_mute, 1, mix->auto_mute_notify,
                           chip->speaker_sw_ctl);
                mix->drc_enable = 0;
@@ -942,7 +954,7 @@ static void device_change_handler(void *self)
                check_mute(chip, &mix->amp_mute, 0, mix->auto_mute_notify,
                           chip->speaker_sw_ctl);
                if (mix->anded_reset)
-                       big_mdelay(10);
+                       msleep(10);
                check_mute(chip, &mix->hp_mute, 1, mix->auto_mute_notify,
                           chip->master_sw_ctl);
                if (mix->line_mute.addr != 0)
@@ -1097,26 +1109,26 @@ static void tumbler_reset_audio(pmac_t *chip)
                DBG("(I) codec anded reset !\n");
                write_audio_gpio(&mix->hp_mute, 0);
                write_audio_gpio(&mix->amp_mute, 0);
-               big_mdelay(200);
+               msleep(200);
                write_audio_gpio(&mix->hp_mute, 1);
                write_audio_gpio(&mix->amp_mute, 1);
-               big_mdelay(100);
+               msleep(100);
                write_audio_gpio(&mix->hp_mute, 0);
                write_audio_gpio(&mix->amp_mute, 0);
-               big_mdelay(100);
+               msleep(100);
        } else {
                DBG("(I) codec normal reset !\n");
 
                write_audio_gpio(&mix->audio_reset, 0);
-               big_mdelay(200);
+               msleep(200);
                write_audio_gpio(&mix->audio_reset, 1);
-               big_mdelay(100);
+               msleep(100);
                write_audio_gpio(&mix->audio_reset, 0);
-               big_mdelay(100);
+               msleep(100);
        }
 }
 
-#ifdef CONFIG_PMAC_PBOOK
+#ifdef CONFIG_PM
 /* suspend mixer */
 static void tumbler_suspend(pmac_t *chip)
 {
@@ -1128,6 +1140,8 @@ static void tumbler_suspend(pmac_t *chip)
                disable_irq(mix->lineout_irq);
        mix->save_master_switch[0] = mix->master_switch[0];
        mix->save_master_switch[1] = mix->master_switch[1];
+       mix->save_master_vol[0] = mix->master_vol[0];
+       mix->save_master_vol[1] = mix->master_vol[1];
        mix->master_switch[0] = mix->master_switch[1] = 0;
        tumbler_set_master_volume(mix);
        if (!mix->anded_reset) {
@@ -1155,6 +1169,8 @@ static void tumbler_resume(pmac_t *chip)
        mix->acs &= ~1;
        mix->master_switch[0] = mix->save_master_switch[0];
        mix->master_switch[1] = mix->save_master_switch[1];
+       mix->master_vol[0] = mix->save_master_vol[0];
+       mix->master_vol[1] = mix->save_master_vol[1];
        tumbler_reset_audio(chip);
        if (mix->i2c.client && mix->i2c.init_client) {
                if (mix->i2c.init_client(&mix->i2c) < 0)
@@ -1354,7 +1370,7 @@ int __init snd_pmac_tumbler_init(pmac_t *chip)
        if ((err = snd_ctl_add(chip->card, chip->drc_sw_ctl)) < 0)
                return err;
 
-#ifdef CONFIG_PMAC_PBOOK
+#ifdef CONFIG_PM
        chip->suspend = tumbler_suspend;
        chip->resume = tumbler_resume;
 #endif