ALSA: bebob: register the size of PCM period to AMDTP domain
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 7 Oct 2019 11:05:17 +0000 (20:05 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 17 Oct 2019 10:02:40 +0000 (12:02 +0200)
This commit is a preparation to share the size of PCM period between
PCM substreams on AMDTP streams in the same domain. At this time,
the size of PCM period in PCM substream which starts AMDTP streams in the
same domain is recorded.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191007110532.30270-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/bebob/bebob.h
sound/firewire/bebob/bebob_midi.c
sound/firewire/bebob/bebob_pcm.c
sound/firewire/bebob/bebob_stream.c

index 356d6ba609590750a7b08e29de5bd263df5fc80d..8738c1d8abf70b8dc5e8f0d92440989fbac46f76 100644 (file)
@@ -217,7 +217,8 @@ int snd_bebob_stream_get_clock_src(struct snd_bebob *bebob,
                                   enum snd_bebob_clock_type *src);
 int snd_bebob_stream_discover(struct snd_bebob *bebob);
 int snd_bebob_stream_init_duplex(struct snd_bebob *bebob);
-int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate);
+int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate,
+                                   unsigned int frames_per_period);
 int snd_bebob_stream_start_duplex(struct snd_bebob *bebob);
 void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob);
 void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob);
index 4d8805fa8a00a1f06ea5115aaaa89802ac685d52..e8f9edf50be5826d55f4104c5873a4c1b024545b 100644 (file)
@@ -17,7 +17,7 @@ static int midi_open(struct snd_rawmidi_substream *substream)
                return err;
 
        mutex_lock(&bebob->mutex);
-       err = snd_bebob_stream_reserve_duplex(bebob, 0);
+       err = snd_bebob_stream_reserve_duplex(bebob, 0, 0);
        if (err >= 0) {
                ++bebob->substreams_counter;
                err = snd_bebob_stream_start_duplex(bebob);
index 0fb9eed468378e53643f4f76425a784cf1281be9..3b2227abf8a901b08e1c01538ee0ef1eebc01f1e 100644 (file)
@@ -197,9 +197,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);
 
                mutex_lock(&bebob->mutex);
-               err = snd_bebob_stream_reserve_duplex(bebob, rate);
+               err = snd_bebob_stream_reserve_duplex(bebob, rate,
+                                                     frames_per_period);
                if (err >= 0)
                        ++bebob->substreams_counter;
                mutex_unlock(&bebob->mutex);
index 73fee991bd75a500d25f074d78d6c71843505881..f1db3ddc3e0046331c30d38307a270c71e6a3faa 100644 (file)
@@ -554,7 +554,8 @@ static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream,
        return cmp_connection_reserve(conn, amdtp_stream_get_max_payload(stream));
 }
 
-int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate)
+int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate,
+                                   unsigned int frames_per_period)
 {
        unsigned int curr_rate;
        int err;
@@ -607,6 +608,14 @@ int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate)
                        cmp_connection_release(&bebob->out_conn);
                        return err;
                }
+
+               err = amdtp_domain_set_events_per_period(&bebob->domain,
+                                                        frames_per_period);
+               if (err < 0) {
+                       cmp_connection_release(&bebob->out_conn);
+                       cmp_connection_release(&bebob->in_conn);
+                       return err;
+               }
        }
 
        return 0;