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

Modified Files:
        ac97_pcm.c 
Log Message:
- added spdif field to struct ac97_pcm.
- snd_ac97_set_rate() accepts AC97_SPDIF.
- allow fixed rate mic capture.
- optimized the loop in snd_ac97_pcm_open.




Index: ac97_pcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_pcm.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ac97_pcm.c  30 Nov 2003 18:35:33 -0000      1.7
+++ ac97_pcm.c  3 Dec 2003 13:39:06 -0000       1.8
@@ -165,6 +165,8 @@
                return 0xff;
        if (slot > 11)
                return 0xff;
+       if (pcm->spdif)
+               return AC97_SPDIF; /* pseudo register */
        if (pcm->stream == SNDRV_PCM_STREAM_PLAYBACK)
                return rate_reg_tables[dbl][pcm->r[dbl].rate_table[cidx]][slot - 3];
        else
@@ -230,6 +232,8 @@
  * AC97_PCM_FRONT_DAC_RATE, AC97_PCM_LR_ADC_RATE.
  * AC97_PCM_SURR_DAC_RATE and AC97_PCM_LFE_DAC_RATE are accepted
  * if the codec supports them.
+ * AC97_SPDIF is accepted as a pseudo register to modify the SPDIF
+ * status bits.
  *
  * Returns zero if successful, or a negative error code on failure.
  */
@@ -257,6 +261,9 @@
                if (! (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC))
                        return -EINVAL;
                break;
+       case AC97_SPDIF:
+               /* special case */
+               return set_spdif_rate(ac97, rate);
        default:
                return -EINVAL;
        }
@@ -350,8 +357,7 @@
        if (!ac97_is_audio(ac97))
                return 0;
        slots = (1<<AC97_SLOT_PCM_LEFT)|(1<<AC97_SLOT_PCM_RIGHT);
-       if (ac97->ext_id & AC97_EI_VRM)
-               slots |= (1<<AC97_SLOT_MIC);
+       slots |= (1<<AC97_SLOT_MIC);
        return slots;
 }
 
@@ -431,6 +437,7 @@
                }
                rpcm->stream = pcm->stream;
                rpcm->exclusive = pcm->exclusive;
+               rpcm->spdif = pcm->spdif;
                rpcm->private_value = pcm->private_value;
                rpcm->bus = bus;
                rpcm->rates = ~0;
@@ -467,6 +474,8 @@
                        rpcm->r[0].slots |= tmp;
                        rpcm->rates &= rates;
                }
+               if (rpcm->rates == ~0)
+                       rpcm->rates = 0; /* not used */
        }
        bus->pcms_count = pcms_count;
        bus->pcms = rpcms;
@@ -487,8 +496,9 @@
 {
        ac97_bus_t *bus;
        int i, cidx, r = 0, ok_flag;
-       unsigned short reg_ok = 0, reg_ok_new;
+       unsigned int reg_ok = 0;
        unsigned char reg;
+       int err = 0;
 
        if (rate > 48000)       /* FIXME: add support for double rate */
                return -EINVAL;
@@ -506,27 +516,23 @@
        for (i = 3; i < 12; i++) {
                if (!(slots & (1 << i)))
                        continue;
-               for (cidx = 0; cidx < 4; cidx++)
+               ok_flag = 0;
+               for (cidx = 0; cidx < 4; cidx++) {
                        if (bus->used_slots[pcm->stream][cidx] & (1 << i)) {
                                spin_unlock_irq(&pcm->bus->bus_lock);
-                               return -EBUSY;
+                               err = -EBUSY;
+                               goto error;
                        }
-       }
-       for (i = 3; i < 12; i++) {
-               if (!(slots & (1 << i)))
-                       continue;
-               ok_flag = 0;
-               for (cidx = 0; cidx < 4; cidx++)
                        if (pcm->r[r].rslots[cidx] & (1 << i)) {
                                bus->used_slots[pcm->stream][cidx] |= (1 << i);
                                ok_flag++;
                        }
+               }
                if (!ok_flag) {
                        spin_unlock_irq(&pcm->bus->bus_lock);
                        snd_printk(KERN_ERR "cannot find configuration for AC97 slot 
%i\n", i);
-                       pcm->aslots = slots;
-                       snd_ac97_pcm_close(pcm);
-                       return -EAGAIN;
+                       err = -EAGAIN;
+                       goto error;
                }
        }
        spin_unlock_irq(&pcm->bus->bus_lock);
@@ -534,23 +540,29 @@
                if (!(slots & (1 << i)))
                        continue;
                for (cidx = 0; cidx < 4; cidx++) {
-                       reg_ok_new = 0;
                        if (pcm->r[r].rslots[cidx] & (1 << i)) {
-                               reg = get_slot_reg(pcm, cidx, i, 0);
+                               reg = get_slot_reg(pcm, cidx, i, r);
                                if (reg == 0xff) {
                                        snd_printk(KERN_ERR "invalid AC97 slot %i?\n", 
i);
                                        continue;
                                }
                                if (reg_ok & (1 << (reg - AC97_PCM_FRONT_DAC_RATE)))
                                        continue;
-                               snd_ac97_set_rate(pcm->r[r].codec[cidx], reg, rate);
-                               reg_ok_new |= (1 << (reg - AC97_PCM_FRONT_DAC_RATE));
+                               err = snd_ac97_set_rate(pcm->r[r].codec[cidx], reg, 
rate);
+                               if (err < 0)
+                                       snd_printk(KERN_ERR "error in 
snd_ac97_set_rate: cidx=%d, reg=0x%x, rate=%d\n, err=%d", cidx, reg, rate, err);
+                               else
+                                       reg_ok |= (1 << (reg - 
AC97_PCM_FRONT_DAC_RATE));
                        }
-                       reg_ok |= reg_ok_new;
                }
        }
        pcm->aslots = slots;
        return 0;
+
+ error:
+       pcm->aslots = slots;
+       snd_ac97_pcm_close(pcm);
+       return err;
 }
 
 /**



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to