Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
[pandora-kernel.git] / sound / pci / rme96.c
index e3304b7..3fdd488 100644 (file)
@@ -23,7 +23,6 @@
  *
  */      
 
-#include <sound/driver.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -300,20 +299,6 @@ snd_rme96_capture_ptr(struct rme96 *rme96)
                & RME96_RCR_AUDIO_ADDR_MASK) >> rme96->capture_frlog;
 }
 
-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) */
@@ -1176,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);
@@ -1194,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;
        }        
@@ -1214,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)
@@ -1223,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;
         }
@@ -1247,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);
@@ -1265,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;
        }        
@@ -1280,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
@@ -1292,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;
         }
@@ -1582,7 +1559,8 @@ 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;
        }
@@ -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;