[ALSA] rme96 - Fix OSS full-duplex
authorTakashi Iwai <tiwai@suse.de>
Wed, 10 May 2006 14:24:42 +0000 (16:24 +0200)
committerJaroslav Kysela <perex@suse.cz>
Thu, 22 Jun 2006 19:33:32 +0000 (21:33 +0200)
Fixed a bug in rme96 driver that the full-duplex on OSS emulation
doesn't work due to the invalid period size parameter.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/rme96.c

index 75a8b754ef2899001c978f68ffbcf2596861dab2..65611a7d366d557b323d23d777c028756046bcd2 100644 (file)
@@ -1151,6 +1151,25 @@ static struct snd_pcm_hw_constraint_list hw_constraints_period_bytes = {
        .mask = 0
 };
 
+static void
+rme96_set_buffer_size_constraint(struct rme96 *rme96,
+                                struct snd_pcm_runtime *runtime)
+{
+       unsigned int size;
+
+       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
+                                    RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
+       if ((size = rme96->playback_periodsize) != 0 ||
+           (size = rme96->capture_periodsize) != 0)
+               snd_pcm_hw_constraint_minmax(runtime,
+                                            SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+                                            size, size);
+       else
+               snd_pcm_hw_constraint_list(runtime, 0,
+                                          SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+                                          &hw_constraints_period_bytes);
+}
+
 static int
 snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream)
 {
@@ -1180,8 +1199,7 @@ snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream)
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
        }        
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
+       rme96_set_buffer_size_constraint(rme96, runtime);
 
        rme96->wcreg_spdif_stream = rme96->wcreg_spdif;
        rme96->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
@@ -1219,9 +1237,7 @@ snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream)
        rme96->capture_substream = substream;
        spin_unlock_irq(&rme96->lock);
        
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
-
+       rme96_set_buffer_size_constraint(rme96, runtime);
        return 0;
 }
 
@@ -1254,8 +1270,7 @@ snd_rme96_playback_adat_open(struct snd_pcm_substream *substream)
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
        }        
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
+       rme96_set_buffer_size_constraint(rme96, runtime);
        return 0;
 }
 
@@ -1291,8 +1306,7 @@ snd_rme96_capture_adat_open(struct snd_pcm_substream *substream)
        rme96->capture_substream = substream;
        spin_unlock_irq(&rme96->lock);
 
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
+       rme96_set_buffer_size_constraint(rme96, runtime);
        return 0;
 }