diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-15 11:29:05 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-15 11:29:05 +0200 |
commit | 324a8a71bb7d9e4f8bc49b6bc47efaf9fb58282e (patch) | |
tree | bd2d48a139bfbe869f4f49359b63097931a45e7b /sanei/sanei_usb.c | |
parent | 2ca8a81bd0d99fe4d75c229d0e988d8ef710285f (diff) | |
parent | 1edb02101a9306fc711cd422ed507d18165b1691 (diff) |
Merge branch 'release/experimental/1.0.27-1_experimental1'experimental/1.0.27-1_experimental1
Diffstat (limited to 'sanei/sanei_usb.c')
-rw-r--r-- | sanei/sanei_usb.c | 262 |
1 files changed, 147 insertions, 115 deletions
diff --git a/sanei/sanei_usb.c b/sanei/sanei_usb.c index f210d4f..e4b23dc 100644 --- a/sanei/sanei_usb.c +++ b/sanei/sanei_usb.c @@ -62,31 +62,22 @@ #include <dirent.h> #include <time.h> -/* for debug messages */ -#if __STDC_VERSION__ < 199901L -# if __GNUC__ >= 2 -# define __func__ __FUNCTION__ -# else -# define __func__ "<unknown>" -# endif -#endif - #ifdef HAVE_RESMGR #include <resmgr.h> #endif -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY #ifdef HAVE_LUSB0_USB_H #include <lusb0_usb.h> #else #include <usb.h> #endif -#endif /* HAVE_LIBUSB */ +#endif /* HAVE_LIBUSB_LEGACY */ -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB #include <libusb.h> -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ #ifdef HAVE_USBCALLS #include <usb.h> @@ -156,14 +147,14 @@ typedef struct SANE_Int interface_nr; SANE_Int alt_setting; SANE_Int missing; -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY usb_dev_handle *libusb_handle; struct usb_device *libusb_device; -#endif /* HAVE_LIBUSB */ -#ifdef HAVE_LIBUSB_1_0 +#endif /* HAVE_LIBUSB_LEGACY */ +#ifdef HAVE_LIBUSB libusb_device *lu_device; libusb_device_handle *lu_handle; -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ } device_list_type; @@ -183,13 +174,13 @@ static int device_number=0; * count number of time sanei_usb has been initialized */ static int initialized=0; -#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) +#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB) static int libusb_timeout = 30 * 1000; /* 30 seconds */ -#endif /* HAVE_LIBUSB */ +#endif /* HAVE_LIBUSB_LEGACY */ -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB static libusb_context *sanei_usb_ctx; -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ #if defined (__linux__) /* From /usr/src/linux/driver/usb/scanner.h */ @@ -266,7 +257,7 @@ print_buffer (const SANE_Byte * buffer, SANE_Int size) } } -#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) +#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) static void kernel_get_vendor_product (int fd, const char *name, int *vendorID, int *productID) { @@ -340,7 +331,7 @@ kernel_get_vendor_product (int fd, const char *name, int *vendorID, int *product #endif /* defined (__linux__), defined(__BEOS__), ... */ /* put more os-dependant stuff ... */ } -#endif /* !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) */ +#endif /* !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) */ /** * store the given device in device list if it isn't already @@ -366,10 +357,10 @@ store_device (device_list_type device) * Need to update the LibUSB device pointer, since it might * have changed after the latest USB scan. */ -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY devices[i].libusb_device = device.libusb_device; #endif -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB devices[i].lu_device = device.lu_device; #endif @@ -408,7 +399,7 @@ store_device (device_list_type device) devices[pos].open = SANE_FALSE; } -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB static char * sanei_libusb_strerror (int errcode) { @@ -462,14 +453,14 @@ sanei_libusb_strerror (int errcode) return "Unknown libusb-1.0 error code"; } } -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ void sanei_usb_init (void) { -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB int ret; -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ DBG_INIT (); #ifdef DBG_LEVEL @@ -483,18 +474,18 @@ sanei_usb_init (void) memset (devices, 0, sizeof (devices)); /* initialize USB with old libusb library */ -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY DBG (4, "%s: Looking for libusb devices\n", __func__); usb_init (); #ifdef DBG_LEVEL if (DBG_LEVEL > 4) usb_set_debug (255); #endif /* DBG_LEVEL */ -#endif /* HAVE_LIBUSB */ +#endif /* HAVE_LIBUSB_LEGACY */ /* initialize USB using libusb-1.0 */ -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB if (!sanei_usb_ctx) { DBG (4, "%s: initializing libusb-1.0\n", __func__); @@ -511,9 +502,9 @@ sanei_usb_init (void) libusb_set_debug (sanei_usb_ctx, 3); #endif /* DBG_LEVEL */ } -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ -#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) +#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) DBG (4, "%s: SANE is built without support for libusb\n", __func__); #endif @@ -553,7 +544,7 @@ int i; devices[i].devname=NULL; } } -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB if (sanei_usb_ctx) { libusb_exit (sanei_usb_ctx); @@ -643,7 +634,7 @@ static void usbcall_scan_devices(void) } #endif /* HAVE_USBCALLS */ -#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) +#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) /** scan for devices using kernel device. * Check for devices using kernel device */ @@ -742,9 +733,9 @@ static void kernel_scan_devices(void) closedir (dir); } } -#endif /* !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) */ +#endif /* !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) */ -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY /** scan for devices using old libusb * Check for devices using 0.1.x libusb */ @@ -855,9 +846,9 @@ static void libusb_scan_devices(void) } } } -#endif /* HAVE_LIBUSB */ +#endif /* HAVE_LIBUSB_LEGACY */ -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB /** scan for devices using libusb * Check for devices using libusb-1.0 */ @@ -1031,7 +1022,7 @@ static void libusb_scan_devices(void) libusb_free_device_list (devlist, 1); } -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ void @@ -1057,11 +1048,11 @@ sanei_usb_scan_devices (void) } /* Check for devices using the kernel scanner driver */ -#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) +#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) kernel_scan_devices(); #endif -#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) +#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB) /* Check for devices using libusb (old or new)*/ libusb_scan_devices(); #endif @@ -1308,7 +1299,6 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn) { int devcount; SANE_Bool found = SANE_FALSE; - int c, i, a; DBG (5, "sanei_usb_open: trying to open device `%s'\n", devname); if (!dn) @@ -1341,10 +1331,11 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn) if (devices[devcount].method == sanei_usb_method_libusb) { -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY struct usb_device *dev; struct usb_interface_descriptor *interface; int result, num; + int c, i, a; devices[devcount].libusb_handle = usb_open (devices[devcount].libusb_device); @@ -1600,13 +1591,14 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn) } } -#elif defined(HAVE_LIBUSB_1_0) /* libusb-1.0 */ +#elif defined(HAVE_LIBUSB) /* libusb-1.0 */ int config; libusb_device *dev; struct libusb_device_descriptor desc; struct libusb_config_descriptor *config0; int result, num; + int c, i, a; dev = devices[devcount].lu_device; @@ -1902,11 +1894,11 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn) libusb_free_config_descriptor (config); } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ DBG (1, "sanei_usb_open: can't open device `%s': " "libusb support missing\n", devname); return SANE_STATUS_UNSUPPORTED; -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ } else if (devices[devcount].method == sanei_usb_method_scanner_driver) { @@ -2108,6 +2100,17 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn) void sanei_usb_close (SANE_Int dn) { + char *env; + int workaround = 0; + + DBG (5, "sanei_usb_close: evaluating environment variable SANE_USB_WORKAROUND\n"); + env = getenv ("SANE_USB_WORKAROUND"); + if (env) + { + workaround = atoi(env); + DBG (5, "sanei_usb_close: workaround: %d\n", workaround); + } + DBG (5, "sanei_usb_close: closing device %d\n", dn); if (dn >= device_number || dn < 0) { @@ -2133,31 +2136,37 @@ sanei_usb_close (SANE_Int dn) #endif } else -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { /* This call seems to be required by Linux xhci driver * even though it should be a no-op. Without it, the * host or driver does not reset it's data toggle bit. * We intentionally ignore the return val */ - sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + if (workaround) + { + sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + } usb_release_interface (devices[dn].libusb_handle, devices[dn].interface_nr); usb_close (devices[dn].libusb_handle); } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { /* This call seems to be required by Linux xhci driver * even though it should be a no-op. Without it, the * host or driver does not reset it's data toggle bit. * We intentionally ignore the return val */ - sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + if (workaround) + { + sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + } libusb_release_interface (devices[dn].lu_handle, devices[dn].interface_nr); libusb_close (devices[dn].lu_handle); } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ DBG (1, "sanei_usb_close: libusb support missing\n"); #endif devices[dn].open = SANE_FALSE; @@ -2165,19 +2174,28 @@ sanei_usb_close (SANE_Int dn) } void -sanei_usb_set_timeout (SANE_Int timeout) +sanei_usb_set_timeout (SANE_Int __sane_unused__ timeout) { -#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) +#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB) libusb_timeout = timeout; #else DBG (1, "sanei_usb_set_timeout: libusb support missing\n"); -#endif /* HAVE_LIBUSB || HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB_LEGACY || HAVE_LIBUSB */ } SANE_Status sanei_usb_clear_halt (SANE_Int dn) { - int ret; + char *env; + int workaround = 0; + + DBG (5, "sanei_usb_clear_halt: evaluating environment variable SANE_USB_WORKAROUND\n"); + env = getenv ("SANE_USB_WORKAROUND"); + if (env) + { + workaround = atoi(env); + DBG (5, "sanei_usb_clear_halt: workaround: %d\n", workaround); + } if (dn >= device_number || dn < 0) { @@ -2185,13 +2203,17 @@ sanei_usb_clear_halt (SANE_Int dn) return SANE_STATUS_INVAL; } -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY + int ret; /* This call seems to be required by Linux xhci driver * even though it should be a no-op. Without it, the * host or driver does not send the clear to the device. * We intentionally ignore the return val */ - sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + if (workaround) + { + sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + } ret = usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep); if (ret){ @@ -2205,13 +2227,17 @@ sanei_usb_clear_halt (SANE_Int dn) return SANE_STATUS_INVAL; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) + int ret; /* This call seems to be required by Linux xhci driver * even though it should be a no-op. Without it, the * host or driver does not send the clear to the device. * We intentionally ignore the return val */ - sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + if (workaround) + { + sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + } ret = libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep); if (ret){ @@ -2224,17 +2250,17 @@ sanei_usb_clear_halt (SANE_Int dn) DBG (1, "sanei_usb_clear_halt: BULK_OUT ret=%d\n", ret); return SANE_STATUS_INVAL; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ DBG (1, "sanei_usb_clear_halt: libusb support missing\n"); -#endif /* HAVE_LIBUSB || HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB_LEGACY || HAVE_LIBUSB */ return SANE_STATUS_GOOD; } SANE_Status -sanei_usb_reset (SANE_Int dn) +sanei_usb_reset (SANE_Int __sane_unused__ dn) { -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY int ret; ret = usb_reset (devices[dn].libusb_handle); @@ -2243,7 +2269,7 @@ sanei_usb_reset (SANE_Int dn) return SANE_STATUS_INVAL; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) int ret; ret = libusb_reset_device (devices[dn].lu_handle); @@ -2252,9 +2278,9 @@ sanei_usb_reset (SANE_Int dn) return SANE_STATUS_INVAL; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ DBG (1, "sanei_usb_reset: libusb support missing\n"); -#endif /* HAVE_LIBUSB || HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB_LEGACY || HAVE_LIBUSB */ return SANE_STATUS_GOOD; } @@ -2287,7 +2313,7 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) strerror (errno)); } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { if (devices[dn].bulk_in_ep) { @@ -2306,14 +2332,14 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) return SANE_STATUS_INVAL; } } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { if (devices[dn].bulk_in_ep) { - int ret; + int ret, rsize; ret = libusb_bulk_transfer (devices[dn].lu_handle, devices[dn].bulk_in_ep, buffer, - (int) *size, (int *) &read_size, + (int) *size, &rsize, libusb_timeout); if (ret < 0) @@ -2323,6 +2349,10 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) read_size = -1; } + else + { + read_size = rsize; + } } else { @@ -2331,12 +2361,12 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) return SANE_STATUS_INVAL; } } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_usb_read_bulk: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB */ +#endif /* not HAVE_LIBUSB_LEGACY */ else if (devices[dn].method == sanei_usb_method_usbcalls) { #ifdef HAVE_USBCALLS @@ -2382,10 +2412,10 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) if (read_size < 0) { -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY if (devices[dn].method == sanei_usb_method_libusb) usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep); -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) if (devices[dn].method == sanei_usb_method_libusb) libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep); #endif @@ -2437,7 +2467,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) strerror (errno)); } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { if (devices[dn].bulk_out_ep) { @@ -2456,7 +2486,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) return SANE_STATUS_INVAL; } } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { if (devices[dn].bulk_out_ep) { @@ -2464,7 +2494,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) int trans_bytes; ret = libusb_bulk_transfer (devices[dn].lu_handle, devices[dn].bulk_out_ep, - buffer, + (unsigned char *) buffer, (int) *size, &trans_bytes, libusb_timeout); if (ret < 0) @@ -2484,12 +2514,12 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) return SANE_STATUS_INVAL; } } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_usb_write_bulk: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ else if (devices[dn].method == sanei_usb_method_usbcalls) { #ifdef HAVE_USBCALLS @@ -2537,10 +2567,10 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) if (write_size < 0) { *size = 0; -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY if (devices[dn].method == sanei_usb_method_libusb) usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_out_ep); -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) if (devices[dn].method == sanei_usb_method_libusb) libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_out_ep); #endif @@ -2616,7 +2646,7 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req, #endif /* not __linux__ */ } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { int result; @@ -2633,7 +2663,7 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req, print_buffer (data, len); return SANE_STATUS_GOOD; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { int result; @@ -2650,12 +2680,12 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req, print_buffer (data, len); return SANE_STATUS_GOOD; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0*/ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB*/ { DBG (1, "sanei_usb_control_msg: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ else if (devices[dn].method == sanei_usb_method_usbcalls) { #ifdef HAVE_USBCALLS @@ -2692,7 +2722,7 @@ SANE_Status sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) { ssize_t read_size = 0; -#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) +#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB) SANE_Bool stalled = SANE_FALSE; #endif @@ -2717,7 +2747,7 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) return SANE_STATUS_INVAL; } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { if (devices[dn].int_in_ep) { @@ -2739,7 +2769,7 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) return SANE_STATUS_INVAL; } } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { if (devices[dn].int_in_ep) { @@ -2764,12 +2794,12 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) return SANE_STATUS_INVAL; } } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_usb_read_int: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ else if (devices[dn].method == sanei_usb_method_usbcalls) { #ifdef HAVE_USBCALLS @@ -2808,11 +2838,11 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) if (read_size < 0) { -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY if (devices[dn].method == sanei_usb_method_libusb) if (stalled) usb_clear_halt (devices[dn].libusb_handle, devices[dn].int_in_ep); -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) if (devices[dn].method == sanei_usb_method_libusb) if (stalled) libusb_clear_halt (devices[dn].lu_handle, devices[dn].int_in_ep); @@ -2858,7 +2888,7 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration) #endif /* not __linux__ */ } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { int result; @@ -2872,7 +2902,7 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration) } return SANE_STATUS_GOOD; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { int result; @@ -2885,12 +2915,12 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration) } return SANE_STATUS_GOOD; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_usb_set_configuration: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ else { DBG (1, @@ -2928,7 +2958,7 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number) #endif /* not __linux__ */ } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { int result; @@ -2941,7 +2971,7 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number) } return SANE_STATUS_GOOD; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { int result; @@ -2954,12 +2984,12 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number) } return SANE_STATUS_GOOD; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_usb_claim_interface: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ else { DBG (1, "sanei_usb_claim_interface: access method %d not implemented\n", @@ -2995,7 +3025,7 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number) #endif /* not __linux__ */ } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { int result; @@ -3008,7 +3038,7 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number) } return SANE_STATUS_GOOD; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { int result; @@ -3021,12 +3051,12 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number) } return SANE_STATUS_GOOD; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_usb_release_interface: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ else { DBG (1, @@ -3061,7 +3091,7 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate) #endif /* not __linux__ */ } else if (devices[dn].method == sanei_usb_method_libusb) -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { int result; @@ -3074,7 +3104,7 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate) } return SANE_STATUS_GOOD; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { int result; @@ -3088,12 +3118,12 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate) } return SANE_STATUS_GOOD; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_set_altinterface: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ else { DBG (1, @@ -3104,7 +3134,9 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate) } extern SANE_Status -sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc ) +sanei_usb_get_descriptor( SANE_Int dn, + struct sanei_usb_dev_descriptor __sane_unused__ + *desc ) { if (dn >= device_number || dn < 0) { @@ -3115,7 +3147,7 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc ) } DBG (5, "sanei_usb_get_descriptor\n"); -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY { struct usb_device_descriptor *usb_descr; @@ -3130,7 +3162,7 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc ) desc->max_packet_size = usb_descr->bMaxPacketSize0; return SANE_STATUS_GOOD; } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) { struct libusb_device_descriptor lu_desc; int ret; @@ -3155,10 +3187,10 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc ) desc->max_packet_size = lu_desc.bMaxPacketSize0; return SANE_STATUS_GOOD; } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ { DBG (1, "sanei_usb_get_descriptor: libusb support missing\n"); return SANE_STATUS_UNSUPPORTED; } -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ } |