]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/usb-libusb.c
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / backend / usb-libusb.c
index 2a0884ce22412f75889c1cbe8dbe7e31d4e5305a..c48c6ecb584ebf9e55b68e45937fd1434d89b983 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * "$Id$"
- *
  * LIBUSB interface code for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
@@ -18,6 +16,7 @@
 
 #include <libusb.h>
 #include <cups/cups-private.h>
+#include <cups/ppd-private.h>
 #include <cups/dir.h>
 #include <pthread.h>
 #include <sys/select.h>
@@ -103,6 +102,7 @@ typedef struct usb_globals_s                /* Global USB printer information */
 #define USB_QUIRK_USB_INIT     0x0010  /* Needs vendor USB init string */
 #define USB_QUIRK_VENDOR_CLASS 0x0020  /* Descriptor uses vendor-specific
                                           Class or SubClass */
+#define USB_QUIRK_DELAY_CLOSE  0x0040  /* Delay close */
 #define USB_QUIRK_WHITELIST    0x0000  /* no quirks */
 
 
@@ -641,6 +641,9 @@ print_device(const char *uri,               /* I - Device URI */
   * Close the connection and input file and general clean up...
   */
 
+  if (g.printer->quirks & USB_QUIRK_DELAY_CLOSE)
+    sleep(1);
+
   close_device(g.printer);
 
  /*
@@ -915,7 +918,7 @@ find_device(usb_cb_t   cb,          /* I - Callback function */
                  write_endp = endp;
              }
 
-            if (write_endp >= 0)
+            if (write_endp != 0xff)
            {
             /*
              * Save the best match so far...
@@ -1211,6 +1214,9 @@ load_quirks(void)
       if (strstr(line, " blacklist"))
         quirk->quirks |= USB_QUIRK_BLACKLIST;
 
+      if (strstr(line, " delay-close"))
+        quirk->quirks |= USB_QUIRK_DELAY_CLOSE;
+
       if (strstr(line, " no-reattach"))
         quirk->quirks |= USB_QUIRK_NO_REATTACH;
 
@@ -1451,9 +1457,14 @@ open_device(usb_printer_t *printer,      /* I - Printer */
   else
   {
     printer->usblp_attached = 0;
-    fprintf(stderr, "DEBUG: Failed to check whether %04x:%04x has the \"usblp\" kernel module attached\n",
-             devdesc.idVendor, devdesc.idProduct);
-    goto error;
+
+    if (errcode != LIBUSB_ERROR_NOT_SUPPORTED)
+    {
+      fprintf(stderr,
+              "DEBUG: Failed to check whether %04x:%04x has the \"usblp\" "
+              "kernel module attached\n", devdesc.idVendor, devdesc.idProduct);
+      goto error;
+    }
   }
 
  /*
@@ -1517,6 +1528,16 @@ open_device(usb_printer_t *printer,      /* I - Printer */
 
       goto error;
     }
+    else if ((errcode = libusb_detach_kernel_driver(printer->handle, printer->iface)) < 0)
+    {
+      fprintf(stderr,
+              "DEBUG: Failed to detach \"usblp\" module from %04x:%04x\n",
+              devdesc.idVendor, devdesc.idProduct);
+
+      goto error;
+    }
+
+    sleep (1);
   }
 
  /*
@@ -1996,9 +2017,3 @@ soft_reset_printer(
 
   return (errcode);
 }
-
-
-/*
- * End of "$Id$".
- */
-