Add a new quirk flag to not attach video devices which aren't supported by
authormglocker <mglocker@openbsd.org>
Mon, 5 Apr 2021 20:45:49 +0000 (20:45 +0000)
committermglocker <mglocker@openbsd.org>
Mon, 5 Apr 2021 20:45:49 +0000 (20:45 +0000)
uvideo(4) currently, like the Chicony Integrated IR Camera.  This is
especially helpful when you have two video devices of which the unsupported
one is attached first as reported by martijn@.

OK gnezdo@

sys/dev/usb/usbdevs
sys/dev/usb/uvideo.c

index 755a8be..8dc163d 100644 (file)
@@ -1,4 +1,4 @@
-$OpenBSD: usbdevs,v 1.737 2021/04/05 16:17:25 landry Exp $
+$OpenBSD: usbdevs,v 1.738 2021/04/05 20:45:49 mglocker Exp $
 /* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
 
 /*
@@ -1338,6 +1338,7 @@ product CHICONY RTL8188CUS_3      0xaff9  RTL8188CUS
 product CHICONY RTL8188CUS_4   0xaffa  RTL8188CUS
 product CHICONY RTL8188CUS_5   0xaffb  RTL8188CUS
 product CHICONY RTL8188CUS_6   0xaffc  RTL8188CUS
+product CHICONY IRCAMERA       0xb615  Integrated IR Camera
 
 /* CH Products */
 product CHPRODUCTS PROTHROTTLE 0x00f1  Pro Throttle
index d18827d..79297d8 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvideo.c,v 1.211 2021/01/27 17:28:19 mglocker Exp $ */
+/*     $OpenBSD: uvideo.c,v 1.212 2021/04/05 20:45:49 mglocker Exp $ */
 
 /*
  * Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -307,6 +307,7 @@ struct video_hw_if uvideo_hw_if = {
 #define UVIDEO_FLAG_ISIGHT_STREAM_HEADER       0x1
 #define UVIDEO_FLAG_REATTACH                   0x2
 #define UVIDEO_FLAG_VENDOR_CLASS               0x4
+#define UVIDEO_FLAG_NOATTACH                   0x8
 struct uvideo_devs {
        struct usb_devno         uv_dev;
        char                    *ucode_name;
@@ -382,6 +383,12 @@ struct uvideo_devs {
            NULL,
            UVIDEO_FLAG_VENDOR_CLASS
        },
+       {   /* Infrared camera not supported */
+           { USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_IRCAMERA },
+           NULL,
+           NULL,
+           UVIDEO_FLAG_NOATTACH
+       },
 };
 #define uvideo_lookup(v, p) \
        ((struct uvideo_devs *)usb_lookup(uvideo_devs, v, p))
@@ -480,13 +487,12 @@ uvideo_match(struct device *parent, void *match, void *aux)
        if (id == NULL)
                return (UMATCH_NONE);
 
-       if (id->bInterfaceClass == UICLASS_VIDEO &&
-           id->bInterfaceSubClass == UISUBCLASS_VIDEOCONTROL)
-               return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
-
-       /* quirk devices which we want to attach */
+       /* quirk devices */
        quirk = uvideo_lookup(uaa->vendor, uaa->product);
        if (quirk != NULL) {
+               if (quirk->flags & UVIDEO_FLAG_NOATTACH)
+                       return (UMATCH_NONE);
+
                if (quirk->flags & UVIDEO_FLAG_REATTACH)
                        return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
 
@@ -496,6 +502,10 @@ uvideo_match(struct device *parent, void *match, void *aux)
                        return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
        }
 
+       if (id->bInterfaceClass == UICLASS_VIDEO &&
+           id->bInterfaceSubClass == UISUBCLASS_VIDEOCONTROL)
+               return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
+
        return (UMATCH_NONE);
 }