Skip to contentSkip to conversation

remove AC97 existing control

PATCH In review [email protected] 2 participants 4 messages Mar 22, 2005 – Mar 24, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove AC97 existing control

This patch should fix bug report 752 by removing the existing control from the AC97.

Sign off: Francisco Moraes

Index: alsa-kernel/pci/emu10k1/emu10k1x.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1x.c,v retrieving revision 1.7

pci/emu10k1/emu10k1x.c +24 -0
diff -u -r1.7 emu10k1x.c
@@ -1201,6 +1201,25 @@
 	.put =          snd_emu10k1x_spdif_put
 };
 
+static int remove_ctl(snd_card_t *card, const char *name)
+{
+	snd_ctl_elem_id_t id;
+	memset(&id, 0, sizeof(id));
+	strcpy(id.name, name);
+	id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+	return snd_ctl_remove_id(card, &id);
+}
+
+static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name)
+{
+	snd_ctl_elem_id_t sid;
+	memset(&sid, 0, sizeof(sid));
+	/* FIXME: strcpy is bad. */
+	strcpy(sid.name, name);
+	sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+	return snd_ctl_find_id(card, &sid);
+}
+
 static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu)
 {
 	int err;
@@ -1215,6 +1234,11 @@
 		return -ENOMEM;
 	if ((err = snd_ctl_add(card, kctl)))
 		return err;
+	if ((kctl = ctl_find(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT))) != NULL) {
+		/* already defined by ac97, remove it */
+		/* FIXME: or do we need both controls? */
+		remove_ctl(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT));
+	}
 	if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_control, emu)) == NULL)
 		return -ENOMEM;
 	if ((err = snd_ctl_add(card, kctl)))
#1 lore raw

At Tue, 22 Mar 2005 07:45:15 -0500,

Quoted 5 lines · [email protected] wrote:

This patch should fix bug report 752 by removing the existing control from the AC97.

Sign off: Francisco Moraes

Right now I created a patch to prevent SPDIF controls on ac97 for drivers which are known to work without AC97 spdif (conflicting with the native SPDIF support).

The patch is below. I guess this will do the same job as this patch. Could you check whether it works?

Takashi

Index: alsa-kernel/include/ac97_codec.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/include/ac97_codec.h,v retrieving revision 1.63

include/ac97_codec.h +1 -0
diff -u -r1.63 ac97_codec.h
@@ -356,6 +356,7 @@
 #define AC97_SCAP_INDEP_SDIN	(1<<6)	/* independent SDIN */
 #define AC97_SCAP_INV_EAPD	(1<<7)	/* inverted EAPD */
 #define AC97_SCAP_DETECT_BY_VENDOR (1<<8) /* use vendor registers for read tests */
+#define AC97_SCAP_NO_SPDIF	(1<<9)	/* don't build SPDIF controls */
 
 /* ac97->flags */
 #define AC97_HAS_PC_BEEP	(1<<0)	/* force PC Speaker usage */

Index: alsa-kernel/pci/atiixp.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/atiixp.c,v retrieving revision 1.34

pci/atiixp.c +2 -0
diff -u -r1.34 atiixp.c
@@ -1376,6 +1376,8 @@
 		ac97.pci = chip->pci;
 		ac97.num = i;
 		ac97.scaps = AC97_SCAP_SKIP_MODEM;
+		if (! chip->spdif_over_aclink)
+			ac97.scaps |= AC97_SCAP_NO_SPDIF;
 		if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
 			chip->ac97[i] = NULL; /* to be sure */
 			snd_printdd("atiixp: codec %d not available for audio\n", i);

Index: alsa-kernel/pci/ac97/ac97_codec.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/ac97/ac97_codec.c,v retrieving revision 1.171

pci/ac97/ac97_codec.c +1 -1
diff -u -r1.171 ac97_codec.c
@@ -1486,7 +1486,7 @@
 	}
 
 	/* build S/PDIF controls */
-	if (ac97->ext_id & AC97_EI_SPDIF) {
+	if ((ac97->ext_id & AC97_EI_SPDIF) && !(ac97->scaps & AC97_SCAP_NO_SPDIF)) {
 		if (ac97->build_ops->build_spdif) {
 			if ((err = ac97->build_ops->build_spdif(ac97)) < 0)
 				return err;

Index: alsa-kernel/pci/au88x0/au88x0_mixer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/au88x0/au88x0_mixer.c,v retrieving revision 1.4

pci/au88x0/au88x0_mixer.c +1 -0
diff -u -r1.4 au88x0_mixer.c
@@ -26,6 +26,7 @@
 	memset(&ac97, 0, sizeof(ac97));
 	// Intialize AC97 codec stuff.
 	ac97.private_data = vortex;
+	ac97.scaps = AC97_SCAP_NO_SPDIF;
 	err = snd_ac97_mixer(pbus, &ac97, &vortex->codec);
 	vortex->isquad = ((vortex->codec == NULL) ?  0 : (vortex->codec->ext_id&0x80));
 	return err;

Index: alsa-kernel/pci/emu10k1/emu10k1x.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/emu10k1/emu10k1x.c,v retrieving revision 1.7

pci/emu10k1/emu10k1x.c +1 -0
diff -u -r1.7 emu10k1x.c
@@ -749,6 +749,7 @@
 
 	memset(&ac97, 0, sizeof(ac97));
 	ac97.private_data = chip;
+	ac97.scaps = AC97_SCAP_NO_SPDIF;
 	return snd_ac97_mixer(pbus, &ac97, &chip->ac97);
 }
 

Index: alsa-kernel/pci/emu10k1/emumixer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/emu10k1/emumixer.c,v retrieving revision 1.31

pci/emu10k1/emumixer.c +1 -5
diff -u -r1.31 emumixer.c
@@ -806,6 +806,7 @@
 		memset(&ac97, 0, sizeof(ac97));
 		ac97.private_data = emu;
 		ac97.private_free = snd_emu10k1_mixer_free_ac97;
+		ac97.scaps = AC97_SCAP_NO_SPDIF;
 		if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0)
 			return err;
 		if (emu->audigy) {
@@ -923,11 +924,6 @@
 			return -ENOMEM;
 		if ((err = snd_ctl_add(card, kctl)))
 			return err;
-		if ((kctl = ctl_find(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT))) != NULL) {
-			/* already defined by ac97, remove it */
-			/* FIXME: or do we need both controls? */
-			remove_ctl(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT));
-		}
 		if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu)) == NULL)
 			return -ENOMEM;
 		if ((err = snd_ctl_add(card, kctl)))
#2 lore raw
Quoted 11 lines · Takashi Iwai

At Tue, 22 Mar 2005 07:45:15 -0500,

Quoted 6 lines · [email protected] wrote:

This patch should fix bug report 752 by removing the existing control from the AC97.

Sign off: Francisco Moraes

Quoted 8 lines

Right now I created a patch to prevent SPDIF controls on ac97 for drivers which are known to work without AC97 spdif (conflicting with the native SPDIF support).

The patch is below. I guess this will do the same job as this patch. Could you check whether it works?

I tested the patch and it works on my system, but I don't have the AC97 problem, so I cannot confirm that it does fixes the problem, although it looks like from the changes. Also, the ca0106 driver has the same exact code.

Francisco

-------------------------------------------------------
This SF.net email is sponsored by Microsoft Mobile & Embedded DevCon 2005 Attend MEDC 2005 May 9-12 in Vegas. Learn more about the latest Windows Embedded(r) & Windows Mobile(tm) platforms, applications & content. Register by 3/29 & save $300 http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click

#3 lore raw

At Thu, 24 Mar 2005 08:24:03 -0500,

Quoted 23 lines · Francisco Moraes
Quoted 11 lines · Takashi Iwai

At Tue, 22 Mar 2005 07:45:15 -0500,

Quoted 6 lines · [email protected] wrote:

This patch should fix bug report 752 by removing the existing control from the AC97.

Sign off: Francisco Moraes

Quoted 8 lines

Right now I created a patch to prevent SPDIF controls on ac97 for drivers which are known to work without AC97 spdif (conflicting with the native SPDIF support).

The patch is below. I guess this will do the same job as this patch. Could you check whether it works?

Quoted 4 lines

I tested the patch and it works on my system, but I don't have the AC97 problem, so I cannot confirm that it does fixes the problem, although it looks like from the changes. Also, the ca0106 driver has the same exact code.

Now ca0106 driver was changed on CVS, too.

Takashi

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click