[Pcsclite-cvs-commit] r3488 - in /trunk/Drivers/ccid/src: ccid.h ccid_serial.c ccid_usb.c commands.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Thu May 7 08:04:20 UTC 2009


Author: rousseau
Date: Thu May  7 08:04:20 2009
New Revision: 3488

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3488
Log:
do not power up a card with a voltage not supported by the reader

Modified:
    trunk/Drivers/ccid/src/ccid.h
    trunk/Drivers/ccid/src/ccid_serial.c
    trunk/Drivers/ccid/src/ccid_usb.c
    trunk/Drivers/ccid/src/commands.c

Modified: trunk/Drivers/ccid/src/ccid.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ccid.h?rev=3488&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ccid.h (original)
+++ trunk/Drivers/ccid/src/ccid.h Thu May  7 08:04:20 2009
@@ -113,6 +113,14 @@
 	 * of IFD_ICC_PRESENT
 	 */
 	int dwSlotStatus;
+
+	/*
+	 * bVoltageSupport (bit field)
+	 * 1 = 5.0V
+	 * 2 = 3.0V
+	 * 4 = 1.8V
+	 */
+	int bVoltageSupport;
 } _ccid_descriptor;
 
 /* Features from dwFeatures */

Modified: trunk/Drivers/ccid/src/ccid_serial.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ccid_serial.c?rev=3488&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ccid_serial.c (original)
+++ trunk/Drivers/ccid/src/ccid_serial.c Thu May  7 08:04:20 2009
@@ -591,6 +591,7 @@
 	serialDevice[reader_index].ccid.bMaxSlotIndex = 0;
 	serialDevice[reader_index].ccid.arrayOfSupportedDataRates = SerialTwinDataRates;
 	serialDevice[reader_index].ccid.dwSlotStatus = IFD_ICC_PRESENT;
+	serialDevice[reader_index].ccid.bVoltageSupport = 0x07;	/* 1.8V, 3V and 5V */
 	serialDevice[reader_index].echo = TRUE;
 
 	/* change some values depending on the reader */

Modified: trunk/Drivers/ccid/src/ccid_usb.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ccid_usb.c?rev=3488&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ccid_usb.c (original)
+++ trunk/Drivers/ccid/src/ccid_usb.c Thu May  7 08:04:20 2009
@@ -555,6 +555,7 @@
 					usbDevice[reader_index].ccid.bInterfaceProtocol = usb_interface->altsetting->bInterfaceProtocol;
 					usbDevice[reader_index].ccid.bNumEndpoints = usb_interface->altsetting->bNumEndpoints;
 					usbDevice[reader_index].ccid.dwSlotStatus = IFD_ICC_PRESENT;
+					usbDevice[reader_index].ccid.bVoltageSupport = usb_interface->altsetting->extra[5];
 					goto end;
 				}
 			}

Modified: trunk/Drivers/ccid/src/commands.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/commands.c?rev=3488&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/commands.c (original)
+++ trunk/Drivers/ccid/src/commands.c Thu May  7 08:04:20 2009
@@ -171,6 +171,28 @@
 
 	if (ccid_descriptor->dwFeatures & CCID_CLASS_AUTO_VOLTAGE)
 		voltage = 0;	/* automatic voltage selection */
+	else
+	{
+		int bVoltageSupport = ccid_descriptor->bVoltageSupport;
+
+		if ((1 == voltage) && !(bVoltageSupport & 1))
+		{
+			DEBUG_INFO("5V requested but not support by reader");
+			voltage = 2;	/* 3V */
+		}
+
+		if ((2 == voltage) && !(bVoltageSupport & 2))
+		{
+			DEBUG_INFO("3V requested but not support by reader");
+			voltage = 3;	/* 1.8V */
+		}
+
+		if ((3 == voltage) && !(bVoltageSupport & 4))
+		{
+			DEBUG_INFO("1.8V requested but not support by reader");
+			voltage = 0;	/* auto */
+		}
+	}
 
 again:
 	cmd[0] = 0x62; /* IccPowerOn */




More information about the Pcsclite-cvs-commit mailing list