Skip to contentSkip to conversation

Problems with multiple simultaneous ac97 quirks

DISCUSSION Matthew Garrett 3 participants 9 messages Sep 15, 2005 – Sep 16, 2005 Sound

lore
Share & tools
lore
#0 lore raw

Hi,

Lots of current HP hardware would benefit from both AC97_TUNE_MUTE_LED and AC97_TUNE_HP_ONLY. However, this is made difficult by the fact that both of these options set the master volume switch put function to their own one. This is easy enough to work around by adding another quirk, but that would soon lead to combinatorial explosion. What's the best approach to being able to add multiple interacting quirks?

Signature · 8 lines
Matthew Garrett | [email protected]


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
#1 lore raw

At Thu, 15 Sep 2005 19:04:15 +0100,

Quoted 9 lines · Matthew Garrett

Hi,

Lots of current HP hardware would benefit from both AC97_TUNE_MUTE_LED and AC97_TUNE_HP_ONLY. However, this is made difficult by the fact that both of these options set the master volume switch put function to their own one. This is easy enough to work around by adding another quirk, but that would soon lead to combinatorial explosion. What's the best approach to being able to add multiple interacting quirks?

I think the new quirk is the only solution in this case. And there won't be so many combinations in the real world, I'd expect.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#2 lore raw
Quoted 3 lines · Takashi Iwai

I think the new quirk is the only solution in this case. And there won't be so many combinations in the real world, I'd expect.

Ok. Something like the following patch? It introduces AC97_TUNE_HP_MUTE_LED (yes, it's a poor name...) which is identical to AC97_TUNE_MUTE_LED except it calls bind_hp_volsw_put instead of snd_ac97_put_volsw and removes the headphone mixer controls.

Signature · 1 line
Matthew Garrett | [email protected]
sound/pci/ac97/ac97_codec.c renamed from pci/ac97/ac97_codec.c.orig +3 -2
@@ -2551,9 +2551,10 @@ int snd_ac97_tune_hardware(ac97_t *ac97,
 				continue;
 			snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device);
 			result = apply_quirk(ac97, quirk->type);
-			if (result < 0)
+			if (result < 0) {
 				snd_printk(KERN_ERR "applying quirk type %d for %s failed (%d)\n", quirk->type, quirk->name, result);
-			return result;
+				return result;
+			}
 		}
 	}
 	return 0;
#3 lore raw

At Thu, 15 Sep 2005 21:28:58 +0100,

Quoted 11 lines · Matthew Garrett
Quoted 3 lines · Takashi Iwai

I think the new quirk is the only solution in this case. And there won't be so many combinations in the real world, I'd expect.

Ok. Something like the following patch? It introduces AC97_TUNE_HP_MUTE_LED (yes, it's a poor name...) which is identical to AC97_TUNE_MUTE_LED except it calls bind_hp_volsw_put instead of snd_ac97_put_volsw and removes the headphone mixer controls.

Looks like the most of patch is missing...

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#4 lore raw
In reply to Matthew Garrett
Quoted 4 lines · Matthew Garrett

Ok. Something like the following patch? It introduces AC97_TUNE_HP_MUTE_LED (yes, it's a poor name...) which is identical to AC97_TUNE_MUTE_LED except it calls bind_hp_volsw_put instead of snd_ac97_put_volsw and removes the headphone mixer controls.

Oops. Entirely the wrong patch. Here we go:

Signature · 1 line
Matthew Garrett | [email protected]
include/sound/ac97_codec.h renamed from sound/ac97_codec.h.orig +1 -0
@@ -570,6 +570,7 @@
 	AC97_TUNE_ALC_JACK,	/* for Realtek, enable JACK detection */
 	AC97_TUNE_INV_EAPD,	/* inverted EAPD implementation */
 	AC97_TUNE_MUTE_LED,	/* EAPD bit works as mute LED */
+	AC97_TUNE_HP_MUTE_LED,  /* EAPD bit works as mute LED, use headphone control as master */
 };
 
 struct ac97_quirk {
sound/pci/ac97/ac97_codec.c renamed from pci/ac97/ac97_codec.c.orig +35 -0
@@ -2470,6 +2470,40 @@
 	return 0;
 }
 
+static int hp_master_mute_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+	int err = bind_hp_volsw_put(kcontrol, ucontrol);
+	if (err > 0) {
+		ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+		int shift = (kcontrol->private_value >> 8) & 0x0f;
+		int rshift = (kcontrol->private_value >> 12) & 0x0f;
+		unsigned short mask;
+		if (shift != rshift)
+			mask = 0x8080;
+		else
+			mask = 0x8000;
+		snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000,
+				     (ac97->regs[AC97_MASTER] & mask) == mask ?
+				     0x8000 : 0);
+	}
+	return err;
+}
+
+static int tune_hp_mute_led(ac97_t *ac97)
+{
+	snd_kcontrol_t *msw = ctl_find(ac97, "Master Playback Switch", NULL);
+	snd_kcontrol_t *mvol = ctl_find(ac97, "Master Playback Volume", NULL);
+	if (! msw || ! mvol)
+		return -ENOENT;
+	msw->put = hp_master_mute_sw_put;
+	mvol->put = bind_hp_volsw_put;
+	snd_ac97_remove_ctl(ac97, "External Amplifier", NULL);
+	snd_ac97_remove_ctl(ac97, "Headphone Playback", "Switch");
+	snd_ac97_remove_ctl(ac97, "Headphone Playback", "Volume");
+	snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000, 0x8000); /* mute LED on */
+	return 0;
+}
+
 struct quirk_table {
 	const char *name;
 	int (*func)(ac97_t *);
@@ -2484,6 +2518,7 @@
 	{ "alc_jack", tune_alc_jack },
 	{ "inv_eapd", tune_inv_eapd },
 	{ "mute_led", tune_mute_led },
+	{ "hp_mute_led", tune_hp_mute_led },
 };
 
 /* apply the quirk with the given type */
#5 lore raw
Quoted 6 lines · Matthew Garrett
Quoted 4 lines · Matthew Garrett

Ok. Something like the following patch? It introduces AC97_TUNE_HP_MUTE_LED (yes, it's a poor name...) which is identical to AC97_TUNE_MUTE_LED except it calls bind_hp_volsw_put instead of snd_ac97_put_volsw and removes the headphone mixer controls.

I don't suppose you have a list of PCI sub-system IDs that this helps?

Thanks,

John

Signature · 9 lines
John W. Linville
[email protected]


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
#6 lore raw
Quoted 1 line · John W. Linville

I don't suppose you have a list of PCI sub-system IDs that this helps?

Yup:

AC97_TUNE_HP_MUTE_LED

4200 103c:0938
6120 103c:099c
6220 103c:0944
8220 103c:0934

All of Those plus the following also want to be added to the list in check_ad1981_hp_jack_sense():

4000/10 0e11:005a

The 6125 wants AC97_TUNE_MUTE_LED - it's an ATI chipset, using the snd-atiixp driver. It's 103c:308b. However, it doesn't need TUNE_HP_ONLY and doesn't need to be added to check_ad1981_hp_jack_sense().

I'd guess that the nx9600 probably needs the same, but I don't have access to one of those to check. The 8230 and 8240 have the same IDs as the 8220, and the 6110 shares with the 6120 (it doesn't actually have a mute LED, but the motherboard is identical). The 6230 ought to be identical to the 6220.

I'd guess that some of the consumer range also has these requirements, but I'm afraid I don't have any available to test.

Signature · 8 lines
Matthew Garrett | [email protected]


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
#7 lore raw

At Fri, 16 Sep 2005 15:25:44 +0100,

Quoted 14 lines · Matthew Garrett
Quoted 1 line · John W. Linville

I don't suppose you have a list of PCI sub-system IDs that this helps?

Yup:

AC97_TUNE_HP_MUTE_LED

4200 103c:0938
6120 103c:099c
6220 103c:0944
8220 103c:0934

Quoted 8 lines

All of Those plus the following also want to be added to the list in check_ad1981_hp_jack_sense():

4000/10 0e11:005a

The 6125 wants AC97_TUNE_MUTE_LED - it's an ATI chipset, using the snd-atiixp driver. It's 103c:308b. However, it doesn't need TUNE_HP_ONLY and doesn't need to be added to check_ad1981_hp_jack_sense().

Care to create a patch for the above?

Quoted 5 lines

I'd guess that the nx9600 probably needs the same, but I don't have access to one of those to check. The 8230 and 8240 have the same IDs as the 8220, and the 6110 shares with the 6120 (it doesn't actually have a mute LED, but the motherboard is identical). The 6230 ought to be identical to the 6220.

They can be fixed later.

Thanks,

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#8 lore raw
In reply to Matthew Garrett

At Fri, 16 Sep 2005 11:41:37 +0100,

Quoted 10 lines · Matthew Garrett

[1 <text/plain; us-ascii (7bit)>]

Quoted 4 lines · Matthew Garrett

Ok. Something like the following patch? It introduces AC97_TUNE_HP_MUTE_LED (yes, it's a poor name...) which is identical to AC97_TUNE_MUTE_LED except it calls bind_hp_volsw_put instead of snd_ac97_put_volsw and removes the headphone mixer controls.

Oops. Entirely the wrong patch. Here we go:

Then the last change to allow double entries is no longer needed. Shall we take it back?

Also, it'd be nice if you update ALSA-Configuration.txt, too. And, don't forget Signed-off-by, too.

Thanks,

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php