On Fri, 2 Jan 2009, Alon Bar-Lev wrote:

                   ifd_sysdep_usb_set_interface(dev,
                                                   params->usb.interface,
                                                   params->usb.altsetting))
A usb device may provide multiple programming interfaces to its underlying functionality. This call selects the one we want to use.

I could not find calls to RESET, RESETEP and SETINTERFACE in libusb-1,
so I guess normal applications should not use these?
libusb refers to these as IOCTL_USB_RESET, IOCTL_USB_RESETEP, and IOCTL_USB_SETINTF

This patch should help. It avoids changing the altsetting if there is only one, which makes it somewhat safe to skip. I don't really like this idea, since unlike SETCONFIGURATION, there is not really a good reason to avoid using SETINTERFACE.

It's actually possible that doing the SETCONFIGURATION would make your device behave better, but we can't put it back without adding alot of probing to make sure it will work.
Index: ifd-ccid.c
===================================================================
--- ifd-ccid.c	(revision 1094)
+++ ifd-ccid.c	(working copy)
@@ -477,7 +477,7 @@
 {
 	ccid_status_t *st;
 	ifd_device_params_t params;
-	int r, i, c, ifc, alt;
+	int r, i, c, ifc, alt, num_alt;
 	struct ifd_usb_device_descriptor de;
 	struct ifd_usb_config_descriptor conf;
 	struct ifd_usb_interface_descriptor *intf;
@@ -516,8 +516,8 @@
 			continue;
 
 		for (ifc = 0; ifc < conf.bNumInterfaces; ifc++) {
-			for (alt = 0; alt < conf.interface[ifc].num_altsetting;
-			     alt++) {
+			num_alt = conf.interface[ifc].num_altsetting;
+			for (alt = 0; alt < num_alt; alt++) {
 				int typeok = 0;
 				int ok = 0;
 				intf = &conf.interface[ifc].altsetting[alt];
@@ -646,7 +646,10 @@
 		params.usb.configuration = -1;
 
 	params.usb.interface = intf->bInterfaceNumber;
-	params.usb.altsetting = intf->bAlternateSetting;
+	if (num_alt > 1 || intf->bAlternateSetting > 0)
+		params.usb.altsetting = intf->bAlternateSetting;
+	else
+		params.usb.altsetting = -1;
 
 	r = ccid_parse_descriptor(&ccid, p, r - i);
 	ifd_usb_free_configuration(&conf);
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to