On Tue, Apr 23, 2024 at 4:23 AM Alexandre Ratchov <a...@caoua.org> wrote:
> > > On Mon, Apr 22, 2024 at 01:14:43PM -0300, Thanos Tsouanas wrote:
> > > > [...]
> > > > uaudio0: class v1, full-speed, sync, channels: 0 play, 0 rec, 3 ctls
> > >
> > > 0 channels seems wrong.  So, you confirm that this device used to work?
> >
> > Yes: it has been my main audio interface for OpenBSD ever
> > since 2018 that I bought it; it has worked perfectly on all
> > releases up to now.
> >
> > Just to rule out the possibility of a coincidence of
> > hardware failure at the moment of my sysupgrade, I plugged
> > it on a mac mini and it works.  To be honest I am not 100%
> > sure I can rule out *some* hardware issue, because its
> > volume on the mac mini is about 60% of what it used to be
> > (until yesterday!) on OpenBSD (in both cases set to 100%,
> > rest of my audio setup identical).
> >
> > Until yesterday, it has always been plugged on my OpenBSD
> > computer and working perfectly (and loudly).
> >
> > I will install a 7.4 system on a usb stick just to verify
> > that the issue is indeed related with the 7.4->7.5 upgrade.
>
> Could you try the diff below? possibly set the UAUDIO_DEBUG
> option in your kernel config to better see what's going on.
>
> BTW, there's a single change in the uaudio driver between
> openbsd 7.4 and 7.5, so a quick workaround would be to
> revert it.
>
> In any case, could you run the program attached to this mail
> and send me its output?  It would allow me to test parts of
> the uaudio driver on your device.
>
> First, run 'usbdevs' to figure out the bus and address
> numbers of the device, then run 'uacdump <bus> <addr>' and
> send me its output.
>
> Thanks
>
> Index: uaudio.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/uaudio.c,v
> diff -u -p -u -p -r1.174 uaudio.c
> --- uaudio.c    10 Dec 2023 06:32:14 -0000      1.174
> +++ uaudio.c    23 Apr 2024 07:01:59 -0000
> @@ -2702,6 +2702,22 @@ uaudio_fixup_params(struct uaudio_softc
>         }
>  }
>
> +int
> +uaudio_iface_index(struct uaudio_softc *sc, int ifnum)
> +{
> +       int i, nifaces;
> +
> +       nifaces = sc->udev->cdesc->bNumInterfaces;
> +
> +       for (i = 0; i < nifaces; i++) {
> +               if (sc->udev->ifaces[i].idesc->bInterfaceNumber == ifnum)
> +                       return i;
> +       }
> +
> +       printf("%s: %d: invalid interface number\n", __func__, ifnum);
> +       return -1;
> +}
> +
>  /*
>   * Parse all descriptors and build configuration of the device.
>   */
> @@ -2711,6 +2727,7 @@ uaudio_process_conf(struct uaudio_softc
>         struct uaudio_blob dp;
>         struct uaudio_alt *a;
>         unsigned int type, ifnum, altnum, nep, class, subclass;
> +       int i;
>
>         while (p->rptr != p->wptr) {
>                 if (!uaudio_getdesc(p, &dp))
> @@ -2736,7 +2753,8 @@ uaudio_process_conf(struct uaudio_softc
>
>                 switch (subclass) {
>                 case UISUBCLASS_AUDIOCONTROL:
> -                       if (usbd_iface_claimed(sc->udev, ifnum)) {
> +                       i = uaudio_iface_index(sc, ifnum);
> +                       if (i != -1 && usbd_iface_claimed(sc->udev, i)) {
>                                 DPRINTF("%s: %d: AC already claimed\n", 
> __func__, ifnum);
>                                 break;
>                         }
> @@ -2748,7 +2766,8 @@ uaudio_process_conf(struct uaudio_softc
>                                 return 0;
>                         break;
>                 case UISUBCLASS_AUDIOSTREAM:
> -                       if (usbd_iface_claimed(sc->udev, ifnum)) {
> +                       i = uaudio_iface_index(sc, ifnum);
> +                       if (i != -1 && usbd_iface_claimed(sc->udev, i)) {
>                                 DPRINTF("%s: %d: AS already claimed\n", 
> __func__, ifnum);
>                                 break;
>                         }
> @@ -2768,10 +2787,19 @@ done:
>          * Claim all interfaces we use. This prevents other uaudio(4)
>          * devices from trying to use them.
>          */
> -       for (a = sc->alts; a != NULL; a = a->next)
> -               usbd_claim_iface(sc->udev, a->ifnum);
> +       for (a = sc->alts; a != NULL; a = a->next) {
> +               i = uaudio_iface_index(sc, a->ifnum);
> +               if (i != -1) {
> +                       DPRINTF("%s: claim: %d at %d\n", __func__, a->ifnum, 
> i);
> +                       usbd_claim_iface(sc->udev, i);
> +               }
> +       }
>
> -       usbd_claim_iface(sc->udev, sc->ctl_ifnum);
> +       i = uaudio_iface_index(sc, sc->ctl_ifnum);
> +       if (i != -1) {
> +               DPRINTF("%s: claim: ac %d at %d\n", __func__, sc->ctl_ifnum, 
> i);
> +               usbd_claim_iface(sc->udev, i);
> +       }
>
>         return 1;
>  }

So, the good news is that it seems to be a hardware problem:
I installed 7.4 on a usb stick just to test it and it did
work, but when I booted back to the same 7.5 that it didn't,
it was recognized properly this time, to my surprise:

uaudio0 at uhub3 port 3 configuration 1 interface 3 "JDS Labs Inc JDS
Labs DAC" rev 1.10/0.01 addr 7
uaudio0: class v1, full-speed, sync, channels: 2 play, 0 rec, 3 ctls
audio1 at uaudio0

...and worked perfectly well.

Plugging it in and out I notice that: *most* of the times it's
recognized as 0 play channels, sometimes as 2 play channels,
and sometimes not even seen by the kernel at all.

I guess it's safe to assume that it's a hardware problem?

After this, let me know if it still makes sense to run the
program you sent and share the output.  (I suppose the diff
you sent was to change uaudio back to 7.4's version?)

Thanks!

P.S. Sorry, I messed up the mail reply.

-- 
Thanos Tsouanas
http://www.tsouanas.org/

On Tue, Apr 23, 2024 at 4:23 AM Alexandre Ratchov <a...@caoua.org> wrote:
>
> On Mon, Apr 22, 2024 at 03:55:56PM -0300, Thanos Tsouanas wrote:
> > On Mon, Apr 22, 2024 at 1:31 PM Alexandre Ratchov <a...@caoua.org> wrote:
> > > On Mon, Apr 22, 2024 at 01:14:43PM -0300, Thanos Tsouanas wrote:
> > > > [...]
> > > > My audio interface is recognized by the 7.5 kernel:
> > > >
> > > > uaudio0 at uhub1 port 1 configuration 1 interface 3 "JDS Labs Inc JDS
> > > > Labs DAC" rev 1.10/0.01 addr 7
> > > > uaudio0: class v1, full-speed, sync, channels: 0 play, 0 rec, 3 ctls
> > >
> > > 0 channels seems wrong.  So, you confirm that this device used to work?
> >
> > Yes: it has been my main audio interface for OpenBSD ever
> > since 2018 that I bought it; it has worked perfectly on all
> > releases up to now.
> >
>
> Hi,
>
> Could you try the diff below? possibly set the UAUDIO_DEBUG option
> in your kernel config to better see what's going on.
>
> BTW, there's a single change in the uaudio driver between openbsd 7.4 and
> 7.5, so a quick workaround would be to revert it.
>
> In any case, could you run the program attached to this mail and send me its
> output?  It would allow me to test parts of the uaudio driver on your
> device.
>
> First, run 'usbdevs' to figure out the bus and address numbers of the
> device, then run 'uacdump <bus> <addr>' and send me its output.
>
> Thanks
>
> Index: uaudio.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/uaudio.c,v
> diff -u -p -u -p -r1.174 uaudio.c
> --- uaudio.c    10 Dec 2023 06:32:14 -0000      1.174
> +++ uaudio.c    23 Apr 2024 07:01:59 -0000
> @@ -2702,6 +2702,22 @@ uaudio_fixup_params(struct uaudio_softc
>         }
>  }
>
> +int
> +uaudio_iface_index(struct uaudio_softc *sc, int ifnum)
> +{
> +       int i, nifaces;
> +
> +       nifaces = sc->udev->cdesc->bNumInterfaces;
> +
> +       for (i = 0; i < nifaces; i++) {
> +               if (sc->udev->ifaces[i].idesc->bInterfaceNumber == ifnum)
> +                       return i;
> +       }
> +
> +       printf("%s: %d: invalid interface number\n", __func__, ifnum);
> +       return -1;
> +}
> +
>  /*
>   * Parse all descriptors and build configuration of the device.
>   */
> @@ -2711,6 +2727,7 @@ uaudio_process_conf(struct uaudio_softc
>         struct uaudio_blob dp;
>         struct uaudio_alt *a;
>         unsigned int type, ifnum, altnum, nep, class, subclass;
> +       int i;
>
>         while (p->rptr != p->wptr) {
>                 if (!uaudio_getdesc(p, &dp))
> @@ -2736,7 +2753,8 @@ uaudio_process_conf(struct uaudio_softc
>
>                 switch (subclass) {
>                 case UISUBCLASS_AUDIOCONTROL:
> -                       if (usbd_iface_claimed(sc->udev, ifnum)) {
> +                       i = uaudio_iface_index(sc, ifnum);
> +                       if (i != -1 && usbd_iface_claimed(sc->udev, i)) {
>                                 DPRINTF("%s: %d: AC already claimed\n", 
> __func__, ifnum);
>                                 break;
>                         }
> @@ -2748,7 +2766,8 @@ uaudio_process_conf(struct uaudio_softc
>                                 return 0;
>                         break;
>                 case UISUBCLASS_AUDIOSTREAM:
> -                       if (usbd_iface_claimed(sc->udev, ifnum)) {
> +                       i = uaudio_iface_index(sc, ifnum);
> +                       if (i != -1 && usbd_iface_claimed(sc->udev, i)) {
>                                 DPRINTF("%s: %d: AS already claimed\n", 
> __func__, ifnum);
>                                 break;
>                         }
> @@ -2768,10 +2787,19 @@ done:
>          * Claim all interfaces we use. This prevents other uaudio(4)
>          * devices from trying to use them.
>          */
> -       for (a = sc->alts; a != NULL; a = a->next)
> -               usbd_claim_iface(sc->udev, a->ifnum);
> +       for (a = sc->alts; a != NULL; a = a->next) {
> +               i = uaudio_iface_index(sc, a->ifnum);
> +               if (i != -1) {
> +                       DPRINTF("%s: claim: %d at %d\n", __func__, a->ifnum, 
> i);
> +                       usbd_claim_iface(sc->udev, i);
> +               }
> +       }
>
> -       usbd_claim_iface(sc->udev, sc->ctl_ifnum);
> +       i = uaudio_iface_index(sc, sc->ctl_ifnum);
> +       if (i != -1) {
> +               DPRINTF("%s: claim: ac %d at %d\n", __func__, sc->ctl_ifnum, 
> i);
> +               usbd_claim_iface(sc->udev, i);
> +       }
>
>         return 1;
>  }



-- 
Thanos Tsouanas
http://www.tsouanas.org/

Reply via email to