From patchwork Tue May 31 13:07:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 577845 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 05E2DC433F5 for ; Tue, 31 May 2022 13:08:53 +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 917DA1AA8; Tue, 31 May 2022 15:08:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 917DA1AA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654002531; bh=BBKVZ7wpUbA9Wt64B8jqvTMX/ygPWLkdIVpcv+PxZko=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Z0wXYWG3iqvvmC/Hk1Tf734FbfiNtlFKp0NjBMD8oftsGFW8F3TWZ7WFSwxDKP2Vi i+9NzwuPptC2wtUz9xtdaSt5j/2FmIy1rguYFiThmngft+7b2tFyzt+2kHnMiDQWyA JJOtdFY9vewVclLeyH5E+ZiZLs43GTEcCqfQb6KE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 15DF0F800DE; Tue, 31 May 2022 15:08:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BCB21F80161; Tue, 31 May 2022 15:07:59 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AABC4F800DE for ; Tue, 31 May 2022 15:07:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AABC4F800DE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="pfvS3wQu"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="zqPrIAxF" Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D912B21B46; Tue, 31 May 2022 13:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1654002472; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QkK4V5rYWedJCyCMSZfFS+swXMEXLQXCUjsN+sWhD88=; b=pfvS3wQuQhGoT1QgFA+x5Yf0ZWEnazmFtDauCIGb4T5QZinGT4SYMDdBxaUvGobRuIKLI6 vNb5cWBrQwnGGOynOTibIFFzyv6+tuKhzmMKwS9YhHH/f2PaPzIVpSQaTEMkNsXMOJcCEV Yg8IOMK1qEMYGdNKXxo5NCiyQnaaIj4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1654002472; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QkK4V5rYWedJCyCMSZfFS+swXMEXLQXCUjsN+sWhD88=; b=zqPrIAxF9aT24HA7yafnjK9DK3bI+fvpVRjp+YsZ5FclEflapPVXEmUR6WxGWHlSDkRs7X cRX8RLpaa4bwfmCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BC9B913AA2; Tue, 31 May 2022 13:07:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sS07LSgTlmLlBAAAMHmgww (envelope-from ); Tue, 31 May 2022 13:07:52 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH] ALSA: usb-audio: Optimize TEAC clock quirk Date: Tue, 31 May 2022 15:07:49 +0200 Message-Id: <20220531130749.30357-1-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 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" Maris found out that the quirk for TEAC devices to work around the clock setup is needed to apply only when the base clock is changed, e.g. from 48000-based clocks (48000, 96000, 192000, 384000) to 44100-based clocks (44100, 88200, 176400, 352800), or vice versa, while switching to another clock with the same base clock doesn't need the (forcible) interface setup. This patch implements the optimization for the TEAC clock quirk to avoid the unnecessary interface re-setup. Fixes: 5ce0b06ae5e6 ("ALSA: usb-audio: Workaround for clock setup on TEAC devices") Reported-by: Maris Abele Cc: Signed-off-by: Takashi Iwai --- sound/usb/clock.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/usb/clock.c b/sound/usb/clock.c index 3c435d379306..db429320599e 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -573,10 +573,14 @@ static int set_sample_rate_v2v3(struct snd_usb_audio *chip, } /* FIXME - TEAC devices require the immediate interface setup */ - if (rate != prev_rate && USB_ID_VENDOR(chip->usb_id) == 0x0644) { - usb_set_interface(chip->dev, fmt->iface, fmt->altsetting); - if (chip->quirk_flags & QUIRK_FLAG_IFACE_DELAY) - msleep(50); + if (USB_ID_VENDOR(chip->usb_id) == 0x0644) { + bool cur_base_48k = (rate % 48000 == 0); + bool prev_base_48k = (prev_rate % 48000 == 0); + if (cur_base_48k != prev_base_48k) { + usb_set_interface(chip->dev, fmt->iface, fmt->altsetting); + if (chip->quirk_flags & QUIRK_FLAG_IFACE_DELAY) + msleep(50); + } } validation: