From patchwork Thu Feb 1 07:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vincenttew X-Patchwork-Id: 195181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp261319dyc; Wed, 31 Jan 2024 23:07:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFj4S5jSGINTmbzbYv6OJmmkXsQsDVPPX8kR+zUL8HlL78wXQxY4veA2N0uXZV+ESXpISmC X-Received: by 2002:a05:6402:618:b0:55f:c995:6d69 with SMTP id n24-20020a056402061800b0055fc9956d69mr9444edv.10.1706771261363; Wed, 31 Jan 2024 23:07:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706771261; cv=pass; d=google.com; s=arc-20160816; b=yFoKAQo3flRBx6LB5839nFlGCGJfSUEwYR5KCrkzmY0yC+c2sVaSYKQcxvYmhaJLZL ZMpszF6bvnYdJW7f0r3Pc5QVYZ4CnOC+nD3jq7953+IG7trB7BrCUcDvZ63RvbxrQmk4 U44G/JmNETC9/4S/dDtmz1To/tfIiHyIK5yxEZYYyUMGEYk4uOBbrvDk9hPSfKSKEe9i 7yU4Q0vL41ebeOHFwpUhf1LbmbK7lihCKqAIzwlqpzkYs3ozWPW02nIX6NY9MHNPScHc Kv4s6PyBjKpQTwiCKWj97IYBtueU5YuVGHny4q6wLvUN+q4Zt5iaOgQ8lSdGus8TSrhl IQHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=nARAJpsDECWE0kiylBNBZDPewhI1rfVQYGPQbaScn7c=; fh=xE/EZnLvYO4+WgTEEs/nvBmmIhhYM/UMcZ5JnKmAKwg=; b=B+sy2qI+dOTwpHzFycp2Gy0mWhD20/NSRZ9KXV6pVJBkTv7q1L10gr3XWJF/+EmeS2 ZFCHi5EK+0hi9uN0Hew7tS/LnD+zul6Ha859goIAereFpMYlXSa8mKAqIi9PJtqSLzYn QLoMkSUNg+2a1HJc5uFQtR5tg1sRuOvd98guTMHr8xoMHypXJbbSRhzq30dOgCK7CstM FYtAiXdAOwQtKTPeHSaVfwrjkPQEDPxFSRcT4easccBldYOH4l71zs5cdvL+YwvS5NOH YSEYprap1bRhuuFA5NFILkxseFP51qb0Abu2cXdqOFqSiNzAIxGgg3GlVchGt8EJsGA7 +Ltg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ixM97rRB; arc=pass (i=1 spf=pass spfdomain=flex--vincenttew.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47720-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47720-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCUAJrHegnWNRjj9offM9KizwjvB7/IWUH/zEezoxNbf1UOK3CJNZ5DGuJucOqiBTgh63qeD4Xol5uQ/z6JHNpegYq2UVQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e17-20020a50ec91000000b0055fc7accffasi49431edr.293.2024.01.31.23.07.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 23:07:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47720-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ixM97rRB; arc=pass (i=1 spf=pass spfdomain=flex--vincenttew.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47720-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47720-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6D3F51F27C11 for ; Thu, 1 Feb 2024 07:07:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08515157E80; Thu, 1 Feb 2024 07:07:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ixM97rRB" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2179157E90 for ; Thu, 1 Feb 2024 07:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706771234; cv=none; b=LkFYT/Odv21zg6o/qK5QYVOEsSiESzMN5lsOJ3ub9XeP8rf1WyiTekQgkychKXK8Tvz+m4xbzjLl6Kb9yMC4GxkdqM0i6Fn4z0En4bM9NcjoqDYENH0SSOLCNi0FyYp6JpLhFMTy4y2VIWwyjRQaXOOdHr5kF69AKButQJraT0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706771234; c=relaxed/simple; bh=Cq73BcEx/uYKDbOU3/mg9M1bMhtj7nZ8crkg4Fn+pc0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=WsgiCyAzDFgJhUpPxhXA3arji883tZ7X73NG1zJ47sC7bpN3jqhE0v9XRw7KHbi4tTH7WFsevut7ntnhbpjdP9VTW2SB5bauHXbIB1+inACBA4zjIfmWuGrV6nw3GxlaX/NiJHVgVELqZjKMuXj5oC319RbJ5FqknMKvRSl+v/E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vincenttew.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ixM97rRB; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vincenttew.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-60407831b3cso11374527b3.1 for ; Wed, 31 Jan 2024 23:07:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706771231; x=1707376031; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=nARAJpsDECWE0kiylBNBZDPewhI1rfVQYGPQbaScn7c=; b=ixM97rRBFltiLaTHg0ReAjOqOOGM6HjhTmNEv5fzA2bXq0TTZAvh+PmQggDpOaF1Ju BepaFkKwQMv8ayl6u7BEHBOSTQsdj/8vYsNJtGLJoGRwD3eejrbshZ/juWssqpPKYiiN xhjqZGDXh56dBJU+i6DaVHTrTyssGawP12D1WLQTJupOTJdp6Hv9u+6xFui9sPAp7PRc cF7EefU31biAvr7S43l/ViX5MDCmuIWVrIh7IeoZEbYGtWTIZREnm4/h+kDbuPw7uhIi hrcI+hgauABGsQzRHVC0ueKdW5UzEmSBNGU7uQAsysPt9o+ByLSaXfJFKXxV+wzpzmb+ ZEwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706771231; x=1707376031; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nARAJpsDECWE0kiylBNBZDPewhI1rfVQYGPQbaScn7c=; b=CR7kOX97B/avSbSKKoYKAHs6QYC0v5D1cv9UMCFUG/FiYrYytsuNum2Sj60qKFTokE THNQslV3N2u/OztEepINd3Rzt45erbu7n5Yj2Rgwp8yCjPLxs+W7mMsKidPEDciaBhyw dKZ3RFqtArOCX57skzwxY8Wbh0oJGCW0GcL/53dHkAVhXSj/kbJMdK0y+ETu96WKGTaS aQzoKILLJrZ2G026kXtbfpo7+KQAIPEgAl0ITbAzMF9vpK5cbhwZhOGBpMxWHBgq/Ujh a1ZqfoSFSlzDnYk7T1MrUDe3X9YNmeqy9nq+kaxV6Jd72RjW0SD4CZNSejSF92lE+KJu 5Hqg== X-Gm-Message-State: AOJu0Yz2B3GI6TZmDMlL/fvcMtqRzB+iV18tjb5EH1Tmo8BnOOqVYPY+ WkYxMcmUb5N7zc0l6Cc9r0eXF8vkmVmBum9sFwFdbmZ/WMPwja80RscG5MI4pg9OymRK0rnR2PY m35J0LiT2DUlm/qFAFw== X-Received: from vincenttew1.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:1bb2]) (user=vincenttew job=sendgmr) by 2002:a81:9b12:0:b0:5fb:455a:df08 with SMTP id s18-20020a819b12000000b005fb455adf08mr928942ywg.7.1706771231672; Wed, 31 Jan 2024 23:07:11 -0800 (PST) Date: Thu, 1 Feb 2024 15:06:09 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201070641.401684-1-vincenttew@google.com> Subject: [PATCH] ALSA: usb-audio: retry clock validate when it takes some times From: vincenttew To: perex@perex.cz, tiwai@suse.com, vincenttew@google.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Cc: alexander@tsoy.me X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789679382162761613 X-GMAIL-MSGID: 1789679382162761613 Behringer UMC202HD and UMC404HD take some times to validate the clock source. To prevent more DAC have the same delay which return the false in the first time, remove the USB id check to have a chance to retry the clock validate. Signed-off-by: vincenttew --- sound/usb/clock.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/sound/usb/clock.c b/sound/usb/clock.c index b118cf97607f..16d7a456dd10 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -181,34 +181,27 @@ static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip, return true; } - /* - * MOTU MicroBook IIc - * Sample rate changes takes more than 2 seconds for this device. Clock - * validity request returns false during that period. - */ - if (chip->usb_id == USB_ID(0x07fd, 0x0004)) { - count = 0; + count = 0; - while ((!ret) && (count < 50)) { - int err; + while ((!ret) && (count < 50)) { + int err; - msleep(100); - - err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, - USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_CLOCK_VALID << 8, - snd_usb_ctrl_intf(chip) | (source_id << 8), - &data, sizeof(data)); - if (err < 0) { - dev_warn(&dev->dev, - "%s(): cannot get clock validity for id %d\n", - __func__, source_id); - return false; - } - - ret = !!data; - count++; + msleep(100); + + err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, + UAC2_CS_CONTROL_CLOCK_VALID << 8, + snd_usb_ctrl_intf(chip) | (source_id << 8), + &data, sizeof(data)); + if (err < 0) { + dev_warn(&dev->dev, + "%s(): cannot get clock validity for id %d\n", + __func__, source_id); + return false; } + + ret = !!data; + count++; } return ret;