]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/usb-libusb.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / backend / usb-libusb.c
index 07796ce0b3c57626b462a01a3ac6416763c52d93..7ec9a6d6e0a2cc21a376a0215ccccd486660847b 100644 (file)
@@ -1,15 +1,9 @@
 /*
- * "$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
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
@@ -18,6 +12,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 +98,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 +637,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);
 
  /*
@@ -1211,6 +1210,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 +1453,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 +1524,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 +2013,3 @@ soft_reset_printer(
 
   return (errcode);
 }
-
-
-/*
- * End of "$Id$".
- */
-