From d9748fb14cf1049d3b7ec2a987cc443480ec1e09 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Apr 10 2018 05:29:03 +0000 Subject: import sane-backends-1.0.24-11.el7 --- diff --git a/SOURCES/sane-backends-1.0.24-usb3-xhci.patch b/SOURCES/sane-backends-1.0.24-usb3-xhci.patch new file mode 100644 index 0000000..7ba700d --- /dev/null +++ b/SOURCES/sane-backends-1.0.24-usb3-xhci.patch @@ -0,0 +1,199 @@ +diff -up sane-backends-1.0.24/doc/sane-usb.man.usb3-xhci sane-backends-1.0.24/doc/sane-usb.man +--- sane-backends-1.0.24/doc/sane-usb.man.usb3-xhci 2013-02-23 03:00:56.000000000 +0100 ++++ sane-backends-1.0.24/doc/sane-usb.man 2017-07-21 16:32:40.650531762 +0200 +@@ -138,6 +138,13 @@ environment variable controls the debug + subsystem. E.g., a value of 128 requests all debug output to be + printed. Smaller levels reduce verbosity. Values greater than 4 enable + libusb debugging (if available). Example: export SANE_DEBUG_SANEI_USB=4. ++.PP ++.TP ++.B SANE_USB_WORKAROUND ++If your scanner does not work when plugged into a USB3 port, try ++setting the environment variable SANE_USB_WORKAROUND to 1. This ++may work around issues which happen with particular kernel ++versions. Example: export SANE_USB_WORKAROUND=1. + + .SH "SEE ALSO" + .BR sane (7), +diff -up sane-backends-1.0.24/sanei/sanei_usb.c.usb3-xhci sane-backends-1.0.24/sanei/sanei_usb.c +--- sane-backends-1.0.24/sanei/sanei_usb.c.usb3-xhci 2017-07-19 13:34:05.901456398 +0200 ++++ sane-backends-1.0.24/sanei/sanei_usb.c 2017-07-19 13:34:05.905456364 +0200 +@@ -154,6 +154,7 @@ typedef struct + SANE_Int control_in_ep; + SANE_Int control_out_ep; + SANE_Int interface_nr; ++ SANE_Int alt_setting; + SANE_Int missing; + #ifdef HAVE_LIBUSB + usb_dev_handle *libusb_handle; +@@ -633,6 +634,7 @@ static void usbcall_scan_devices(void) + device.product = pDevDesc->idProduct; + device.method = sanei_usb_method_usbcalls; + device.interface_nr = interface; ++ device.alt_setting = 0; + DBG (4, "%s: found usbcalls device (0x%04x/0x%04x) as device number %s\n", __func__, + pDevDesc->idVendor, pDevDesc->idProduct,device.devname); + store_device(device); +@@ -819,7 +821,7 @@ static void libusb_scan_devices(void) + "scanner (%d/%d)\n", __func__, dev->descriptor.idVendor, + dev->descriptor.idProduct, interface, + dev->descriptor.bDeviceClass, +- dev->config[0].interface[interface].altsetting != 0 ++ dev->config[0].interface[interface].num_altsetting != 0 + ? dev->config[0].interface[interface].altsetting[0]. + bInterfaceClass : -1); + } +@@ -843,6 +845,7 @@ static void libusb_scan_devices(void) + device.product = dev->descriptor.idProduct; + device.method = sanei_usb_method_libusb; + device.interface_nr = interface; ++ device.alt_setting = 0; + DBG (4, + "%s: found libusb device (0x%04x/0x%04x) interface " + "%d at %s\n", __func__, +@@ -989,7 +992,7 @@ static void libusb_scan_devices(void) + "%s: device 0x%04x/0x%04x, interface %d " + "doesn't look like a scanner (%d/%d)\n", __func__, + vid, pid, interface, desc.bDeviceClass, +- (config0->interface[interface].altsetting != 0) ++ (config0->interface[interface].num_altsetting != 0) + ? config0->interface[interface].altsetting[0].bInterfaceClass : -1); + } + +@@ -1016,6 +1019,7 @@ static void libusb_scan_devices(void) + device.product = pid; + device.method = sanei_usb_method_libusb; + device.interface_nr = interface; ++ device.alt_setting = 0; + DBG (4, + "%s: found libusb-1.0 device (0x%04x/0x%04x) interface " + "%d at %s\n", __func__, +@@ -2099,6 +2103,17 @@ sanei_usb_open (SANE_String_Const devnam + 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) + { +@@ -2126,22 +2141,30 @@ sanei_usb_close (SANE_Int dn) + else + #ifdef HAVE_LIBUSB + { +-#if 0 +- /* Should only be done in case of a stall */ +- usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep); +- usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_out_ep); +- usb_clear_halt (devices[dn].libusb_handle, devices[dn].iso_in_ep); +- /* be careful, we don't know if we are in DATA0 stage now */ +- usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_in_ep); +- usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_out_ep); +- usb_resetep (devices[dn].libusb_handle, devices[dn].iso_in_ep); +-#endif /* 0 */ ++ /* 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 */ ++ 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) + { ++ /* 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 */ ++ 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); +@@ -2166,8 +2189,17 @@ sanei_usb_set_timeout (SANE_Int timeout) + SANE_Status + sanei_usb_clear_halt (SANE_Int dn) + { +-#ifdef HAVE_LIBUSB + 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) + { +@@ -2175,6 +2207,17 @@ sanei_usb_clear_halt (SANE_Int dn) + return SANE_STATUS_INVAL; + } + ++#ifdef 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 send the clear to the device. ++ * We intentionally ignore the return val */ ++ 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){ + DBG (1, "sanei_usb_clear_halt: BULK_IN ret=%d\n", ret); +@@ -2187,17 +2230,15 @@ sanei_usb_clear_halt (SANE_Int dn) + return SANE_STATUS_INVAL; + } + +- /* be careful, we don't know if we are in DATA0 stage now +- ret = usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_in_ep); +- ret = usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_out_ep); +- */ + #elif defined(HAVE_LIBUSB_1_0) +- int ret; + +- if (dn >= device_number || dn < 0) ++ /* 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 */ ++ if (workaround) + { +- DBG (1, "sanei_usb_clear_halt: dn >= device number || dn < 0\n"); +- return SANE_STATUS_INVAL; ++ sanei_usb_set_altinterface (dn, devices[dn].alt_setting); + } + + ret = libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep); +@@ -3036,6 +3077,8 @@ sanei_usb_set_altinterface (SANE_Int dn, + + DBG (5, "sanei_usb_set_altinterface: alternate = %d\n", alternate); + ++ devices[dn].alt_setting = alternate; ++ + if (devices[dn].method == sanei_usb_method_scanner_driver) + { + #if defined(__linux__) diff --git a/SPECS/sane-backends.spec b/SPECS/sane-backends.spec index a38e3a0..3d111a4 100644 --- a/SPECS/sane-backends.spec +++ b/SPECS/sane-backends.spec @@ -37,7 +37,7 @@ Summary: Scanner access software Name: sane-backends Version: 1.0.24 -Release: 9%{?dist} +Release: 11%{?dist} # lib/ is LGPLv2+, backends are GPLv2+ with exceptions # Tools are GPLv2+, docs are public domain # see LICENSE for details @@ -75,6 +75,10 @@ Patch5: sane-backends-1.0.24-pixma_bjnp-crash.patch Patch6: sane-backends-1.0.24-static-code-check.patch # Upstream commit 758731489d0d58bab6e4b70db9556038c9f4bb67 Patch7: sane-backends-1.0.24-scsi-permissions.patch +# Upstream commit 56398ead607d8bcb9deef7ca3f4d7f78478f1b4c +# Upstream commit 1207ce5a40664c04b934bd0a6babbc1575361356 +# Upstream commit 014b45d920f1fb630e1a31bb01f1da02ea2a6a87 +Patch8: sane-backends-1.0.24-usb3-xhci.patch URL: http://www.sane-project.org @@ -191,6 +195,7 @@ This package contains backend drivers to access digital cameras through SANE. %patch5 -p1 -b .pixma_bjnp-crash %patch6 -p1 -b .static-code-check %patch7 -p1 -b .scsi-permissions +%patch8 -p1 -b .usb3-xhci %build CFLAGS="%optflags -fno-strict-aliasing" @@ -312,6 +317,12 @@ udevadm hwdb --update >/dev/null 2>&1 || : %{_libdir}/sane/*gphoto2.so* %changelog +* Tue Oct 10 2017 Zdenek Dohnal - 1.0.24-11 +- 1500219 - rebuild against new libgphoto2 + +* Mon Sep 25 2017 Zdenek Dohnal - 1.0.24-10 +- 1458903 - [Patch] Lack of USB3 xhci patch makes SANE quite unusable with USB3 hardware + * Fri Jan 24 2014 Daniel Mach - 1.0.24-9 - Mass rebuild 2014-01-24