Make libusb-1.0 the default for USB support

When libusb-1.0 is not found, libusb-0.1 will be tried.  On BeOS and
OS2, nothing should have changed in terms of detection of USB support.

On all systems the --enable-libusb* flags are now ignored.  Instead, the
--with-usb and --without-usb flags now control support.  When neither is
given USB support will be enable if possible and disabled otherwise.  If
--with-usb is requested but not possible, ./configure will fail.  There
is no support to prefer libusb-0.1 over libusb-1.0.
merge-requests/1/head
Olaf Meeuwissen 2016-07-01 23:37:49 +09:00
rodzic 418fbb987d
commit a9c813944e
12 zmienionych plików z 187 dodań i 209 usunięć

2
README
Wyświetl plik

@ -47,7 +47,7 @@ configure. On some Linux distributions the header files are part of separate
packages (e.g. usb.h in libusb-devel or libusb-dev). These must also be packages (e.g. usb.h in libusb-devel or libusb-dev). These must also be
installed. installed.
- libusb (>=0.1.8): Strongly recommended if you use a USB scanner. - libusb: Strongly recommended if you use a USB scanner.
Some backends won't work without libusb at all. Some backends won't work without libusb at all.
- libjpeg (>=6B): For the dc210, dc240, and gphoto2 backends. - libjpeg (>=6B): For the dc210, dc240, and gphoto2 backends.

Wyświetl plik

@ -4,7 +4,7 @@
## This file is part of the "Sane" build infra-structure. See ## This file is part of the "Sane" build infra-structure. See
## included LICENSE file for license information. ## included LICENSE file for license information.
AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -DLIBDIR="\"$(libdir)/sane\"" AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include $(USB_CFLAGS) -DLIBDIR="\"$(libdir)/sane\""
AM_LDFLAGS += $(STRICT_LDFLAGS) AM_LDFLAGS += $(STRICT_LDFLAGS)
# The -rpath option is added because we are creating _LTLIBRARIES based # The -rpath option is added because we are creating _LTLIBRARIES based

Wyświetl plik

@ -6672,10 +6672,10 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
DBG_INIT (); DBG_INIT ();
DBG (DBG_init, "SANE Genesys backend version %d.%d build %d from %s\n", DBG (DBG_init, "SANE Genesys backend version %d.%d build %d from %s\n",
SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING);
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
DBG (DBG_init, "SANE Genesys backend built with libusb-1.0\n"); DBG (DBG_init, "SANE Genesys backend built with libusb-1.0\n");
#endif #endif
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
DBG (DBG_init, "SANE Genesys backend built with libusb\n"); DBG (DBG_init, "SANE Genesys backend built with libusb\n");
#endif #endif

Wyświetl plik

@ -73,7 +73,7 @@ Start: 2.4.2001
#include "../include/sane/saneopts.h" #include "../include/sane/saneopts.h"
#include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_usb.h"
#undef HAVE_LIBUSB #undef HAVE_LIBUSB_LEGACY
/* prevent inclusion of scantool.h */ /* prevent inclusion of scantool.h */
#define SCANTOOL_H #define SCANTOOL_H

Wyświetl plik

@ -373,85 +373,63 @@ if test "x$with_systemd" != xno ; then
fi fi
fi fi
dnl *********** dnl ******************************************************************
dnl USB Support dnl Check for USB support
dnl *********** dnl ******************************************************************
dnl Enable libusb-1.0, if available AC_ARG_WITH(usb,
AC_ARG_ENABLE(libusb_1_0, AS_HELP_STRING([--with-usb], [enable USB support @<:@default=check@:>@]),
AS_HELP_STRING([--enable-libusb_1_0], [enable libusb-1.0 support if available]), [],
[enable_libusb_1_0=$enableval], [enable_libusb_1_0=no]) [with_usb=check])
AS_IF([test xno != "x$with_usb"],
dnl USB support enabled by default (if found). Note: Overloading libusb [have_usb=no
dnl option right now to disable USB support on any platform; even AS_CASE(x$host_os, dnl odd-ball operating systems first
dnl if they use a different library name. [beos*],
AC_ARG_ENABLE(libusb, [AC_CHECK_HEADER(be/drivers/USB_scanner.h, [have_usb=yes])],
AS_HELP_STRING([--disable-libusb], [disable support for USB in SANE]),, [os2*],
enable_libusb=auto) [AC_CHECK_HEADER(usbcalls.h,
HAVE_USB=no [AC_CHECK_LIB(usbcall, UsbQueryNumberDevices,
if test "$enable_libusb" != "no"; then [USB_LIBS="-lusbcall"
case ${host_os} in have_usb=yes
beos*) AC_DEFINE(HAVE_USBCALLS, [1],
AC_CHECK_HEADERS(be/drivers/USB_scanner.h, HAVE_USB=yes, AC_MSG_ERROR([USB_scanner.h is required on BeOS])) [Define to 1 if you have usbcall.dll.])
;; ])
os2*) ],
AC_CHECK_HEADER(usbcalls.h, [],
AC_CHECK_LIB(usbcall, UsbQueryNumberDevices, [#include <usb.h>
[USB_LIBS="$USB_LIBS -lusbcall" #include <os2.h>
HAVE_USB=yes]),,[#include <usb.h> ])
#include <os2.h> ],
]) [dnl default to libusb-1.x, fall back to libusb-0.x if missing
;; PKG_CHECK_MODULES([USB], [libusb-1.0],
*) [AC_DEFINE([HAVE_LIBUSB], [1],
dnl If libusb-1.0 is enabled and available, prefer that to the old libusb [Define to 1 if you have libusb-1.0])
have_libusb_1_0=no have_usb=yes
if test "$enable_libusb_1_0" = "yes"; then ],
PKG_CHECK_MODULES(LIBUSB_1_0, [ libusb-1.0 >= 1.0.0 ], have_libusb_1_0=yes, have_libusb_1_0=no) [PKG_CHECK_MODULES([USB], [libusb >= 0.1.8],
if test "$have_libusb_1_0" = "yes"; then [AC_DEFINE([HAVE_LIBUSB_LEGACY], [1],
AM_CFLAGS="$AM_CFLAGS $LIBUSB_1_0_CFLAGS" [Define to 1 if you have libusb-0.1])
USB_LIBS="$USB_LIBS $LIBUSB_1_0_LIBS" have_usb=yes
HAVE_USB=yes ],
fi [dnl 10+ years old libusb or Windows version
fi AC_CHECK_HEADER(usb.h,
AC_CHECK_LIB(usb, usb_interrupt_read,
if test "$have_libusb_1_0" = "no"; then [USB_LIBS="-lusb"
dnl Fallback to the old libusb have_usb=yes
dnl libusb >= 0.1.8 is required, as we need usb_interrupt_read() ]))
AC_CHECK_HEADER(usb.h, AC_CHECK_HEADERS(lusb0_usb.h,
AC_CHECK_LIB(usb, usb_interrupt_read, AC_CHECK_LIB(usb, usb_interrupt_read,
[USB_LIBS="$USB_LIBS -lusb" [USB_LIBS="-lusb"
HAVE_USB=yes])) have_usb=yes
AC_CHECK_HEADERS(lusb0_usb.h, ]))
AC_CHECK_LIB(usb, usb_interrupt_read, ])
[USB_LIBS="$USB_LIBS -lusb" ])
HAVE_USB=yes])) ])
fi ])
;; AS_IF([test xyes = "x$with_usb" && test xyes != have_usb],
esac [AC_MSG_ERROR([USB support requested but required libraries not found.])
fi ])
dnl The following logic is useful for distributions. If they force dnl AM_CONDITIONAL([have_usb], [test x != "x$USB_LIBS])
dnl USB support with --enable-libusb=yes then configure will fail
dnl when its detected that it can not be supported. Default is
dnl "auto" which means only enable if libraries are found and do
dnl not error out.
if test "$enable_libusb" = "yes" && test "$HAVE_USB" = "no"; then
AC_MSG_ERROR([USB support requested but required libraries not found.])
fi
if test "$HAVE_USB" = "yes"; then
case ${host_os} in
os2*)
AC_DEFINE(HAVE_USBCALLS, 1, [Define to 1 if you have usbcall.dll.])
;;
*)
if test "$have_libusb_1_0" = "yes"; then
AC_DEFINE(HAVE_LIBUSB_1_0, 1, [Define to 1 if you have libusb-1.0.])
else
AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have libusb.])
fi
;;
esac
fi
AC_SUBST(USB_LIBS)
dnl ************ dnl ************
dnl SCSI Support dnl SCSI Support
@ -851,10 +829,10 @@ if test "$SELECTED_BACKENDS" != "" ; then
echo "*** connected to your local computer won't be supported. Only a network" echo "*** connected to your local computer won't be supported. Only a network"
echo "*** connection to a remote host is possible." echo "*** connection to a remote host is possible."
fi fi
if test "$enable_libusb" != "no" && test "$HAVE_USB" != "yes" ; then if test "$with_usb" != "no" && test "$have_usb" != "yes" ; then
echo "*** Warning: sane-backends will be built without libusb support. There may" echo "*** Warning: sane-backends will be built without USB support. There may"
echo "*** be valid reasons to do so, e.g. if you don't use USB scanners or on" echo "*** be valid reasons to do so, e.g. if you don't use USB scanners or on"
echo "*** platforms without libusb support but generally this means that you" echo "*** platforms without USB support but generally this means that you"
echo "*** can't use USB devices with SANE. The most probable cause is that" echo "*** can't use USB devices with SANE. The most probable cause is that"
if test "${ac_cv_header_usb_h}" != "yes"; then if test "${ac_cv_header_usb_h}" != "yes"; then
echo "*** the libusb header file usb.h is not installed. If you use Linux" echo "*** the libusb header file usb.h is not installed. If you use Linux"

Wyświetl plik

@ -5,7 +5,7 @@
## included LICENSE file for license information. ## included LICENSE file for license information.
AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include \ AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include \
-I$(top_srcdir)/include -I$(top_srcdir)/include $(USB_CFLAGS)
noinst_LTLIBRARIES = libsanei.la noinst_LTLIBRARIES = libsanei.la

Wyświetl plik

@ -67,17 +67,17 @@
#include <resmgr.h> #include <resmgr.h>
#endif #endif
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
#ifdef HAVE_LUSB0_USB_H #ifdef HAVE_LUSB0_USB_H
#include <lusb0_usb.h> #include <lusb0_usb.h>
#else #else
#include <usb.h> #include <usb.h>
#endif #endif
#endif /* HAVE_LIBUSB */ #endif /* HAVE_LIBUSB_LEGACY */
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
#include <libusb.h> #include <libusb.h>
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */
#ifdef HAVE_USBCALLS #ifdef HAVE_USBCALLS
#include <usb.h> #include <usb.h>
@ -147,14 +147,14 @@ typedef struct
SANE_Int interface_nr; SANE_Int interface_nr;
SANE_Int alt_setting; SANE_Int alt_setting;
SANE_Int missing; SANE_Int missing;
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
usb_dev_handle *libusb_handle; usb_dev_handle *libusb_handle;
struct usb_device *libusb_device; struct usb_device *libusb_device;
#endif /* HAVE_LIBUSB */ #endif /* HAVE_LIBUSB_LEGACY */
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
libusb_device *lu_device; libusb_device *lu_device;
libusb_device_handle *lu_handle; libusb_device_handle *lu_handle;
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */
} }
device_list_type; device_list_type;
@ -174,13 +174,13 @@ static int device_number=0;
* count number of time sanei_usb has been initialized */ * count number of time sanei_usb has been initialized */
static int initialized=0; 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 */ 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; static libusb_context *sanei_usb_ctx;
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */
#if defined (__linux__) #if defined (__linux__)
/* From /usr/src/linux/driver/usb/scanner.h */ /* From /usr/src/linux/driver/usb/scanner.h */
@ -257,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 static void
kernel_get_vendor_product (int fd, const char *name, int *vendorID, int *productID) kernel_get_vendor_product (int fd, const char *name, int *vendorID, int *productID)
{ {
@ -331,7 +331,7 @@ kernel_get_vendor_product (int fd, const char *name, int *vendorID, int *product
#endif /* defined (__linux__), defined(__BEOS__), ... */ #endif /* defined (__linux__), defined(__BEOS__), ... */
/* put more os-dependant stuff ... */ /* 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 * store the given device in device list if it isn't already
@ -357,10 +357,10 @@ store_device (device_list_type device)
* Need to update the LibUSB device pointer, since it might * Need to update the LibUSB device pointer, since it might
* have changed after the latest USB scan. * have changed after the latest USB scan.
*/ */
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
devices[i].libusb_device = device.libusb_device; devices[i].libusb_device = device.libusb_device;
#endif #endif
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
devices[i].lu_device = device.lu_device; devices[i].lu_device = device.lu_device;
#endif #endif
@ -399,7 +399,7 @@ store_device (device_list_type device)
devices[pos].open = SANE_FALSE; devices[pos].open = SANE_FALSE;
} }
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
static char * static char *
sanei_libusb_strerror (int errcode) sanei_libusb_strerror (int errcode)
{ {
@ -453,14 +453,14 @@ sanei_libusb_strerror (int errcode)
return "Unknown libusb-1.0 error code"; return "Unknown libusb-1.0 error code";
} }
} }
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */
void void
sanei_usb_init (void) sanei_usb_init (void)
{ {
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
int ret; int ret;
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */
DBG_INIT (); DBG_INIT ();
#ifdef DBG_LEVEL #ifdef DBG_LEVEL
@ -474,18 +474,18 @@ sanei_usb_init (void)
memset (devices, 0, sizeof (devices)); memset (devices, 0, sizeof (devices));
/* initialize USB with old libusb library */ /* initialize USB with old libusb library */
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
DBG (4, "%s: Looking for libusb devices\n", __func__); DBG (4, "%s: Looking for libusb devices\n", __func__);
usb_init (); usb_init ();
#ifdef DBG_LEVEL #ifdef DBG_LEVEL
if (DBG_LEVEL > 4) if (DBG_LEVEL > 4)
usb_set_debug (255); usb_set_debug (255);
#endif /* DBG_LEVEL */ #endif /* DBG_LEVEL */
#endif /* HAVE_LIBUSB */ #endif /* HAVE_LIBUSB_LEGACY */
/* initialize USB using libusb-1.0 */ /* initialize USB using libusb-1.0 */
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
if (!sanei_usb_ctx) if (!sanei_usb_ctx)
{ {
DBG (4, "%s: initializing libusb-1.0\n", __func__); DBG (4, "%s: initializing libusb-1.0\n", __func__);
@ -502,9 +502,9 @@ sanei_usb_init (void)
libusb_set_debug (sanei_usb_ctx, 3); libusb_set_debug (sanei_usb_ctx, 3);
#endif /* DBG_LEVEL */ #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__); DBG (4, "%s: SANE is built without support for libusb\n", __func__);
#endif #endif
@ -544,7 +544,7 @@ int i;
devices[i].devname=NULL; devices[i].devname=NULL;
} }
} }
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
if (sanei_usb_ctx) if (sanei_usb_ctx)
{ {
libusb_exit (sanei_usb_ctx); libusb_exit (sanei_usb_ctx);
@ -634,7 +634,7 @@ static void usbcall_scan_devices(void)
} }
#endif /* HAVE_USBCALLS */ #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. /** scan for devices using kernel device.
* Check for devices using kernel device * Check for devices using kernel device
*/ */
@ -733,9 +733,9 @@ static void kernel_scan_devices(void)
closedir (dir); 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 /** scan for devices using old libusb
* Check for devices using 0.1.x libusb * Check for devices using 0.1.x libusb
*/ */
@ -846,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 /** scan for devices using libusb
* Check for devices using libusb-1.0 * Check for devices using libusb-1.0
*/ */
@ -1022,7 +1022,7 @@ static void libusb_scan_devices(void)
libusb_free_device_list (devlist, 1); libusb_free_device_list (devlist, 1);
} }
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */
void void
@ -1048,11 +1048,11 @@ sanei_usb_scan_devices (void)
} }
/* Check for devices using the kernel scanner driver */ /* 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(); kernel_scan_devices();
#endif #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)*/ /* Check for devices using libusb (old or new)*/
libusb_scan_devices(); libusb_scan_devices();
#endif #endif
@ -1331,7 +1331,7 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
if (devices[devcount].method == sanei_usb_method_libusb) if (devices[devcount].method == sanei_usb_method_libusb)
{ {
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
struct usb_device *dev; struct usb_device *dev;
struct usb_interface_descriptor *interface; struct usb_interface_descriptor *interface;
int result, num; int result, num;
@ -1591,7 +1591,7 @@ 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; int config;
libusb_device *dev; libusb_device *dev;
@ -1894,11 +1894,11 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
libusb_free_config_descriptor (config); 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': " DBG (1, "sanei_usb_open: can't open device `%s': "
"libusb support missing\n", devname); "libusb support missing\n", devname);
return SANE_STATUS_UNSUPPORTED; 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) else if (devices[devcount].method == sanei_usb_method_scanner_driver)
{ {
@ -2136,7 +2136,7 @@ sanei_usb_close (SANE_Int dn)
#endif #endif
} }
else else
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
/* This call seems to be required by Linux xhci driver /* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the * even though it should be a no-op. Without it, the
@ -2151,7 +2151,7 @@ sanei_usb_close (SANE_Int dn)
devices[dn].interface_nr); devices[dn].interface_nr);
usb_close (devices[dn].libusb_handle); 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 /* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the * even though it should be a no-op. Without it, the
@ -2166,7 +2166,7 @@ sanei_usb_close (SANE_Int dn)
devices[dn].interface_nr); devices[dn].interface_nr);
libusb_close (devices[dn].lu_handle); 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"); DBG (1, "sanei_usb_close: libusb support missing\n");
#endif #endif
devices[dn].open = SANE_FALSE; devices[dn].open = SANE_FALSE;
@ -2176,11 +2176,11 @@ sanei_usb_close (SANE_Int dn)
void void
sanei_usb_set_timeout (SANE_Int timeout) sanei_usb_set_timeout (SANE_Int timeout)
{ {
#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) #if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB)
libusb_timeout = timeout; libusb_timeout = timeout;
#else #else
DBG (1, "sanei_usb_set_timeout: libusb support missing\n"); 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 SANE_Status
@ -2204,7 +2204,7 @@ sanei_usb_clear_halt (SANE_Int dn)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
/* This call seems to be required by Linux xhci driver /* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the * even though it should be a no-op. Without it, the
@ -2227,7 +2227,7 @@ sanei_usb_clear_halt (SANE_Int dn)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
/* This call seems to be required by Linux xhci driver /* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the * even though it should be a no-op. Without it, the
@ -2249,9 +2249,9 @@ sanei_usb_clear_halt (SANE_Int dn)
DBG (1, "sanei_usb_clear_halt: BULK_OUT ret=%d\n", ret); DBG (1, "sanei_usb_clear_halt: BULK_OUT ret=%d\n", ret);
return SANE_STATUS_INVAL; 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"); 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; return SANE_STATUS_GOOD;
} }
@ -2259,7 +2259,7 @@ sanei_usb_clear_halt (SANE_Int dn)
SANE_Status SANE_Status
sanei_usb_reset (SANE_Int dn) sanei_usb_reset (SANE_Int dn)
{ {
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
int ret; int ret;
ret = usb_reset (devices[dn].libusb_handle); ret = usb_reset (devices[dn].libusb_handle);
@ -2268,7 +2268,7 @@ sanei_usb_reset (SANE_Int dn)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
int ret; int ret;
ret = libusb_reset_device (devices[dn].lu_handle); ret = libusb_reset_device (devices[dn].lu_handle);
@ -2277,9 +2277,9 @@ sanei_usb_reset (SANE_Int dn)
return SANE_STATUS_INVAL; 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"); 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; return SANE_STATUS_GOOD;
} }
@ -2312,7 +2312,7 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
strerror (errno)); strerror (errno));
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
if (devices[dn].bulk_in_ep) if (devices[dn].bulk_in_ep)
{ {
@ -2331,7 +2331,7 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
if (devices[dn].bulk_in_ep) if (devices[dn].bulk_in_ep)
{ {
@ -2356,12 +2356,12 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL; 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"); DBG (1, "sanei_usb_read_bulk: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }
#endif /* not HAVE_LIBUSB */ #endif /* not HAVE_LIBUSB_LEGACY */
else if (devices[dn].method == sanei_usb_method_usbcalls) else if (devices[dn].method == sanei_usb_method_usbcalls)
{ {
#ifdef HAVE_USBCALLS #ifdef HAVE_USBCALLS
@ -2407,10 +2407,10 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
if (read_size < 0) if (read_size < 0)
{ {
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
if (devices[dn].method == sanei_usb_method_libusb) if (devices[dn].method == sanei_usb_method_libusb)
usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep); 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) if (devices[dn].method == sanei_usb_method_libusb)
libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep); libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep);
#endif #endif
@ -2462,7 +2462,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
strerror (errno)); strerror (errno));
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
if (devices[dn].bulk_out_ep) if (devices[dn].bulk_out_ep)
{ {
@ -2481,7 +2481,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
if (devices[dn].bulk_out_ep) if (devices[dn].bulk_out_ep)
{ {
@ -2509,12 +2509,12 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL; 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"); DBG (1, "sanei_usb_write_bulk: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; 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) else if (devices[dn].method == sanei_usb_method_usbcalls)
{ {
#ifdef HAVE_USBCALLS #ifdef HAVE_USBCALLS
@ -2562,10 +2562,10 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
if (write_size < 0) if (write_size < 0)
{ {
*size = 0; *size = 0;
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
if (devices[dn].method == sanei_usb_method_libusb) if (devices[dn].method == sanei_usb_method_libusb)
usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_out_ep); 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) if (devices[dn].method == sanei_usb_method_libusb)
libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_out_ep); libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_out_ep);
#endif #endif
@ -2641,7 +2641,7 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req,
#endif /* not __linux__ */ #endif /* not __linux__ */
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
int result; int result;
@ -2658,7 +2658,7 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req,
print_buffer (data, len); print_buffer (data, len);
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
int result; int result;
@ -2675,12 +2675,12 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req,
print_buffer (data, len); print_buffer (data, len);
return SANE_STATUS_GOOD; 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"); DBG (1, "sanei_usb_control_msg: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; 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) else if (devices[dn].method == sanei_usb_method_usbcalls)
{ {
#ifdef HAVE_USBCALLS #ifdef HAVE_USBCALLS
@ -2717,7 +2717,7 @@ SANE_Status
sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
{ {
ssize_t read_size = 0; 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; SANE_Bool stalled = SANE_FALSE;
#endif #endif
@ -2742,7 +2742,7 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
if (devices[dn].int_in_ep) if (devices[dn].int_in_ep)
{ {
@ -2764,7 +2764,7 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
if (devices[dn].int_in_ep) if (devices[dn].int_in_ep)
{ {
@ -2789,12 +2789,12 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL; 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"); DBG (1, "sanei_usb_read_int: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; 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) else if (devices[dn].method == sanei_usb_method_usbcalls)
{ {
#ifdef HAVE_USBCALLS #ifdef HAVE_USBCALLS
@ -2833,11 +2833,11 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
if (read_size < 0) if (read_size < 0)
{ {
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
if (devices[dn].method == sanei_usb_method_libusb) if (devices[dn].method == sanei_usb_method_libusb)
if (stalled) if (stalled)
usb_clear_halt (devices[dn].libusb_handle, devices[dn].int_in_ep); 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 (devices[dn].method == sanei_usb_method_libusb)
if (stalled) if (stalled)
libusb_clear_halt (devices[dn].lu_handle, devices[dn].int_in_ep); libusb_clear_halt (devices[dn].lu_handle, devices[dn].int_in_ep);
@ -2883,7 +2883,7 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration)
#endif /* not __linux__ */ #endif /* not __linux__ */
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
int result; int result;
@ -2897,7 +2897,7 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration)
} }
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
int result; int result;
@ -2910,12 +2910,12 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration)
} }
return SANE_STATUS_GOOD; 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"); DBG (1, "sanei_usb_set_configuration: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }
#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ #endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else else
{ {
DBG (1, DBG (1,
@ -2953,7 +2953,7 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number)
#endif /* not __linux__ */ #endif /* not __linux__ */
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
int result; int result;
@ -2966,7 +2966,7 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number)
} }
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
int result; int result;
@ -2979,12 +2979,12 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number)
} }
return SANE_STATUS_GOOD; 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"); DBG (1, "sanei_usb_claim_interface: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }
#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ #endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else else
{ {
DBG (1, "sanei_usb_claim_interface: access method %d not implemented\n", DBG (1, "sanei_usb_claim_interface: access method %d not implemented\n",
@ -3020,7 +3020,7 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number)
#endif /* not __linux__ */ #endif /* not __linux__ */
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
int result; int result;
@ -3033,7 +3033,7 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number)
} }
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
int result; int result;
@ -3046,12 +3046,12 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number)
} }
return SANE_STATUS_GOOD; 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"); DBG (1, "sanei_usb_release_interface: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }
#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ #endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else else
{ {
DBG (1, DBG (1,
@ -3086,7 +3086,7 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate)
#endif /* not __linux__ */ #endif /* not __linux__ */
} }
else if (devices[dn].method == sanei_usb_method_libusb) else if (devices[dn].method == sanei_usb_method_libusb)
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
int result; int result;
@ -3099,7 +3099,7 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate)
} }
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
int result; int result;
@ -3113,12 +3113,12 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate)
} }
return SANE_STATUS_GOOD; 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"); DBG (1, "sanei_set_altinterface: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }
#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ #endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else else
{ {
DBG (1, DBG (1,
@ -3140,7 +3140,7 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc )
} }
DBG (5, "sanei_usb_get_descriptor\n"); DBG (5, "sanei_usb_get_descriptor\n");
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
{ {
struct usb_device_descriptor *usb_descr; struct usb_device_descriptor *usb_descr;
@ -3155,7 +3155,7 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc )
desc->max_packet_size = usb_descr->bMaxPacketSize0; desc->max_packet_size = usb_descr->bMaxPacketSize0;
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
{ {
struct libusb_device_descriptor lu_desc; struct libusb_device_descriptor lu_desc;
int ret; int ret;
@ -3180,10 +3180,10 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc )
desc->max_packet_size = lu_desc.bMaxPacketSize0; desc->max_packet_size = lu_desc.bMaxPacketSize0;
return SANE_STATUS_GOOD; 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"); DBG (1, "sanei_usb_get_descriptor: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }
#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ #endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
} }

Wyświetl plik

@ -15,7 +15,7 @@ TEST_LDADD = ../../sanei/libsanei.la ../../lib/liblib.la $(MATH_LIB) $(USB_LIBS)
check_PROGRAMS = sanei_usb_test test_wire sanei_check_test sanei_config_test sanei_constrain_test check_PROGRAMS = sanei_usb_test test_wire sanei_check_test sanei_config_test sanei_constrain_test
TESTS = $(check_PROGRAMS) TESTS = $(check_PROGRAMS)
AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include $(USB_CFLAGS)
sanei_constrain_test_SOURCES = sanei_constrain_test.c sanei_constrain_test_SOURCES = sanei_constrain_test.c
sanei_constrain_test_LDADD = $(TEST_LDADD) sanei_constrain_test_LDADD = $(TEST_LDADD)

Wyświetl plik

@ -130,13 +130,13 @@ create_mock_device (char *devname, device_list_type * device)
device->devname = strdup (devname); device->devname = strdup (devname);
device->vendor = 0xdead; device->vendor = 0xdead;
device->product = 0xbeef; device->product = 0xbeef;
#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) #if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB)
device->method = sanei_usb_method_libusb; device->method = sanei_usb_method_libusb;
#endif #endif
#ifdef HAVE_USBCALLS #ifdef HAVE_USBCALLS
device->method = sanei_usb_method_usbcalls; device->method = sanei_usb_method_usbcalls;
#endif #endif
#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) && !defined(HAVE_USBCALLS) #if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) && !defined(HAVE_USBCALLS)
device->method == sanei_usb_method_scanner_driver; device->method == sanei_usb_method_scanner_driver;
#endif #endif
} }
@ -689,7 +689,7 @@ test_vendor_by_id (void)
static int static int
test_timeout (void) test_timeout (void)
{ {
#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) #if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB)
int timeout = libusb_timeout; int timeout = libusb_timeout;
sanei_usb_set_timeout (5000); sanei_usb_set_timeout (5000);
@ -832,16 +832,16 @@ main (int argc, char **argv)
int detected, opened, i; int detected, opened, i;
SANE_Int dn[MAX_DEVICES]; SANE_Int dn[MAX_DEVICES];
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
printf ("\n%s built with old libusb\n\n", argv[0]); printf ("\n%s built with old libusb\n\n", argv[0]);
#endif #endif
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
printf ("\n%s built with libusb-1.0\n\n", argv[0]); printf ("\n%s built with libusb-1.0\n\n", argv[0]);
#endif #endif
#ifdef HAVE_USBCALLS #ifdef HAVE_USBCALLS
printf ("\n%s built with usbcalls\n\n", argv[0]); printf ("\n%s built with usbcalls\n\n", argv[0]);
#endif #endif
#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) && !defined(HAVE_USBCALLS) #if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) && !defined(HAVE_USBCALLS)
printf ("\n%s relying on deprecated scanner kernel module\n", argv[0]); printf ("\n%s relying on deprecated scanner kernel module\n", argv[0]);
#endif #endif

Wyświetl plik

@ -5,7 +5,7 @@
## included LICENSE file for license information. ## included LICENSE file for license information.
AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include \ AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include \
-I$(top_srcdir)/include -I$(top_srcdir)/include $(USB_CFLAGS)
bin_PROGRAMS = sane-find-scanner gamma4scanimage bin_PROGRAMS = sane-find-scanner gamma4scanimage
noinst_PROGRAMS = sane-desc noinst_PROGRAMS = sane-desc

Wyświetl plik

@ -28,7 +28,7 @@
#include "../include/sane/config.h" #include "../include/sane/config.h"
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
#include "../include/sane/sane.h" #include "../include/sane/sane.h"
#include <stdio.h> #include <stdio.h>
@ -3430,9 +3430,9 @@ check_usb_chip (struct usb_device *dev, int verbosity, SANE_Bool from_file)
return chip_name; return chip_name;
} }
#endif /* HAVE_LIBUSB */ #endif /* HAVE_LIBUSB_LEGACY */
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
#include <libusb.h> #include <libusb.h>
@ -4335,4 +4335,4 @@ check_usb_chip (int verbosity,
libusb_release_interface (hdl, 0); libusb_release_interface (hdl, 0);
return chip_name; return chip_name;
} }
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */

Wyświetl plik

@ -46,7 +46,7 @@
#include "../include/sane/sanei_pa4s2.h" #include "../include/sane/sanei_pa4s2.h"
#include "../include/sane/sanei_config.h" #include "../include/sane/sanei_config.h"
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
#ifdef HAVE_LUSB0_USB_H #ifdef HAVE_LUSB0_USB_H
#include <lusb0_usb.h> #include <lusb0_usb.h>
#else #else
@ -55,7 +55,7 @@
extern char * check_usb_chip (struct usb_device *dev, int verbosity, SANE_Bool from_file); extern char * check_usb_chip (struct usb_device *dev, int verbosity, SANE_Bool from_file);
#endif #endif
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
#include <libusb.h> #include <libusb.h>
extern char * check_usb_chip (int verbosity, extern char * check_usb_chip (int verbosity,
struct libusb_device_descriptor desc, struct libusb_device_descriptor desc,
@ -76,7 +76,7 @@ static SANE_Bool device_found = SANE_FALSE;
static SANE_Bool libusb_device_found = SANE_FALSE; static SANE_Bool libusb_device_found = SANE_FALSE;
static SANE_Bool unknown_found = SANE_FALSE; static SANE_Bool unknown_found = SANE_FALSE;
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
libusb_context *sfs_usb_ctx; libusb_context *sfs_usb_ctx;
#endif #endif
@ -115,7 +115,7 @@ usage (char *msg)
fprintf (stderr, "\t-f: force opening devname as SCSI even if it looks " fprintf (stderr, "\t-f: force opening devname as SCSI even if it looks "
"like USB\n"); "like USB\n");
fprintf (stderr, "\t-p: enable scanning for parallel port devices\n"); fprintf (stderr, "\t-p: enable scanning for parallel port devices\n");
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
fprintf (stderr, "\t-F file: try to detect chipset from given " fprintf (stderr, "\t-F file: try to detect chipset from given "
"/proc/bus/usb/devices file\n"); "/proc/bus/usb/devices file\n");
#endif #endif
@ -403,7 +403,7 @@ check_usb_file (char *file_name)
} }
} }
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
static char * static char *
get_libusb_string_descriptor (struct usb_device *dev, int index) get_libusb_string_descriptor (struct usb_device *dev, int index)
@ -701,10 +701,10 @@ check_libusb_device (struct usb_device *dev, SANE_Bool from_file)
if (product) if (product)
free (product); free (product);
} }
#endif /* HAVE_LIBUSB */ #endif /* HAVE_LIBUSB_LEGACY */
#ifdef HAVE_LIBUSB_1_0 #ifdef HAVE_LIBUSB
static char * static char *
sfs_libusb_strerror (int errcode) sfs_libusb_strerror (int errcode)
{ {
@ -1095,7 +1095,7 @@ check_libusb_device (libusb_device *dev, SANE_Bool from_file)
if (product) if (product)
free (product); free (product);
} }
#endif /* HAVE_LIBUSB_1_0 */ #endif /* HAVE_LIBUSB */
static DIR * static DIR *
@ -1355,7 +1355,7 @@ check_mustek_pp_device (void)
return (found > 0 || scsi > 0); return (found > 0 || scsi > 0);
} }
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
static SANE_Bool static SANE_Bool
parse_num (char* search, const char* line, int base, long int * number) parse_num (char* search, const char* line, int base, long int * number)
{ {
@ -1596,9 +1596,9 @@ main (int argc, char **argv)
break; break;
case 'F': case 'F':
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
parse_file ((char *) (*(++ap))); parse_file ((char *) (*(++ap)));
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
printf ("option -F not implemented with libusb-1.0\n"); printf ("option -F not implemented with libusb-1.0\n");
#else #else
printf ("libusb not available: option -F can't be used\n"); printf ("libusb not available: option -F can't be used\n");
@ -1948,7 +1948,7 @@ main (int argc, char **argv)
check_usb_file (dev_name); check_usb_file (dev_name);
} }
} }
#ifdef HAVE_LIBUSB #ifdef HAVE_LIBUSB_LEGACY
/* Now the libusb devices */ /* Now the libusb devices */
{ {
struct usb_bus *bus; struct usb_bus *bus;
@ -1973,7 +1973,7 @@ main (int argc, char **argv)
} /* for (bus) */ } /* for (bus) */
} }
} }
#elif defined(HAVE_LIBUSB_1_0) #elif defined(HAVE_LIBUSB)
/* Now the libusb-1.0 devices */ /* Now the libusb-1.0 devices */
{ {
if (ap < argv + argc) if (ap < argv + argc)
@ -2026,10 +2026,10 @@ main (int argc, char **argv)
; /* init failed, jumping here */ ; /* init failed, jumping here */
} }
} }
#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ #else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
if (verbose > 1) if (verbose > 1)
printf ("libusb not available\n"); printf ("libusb not available\n");
#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ #endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
if (device_found) if (device_found)
{ {
@ -2062,7 +2062,7 @@ main (int argc, char **argv)
"make sure that\n # you have loaded a kernel driver for your USB host " "make sure that\n # you have loaded a kernel driver for your USB host "
"controller and have setup\n # the USB system correctly. " "controller and have setup\n # the USB system correctly. "
"See man sane-usb for details.\n"); "See man sane-usb for details.\n");
#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) #if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB)
if (verbose > 0) if (verbose > 0)
printf (" # SANE has been built without libusb support. This may be a " printf (" # SANE has been built without libusb support. This may be a "
"reason\n # for not detecting USB scanners. Read README for " "reason\n # for not detecting USB scanners. Read README for "