ALSA: snd-powermac: HP detection for 1st iMac G3 SL
authorRisto Suominen <Risto.Suominen@gmail.com>
Mon, 25 Aug 2008 06:04:23 +0000 (08:04 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 2 Oct 2008 10:50:37 +0000 (12:50 +0200)
Correct headphone detection for 1st generation iMac G3 Slot-loading (Screamer).

This patch fixes the regression in the recent snd-powermac which
doesn't support some G3/G4 PowerMacs:
    http://lkml.org/lkml/2008/10/1/220

Signed-off-by: Risto Suominen <Risto.Suominen@gmail.com>
Tested-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Cc: stable@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/ppc/awacs.c

index 543d4f1..106c482 100644 (file)
@@ -695,7 +695,10 @@ static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __initdata = {
 static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __initdata =
 AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1);
 
-static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac __initdata =
+static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 __initdata =
+AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 1);
+
+static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 __initdata =
 AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 0);
 
 
@@ -772,12 +775,12 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip)
 
 #define IS_PM7500 (machine_is_compatible("AAPL,7500"))
 #define IS_BEIGE (machine_is_compatible("AAPL,Gossamer"))
-#define IS_IMAC (machine_is_compatible("PowerMac2,1") \
-               || machine_is_compatible("PowerMac2,2") \
+#define IS_IMAC1 (machine_is_compatible("PowerMac2,1"))
+#define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \
                || machine_is_compatible("PowerMac4,1"))
 #define IS_G4AGP (machine_is_compatible("PowerMac3,1"))
 
-static int imac;
+static int imac1, imac2;
 
 #ifdef PMAC_SUPPORT_AUTOMUTE
 /*
@@ -823,13 +826,18 @@ static void snd_pmac_awacs_update_automute(struct snd_pmac *chip, int do_notify)
                {
                        int reg = chip->awacs_reg[1]
                                | (MASK_HDMUTE | MASK_SPKMUTE);
-                       if (imac) {
+                       if (imac1) {
+                               reg &= ~MASK_SPKMUTE;
+                               reg |= MASK_PAROUT1;
+                       } else if (imac2) {
                                reg &= ~MASK_SPKMUTE;
                                reg &= ~MASK_PAROUT1;
                        }
                        if (snd_pmac_awacs_detect_headphone(chip))
                                reg &= ~MASK_HDMUTE;
-                       else if (imac)
+                       else if (imac1)
+                               reg &= ~MASK_PAROUT1;
+                       else if (imac2)
                                reg |= MASK_PAROUT1;
                        else
                                reg &= ~MASK_SPKMUTE;
@@ -859,9 +867,12 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
        int pm7500 = IS_PM7500;
        int beige = IS_BEIGE;
        int g4agp = IS_G4AGP;
+       int imac;
        int err, vol;
 
-       imac = IS_IMAC;
+       imac1 = IS_IMAC1;
+       imac2 = IS_IMAC2;
+       imac = imac1 || imac2;
        /* looks like MASK_GAINLINE triggers something, so we set here
         * as start-up
         */
@@ -1017,8 +1028,10 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
                                        snd_pmac_awacs_speaker_vol);
                if (err < 0)
                        return err;
-               chip->speaker_sw_ctl = snd_ctl_new1(imac
-                               ? &snd_pmac_awacs_speaker_sw_imac
+               chip->speaker_sw_ctl = snd_ctl_new1(imac1
+                               ? &snd_pmac_awacs_speaker_sw_imac1
+                               : imac2
+                               ? &snd_pmac_awacs_speaker_sw_imac2
                                : &snd_pmac_awacs_speaker_sw, chip);
                err = snd_ctl_add(chip->card, chip->speaker_sw_ctl);
                if (err < 0)