public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: vincenttew <vincenttew@google.com>
To: perex@perex.cz, tiwai@suse.com, vincenttew@google.com,
	 linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org
Cc: alexander@tsoy.me
Subject: [PATCH] ALSA: usb-audio: retry clock validate when it takes some times
Date: Thu,  1 Feb 2024 15:06:09 +0800	[thread overview]
Message-ID: <20240201070641.401684-1-vincenttew@google.com> (raw)

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 <vincenttew@google.com>
---
 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;
-- 
2.43.0.429.g432eaa2c6b-goog


             reply	other threads:[~2024-02-01  7:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01  7:06 vincenttew [this message]
2024-02-01 10:36 ` [PATCH] ALSA: usb-audio: retry clock validate when it takes some times Alexander Tsoy
2024-02-01 13:02   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240201070641.401684-1-vincenttew@google.com \
    --to=vincenttew@google.com \
    --cc=alexander@tsoy.me \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox