diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2019-06-11 22:21:10 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-06-11 16:02:04 +0200 |
commit | ad3065054761c86d3284315b67512a70f5ae0c04 (patch) | |
tree | 6ea3c45835cd7b1a069f92f7978e55a0625140f6 | |
parent | 638e19fc46afceb65f6bfff65b2164fbb3324cb3 (diff) | |
download | linux-stable-ad3065054761c86d3284315b67512a70f5ae0c04.tar.gz linux-stable-ad3065054761c86d3284315b67512a70f5ae0c04.tar.bz2 linux-stable-ad3065054761c86d3284315b67512a70f5ae0c04.zip |
ALSA: firewire-digi00x: code refactoring to keep isochronous resources
This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.
All of models in Digidesign Digi00x family have the same formation of
data channels in isochronous packet for both directions. This commit
simplifies allocation of isochronous resources in this point.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/firewire/digi00x/digi00x-stream.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/sound/firewire/digi00x/digi00x-stream.c b/sound/firewire/digi00x/digi00x-stream.c index 8104af94aed5..2bddeb3e4bf5 100644 --- a/sound/firewire/digi00x/digi00x-stream.c +++ b/sound/firewire/digi00x/digi00x-stream.c @@ -196,12 +196,14 @@ static void release_resources(struct snd_dg00x *dg00x) fw_iso_resources_free(&dg00x->rx_resources); } -static int keep_resources(struct snd_dg00x *dg00x, unsigned int rate) +static int keep_resources(struct snd_dg00x *dg00x, struct amdtp_stream *stream, + unsigned int rate) { - unsigned int i; + struct fw_iso_resources *resources; + int i; int err; - /* Check sampling rate. */ + // Check sampling rate. for (i = 0; i < SND_DG00X_RATE_COUNT; i++) { if (snd_dg00x_stream_rates[i] == rate) break; @@ -209,31 +211,19 @@ static int keep_resources(struct snd_dg00x *dg00x, unsigned int rate) if (i == SND_DG00X_RATE_COUNT) return -EINVAL; - /* Keep resources for out-stream. */ - err = amdtp_dot_set_parameters(&dg00x->rx_stream, rate, - snd_dg00x_stream_pcm_channels[i]); - if (err < 0) - return err; - err = fw_iso_resources_allocate(&dg00x->rx_resources, - amdtp_stream_get_max_payload(&dg00x->rx_stream), - fw_parent_device(dg00x->unit)->max_speed); - if (err < 0) - return err; + if (stream == &dg00x->tx_stream) + resources = &dg00x->tx_resources; + else + resources = &dg00x->rx_resources; - /* Keep resources for in-stream. */ - err = amdtp_dot_set_parameters(&dg00x->tx_stream, rate, + err = amdtp_dot_set_parameters(stream, rate, snd_dg00x_stream_pcm_channels[i]); if (err < 0) return err; - err = fw_iso_resources_allocate(&dg00x->tx_resources, - amdtp_stream_get_max_payload(&dg00x->tx_stream), - fw_parent_device(dg00x->unit)->max_speed); - if (err < 0) { - fw_iso_resources_free(&dg00x->rx_resources); - return err; - } - return 0; + return fw_iso_resources_allocate(resources, + amdtp_stream_get_max_payload(stream), + fw_parent_device(dg00x->unit)->max_speed); } int snd_dg00x_stream_init_duplex(struct snd_dg00x *dg00x) @@ -306,7 +296,11 @@ int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x, unsigned int rate) if (err < 0) goto error; - err = keep_resources(dg00x, rate); + err = keep_resources(dg00x, &dg00x->rx_stream, rate); + if (err < 0) + goto error; + + err = keep_resources(dg00x, &dg00x->tx_stream, rate); if (err < 0) goto error; |