Message ID | 20221128122353.763696-1-john@metanate.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5624710wrr; Mon, 28 Nov 2022 04:28:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ygP6RRqjmSdx2NCBtRNZV/ItFtvp0VtQRgKBmGmuZUdA6wsh6GRUMivf5kA02p/hgFpiB X-Received: by 2002:a17:903:cc:b0:189:7441:1ada with SMTP id x12-20020a17090300cc00b0018974411adamr11591375plc.13.1669638526149; Mon, 28 Nov 2022 04:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669638526; cv=none; d=google.com; s=arc-20160816; b=Xtqgs2lwxE0eRaAsjU+4oV3xUFQCUwbLBjNssnU7Uil5GMjPcL2x0kP3dmoM1OYKHm v8gVbyPZyR3oXNu2K4C48WU1bNWYOr3Vxfv/b8HFTTYUP8KscsrCC+fhQbDYzHQAtzob g+j7MX+NAUGKVEryOS6bE2gkr2LOqqouSMXqDiwBKyzyxHOBkQxhOSlrjHrnmIuJWec2 7uYpOZEa+VH7Q0KsqrpTclI2TDTfLUx/wbd8LaaKUXE3/j/CX+u7dfqHWgn89iv3CKM5 GFZZm8xDbYoT1spREnEmggxIz2J9yvMiod7Y9iR3QQtn6sBIb5RTXNC8hGmXfzAgzADd b7Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=RNWWEK+RDLZlOOb7mMVxwyBbEJGGGcgM7PpYCOsgTyc=; b=K8N0CEG7wIdhBefXzO90nh11FM2wwrdZtKEdBJjATX9DUr3WL7MMHRyCOi2kctWwLU jskP3f0wduJ76xTjyyJcPfRDbLnWehliNgUjnmY4sANQrhgUiJT9Bb7G/EvtqyZSlgQP ziMxNyIJhpBYXm8ws5JZZohS9EtRl7g5XZERHSwPn3VTa1ePnT89CN9rLWRaVITAA3cw nUykF/KWAPwBIhgqpXLSWVWva7S8VxbODeuyMCwvfuYmZq/F585YIBnMbbI/AJiPkYXG eXkiMCUReyjwh5Bx7KdcnuKOGOoSzYoPDrBC0cKkzOOGdV1sgsxhpcXrm91wo4vxEP67 KcWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=0fkMw+g7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b25-20020a631b19000000b00434ffe3cc11si11422487pgb.870.2022.11.28.04.28.32; Mon, 28 Nov 2022 04:28:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=0fkMw+g7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbiK1MZz (ORCPT <rfc822;gah0developer@gmail.com> + 99 others); Mon, 28 Nov 2022 07:25:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbiK1MZg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 28 Nov 2022 07:25:36 -0500 Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8F6186F9 for <linux-kernel@vger.kernel.org>; Mon, 28 Nov 2022 04:24:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=RNWWEK+RDLZlOOb7mMVxwyBbEJGGGcgM7PpYCOsgTyc=; b=0f kMw+g7edeMTG1C7jJsRU1s2XGLSRTXyK0njwmb5WjFBRgpAqR8xAdnJ4k+Pf3i6DgJ5P1yADTZwOU GBHxR8muW8O1B/HxjGGk/otFKj23k4z/0iMi5wqxo0b5wzNfOx+L73D1RCTdh3IOycVqE7TZIkpKB K0A3BQLUvvPmirrih2jALVeM2zE1Sab8dwEHeLUz58ApnGbZodw/igvDWuHa51lnQO4YIZ2k+nSRJ 5UJRZVUVL+yK+nfFhinMinckxdf/35fkys0SFbQwqTHXwJqyTGAn8BoIGlbhTSHC8+VwK3b4J99bB epnR+7T6dMcKzw8SDpjjCjN5KkI9r+Yg==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from <john@metanate.com>) id 1ozdB3-0006Co-Da; Mon, 28 Nov 2022 12:24:02 +0000 From: John Keeping <john@metanate.com> To: alsa-devel@alsa-project.org Cc: John Keeping <john@metanate.com>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: usb-audio: Add quirk for Tascam Model 12 Date: Mon, 28 Nov 2022 12:23:52 +0000 Message-Id: <20221128122353.763696-1-john@metanate.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated: YES X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750742887271531791?= X-GMAIL-MSGID: =?utf-8?q?1750742887271531791?= |
Series |
ALSA: usb-audio: Add quirk for Tascam Model 12
|
|
Commit Message
John Keeping
Nov. 28, 2022, 12:23 p.m. UTC
Tascam's Model 12 is a mixer which can also operate as a USB audio
interface. The audio interface uses explicit feedback but it seems that
it does not correctly handle missing isochronous frames.
When injecting an xrun (or doing anything else that pauses the playback
stream) the feedback rate climbs (for example, at 44,100Hz nominal, I
see a stable rate around 44,099 but xrun injection sees this peak at
around 44,135 in most cases) and glitches are heard in the audio stream
for several seconds - this is significantly worse than the single glitch
expected for an underrun.
While the stream does normally recover and the feedback rate returns to
a stable value, I have seen some occurrences where this does not happen
and the rate continues to increase while no audio is heard from the
output. I have not found a solid reproduction for this.
This misbehaviour can be avoided by totally resetting the stream state
by switching the interface to alt 0 and back before restarting the
playback stream.
Add a new quirk flag which forces the endpoint and interface to be
reconfigured whenever the stream is stopped, and use this for the Tascam
Model 12.
Signed-off-by: John Keeping <john@metanate.com>
---
sound/usb/endpoint.c | 7 +++++++
sound/usb/quirks.c | 2 ++
sound/usb/usbaudio.h | 4 ++++
3 files changed, 13 insertions(+)
Comments
On Mon, 28 Nov 2022 13:23:52 +0100, John Keeping wrote: > > Tascam's Model 12 is a mixer which can also operate as a USB audio > interface. The audio interface uses explicit feedback but it seems that > it does not correctly handle missing isochronous frames. > > When injecting an xrun (or doing anything else that pauses the playback > stream) the feedback rate climbs (for example, at 44,100Hz nominal, I > see a stable rate around 44,099 but xrun injection sees this peak at > around 44,135 in most cases) and glitches are heard in the audio stream > for several seconds - this is significantly worse than the single glitch > expected for an underrun. > > While the stream does normally recover and the feedback rate returns to > a stable value, I have seen some occurrences where this does not happen > and the rate continues to increase while no audio is heard from the > output. I have not found a solid reproduction for this. > > This misbehaviour can be avoided by totally resetting the stream state > by switching the interface to alt 0 and back before restarting the > playback stream. > > Add a new quirk flag which forces the endpoint and interface to be > reconfigured whenever the stream is stopped, and use this for the Tascam > Model 12. > > Signed-off-by: John Keeping <john@metanate.com> Thanks for the patch, it's an interesting case. About the code change: > --- a/sound/usb/endpoint.c > +++ b/sound/usb/endpoint.c > @@ -1673,6 +1673,13 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending) > stop_urbs(ep, false, keep_pending); > if (ep->clock_ref) > atomic_dec(&ep->clock_ref->locked); > + > + if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET && > + usb_pipeout(ep->pipe)) { > + ep->need_setup = true; > + if (ep->iface_ref) > + ep->iface_ref->need_setup = true; > + } Is this the forced reset always safe? Imagine that you have individual playback and capture streams, and what if only one of them gets stopped and restarted while another keeps running? thanks, Takashi
On Mon, Nov 28, 2022 at 02:51:15PM +0100, Takashi Iwai wrote: > On Mon, 28 Nov 2022 13:23:52 +0100, > John Keeping wrote: > > > > Tascam's Model 12 is a mixer which can also operate as a USB audio > > interface. The audio interface uses explicit feedback but it seems that > > it does not correctly handle missing isochronous frames. > > > > When injecting an xrun (or doing anything else that pauses the playback > > stream) the feedback rate climbs (for example, at 44,100Hz nominal, I > > see a stable rate around 44,099 but xrun injection sees this peak at > > around 44,135 in most cases) and glitches are heard in the audio stream > > for several seconds - this is significantly worse than the single glitch > > expected for an underrun. > > > > While the stream does normally recover and the feedback rate returns to > > a stable value, I have seen some occurrences where this does not happen > > and the rate continues to increase while no audio is heard from the > > output. I have not found a solid reproduction for this. > > > > This misbehaviour can be avoided by totally resetting the stream state > > by switching the interface to alt 0 and back before restarting the > > playback stream. > > > > Add a new quirk flag which forces the endpoint and interface to be > > reconfigured whenever the stream is stopped, and use this for the Tascam > > Model 12. > > > > Signed-off-by: John Keeping <john@metanate.com> > > Thanks for the patch, it's an interesting case. > About the code change: > > > --- a/sound/usb/endpoint.c > > +++ b/sound/usb/endpoint.c > > @@ -1673,6 +1673,13 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending) > > stop_urbs(ep, false, keep_pending); > > if (ep->clock_ref) > > atomic_dec(&ep->clock_ref->locked); > > + > > + if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET && > > + usb_pipeout(ep->pipe)) { > > + ep->need_setup = true; It seems I missed this when forward porting the patch from 5.15 - this should be setting ep->need_prepare and will change in v2. > > + if (ep->iface_ref) > > + ep->iface_ref->need_setup = true; > > + } > > Is this the forced reset always safe? Imagine that you have > individual playback and capture streams, and what if only one of them > gets stopped and restarted while another keeps running? I /think/ this is okay because the interfaces for capture & playback are separate (although the clock is shared). There are two endpoints on the playback interface - the playback data and explicit feedback endpoints - but these are always stopped and started at the same time so I can't see any problem here. (Only the data endpoint will trigger the reset request here due to the usb_pipeout() check.)
On Mon, 28 Nov 2022 20:20:05 +0100, John Keeping wrote: > > On Mon, Nov 28, 2022 at 02:51:15PM +0100, Takashi Iwai wrote: > > On Mon, 28 Nov 2022 13:23:52 +0100, > > John Keeping wrote: > > > > > > Tascam's Model 12 is a mixer which can also operate as a USB audio > > > interface. The audio interface uses explicit feedback but it seems that > > > it does not correctly handle missing isochronous frames. > > > > > > When injecting an xrun (or doing anything else that pauses the playback > > > stream) the feedback rate climbs (for example, at 44,100Hz nominal, I > > > see a stable rate around 44,099 but xrun injection sees this peak at > > > around 44,135 in most cases) and glitches are heard in the audio stream > > > for several seconds - this is significantly worse than the single glitch > > > expected for an underrun. > > > > > > While the stream does normally recover and the feedback rate returns to > > > a stable value, I have seen some occurrences where this does not happen > > > and the rate continues to increase while no audio is heard from the > > > output. I have not found a solid reproduction for this. > > > > > > This misbehaviour can be avoided by totally resetting the stream state > > > by switching the interface to alt 0 and back before restarting the > > > playback stream. > > > > > > Add a new quirk flag which forces the endpoint and interface to be > > > reconfigured whenever the stream is stopped, and use this for the Tascam > > > Model 12. > > > > > > Signed-off-by: John Keeping <john@metanate.com> > > > > Thanks for the patch, it's an interesting case. > > About the code change: > > > > > --- a/sound/usb/endpoint.c > > > +++ b/sound/usb/endpoint.c > > > @@ -1673,6 +1673,13 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending) > > > stop_urbs(ep, false, keep_pending); > > > if (ep->clock_ref) > > > atomic_dec(&ep->clock_ref->locked); > > > + > > > + if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET && > > > + usb_pipeout(ep->pipe)) { > > > + ep->need_setup = true; > > It seems I missed this when forward porting the patch from 5.15 - this > should be setting ep->need_prepare and will change in v2. > > > > + if (ep->iface_ref) > > > + ep->iface_ref->need_setup = true; > > > + } > > > > Is this the forced reset always safe? Imagine that you have > > individual playback and capture streams, and what if only one of them > > gets stopped and restarted while another keeps running? > > I /think/ this is okay because the interfaces for capture & playback are > separate (although the clock is shared). > > There are two endpoints on the playback interface - the playback data > and explicit feedback endpoints - but these are always stopped and > started at the same time so I can't see any problem here. (Only the > data endpoint will trigger the reset request here due to the > usb_pipeout() check.) Ah OK, then it should be safe -- and it'd be worth to mention it in the changelog, too (hint for the resubmission :) Takashi
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 310cd6fb0038..ab248d554774 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -1673,6 +1673,13 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending) stop_urbs(ep, false, keep_pending); if (ep->clock_ref) atomic_dec(&ep->clock_ref->locked); + + if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET && + usb_pipeout(ep->pipe)) { + ep->need_setup = true; + if (ep->iface_ref) + ep->iface_ref->need_setup = true; + } } } diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 0f4dd3503a6a..58b37bfc885c 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2044,6 +2044,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { DEVICE_FLG(0x0644, 0x804a, /* TEAC UD-301 */ QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY), + DEVICE_FLG(0x0644, 0x805f, /* TEAC Model 12 */ + QUIRK_FLAG_FORCE_IFACE_RESET), DEVICE_FLG(0x06f8, 0xb000, /* Hercules DJ Console (Windows Edition) */ QUIRK_FLAG_IGNORE_CTL_ERROR), DEVICE_FLG(0x06f8, 0xd002, /* Hercules DJ Console (Macintosh Edition) */ diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index e97141ef730a..2aba508a4831 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -172,6 +172,9 @@ extern bool snd_usb_skip_validation; * Don't apply implicit feedback sync mode * QUIRK_FLAG_IFACE_SKIP_CLOSE * Don't closed interface during setting sample rate + * QUIRK_FLAG_FORCE_IFACE_RESET + * Force an interface reset whenever stopping & restarting a stream + * (e.g. after xrun) */ #define QUIRK_FLAG_GET_SAMPLE_RATE (1U << 0) @@ -194,5 +197,6 @@ extern bool snd_usb_skip_validation; #define QUIRK_FLAG_GENERIC_IMPLICIT_FB (1U << 17) #define QUIRK_FLAG_SKIP_IMPLICIT_FB (1U << 18) #define QUIRK_FLAG_IFACE_SKIP_CLOSE (1U << 19) +#define QUIRK_FLAG_FORCE_IFACE_RESET (1U << 20) #endif /* __USBAUDIO_H */