ALSA: oxfw: register the size of PCM period to AMDTP domain
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 7 Oct 2019 11:05:19 +0000 (20:05 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 17 Oct 2019 10:02:41 +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-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/oxfw/oxfw-midi.c
sound/firewire/oxfw/oxfw-pcm.c
sound/firewire/oxfw/oxfw-stream.c
sound/firewire/oxfw/oxfw.h

index 9bdec08..72db7a1 100644 (file)
@@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->tx_stream, 0, 0);
+       err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->tx_stream, 0, 0, 0);
        if (err >= 0) {
                ++oxfw->substreams_count;
                err = snd_oxfw_stream_start_duplex(oxfw);
@@ -45,7 +45,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
 
        mutex_lock(&oxfw->mutex);
 
-       err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->rx_stream, 0, 0);
+       err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->rx_stream, 0, 0, 0);
        if (err >= 0) {
                ++oxfw->substreams_count;
                err = snd_oxfw_stream_start_duplex(oxfw);
index 7c6d1c2..2d1b503 100644 (file)
@@ -221,10 +221,11 @@ static int pcm_capture_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 channels = params_channels(hw_params);
+               unsigned int frames_per_period = params_period_size(hw_params);
 
                mutex_lock(&oxfw->mutex);
                err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->tx_stream,
-                                                    rate, channels);
+                                       rate, channels, frames_per_period);
                if (err >= 0)
                        ++oxfw->substreams_count;
                mutex_unlock(&oxfw->mutex);
@@ -246,10 +247,11 @@ static int pcm_playback_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 channels = params_channels(hw_params);
+               unsigned int frames_per_period = params_period_size(hw_params);
 
                mutex_lock(&oxfw->mutex);
                err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->rx_stream,
-                                                    rate, channels);
+                                       rate, channels, frames_per_period);
                if (err >= 0)
                        ++oxfw->substreams_count;
                mutex_unlock(&oxfw->mutex);
index 3c9a796..7d2e88c 100644 (file)
@@ -244,7 +244,8 @@ static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
 
 int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
                                   struct amdtp_stream *stream,
-                                  unsigned int rate, unsigned int pcm_channels)
+                                  unsigned int rate, unsigned int pcm_channels,
+                                  unsigned int frames_per_period)
 {
        struct snd_oxfw_stream_formation formation;
        enum avc_general_plug_dir dir;
@@ -305,6 +306,15 @@ int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
                                return err;
                        }
                }
+
+               err = amdtp_domain_set_events_per_period(&oxfw->domain,
+                                                       frames_per_period);
+               if (err < 0) {
+                       cmp_connection_release(&oxfw->in_conn);
+                       if (oxfw->has_output)
+                               cmp_connection_release(&oxfw->out_conn);
+                       return err;
+               }
        }
 
        return 0;
index c9627b8..422746e 100644 (file)
@@ -103,7 +103,8 @@ int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate,
 int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw);
 int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
                                   struct amdtp_stream *stream,
-                                  unsigned int rate, unsigned int pcm_channels);
+                                  unsigned int rate, unsigned int pcm_channels,
+                                  unsigned int frames_per_period);
 int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw);
 void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw);
 void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw);