Update of /cvsroot/alsa/alsa-kernel/pci/emu10k1
In directory sc8-pr-cvs1:/tmp/cvs-serv20331

Modified Files:
        emu10k1.c emu10k1_main.c emufx.c emumixer.c irq.c 
Log Message:
- fixed the detection of audigy2 EX.
  no ac97 mixer is built on this board.
- mo' better mixer for audigy2. 
  Wave is renamed to PCM, additional Master (digital) volume.
- make sure to disable all interrupts when unprocessed status bits
  remain.



Index: emu10k1.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- emu10k1.c   21 Jun 2003 07:52:38 -0000      1.18
+++ emu10k1.c   25 Jul 2003 10:39:38 -0000      1.19
@@ -135,11 +135,9 @@
                snd_card_free(card);
                return err;
        }               
-       if (!emu->APS) {        /* APS board has not an AC97 mixer */
-               if ((err = snd_emu10k1_mixer(emu)) < 0) {
-                       snd_card_free(card);
-                       return err;
-               }               
+       if ((err = snd_emu10k1_mixer(emu)) < 0) {
+               snd_card_free(card);
+               return err;
        }
        if (emu->audigy) {
                if ((err = snd_emu10k1_audigy_midi(emu)) < 0) {

Index: emu10k1_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_main.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- emu10k1_main.c      2 Apr 2003 14:35:56 -0000       1.24
+++ emu10k1_main.c      25 Jul 2003 10:39:38 -0000      1.25
@@ -674,6 +674,14 @@
        if (emu->serial == 0x40011102) {
                emu->card_type = EMU10K1_CARD_EMUAPS;
                emu->APS = 1;
+               emu->no_ac97 = 1; /* APS has no AC97 chip */
+       }
+       else if (emu->revision == 4 && emu->serial == 0x10051102) {
+               /* Audigy 2 EX has apparently no effective AC97 controls
+                * (for both input and output), so we skip the AC97 detections
+                */
+               snd_printdd(KERN_INFO "Audigy2 EX is detected. skpping ac97.\n");
+               emu->no_ac97 = 1;
        }
        
        emu->fx8010.fxbus_mask = 0x303f;

Index: emufx.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emufx.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- emufx.c     1 Jul 2003 10:07:54 -0000       1.35
+++ emufx.c     25 Jul 2003 10:39:38 -0000      1.36
@@ -1238,7 +1238,10 @@
 
 static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu)
 {
-       int err, i, z, gpr, tmp, playback, capture, nctl;
+       int err, i, z, gpr, nctl;
+       const int playback = 10;
+       const int capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we 
reserve 10 voices */
+       const int tmp = 0x88;
        u32 ptr;
        emu10k1_fx8010_code_t *icode;
        emu10k1_fx8010_control_gpr_t *controls, *ctl;
@@ -1261,19 +1264,15 @@
        strcpy(icode->name, "Audigy DSP code for ALSA");
        ptr = 0;
        nctl = 0;
-       playback = 10;
-       capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we reserve 10 
voices */
        gpr = capture + 10;
-       tmp = 0x88;
 
        /* stop FX processor */
        snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | 
A_DBG_SINGLE_STEP);
 
-       /* Wave Playback */
+       /* Wave Playback Volume */
        A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), 
A_FXBUS(FXBUS_PCM_LEFT));
        A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), 
A_FXBUS(FXBUS_PCM_RIGHT));
-       snd_emu10k1_init_stereo_control(&controls[nctl++], "Wave Playback Volume", gpr,
-                                       emu->revision == 4 ? 50 : 100);
+       snd_emu10k1_init_stereo_control(&controls[nctl++], "Wave Playback Volume", 
gpr, 100);
        gpr += 2;
 
        /* Wave Surround Playback */
@@ -1497,6 +1496,14 @@
        snd_emu10k1_init_stereo_onoff_control(controls + nctl++, "Tone Control - 
Switch", gpr, 0);
        gpr += 2;
 
+       /* Master volume for audigy2 */
+       if (emu->revision == 4) {
+               A_OP(icode, &ptr, iMAC0, 
A_GPR(playback+0+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), 
A_GPR(playback+0+SND_EMU10K1_PLAYBACK_CHANNELS));
+               A_OP(icode, &ptr, iMAC0, 
A_GPR(playback+1+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr+1), 
A_GPR(playback+1+SND_EMU10K1_PLAYBACK_CHANNELS));
+               snd_emu10k1_init_stereo_control(&controls[nctl++], "Wave Master 
Playback Volume", gpr, 0);
+               gpr += 2;
+       }
+
        /* digital outputs */
        A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + 
SND_EMU10K1_PLAYBACK_CHANNELS);
        A_PUT_STEREO_OUTPUT(A_EXTOUT_REAR_L, A_EXTOUT_REAR_R, playback+2 + 
SND_EMU10K1_PLAYBACK_CHANNELS);
@@ -1504,7 +1511,7 @@
        A_PUT_OUTPUT(A_EXTOUT_LFE, playback+5 + SND_EMU10K1_PLAYBACK_CHANNELS);
 
        /* analog speakers */
-       if (emu->audigy && emu->revision == 4) { /* audigy2 */
+       if (emu->revision == 4) { /* audigy2 */
                A_PUT_STEREO_OUTPUT(A_EXTOUT_AFRONT_L, A_EXTOUT_AFRONT_R, playback + 
SND_EMU10K1_PLAYBACK_CHANNELS);
        } else {
                A_PUT_STEREO_OUTPUT(A_EXTOUT_AC97_L, A_EXTOUT_AC97_R, playback + 
SND_EMU10K1_PLAYBACK_CHANNELS);

Index: emumixer.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emumixer.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- emumixer.c  9 Apr 2003 15:00:04 -0000       1.15
+++ emumixer.c  25 Jul 2003 10:39:38 -0000      1.16
@@ -423,6 +423,36 @@
        emu->ac97 = NULL;
 }
 
+/*
+ */
+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));
+       strcpy(sid.name, name);
+       sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+       return snd_ctl_find_id(card, &sid);
+}
+
+static int rename_ctl(snd_card_t *card, const char *src, const char *dst)
+{
+       snd_kcontrol_t *kctl = ctl_find(card, src);
+       if (kctl) {
+               strcpy(kctl->id.name, dst);
+               return 0;
+       }
+       return -ENOENT;
+}
+
 int __devinit snd_emu10k1_mixer(emu10k1_t *emu)
 {
        ac97_t ac97;
@@ -430,7 +460,7 @@
        snd_kcontrol_t *kctl;
        snd_card_t *card = emu->card;
 
-       if (!emu->APS) {
+       if (!emu->no_ac97) {
                memset(&ac97, 0, sizeof(ac97));
                ac97.write = snd_emu10k1_ac97_write;
                ac97.read = snd_emu10k1_ac97_read;
@@ -438,8 +468,33 @@
                ac97.private_free = snd_emu10k1_mixer_free_ac97;
                if ((err = snd_ac97_mixer(emu->card, &ac97, &emu->ac97)) < 0)
                        return err;
+               if (emu->audigy && emu->revision == 4) {
+                       /* Master/PCM controls on ac97 of Audigy2 has no effect */
+                       /* FIXME: keep master volume/switch to be sure.
+                        * once after we check that they play really no roles,
+                        * they shall be removed.
+                        */
+                       rename_ctl(card, "Master Playback Switch", "AC97 Master 
Playback Switch");
+                       rename_ctl(card, "Master Playback Volume", "AC97 Master 
Playback Volume");
+                       /* pcm controls are removed */
+                       remove_ctl(card, "PCM Playback Switch");
+                       remove_ctl(card, "PCM Playback Volume");
+               }
        } else {
-               strcpy(emu->card->mixername, "EMU APS");
+               if (emu->APS)
+                       strcpy(emu->card->mixername, "EMU APS");
+               else if (emu->audigy)
+                       strcpy(emu->card->mixername, "SB Audigy");
+               else
+                       strcpy(emu->card->mixername, "Emu10k1");
+       }
+
+       if (emu->audigy && emu->revision == 4) {
+               /* Audigy2 and Audigy2 EX */
+               /* use the conventional names */
+               rename_ctl(card, "Wave Playback Volume", "PCM Playback Volume");
+               rename_ctl(card, "Wave Playback Volume", "PCM Capture Volume");
+               rename_ctl(card, "Wave Master Playback Volume", "Master Playback 
Volume");
        }
 
        if ((kctl = emu->ctl_send_routing = 
snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL)
@@ -455,6 +510,7 @@
        if ((err = snd_ctl_add(card, kctl)))
                return err;
 
+       /* intiailize the routing and volume table for each pcm playback stream */
        for (pcm = 0; pcm < 32; pcm++) {
                emu10k1_pcm_mixer_t *mix;
                int v;
@@ -474,21 +530,25 @@
                mix->attn[0] = mix->attn[1] = mix->attn[2] = 0xffff;
        }
        
-       if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL)
-               return -ENOMEM;
-       if ((err = snd_ctl_add(card, kctl)))
-               return err;
-       if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu)) == NULL)
-               return -ENOMEM;
-       if ((err = snd_ctl_add(card, kctl)))
-               return err;
+       if (! emu->APS) { /* FIXME: APS has these controls? */
+               /* sb live! and audigy */
+               if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == 
NULL)
+                       return -ENOMEM;
+               if ((err = snd_ctl_add(card, kctl)))
+                       return err;
+               if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu)) == NULL)
+                       return -ENOMEM;
+               if ((err = snd_ctl_add(card, kctl)))
+                       return err;
+       }
 
        if (emu->audigy) {
                if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL)
                        return -ENOMEM;
                if ((err = snd_ctl_add(card, kctl)))
                        return err;
-       } else {
+       } else if (! emu->APS) {
+               /* sb live! */
                if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL)
                        return -ENOMEM;
                if ((err = snd_ctl_add(card, kctl)))

Index: irq.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/irq.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- irq.c       23 Apr 2003 13:25:10 -0000      1.8
+++ irq.c       25 Jul 2003 10:39:38 -0000      1.9
@@ -55,15 +55,13 @@
                if (status & IPR_CHANNELLOOP) {
                        int voice;
                        int voice_max = status & IPR_CHANNELNUMBERMASK;
-                       int voice_max_l;
                        u32 val;
                        emu10k1_voice_t *pvoice = emu->voices;
 
                        val = snd_emu10k1_ptr_read(emu, CLIPL, 0);
-                       voice_max_l = voice_max;
-                       if (voice_max_l >= 0x20)
-                               voice_max_l = 0x1f;
-                       for (voice = 0; voice <= voice_max_l; voice++) {
+                       for (voice = 0; voice <= voice_max; voice++) {
+                               if (voice == 0x20)
+                                       val = snd_emu10k1_ptr_read(emu, CLIPH, 0);
                                if (val & 1) {
                                        if (pvoice->use && pvoice->interrupt != NULL) {
                                                pvoice->interrupt(emu, pvoice);
@@ -75,21 +73,6 @@
                                val >>= 1;
                                pvoice++;
                        }
-                       if (voice_max > 0x1f) {
-                               val = snd_emu10k1_ptr_read(emu, CLIPH, 0);
-                               for (; voice <= voice_max; voice++) {
-                                       if(val & 1) {
-                                               if (pvoice->use && pvoice->interrupt 
!= NULL) {
-                                                       pvoice->interrupt(emu, pvoice);
-                                                       
snd_emu10k1_voice_intr_ack(emu, voice);
-                                               } else {
-                                                       
snd_emu10k1_voice_intr_disable(emu, voice);
-                                               }
-                                       }
-                                       val >>= 1;
-                                       pvoice++;
-                               }
-                       }
                        status &= ~IPR_CHANNELLOOP;
                }
                status &= ~IPR_CHANNELNUMBERMASK;
@@ -150,9 +133,27 @@
                        status &= ~IPR_FXDSP;
                }
                if (status) {
-                       snd_printd(KERN_WARNING "emu10k1: unhandled interrupt: 
0x%08x\n", status);
+                       unsigned int bits;
+                       snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", 
status);
+                       //make sure any interrupts we don't handle are disabled:
+                       bits = INTE_FXDSPENABLE |
+                               INTE_PCIERRORENABLE |
+                               INTE_VOLINCRENABLE |
+                               INTE_VOLDECRENABLE |
+                               INTE_MUTEENABLE |
+                               INTE_MICBUFENABLE |
+                               INTE_ADCBUFENABLE |
+                               INTE_EFXBUFENABLE |
+                               INTE_GPSPDIFENABLE |
+                               INTE_CDSPDIFENABLE |
+                               INTE_INTERVALTIMERENB |
+                               INTE_MIDITXENABLE |
+                               INTE_MIDIRXENABLE;
+                       if (emu->audigy)
+                               bits |= INTE_A_MIDITXENABLE2 | INTE_A_MIDIRXENABLE2;
+                       snd_emu10k1_intr_disable(emu, bits);
                }
-               outl(orig_status, emu->port + IPR); /* ack */
+               outl(orig_status, emu->port + IPR); /* ack all */
        }
        return IRQ_RETVAL(handled);
 }



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to