From d18b0a6e42f7d4fca64f34ea0b76a312be632d7a Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Tue, 11 Jun 2019 22:21:08 +0900 Subject: [PATCH] ALSA: firewire-digi00x: code refactoring to finish streaming session This commit is a part of preparation to perform allocation/release of isochronous resources in pcm.hw_params/hw_free callbacks. The operation to finish packet streaming corresponds to stopping isochronous contexts. This commit applies code refactoring to move codes to stop into a helper function to finish the session. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/digi00x/digi00x-stream.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sound/firewire/digi00x/digi00x-stream.c b/sound/firewire/digi00x/digi00x-stream.c index 455c43e81850..90e31b63ac2f 100644 --- a/sound/firewire/digi00x/digi00x-stream.c +++ b/sound/firewire/digi00x/digi00x-stream.c @@ -125,8 +125,12 @@ int snd_dg00x_stream_get_external_rate(struct snd_dg00x *dg00x, static void finish_session(struct snd_dg00x *dg00x) { - __be32 data = cpu_to_be32(0x00000003); + __be32 data; + + amdtp_stream_stop(&dg00x->tx_stream); + amdtp_stream_stop(&dg00x->rx_stream); + data = cpu_to_be32(0x00000003); snd_fw_transaction(dg00x->unit, TCODE_WRITE_QUADLET_REQUEST, DG00X_ADDR_BASE + DG00X_OFFSET_STREAMING_SET, &data, sizeof(data), 0); @@ -136,6 +140,10 @@ static void finish_session(struct snd_dg00x *dg00x) snd_fw_transaction(dg00x->unit, TCODE_WRITE_QUADLET_REQUEST, DG00X_ADDR_BASE + DG00X_OFFSET_ISOC_CHANNELS, &data, sizeof(data), 0); + + // Just after finishing the session, the device may lost transmitting + // functionality for a short time. + msleep(50); } static int begin_session(struct snd_dg00x *dg00x) @@ -289,8 +297,6 @@ int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x, unsigned int rate) amdtp_streaming_error(&dg00x->rx_stream)) { finish_session(dg00x); - amdtp_stream_stop(&dg00x->tx_stream); - amdtp_stream_stop(&dg00x->rx_stream); release_resources(dg00x); } @@ -346,8 +352,6 @@ end: error: finish_session(dg00x); - amdtp_stream_stop(&dg00x->tx_stream); - amdtp_stream_stop(&dg00x->rx_stream); release_resources(dg00x); return err; @@ -358,16 +362,8 @@ void snd_dg00x_stream_stop_duplex(struct snd_dg00x *dg00x) if (dg00x->substreams_counter > 0) return; - amdtp_stream_stop(&dg00x->tx_stream); - amdtp_stream_stop(&dg00x->rx_stream); finish_session(dg00x); release_resources(dg00x); - - /* - * Just after finishing the session, the device may lost transmitting - * functionality for a short time. - */ - msleep(50); } void snd_dg00x_stream_update_duplex(struct snd_dg00x *dg00x) -- 2.30.2