From patchwork Tue Nov 29 13:00:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 629178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 782BEC4321E for ; Tue, 29 Nov 2022 13:02:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ACDFC16C5; Tue, 29 Nov 2022 14:01:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ACDFC16C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669726934; bh=nEE7ANLnijcZDTl7B3nrmP9X5x04U/HMRJoIZcA/s3A=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=JDCiSDeM3ghrk5xl17YGyhQZGfL4U8rjy4B5mlC5briFggzeoaIKF4fPyaYXgqEwI BJMklEykirhf++j0D+TEAhuwQANNwQYuyrlvcB5DdiO93Ar0W65EEzjMgWXK/LhaIX /FaJz4Q6JUYBXlimLNiSpJNLRjrHau8OAiq5W4LQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5BCD9F801F5; Tue, 29 Nov 2022 14:01:24 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B48CAF801F7; Tue, 29 Nov 2022 14:01:23 +0100 (CET) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9E6C7F80166 for ; Tue, 29 Nov 2022 14:01:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9E6C7F80166 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metanate.com header.i=@metanate.com header.b="4wuyprYT" 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=bKaY7Cs8aW9BtrIz5l8sVTAqT6Jm4plh5nuX1ZZOV7c=; b=4w uyprYTnBDw9+bKADMhMaOYhNV2X9SJzgWDZOed+XhFsd6HC+XilWs4OPNHRkSaw06qZP9Hsa2jsib GZYEwjaR/OQrmb3uPIijnJUgAlz1CA8oTBjeDvvqUyGQaGadLUtRLaHbxawLbG9TKvyDf02hhakIo Tc1xYex1iAzFWmyULhoclApJXpZbCcCe0oIVYnv01/yi5wKBto+vYo/48Kdg2cP57xXUMSm7H/2Qb kvghj0y81P9nFlSVsivPPZliXRtEg/UOYcZGTVdSepYsnTvM9uXNZ3RyRyzLqhJrErSbnCgKga2h+ 6SzUPLgjsfea4IDdEJjUhDudipuTgSJA==; 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 ) id 1p00Ec-0003dc-K7; Tue, 29 Nov 2022 13:01:15 +0000 From: John Keeping To: alsa-devel@alsa-project.org Subject: [PATCH v2] ALSA: usb-audio: Add quirk for Tascam Model 12 Date: Tue, 29 Nov 2022 13:00:59 +0000 Message-Id: <20221129130100.1257904-1-john@metanate.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Authenticated: YES Cc: linux-kernel@vger.kernel.org, John Keeping , Takashi Iwai X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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. Separate interfaces are used for the playback and capture endpoints, so resetting the playback interface here will not affect the capture stream if it is running. While there are two endpoints on the interface, these are the OUT data endpoint and the IN explicit feedback endpoint corresponding to it and these are always stopped and started together. Signed-off-by: John Keeping --- v2: - Set ep->need_prepare not ep->need_setup; this was missed when forward porting the patch as need_prepare is new in 6.1 - Add more details to the commit message about why it is safe to reset the interface here sound/usb/endpoint.c | 7 +++++++ sound/usb/quirks.c | 2 ++ sound/usb/usbaudio.h | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 310cd6fb0038..4aaf0784940b 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_prepare = 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 */