Skip to content

Commit d2e8f64

Browse files
committed
ALSA: usb-audio: Explicitly set up the clock selector
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 086b957 "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 <[email protected]> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199327 Link: https://lore.kernel.org/r/CAEsQvcvF7LnO8PxyyCxuRCx=7jNeSCvFAd-+dE0g_rd1rOxxdw@mail.gmail.com Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d91cbe8 commit d2e8f64

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

sound/usb/clock.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
296296

297297
selector = snd_usb_find_clock_selector(chip->ctrl_intf, entity_id);
298298
if (selector) {
299-
int ret, i, cur;
299+
int ret, i, cur, err;
300300

301301
if (selector->bNrInPins == 1) {
302302
ret = 1;
@@ -324,13 +324,17 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
324324
ret = __uac_clock_find_source(chip, fmt,
325325
selector->baCSourceID[ret - 1],
326326
visited, validate);
327+
if (ret > 0) {
328+
err = uac_clock_selector_set_val(chip, entity_id, cur);
329+
if (err < 0)
330+
return err;
331+
}
332+
327333
if (!validate || ret > 0 || !chip->autoclock)
328334
return ret;
329335

330336
/* The current clock source is invalid, try others. */
331337
for (i = 1; i <= selector->bNrInPins; i++) {
332-
int err;
333-
334338
if (i == cur)
335339
continue;
336340

@@ -396,7 +400,7 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip,
396400

397401
selector = snd_usb_find_clock_selector_v3(chip->ctrl_intf, entity_id);
398402
if (selector) {
399-
int ret, i, cur;
403+
int ret, i, cur, err;
400404

401405
/* the entity ID we are looking for is a selector.
402406
* find out what it currently selects */
@@ -418,6 +422,12 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip,
418422
ret = __uac3_clock_find_source(chip, fmt,
419423
selector->baCSourceID[ret - 1],
420424
visited, validate);
425+
if (ret > 0) {
426+
err = uac_clock_selector_set_val(chip, entity_id, cur);
427+
if (err < 0)
428+
return err;
429+
}
430+
421431
if (!validate || ret > 0 || !chip->autoclock)
422432
return ret;
423433

0 commit comments

Comments
 (0)