Commit 18f26034 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-motu: unify the count of subscriber for packet streaming

Two counters are used to maintain isochronous packet streaming for both
directions. However, like the other drivers, they can be replaced with
one counter. This commit unifies them.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7bc93821
...@@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) ...@@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
motu->capture_substreams++; motu->substreams_counter++;
err = snd_motu_stream_start_duplex(motu, 0); err = snd_motu_stream_start_duplex(motu, 0);
mutex_unlock(&motu->mutex); mutex_unlock(&motu->mutex);
...@@ -40,7 +40,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) ...@@ -40,7 +40,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
motu->playback_substreams++; motu->substreams_counter++;
err = snd_motu_stream_start_duplex(motu, 0); err = snd_motu_stream_start_duplex(motu, 0);
mutex_unlock(&motu->mutex); mutex_unlock(&motu->mutex);
...@@ -57,7 +57,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream) ...@@ -57,7 +57,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream)
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
motu->capture_substreams--; motu->substreams_counter--;
snd_motu_stream_stop_duplex(motu); snd_motu_stream_stop_duplex(motu);
mutex_unlock(&motu->mutex); mutex_unlock(&motu->mutex);
...@@ -72,7 +72,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream) ...@@ -72,7 +72,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream)
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
motu->playback_substreams--; motu->substreams_counter--;
snd_motu_stream_stop_duplex(motu); snd_motu_stream_stop_duplex(motu);
mutex_unlock(&motu->mutex); mutex_unlock(&motu->mutex);
......
...@@ -203,7 +203,7 @@ static int capture_hw_params(struct snd_pcm_substream *substream, ...@@ -203,7 +203,7 @@ static int capture_hw_params(struct snd_pcm_substream *substream,
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
motu->capture_substreams++; motu->substreams_counter++;
mutex_unlock(&motu->mutex); mutex_unlock(&motu->mutex);
} }
...@@ -222,7 +222,7 @@ static int playback_hw_params(struct snd_pcm_substream *substream, ...@@ -222,7 +222,7 @@ static int playback_hw_params(struct snd_pcm_substream *substream,
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
motu->playback_substreams++; motu->substreams_counter++;
mutex_unlock(&motu->mutex); mutex_unlock(&motu->mutex);
} }
...@@ -236,7 +236,7 @@ static int capture_hw_free(struct snd_pcm_substream *substream) ...@@ -236,7 +236,7 @@ static int capture_hw_free(struct snd_pcm_substream *substream)
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
motu->capture_substreams--; motu->substreams_counter--;
snd_motu_stream_stop_duplex(motu); snd_motu_stream_stop_duplex(motu);
...@@ -252,7 +252,7 @@ static int playback_hw_free(struct snd_pcm_substream *substream) ...@@ -252,7 +252,7 @@ static int playback_hw_free(struct snd_pcm_substream *substream)
mutex_lock(&motu->mutex); mutex_lock(&motu->mutex);
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
motu->playback_substreams--; motu->substreams_counter--;
snd_motu_stream_stop_duplex(motu); snd_motu_stream_stop_duplex(motu);
......
...@@ -207,7 +207,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) ...@@ -207,7 +207,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate)
unsigned int curr_rate; unsigned int curr_rate;
int err = 0; int err = 0;
if (motu->capture_substreams == 0 && motu->playback_substreams == 0) if (motu->substreams_counter == 0)
return 0; return 0;
/* Some packet queueing errors. */ /* Some packet queueing errors. */
...@@ -271,8 +271,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) ...@@ -271,8 +271,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate)
} }
} }
if (!amdtp_stream_running(&motu->tx_stream) && if (!amdtp_stream_running(&motu->tx_stream)) {
motu->capture_substreams > 0) {
err = start_isoc_ctx(motu, &motu->tx_stream); err = start_isoc_ctx(motu, &motu->tx_stream);
if (err < 0) { if (err < 0) {
dev_err(&motu->unit->device, dev_err(&motu->unit->device,
...@@ -291,15 +290,12 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) ...@@ -291,15 +290,12 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate)
void snd_motu_stream_stop_duplex(struct snd_motu *motu) void snd_motu_stream_stop_duplex(struct snd_motu *motu)
{ {
if (motu->capture_substreams == 0) { if (motu->substreams_counter == 0) {
if (amdtp_stream_running(&motu->tx_stream)) if (amdtp_stream_running(&motu->tx_stream))
stop_isoc_ctx(motu, &motu->tx_stream); stop_isoc_ctx(motu, &motu->tx_stream);
if (motu->playback_substreams == 0) { if (amdtp_stream_running(&motu->rx_stream))
if (amdtp_stream_running(&motu->rx_stream)) stop_isoc_ctx(motu, &motu->rx_stream);
stop_isoc_ctx(motu, &motu->rx_stream);
stop_both_streams(motu);
}
} }
} }
...@@ -372,8 +368,7 @@ void snd_motu_stream_destroy_duplex(struct snd_motu *motu) ...@@ -372,8 +368,7 @@ void snd_motu_stream_destroy_duplex(struct snd_motu *motu)
destroy_stream(motu, AMDTP_IN_STREAM); destroy_stream(motu, AMDTP_IN_STREAM);
destroy_stream(motu, AMDTP_OUT_STREAM); destroy_stream(motu, AMDTP_OUT_STREAM);
motu->playback_substreams = 0; motu->substreams_counter = 0;
motu->capture_substreams = 0;
} }
static void motu_lock_changed(struct snd_motu *motu) static void motu_lock_changed(struct snd_motu *motu)
......
...@@ -60,8 +60,7 @@ struct snd_motu { ...@@ -60,8 +60,7 @@ struct snd_motu {
struct amdtp_stream rx_stream; struct amdtp_stream rx_stream;
struct fw_iso_resources tx_resources; struct fw_iso_resources tx_resources;
struct fw_iso_resources rx_resources; struct fw_iso_resources rx_resources;
unsigned int capture_substreams; unsigned int substreams_counter;
unsigned int playback_substreams;
/* For notification. */ /* For notification. */
struct fw_address_handler async_handler; struct fw_address_handler async_handler;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment