[sane-devel] sanei_usb_open() and multifuntion devices

Gerard Klaver gerard at gkall.hobby.nl
Tue Dec 5 18:08:11 CET 2006

On Wed, 2006-09-13 at 13:29 +0200, Wittawat Yamwong wrote:
> Hello,
> I think that how sanei_usb_open() collects endponts is not correct. It loops 
> through all configurations, interfaces and alternate settings and takes the 
> first bulk in, bulk out and interrupt endpoint it found. This works only for 
> some special cases and it is likely to fail for multifunction devices, e.g. 
> Smartbase MP360 which has endpoints for the scanner function in the interface 
> #1. 
> I would propose that sanei_usb_open() accepts two additional parameters 
> specifying an interface number and an alternate setting. These parameters can 
> be omitted (e.g. set to -1). In this case the behaviour described above is 
> valid. If the parameters are given, sanei_usb_open() must use only the 
> endpoints belonging to the specified interface.
> There is also an issue with sanei_usb_set_configuration(), it simply doesn't 
> work this way because setting new configuration will succeed if and only if 
> there is no interfaces claimed by any driver. But the function takes the 
> device number returned by sanei_usb_open() as a parameter and, unfortunely, 
> sanei_usb_open() implicitly claims one interface. We have chicken and egg 
> problem here. Solution: sanei_usb_set_configuration() have to take the device 
> name instead of the device number as the first parameter.
> If I understand correctly, sanei_usb_claim_interface(), 
> sanei_usb_release_interface() and sanei_usb_set_altinterface() are useless 
> because sanei_usb_open() already claims an interface for you and 
> sanei_usb_close() will release it afterward. Why does one want to claim 
> another interface while he cannot use its endpoints through sanei_usb 
> functions?
> Regards
> -- 
> Wittawat Yamwong
> Hannover, Germany
I use them for my stv680 backend, one problem i had after some updates
(sane, libusb,kernel)  was that setting the configuration didn't work
anymore. Disable of the set_configuration solved it for me at that
moment. If setting the configuration is needed for other devices, i
don't know at the moment if some of the webcams i have need that.

The above lines from some earlier email this year.

I think a table generation with the selectable values for the
configuration, interface and altsetting and then choice which values are
needed will probaly solve some of the present problems when selecting a
device and perform a bulk read. 

Depending on the function of a (for example) webcam (image size etc)
selecting a different altsetting for reading (packet size) data should
be possible (or an option which will be implemented later)

Some usb devices have also for one altsetting 2 bulk read in endpoints
to make it more complex.

I don't know if somebody already made some code for these proposals and
did some testing or has some other comment but i think a update for
these 2 functions is an improvement (sanei_usb_open and

Gerard Klaver

More information about the sane-devel mailing list