On Sat, May 30, 2020 at 07:47:17PM +0200, Jan Stary wrote:
> On May 30 18:50:12, h...@stare.cz wrote:
> > This is current/amd64 on a MacBook2,1 (dmesg below)
> > With the latest upgrade, it has lost video0:
> > 
> > uvideo0 at uhub0 port 4 configuration 1 interface 0 "Micron Built-in 
> > iSight" rev 2.00/1.84 addr 2
> > uvideo0: can't find interface assoc descriptor
> 
> Similar thing happens with current/i386 on a MacBook1,1 (dmesg below):
> uvideo0: can't find video interface
> 
>       Jan

Yeah, this is due to the change to support multiple cameras in one
device.  You can try this diff, let me know if this works on both
of your machines.

Patrick

diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index d33e3079acd..da00d0d3d0d 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -510,6 +510,8 @@ uvideo_attach(struct device *parent, struct device *self, 
void *aux)
        int i;
 
        sc->sc_udev = uaa->device;
+       sc->sc_iface = uaa->ifaceno;
+       sc->sc_nifaces = uaa->nifaces;
 
        /* Find the first unclaimed video interface. */
        for (i = 0; i < uaa->nifaces; i++) {
@@ -521,10 +523,8 @@ uvideo_attach(struct device *parent, struct device *self, 
void *aux)
                if (id->bInterfaceClass == UICLASS_VIDEO)
                        break;
        }
-       if (i == uaa->nifaces) {
-               printf("%s: can't find video interface\n", DEVNAME(sc));
-               return;
-       }
+       if (i == uaa->nifaces)
+               goto attach;
 
        /* Find out which interface association we belong to. */
        usbd_desc_iter_init(sc->sc_udev, &iter);
@@ -540,30 +540,38 @@ uvideo_attach(struct device *parent, struct device *self, 
void *aux)
                        break;
                desc = usbd_desc_iter_next(&iter);
        }
-       if (desc == NULL) {
-               printf("%s: can't find interface assoc descriptor\n",
-                   DEVNAME(sc));
-               return;
-       }
+       if (desc != NULL) {
+               /*
+                * Claim all interfaces of our association.  Interfaces must be
+                * claimed during attach, during attach hooks is too late.
+                */
+               for (i = iad->bFirstInterface;
+                   i < iad->bFirstInterface + iad->bInterfaceCount; i++) {
+                       if (usbd_iface_claimed(sc->sc_udev, i)) {
+                               printf("%s: interface already claimed\n",
+                                   DEVNAME(sc));
+                               return;
+                       }
+                       usbd_claim_iface(sc->sc_udev, i);
+               }
 
-       /*
-        * Claim all interfaces of our association.  Interfaces must be
-        * claimed during attach, during attach hooks is too late.
-        */
-       for (i = iad->bFirstInterface;
-           i < iad->bFirstInterface + iad->bInterfaceCount; i++) {
-               if (usbd_iface_claimed(sc->sc_udev, i)) {
-                       printf("%s: interface already claimed\n",
-                           DEVNAME(sc));
-                       return;
+               /* Remember our association by saving the first interface. */
+               sc->sc_iface = iad->bFirstInterface;
+               sc->sc_nifaces = iad->bInterfaceCount;
+       } else {
+               /* No association, so simply claim them all. */
+               for (i = 0; i < uaa->nifaces; i++) {
+                       if (usbd_iface_claimed(sc->sc_udev, i))
+                               continue;
+                       id = 
usbd_get_interface_descriptor(&sc->sc_udev->ifaces[i]);
+                       if (id == NULL)
+                               continue;
+                       if (id->bInterfaceClass == UICLASS_VIDEO)
+                               usbd_claim_iface(sc->sc_udev, i);
                }
-               usbd_claim_iface(sc->sc_udev, i);
        }
 
-       /* Remember our association by saving the first interface. */
-       sc->sc_iface = iad->bFirstInterface;
-       sc->sc_nifaces = iad->bInterfaceCount;
-
+attach:
        /* maybe the device has quirks */
        sc->sc_quirk = uvideo_lookup(uaa->vendor, uaa->product);
 

Reply via email to