[Libdlo] [PATCH] udlfb: Search config for vendor descriptor

Andrew Kephart akephart at akephart.org
Mon Dec 13 14:03:09 PST 2010


Search DL config descriptor for vendor descriptor if not found
externally

For at least one DisplayLink device, the vendor-specific information can
be found in the config descriptor instead of as a separate, device-level
descriptor.  This patch searches the current interface (of the current
config descriptor) for the DL vendor-specific descriptor.

Signed-off-by: Andrew Kephart <akephart at akephart.org>

diff --git a/udlfb.c b/udlfb.c
index 59a1925..a5fc908 100644
--- a/udlfb.c
+++ b/udlfb.c
@@ -1510,23 +1510,32 @@ static int dlfb_select_std_channel(struct
dlfb_data *dev)
 }

 static int dlfb_parse_vendor_descriptor(struct dlfb_data *dev,
-                                       struct usb_device *usbdev)
+                                       struct usb_interface *interface)
 {
        char *desc;
        char *buf;
        char *desc_end;

-       u8 total_len = 0;
+       int total_len = 0;

        buf = kzalloc(MAX_VENDOR_DESCRIPTOR_SIZE, GFP_KERNEL);
        if (!buf)
                return false;
        desc = buf;

-       total_len = usb_get_descriptor(usbdev, 0x5f, /* vendor specific
*/
+       total_len = usb_get_descriptor(interface_to_usbdev(interface), 
+                    0x5f, /* vendor specific */
                                    0, desc,
MAX_VENDOR_DESCRIPTOR_SIZE);
+
+    /* If not found separately, look in config descriptor */
+    if (total_len < 0) {
+        if (0 == usb_get_extra_descriptor(interface->cur_altsetting, 
+                                          0x5f, &desc))
+            total_len = (int)desc[0];
+    }
+
        if (total_len > 5) {
-               dl_info("vendor descriptor length:%x data:%02x %02x %02x
%02x" \
+               dl_info("vendor descriptor length:%x data:%02x %02x %02x
%02x " \
                        "%02x %02x %02x %02x %02x %02x %02x\n",
                        total_len, desc[0],
                        desc[1], desc[2], desc[3], desc[4], desc[5],
desc[6],
@@ -1565,6 +1574,8 @@ static int dlfb_parse_vendor_descriptor(struct
dlfb_data *dev,
                        }
                        desc += length;
                }
+       } else {
+        dl_info("vendor descriptor not available (%d).\n",total_len);
        }

        goto success;
@@ -1614,7 +1625,7 @@ static int dlfb_usb_probe(struct usb_interface
*interface,

        dev->sku_pixel_limit = 2048 * 1152; /* default to maximum */

-       if (!dlfb_parse_vendor_descriptor(dev, usbdev)) {
+       if (!dlfb_parse_vendor_descriptor(dev, interface)) {
                dl_err("firmware not recognized. Assume incompatible
device\n");
                goto error;
        }




More information about the Libdlo mailing list