Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2538259pxj; Mon, 10 May 2021 05:27:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3yvt8t6Y8nyLR2ObWPIfx96XkYxlWTRBkOb6LPoQ0cJ5etDMNsBmMde4xmb4UWbxiu4ZJ X-Received: by 2002:a02:a68e:: with SMTP id j14mr21189716jam.122.1620649675301; Mon, 10 May 2021 05:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620649675; cv=none; d=google.com; s=arc-20160816; b=cr2JYnHiwrus64Kzub4t4IZbWVqTGOirVEZ4VIYFGkjVrL3zzONthBKNg1+esfSi26 G6iRzIHZ3ZWRKmWMCFxb3xUFC4ArmK3N9CxOF3bLN6Skz0cRTmf5T7XmhRls9u5dvYUP lCxp5fVwAUzWWXiJs/1FKEFP45a02mhJ/+kOmiA3szC2NtlVf8P4LfV16uotwpBoDBYV fwyEADaRG1FtI7dBu6wlHSLHmzQ6fBnUUKr+X4mV9IjQroSJhegVsmlTrqbTn0pv4Jb5 rflK5IJW+K2g0+S9WMQfvAOOlR45t2yUgiK6RBQzjMK8oN+QDNpKdNcpkTgDRvYJbH+I ZziA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qEkwUaJJ8cnty2/iF4XD8dOkAKBi5IMbX2GzVUmXXHU=; b=tYvlqyI+Qn7tGi4E6DT4zzkcXNRcBe14tto+IqEtfJfm9EHKA3PMvwycxo5RXDXKA+ o7BFLG8gNn9FDsqEbupX7bWgR5UlfhYyfsm2PoFkT89SVrbesozBC3SzHFh1fFWaNUtQ wP8w1bvtSqvmVMOUew6F9jj4r+ocR68tjo92imk9RsLRXHxLnfp+jkdtVrIJ/4uugQxb wWukLijClGtisqQRaaftM2Lh2eFqFs7sD8W8/d8u6Nqn73FIPI7oWTV/udYTX+qqg+3h cFh3TiPhRZrF71tQ2Zy+zA8XZBIL5Gu7IwxBBt/Si0IYZ+44CLFGyQ91vq+lJpVtQdyU J+og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T03+NiLb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si1398798ilu.88.2021.05.10.05.27.43; Mon, 10 May 2021 05:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T03+NiLb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234859AbhEJM2G (ORCPT + 99 others); Mon, 10 May 2021 08:28:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:46932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237247AbhEJLLq (ORCPT ); Mon, 10 May 2021 07:11:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C0F461879; Mon, 10 May 2021 11:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644908; bh=2UG/nlHqSK72KX7mMr/KbK8F7icZvugEvKN7RYAV2l8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T03+NiLb0pQGVbZNnXOhWgRdkCSU11Qc3bK+5q6Eon3BCNBcznGvt6nzNtYtLRG+4 Gx8exLHJMzFu9wjBB7WfB+kBP1X2OCehRcjnedSv4iRmPI2qf1qQbCq9r6C5hTm+fr Db+//OxHVtfiZFnJobEGRvVhi9zJyKlNMBVCC2/U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geraldo Nascimento , Takashi Iwai Subject: [PATCH 5.12 274/384] ALSA: usb-audio: Explicitly set up the clock selector Date: Mon, 10 May 2021 12:21:03 +0200 Message-Id: <20210510102023.869143211@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit d2e8f641257d0d3af6e45d6ac2d6f9d56b8ea964 upstream. In the current code, we have some assumption that the audio clock selector has been set up implicitly and don't want to touch it unless it's really needed for the fallback autoclock setup. This works for most devices but some seem having a problem. Partially this was covered for the devices with a single connector at the initialization phase (commit 086b957cc17f "ALSA: usb-audio: Skip the clock selector inquiry for single connections"), but also there are cases where the wrong clock set up is kept silently. The latter seems to be the cause of the noises on Behringer devices. In this patch, we explicitly set up the audio clock selector whenever the appropriate node is found. Reported-by: Geraldo Nascimento BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199327 Link: https://lore.kernel.org/r/CAEsQvcvF7LnO8PxyyCxuRCx=7jNeSCvFAd-+dE0g_rd1rOxxdw@mail.gmail.com Cc: Link: https://lore.kernel.org/r/20210413084152.32325-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/clock.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -296,7 +296,7 @@ static int __uac_clock_find_source(struc selector = snd_usb_find_clock_selector(chip->ctrl_intf, entity_id); if (selector) { - int ret, i, cur; + int ret, i, cur, err; if (selector->bNrInPins == 1) { ret = 1; @@ -324,13 +324,17 @@ static int __uac_clock_find_source(struc ret = __uac_clock_find_source(chip, fmt, selector->baCSourceID[ret - 1], visited, validate); + if (ret > 0) { + err = uac_clock_selector_set_val(chip, entity_id, cur); + if (err < 0) + return err; + } + if (!validate || ret > 0 || !chip->autoclock) return ret; /* The current clock source is invalid, try others. */ for (i = 1; i <= selector->bNrInPins; i++) { - int err; - if (i == cur) continue; @@ -396,7 +400,7 @@ static int __uac3_clock_find_source(stru selector = snd_usb_find_clock_selector_v3(chip->ctrl_intf, entity_id); if (selector) { - int ret, i, cur; + int ret, i, cur, err; /* the entity ID we are looking for is a selector. * find out what it currently selects */ @@ -418,6 +422,12 @@ static int __uac3_clock_find_source(stru ret = __uac3_clock_find_source(chip, fmt, selector->baCSourceID[ret - 1], visited, validate); + if (ret > 0) { + err = uac_clock_selector_set_val(chip, entity_id, cur); + if (err < 0) + return err; + } + if (!validate || ret > 0 || !chip->autoclock) return ret;