summaryrefslogtreecommitdiff
path: root/sound/firewire/fireworks
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-06-12 11:44:08 +0300
committerTakashi Iwai <tiwai@suse.de>2019-06-12 16:26:49 +0300
commit1dc5921082d48dc53e48e88ae2f9a24b9737307d (patch)
treef486dc00ac94d3ad18d83d53f232922876c0fd45 /sound/firewire/fireworks
parent33e41a5ce59ad34c822228d3811ba3785f1a97a2 (diff)
downloadlinux-1dc5921082d48dc53e48e88ae2f9a24b9737307d.tar.xz
ALSA: fireworks: unify substream counter
This commit is a part of preparation to perform allocation/release of isochronous resources in pcm.hw_params/hw_free callbacks. It's inconvenient to handle two isochronous context separately each other. This commit unifies the counters to handle the two at the same time. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/fireworks')
-rw-r--r--sound/firewire/fireworks/fireworks.h3
-rw-r--r--sound/firewire/fireworks/fireworks_midi.c8
-rw-r--r--sound/firewire/fireworks/fireworks_pcm.c8
-rw-r--r--sound/firewire/fireworks/fireworks_stream.c27
4 files changed, 19 insertions, 27 deletions
diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h
index 9b19c7f05d57..42a73038ba4d 100644
--- a/sound/firewire/fireworks/fireworks.h
+++ b/sound/firewire/fireworks/fireworks.h
@@ -89,8 +89,7 @@ struct snd_efw {
struct amdtp_stream rx_stream;
struct cmp_connection out_conn;
struct cmp_connection in_conn;
- unsigned int capture_substreams;
- unsigned int playback_substreams;
+ unsigned int substreams_counter;
/* hardware metering parameters */
unsigned int phys_out;
diff --git a/sound/firewire/fireworks/fireworks_midi.c b/sound/firewire/fireworks/fireworks_midi.c
index f5da2cd4ce42..7e78cdfe699e 100644
--- a/sound/firewire/fireworks/fireworks_midi.c
+++ b/sound/firewire/fireworks/fireworks_midi.c
@@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
goto end;
mutex_lock(&efw->mutex);
- efw->capture_substreams++;
+ ++efw->substreams_counter;
err = snd_efw_stream_start_duplex(efw, 0);
mutex_unlock(&efw->mutex);
if (err < 0)
@@ -38,7 +38,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
goto end;
mutex_lock(&efw->mutex);
- efw->playback_substreams++;
+ ++efw->substreams_counter;
err = snd_efw_stream_start_duplex(efw, 0);
mutex_unlock(&efw->mutex);
if (err < 0)
@@ -52,7 +52,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream)
struct snd_efw *efw = substream->rmidi->private_data;
mutex_lock(&efw->mutex);
- efw->capture_substreams--;
+ --efw->substreams_counter;
snd_efw_stream_stop_duplex(efw);
mutex_unlock(&efw->mutex);
@@ -65,7 +65,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream)
struct snd_efw *efw = substream->rmidi->private_data;
mutex_lock(&efw->mutex);
- efw->playback_substreams--;
+ --efw->substreams_counter;
snd_efw_stream_stop_duplex(efw);
mutex_unlock(&efw->mutex);
diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c
index aed566d82726..a66f6a381dac 100644
--- a/sound/firewire/fireworks/fireworks_pcm.c
+++ b/sound/firewire/fireworks/fireworks_pcm.c
@@ -232,7 +232,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream,
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
mutex_lock(&efw->mutex);
- efw->capture_substreams++;
+ ++efw->substreams_counter;
mutex_unlock(&efw->mutex);
}
@@ -251,7 +251,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
mutex_lock(&efw->mutex);
- efw->playback_substreams++;
+ ++efw->substreams_counter;
mutex_unlock(&efw->mutex);
}
@@ -264,7 +264,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) {
mutex_lock(&efw->mutex);
- efw->capture_substreams--;
+ --efw->substreams_counter;
mutex_unlock(&efw->mutex);
}
@@ -278,7 +278,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) {
mutex_lock(&efw->mutex);
- efw->playback_substreams--;
+ --efw->substreams_counter;
mutex_unlock(&efw->mutex);
}
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c
index 74e122e6e68a..2df39befcde0 100644
--- a/sound/firewire/fireworks/fireworks_stream.c
+++ b/sound/firewire/fireworks/fireworks_stream.c
@@ -194,9 +194,9 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate)
unsigned int curr_rate;
int err = 0;
- /* Need no substreams */
- if (efw->playback_substreams == 0 && efw->capture_substreams == 0)
- goto end;
+ // Need no substreams.
+ if (efw->substreams_counter == 0)
+ return -EIO;
/*
* Considering JACK/FFADO streaming:
@@ -206,19 +206,15 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate)
if (err < 0)
goto end;
- /* packet queueing error */
- if (amdtp_streaming_error(&efw->tx_stream))
- stop_stream(efw, &efw->tx_stream);
- if (amdtp_streaming_error(&efw->rx_stream))
- stop_stream(efw, &efw->rx_stream);
-
/* stop streams if rate is different */
err = snd_efw_command_get_sampling_rate(efw, &curr_rate);
if (err < 0)
goto end;
if (rate == 0)
rate = curr_rate;
- if (rate != curr_rate) {
+ if (rate != curr_rate ||
+ amdtp_streaming_error(&efw->tx_stream) ||
+ amdtp_streaming_error(&efw->rx_stream)) {
stop_stream(efw, &efw->tx_stream);
stop_stream(efw, &efw->rx_stream);
}
@@ -237,13 +233,12 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate)
}
}
- /* start slave if needed */
- if (efw->capture_substreams > 0 &&
- !amdtp_stream_running(&efw->tx_stream)) {
+ if (!amdtp_stream_running(&efw->tx_stream)) {
err = start_stream(efw, &efw->tx_stream, rate);
if (err < 0) {
dev_err(&efw->unit->device,
"fail to start AMDTP slave stream:%d\n", err);
+ stop_stream(efw, &efw->tx_stream);
stop_stream(efw, &efw->rx_stream);
}
}
@@ -253,11 +248,9 @@ end:
void snd_efw_stream_stop_duplex(struct snd_efw *efw)
{
- if (efw->capture_substreams == 0) {
+ if (efw->substreams_counter == 0) {
stop_stream(efw, &efw->tx_stream);
-
- if (efw->playback_substreams == 0)
- stop_stream(efw, &efw->rx_stream);
+ stop_stream(efw, &efw->rx_stream);
}
}