alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Geraldo Nascimento <geraldogabriel@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] ALSA: usb-audio: Explicitly set up the clock selector
Date: Wed, 14 Apr 2021 15:19:01 -0300	[thread overview]
Message-ID: <CAEsQvcufoQCBDpb3cscAor6GbFhsLXdP6vne-A5bc-SZPqt_9g@mail.gmail.com> (raw)
In-Reply-To: <20210413084152.32325-1-tiwai@suse.de>

Thanks, Dr. Iwai!

I haven't tested the finalized patch yet, but I'll give it a shot on top of
5.12-rc7. Should be OK, nevertheless thorough testing is always a good idea.

Regards,
Geraldo

Em Ter, 13 de abr de 2021 05:41, Takashi Iwai <tiwai@suse.de> escreveu:

> 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 <geraldogabriel@gmail.com>
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199327
> Link:
> https://lore.kernel.org/r/CAEsQvcvF7LnO8PxyyCxuRCx=7jNeSCvFAd-+dE0g_rd1rOxxdw@mail.gmail.com
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  sound/usb/clock.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/sound/usb/clock.c b/sound/usb/clock.c
> index a746802d0ac3..17bbde73d4d1 100644
> --- a/sound/usb/clock.c
> +++ b/sound/usb/clock.c
> @@ -296,7 +296,7 @@ static int __uac_clock_find_source(struct
> snd_usb_audio *chip,
>
>         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(struct
> snd_usb_audio *chip,
>                 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(struct
> snd_usb_audio *chip,
>
>         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(struct
> snd_usb_audio *chip,
>                 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;
>
> --
> 2.26.2
>
>

      reply	other threads:[~2021-04-14 18:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  8:41 [PATCH] ALSA: usb-audio: Explicitly set up the clock selector Takashi Iwai
2021-04-14 18:19 ` Geraldo Nascimento [this message]

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=CAEsQvcufoQCBDpb3cscAor6GbFhsLXdP6vne-A5bc-SZPqt_9g@mail.gmail.com \
    --to=geraldogabriel@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).