ALSA: firewire-motu: share PCM buffer size for both direction
[linux-2.6-block.git] / sound / firewire / motu / motu-pcm.c
index 7bbf8b86a33df2faa58a6b5ad406f808fa9a9614..00e693da0cad1992be8de5bcbaa070e6e8218fb9 100644 (file)
@@ -162,6 +162,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
        if (src != SND_MOTU_CLOCK_SOURCE_INTERNAL ||
            (motu->substreams_counter > 0 && d->events_per_period > 0)) {
                unsigned int frames_per_period = d->events_per_period;
+               unsigned int frames_per_buffer = d->events_per_buffer;
                unsigned int rate;
 
                err = protocol->get_clock_rate(motu, &rate);
@@ -179,6 +180,14 @@ static int pcm_open(struct snd_pcm_substream *substream)
                                mutex_unlock(&motu->mutex);
                                goto err_locked;
                        }
+
+                       err = snd_pcm_hw_constraint_minmax(substream->runtime,
+                                       SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
+                                       frames_per_buffer, frames_per_buffer);
+                       if (err < 0) {
+                               mutex_unlock(&motu->mutex);
+                               goto err_locked;
+                       }
                }
        }
 
@@ -216,10 +225,11 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
        if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                unsigned int rate = params_rate(hw_params);
                unsigned int frames_per_period = params_period_size(hw_params);
+               unsigned int frames_per_buffer = params_buffer_size(hw_params);
 
                mutex_lock(&motu->mutex);
                err = snd_motu_stream_reserve_duplex(motu, rate,
-                                                    frames_per_period);
+                                       frames_per_period, frames_per_buffer);
                if (err >= 0)
                        ++motu->substreams_counter;
                mutex_unlock(&motu->mutex);