ALSA: hda - Fix stac92hd83xxx_amp_nids[]
[safe/jmp/linux-2.6] / sound / pci / rme96.c
index fde0f3e..3fdd488 100644 (file)
@@ -23,7 +23,6 @@
  *
  */      
 
-#include <sound/driver.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -232,7 +231,7 @@ struct rme96 {
        struct snd_kcontrol   *spdif_ctl;
 };
 
-static struct pci_device_id snd_rme96_ids[] __devinitdata = {
+static struct pci_device_id snd_rme96_ids[] = {
        { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
        { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8,
@@ -301,20 +300,6 @@ snd_rme96_capture_ptr(struct rme96 *rme96)
 }
 
 static int
-snd_rme96_ratecode(int rate)
-{
-    switch (rate) {
-    case 32000: return SNDRV_PCM_RATE_32000;
-    case 44100: return SNDRV_PCM_RATE_44100;
-    case 48000: return SNDRV_PCM_RATE_48000;
-    case 64000: return SNDRV_PCM_RATE_64000;
-    case 88200: return SNDRV_PCM_RATE_88200;
-    case 96000: return SNDRV_PCM_RATE_96000;
-    }
-    return 0;
-}
-
-static int
 snd_rme96_playback_silence(struct snd_pcm_substream *substream,
                           int channel, /* not used (interleaved data) */
                           snd_pcm_uframes_t pos,
@@ -1117,8 +1102,7 @@ snd_rme96_capture_stop(struct rme96 *rme96)
 
 static irqreturn_t
 snd_rme96_interrupt(int irq,
-                   void *dev_id,
-                   struct pt_regs *regs)
+                   void *dev_id)
 {
        struct rme96 *rme96 = (struct rme96 *)dev_id;
 
@@ -1177,8 +1161,6 @@ snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream)
        struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       snd_pcm_set_sync(substream);
-
        spin_lock_irq(&rme96->lock);    
         if (rme96->playback_substream != NULL) {
                spin_unlock_irq(&rme96->lock);
@@ -1195,7 +1177,7 @@ snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream)
            (rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
        {
                 /* slave clock */
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
        }        
@@ -1215,8 +1197,6 @@ snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream)
        struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       snd_pcm_set_sync(substream);
-
        runtime->hw = snd_rme96_capture_spdif_info;
         if (snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG &&
             (rate = snd_rme96_capture_getrate(rme96, &isadat)) > 0)
@@ -1224,7 +1204,7 @@ snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream)
                 if (isadat) {
                         return -EIO;
                 }
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
         }
@@ -1248,8 +1228,6 @@ snd_rme96_playback_adat_open(struct snd_pcm_substream *substream)
        struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;        
        
-       snd_pcm_set_sync(substream);
-
        spin_lock_irq(&rme96->lock);    
         if (rme96->playback_substream != NULL) {
                spin_unlock_irq(&rme96->lock);
@@ -1266,7 +1244,7 @@ snd_rme96_playback_adat_open(struct snd_pcm_substream *substream)
            (rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
        {
                 /* slave clock */
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
        }        
@@ -1281,8 +1259,6 @@ snd_rme96_capture_adat_open(struct snd_pcm_substream *substream)
        struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       snd_pcm_set_sync(substream);
-
        runtime->hw = snd_rme96_capture_adat_info;
         if (snd_rme96_getinputtype(rme96) == RME96_INPUT_ANALOG) {
                 /* makes no sense to use analog input. Note that analog
@@ -1293,7 +1269,7 @@ snd_rme96_capture_adat_open(struct snd_pcm_substream *substream)
                 if (!isadat) {
                         return -EIO;
                 }
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
         }
@@ -1583,12 +1559,14 @@ snd_rme96_create(struct rme96 *rme96)
                return err;
        rme96->port = pci_resource_start(rme96->pci, 0);
 
-       if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) {
+       rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE);
+       if (!rme96->iobase) {
                snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
                return -ENOMEM;
        }
 
-       if (request_irq(pci->irq, snd_rme96_interrupt, IRQF_DISABLED|IRQF_SHARED, "RME96", (void *)rme96)) {
+       if (request_irq(pci->irq, snd_rme96_interrupt, IRQF_SHARED,
+                       "RME96", rme96)) {
                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                return -EBUSY;
        }
@@ -1826,15 +1804,8 @@ snd_rme96_proc_init(struct rme96 *rme96)
  * control interface
  */
 
-static int
-snd_rme96_info_loopback_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_rme96_info_loopback_control                snd_ctl_boolean_mono_info
+
 static int
 snd_rme96_get_loopback_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
@@ -2224,22 +2195,25 @@ snd_rme96_dac_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
 {
        struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
         int change = 0;
+       unsigned int vol, maxvol;
 
-       if (!RME96_HAS_ANALOG_OUT(rme96)) {
+
+       if (!RME96_HAS_ANALOG_OUT(rme96))
                return -EINVAL;
-       }
+       maxvol = RME96_185X_MAX_OUT(rme96);
        spin_lock_irq(&rme96->lock);
-        if (u->value.integer.value[0] != rme96->vol[0]) {
-               rme96->vol[0] = u->value.integer.value[0];
-                change = 1;
-        }
-        if (u->value.integer.value[1] != rme96->vol[1]) {
-               rme96->vol[1] = u->value.integer.value[1];
-                change = 1;
-        }
-       if (change) {
-               snd_rme96_apply_dac_volume(rme96);
+       vol = u->value.integer.value[0];
+       if (vol != rme96->vol[0] && vol <= maxvol) {
+               rme96->vol[0] = vol;
+               change = 1;
        }
+       vol = u->value.integer.value[1];
+       if (vol != rme96->vol[1] && vol <= maxvol) {
+               rme96->vol[1] = vol;
+               change = 1;
+       }
+       if (change)
+               snd_rme96_apply_dac_volume(rme96);
        spin_unlock_irq(&rme96->lock);
 
         return change;