ALSA: snd-powermac: HP detection for 1st iMac G3 SL

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>
This commit is contained in:
Risto Suominen 2008-08-25 08:04:23 +02:00 committed by Takashi Iwai
parent 4dbf95ba6c
commit 030b655b06

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