1 |
flameeyes 11/02/22 11:55:59 |
2 |
|
3 |
Added: pcsc-lite-1.6.6-libusb-multiinterface.patch |
4 |
Log: |
5 |
Add patch from upstream and me to avoid a feature regression with libusb. |
6 |
|
7 |
(Portage version: 2.2.0_alpha24/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 sys-apps/pcsc-lite/files/pcsc-lite-1.6.6-libusb-multiinterface.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/pcsc-lite/files/pcsc-lite-1.6.6-libusb-multiinterface.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/pcsc-lite/files/pcsc-lite-1.6.6-libusb-multiinterface.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: pcsc-lite-1.6.6-libusb-multiinterface.patch |
16 |
=================================================================== |
17 |
From 5b274f9da45174a444f9e1fe8917862680ea0c2c Mon Sep 17 00:00:00 2001 |
18 |
From: rousseau <rousseau@0ce88b0d-b2fd-0310-8134-9614164e65ea> |
19 |
Date: Mon, 21 Feb 2011 15:05:38 +0000 |
20 |
Subject: [PATCH] If a device has more than one CCID interface the "libhal:" naming scheme |
21 |
(with the interface number included) is used instead of "libusb:". |
22 |
MIME-Version: 1.0 |
23 |
Content-Type: text/plain; charset=UTF-8 |
24 |
Content-Transfer-Encoding: 8bit |
25 |
|
26 |
The new mechanism allows to use multi-interfaces devices like the |
27 |
Gemalto ProxDU also with hotplug_libusb. libhal is deprecated and may |
28 |
not be available everywhere. |
29 |
|
30 |
Thanks to Diego Elio Pettenò for the patch (for Gentoo) |
31 |
|
32 |
|
33 |
git-svn-id: svn://svn.debian.org/pcsclite/trunk/PCSC@5621 0ce88b0d-b2fd-0310-8134-9614164e65ea |
34 |
--- |
35 |
src/hotplug_libusb.c | 88 ++++++++++++++++++++++++++++++++++---------------- |
36 |
1 files changed, 60 insertions(+), 28 deletions(-) |
37 |
|
38 |
diff --git a/src/hotplug_libusb.c b/src/hotplug_libusb.c |
39 |
index f7625ba..772d9e0 100644 |
40 |
--- a/src/hotplug_libusb.c |
41 |
+++ b/src/hotplug_libusb.c |
42 |
@@ -47,8 +47,8 @@ |
43 |
#undef DEBUG_HOTPLUG |
44 |
#define ADD_SERIAL_NUMBER |
45 |
|
46 |
-/* format is "%d:%d", bus_number, device_address */ |
47 |
-#define BUS_DEVICE_STRSIZE 10+1+10+1 |
48 |
+/* format is "%d:%d:%d", bus_number, device_address, interface */ |
49 |
+#define BUS_DEVICE_STRSIZE 10+1+10+1+10+1 |
50 |
|
51 |
#define READER_ABSENT 0 |
52 |
#define READER_PRESENT 1 |
53 |
@@ -98,7 +98,8 @@ static struct _readerTracker |
54 |
|
55 |
static LONG HPAddHotPluggable(struct libusb_device *dev, |
56 |
struct libusb_device_descriptor desc, |
57 |
- const char bus_device[], struct _driverTracker *driver); |
58 |
+ const char bus_device[], int interface, |
59 |
+ struct _driverTracker *driver); |
60 |
static LONG HPRemoveHotPluggable(int reader_index); |
61 |
|
62 |
static LONG HPReadBundleValues(void) |
63 |
@@ -276,6 +277,7 @@ static void HPRescanUsbBus(void) |
64 |
while ((dev = devs[cnt++]) != NULL) |
65 |
{ |
66 |
struct libusb_device_descriptor desc; |
67 |
+ struct libusb_config_descriptor *config_desc; |
68 |
uint8_t bus_number = libusb_get_bus_number(dev); |
69 |
uint8_t device_address = libusb_get_device_address(dev); |
70 |
|
71 |
@@ -287,6 +289,14 @@ static void HPRescanUsbBus(void) |
72 |
continue; |
73 |
} |
74 |
|
75 |
+ r = libusb_get_active_config_descriptor(dev, &config_desc); |
76 |
+ if (r < 0) |
77 |
+ { |
78 |
+ Log3(PCSC_LOG_ERROR, "failed to get device config for %d/%d", |
79 |
+ bus_number, device_address); |
80 |
+ continue; |
81 |
+ } |
82 |
+ |
83 |
/* check if the device is supported by one driver */ |
84 |
for (i=0; i<driverSize; i++) |
85 |
{ |
86 |
@@ -294,38 +304,53 @@ static void HPRescanUsbBus(void) |
87 |
desc.idVendor == driverTracker[i].manuID && |
88 |
desc.idProduct == driverTracker[i].productID) |
89 |
{ |
90 |
- int newreader; |
91 |
+ int interface; |
92 |
|
93 |
- /* A known device has been found */ |
94 |
- snprintf(bus_device, BUS_DEVICE_STRSIZE, "%d:%d", |
95 |
- bus_number, device_address); |
96 |
- bus_device[BUS_DEVICE_STRSIZE - 1] = '\0'; |
97 |
#ifdef DEBUG_HOTPLUG |
98 |
- Log2(PCSC_LOG_DEBUG, "Found matching USB device: %s", |
99 |
- bus_device); |
100 |
+ Log3(PCSC_LOG_DEBUG, "Found matching USB device: %d:%d", |
101 |
+ bus_number, device_address); |
102 |
#endif |
103 |
- newreader = TRUE; |
104 |
|
105 |
- /* Check if the reader is a new one */ |
106 |
- for (j=0; j<PCSCLITE_MAX_READERS_CONTEXTS; j++) |
107 |
+ for (interface = 0; interface < config_desc->bNumInterfaces; |
108 |
+ interface++) |
109 |
{ |
110 |
- if (strncmp(readerTracker[j].bus_device, |
111 |
- bus_device, BUS_DEVICE_STRSIZE) == 0) |
112 |
+ int newreader; |
113 |
+ |
114 |
+ /* A known device has been found */ |
115 |
+ snprintf(bus_device, BUS_DEVICE_STRSIZE, "%d:%d:%d", |
116 |
+ bus_number, device_address, interface); |
117 |
+ bus_device[BUS_DEVICE_STRSIZE - 1] = '\0'; |
118 |
+ newreader = TRUE; |
119 |
+ |
120 |
+ /* Check if the reader is a new one */ |
121 |
+ for (j=0; j<PCSCLITE_MAX_READERS_CONTEXTS; j++) |
122 |
{ |
123 |
- /* The reader is already known */ |
124 |
- readerTracker[j].status = READER_PRESENT; |
125 |
- newreader = FALSE; |
126 |
+ if (strncmp(readerTracker[j].bus_device, |
127 |
+ bus_device, BUS_DEVICE_STRSIZE) == 0) |
128 |
+ { |
129 |
+ /* The reader is already known */ |
130 |
+ readerTracker[j].status = READER_PRESENT; |
131 |
+ newreader = FALSE; |
132 |
#ifdef DEBUG_HOTPLUG |
133 |
- Log2(PCSC_LOG_DEBUG, "Refresh USB device: %s", |
134 |
- bus_device); |
135 |
+ Log2(PCSC_LOG_DEBUG, "Refresh USB device: %s", |
136 |
+ bus_device); |
137 |
#endif |
138 |
- break; |
139 |
+ break; |
140 |
+ } |
141 |
} |
142 |
- } |
143 |
|
144 |
- /* New reader found */ |
145 |
- if (newreader) |
146 |
- HPAddHotPluggable(dev, desc, bus_device, &driverTracker[i]); |
147 |
+ /* New reader found */ |
148 |
+ if (newreader) |
149 |
+ { |
150 |
+ printf("POUET %d\n", config_desc->bNumInterfaces); |
151 |
+ if (config_desc->bNumInterfaces > 1) |
152 |
+ HPAddHotPluggable(dev, desc, bus_device, |
153 |
+ interface, &driverTracker[i]); |
154 |
+ else |
155 |
+ HPAddHotPluggable(dev, desc, bus_device, |
156 |
+ -1, &driverTracker[i]); |
157 |
+ } |
158 |
+ } |
159 |
} |
160 |
} |
161 |
} |
162 |
@@ -470,15 +495,22 @@ LONG HPStopHotPluggables(void) |
163 |
|
164 |
static LONG HPAddHotPluggable(struct libusb_device *dev, |
165 |
struct libusb_device_descriptor desc, |
166 |
- const char bus_device[], struct _driverTracker *driver) |
167 |
+ const char bus_device[], int interface, |
168 |
+ struct _driverTracker *driver) |
169 |
{ |
170 |
int i; |
171 |
char deviceName[MAX_DEVICENAME]; |
172 |
|
173 |
Log2(PCSC_LOG_INFO, "Adding USB device: %s", bus_device); |
174 |
|
175 |
- snprintf(deviceName, sizeof(deviceName), "usb:%04x/%04x:libusb-1.0:%s", |
176 |
- desc.idVendor, desc.idProduct, bus_device); |
177 |
+ if (interface >= 0) |
178 |
+ snprintf(deviceName, sizeof(deviceName), "usb:%04x/%04x:libhal:/org/freedesktop/Hal/devices/usb_device_%04x_%04x_serialnotneeded_if%d", |
179 |
+ desc.idVendor, desc.idProduct, desc.idVendor, desc.idProduct, |
180 |
+ interface); |
181 |
+ else |
182 |
+ snprintf(deviceName, sizeof(deviceName), "usb:%04x/%04x:libusb-1.0:%s", |
183 |
+ desc.idVendor, desc.idProduct, bus_device); |
184 |
+ |
185 |
deviceName[sizeof(deviceName) -1] = '\0'; |
186 |
|
187 |
pthread_mutex_lock(&usbNotifierMutex); |
188 |
-- |
189 |
1.7.4.1 |