Commit bf1ad3e0 authored by Takashi Iwai's avatar Takashi Iwai Committed by Greg Kroah-Hartman

staging: bcm2835-audio: Fix incorrect draining handling

The handling of SNDRV_PCM_TRIGGER_STOP at the trigger callback is
incorrect: when the STOP is issued, the driver is supposed to drop the
stream immediately.  Meanwhile bcm2835 driver checks the DRAINING
state and tries to issue some different command.

This patch straightens things a bit, dropping the incorrect state
checks.  The draining behavior would be still not perfect at this
point, but will be improved in a later patch.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c5e7824b
...@@ -153,7 +153,6 @@ static int snd_bcm2835_playback_open_generic( ...@@ -153,7 +153,6 @@ static int snd_bcm2835_playback_open_generic(
chip->alsa_stream[idx] = alsa_stream; chip->alsa_stream[idx] = alsa_stream;
chip->opened |= (1 << idx); chip->opened |= (1 << idx);
alsa_stream->draining = 1;
out: out:
mutex_unlock(&chip->audio_mutex); mutex_unlock(&chip->audio_mutex);
...@@ -268,6 +267,7 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -268,6 +267,7 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream)
alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream); alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream);
alsa_stream->period_size = snd_pcm_lib_period_bytes(substream); alsa_stream->period_size = snd_pcm_lib_period_bytes(substream);
alsa_stream->pos = 0; alsa_stream->pos = 0;
alsa_stream->draining = false;
audio_debug("buffer_size=%d, period_size=%d pos=%d frame_bits=%d\n", audio_debug("buffer_size=%d, period_size=%d pos=%d frame_bits=%d\n",
alsa_stream->buffer_size, alsa_stream->period_size, alsa_stream->buffer_size, alsa_stream->period_size,
...@@ -312,21 +312,15 @@ static int snd_bcm2835_pcm_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -312,21 +312,15 @@ static int snd_bcm2835_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
err = bcm2835_audio_start(alsa_stream); err = bcm2835_audio_start(alsa_stream);
if (!err) if (err)
alsa_stream->draining = 1;
else
audio_error(" Failed to START alsa device (%d)\n", err); audio_error(" Failed to START alsa device (%d)\n", err);
break; break;
case SNDRV_PCM_TRIGGER_DRAIN:
alsa_stream->draining = true;
break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
audio_info("DRAINING\n");
alsa_stream->draining = 1;
} else {
audio_info("DROPPING\n");
alsa_stream->draining = 0;
}
err = bcm2835_audio_stop(alsa_stream); err = bcm2835_audio_stop(alsa_stream);
if (err != 0) if (err)
audio_error(" Failed to STOP alsa device (%d)\n", err); audio_error(" Failed to STOP alsa device (%d)\n", err);
break; break;
default: default:
......
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