summaryrefslogtreecommitdiffstats
path: root/sound/usb/pcm.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-07-09 11:40:26 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-07-09 11:40:26 -0700
commit3de62951a5bee5dce5f4ffab8b7323ca9d3c7e1c (patch)
tree53a97ab46723bb5e0a55303789cf0e880fa74baa /sound/usb/pcm.c
parent5a7f7fc5ddbbf9bf63eaa8cb9a0d254ab984f3d6 (diff)
parent24d1e49415be546470b20429d748e240d0518b7e (diff)
downloadlinux-stable-3de62951a5bee5dce5f4ffab8b7323ca9d3c7e1c.tar.gz
linux-stable-3de62951a5bee5dce5f4ffab8b7323ca9d3c7e1c.tar.bz2
linux-stable-3de62951a5bee5dce5f4ffab8b7323ca9d3c7e1c.zip
Merge tag 'sound-fix-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "Just a collection of small fixes here: the most outstanding one is the re-application of USB-audio lowlatency support that was reverted in the previous PR. The rest are device-specific quirks/fixes, spelling fixes and a regression fix for the old intel8x0 driver" * tag 'sound-fix-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: intel8x0: Fix breakage at ac97 clock measurement ALSA: usb-audio: Reduce latency at playback start, take#2 ALSA: isa: Fix error return code in snd_cmi8330_probe() ALSA: emux: fix spelling mistakes ALSA: usb-audio: fix spelling mistakes ALSA: bebob: correct duplicated entries with TerraTec OUI ALSA: usx2y: fix spelling mistakes ALSA: x86: fix spelling mistakes ALSA: hda/realtek: fix mute led of the HP Pavilion 15-eh1xxx series
Diffstat (limited to 'sound/usb/pcm.c')
-rw-r--r--sound/usb/pcm.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index e26d37365f02..4e5031a68064 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -611,13 +611,9 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
subs->hwptr_done = 0;
subs->transfer_done = 0;
subs->last_frame_number = 0;
+ subs->period_elapsed_pending = 0;
runtime->delay = 0;
- /* for playback, submit the URBs now; otherwise, the first hwptr_done
- * updates for all URBs would happen at the same time when starting */
- if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
- ret = start_endpoints(subs);
-
unlock:
snd_usb_unlock_shutdown(chip);
return ret;
@@ -1398,6 +1394,10 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
subs->trigger_tstamp_pending_update = false;
}
+ if (period_elapsed && !subs->running) {
+ subs->period_elapsed_pending = 1;
+ period_elapsed = 0;
+ }
spin_unlock_irqrestore(&subs->lock, flags);
urb->transfer_buffer_length = bytes;
if (period_elapsed)
@@ -1413,6 +1413,7 @@ static void retire_playback_urb(struct snd_usb_substream *subs,
{
unsigned long flags;
struct snd_urb_ctx *ctx = urb->context;
+ bool period_elapsed = false;
spin_lock_irqsave(&subs->lock, flags);
if (ctx->queued) {
@@ -1423,13 +1424,20 @@ static void retire_playback_urb(struct snd_usb_substream *subs,
}
subs->last_frame_number = usb_get_current_frame_number(subs->dev);
+ if (subs->running) {
+ period_elapsed = subs->period_elapsed_pending;
+ subs->period_elapsed_pending = 0;
+ }
spin_unlock_irqrestore(&subs->lock, flags);
+ if (period_elapsed)
+ snd_pcm_period_elapsed(subs->pcm_substream);
}
static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substream,
int cmd)
{
struct snd_usb_substream *subs = substream->runtime->private_data;
+ int err;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
@@ -1440,6 +1448,14 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea
prepare_playback_urb,
retire_playback_urb,
subs);
+ if (cmd == SNDRV_PCM_TRIGGER_START) {
+ err = start_endpoints(subs);
+ if (err < 0) {
+ snd_usb_endpoint_set_callback(subs->data_endpoint,
+ NULL, NULL, NULL);
+ return err;
+ }
+ }
subs->running = 1;
dev_dbg(&subs->dev->dev, "%d:%d Start Playback PCM\n",
subs->cur_audiofmt->iface,