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 9bdec08cb8eac0de6605c7832cb067043342c362..72db7a17d0ade131983f33400f2a2f6b91b95ecb 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 7c6d1c277d4d9e52a107c8079ff9f5a3254b4ac9..2d1b5038f7f64acfee53c1d74359948e010c92f8 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 3c9a796b65269594c88886568f09a70627a62e07..7d2e88c5b73d3fb7a026dab610b579359ca7b82a 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 c9627b8c5d6e8a8dca214a3832a91eaaba704803..422746ef2439064b288f254e479c4d282c4e9d2c 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);