Commit 956d444054327cd1a5d7c198e28c5880146c3047

Kano 2013-03-21T15:25:10

avalon usbutils requirements

diff --git a/miner.h b/miner.h
index ee8ce52..b3ac3ae 100644
--- a/miner.h
+++ b/miner.h
@@ -207,6 +207,7 @@ enum drv_driver {
 	DRIVER_ZTEX,
 	DRIVER_CPU,
 	DRIVER_BFLSC,
+	DRIVER_AVALON,
 	DRIVER_MAX
 };
 
diff --git a/usbutils.c b/usbutils.c
index a088a39..1c32461 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -41,6 +41,10 @@
 #define DRV_ICARUS 5
 #endif
 
+#ifdef USE_AVALON
+#define DRV_AVALON 6
+#endif
+
 #define DRV_LAST -1
 
 #define USB_CONFIG 1
@@ -52,10 +56,12 @@
 #define BFLSC_TIMEOUT_MS 500
 #define BITFORCE_TIMEOUT_MS 500
 #define MODMINER_TIMEOUT_MS 200
+#define AVALON_TIMEOUT_MS 500
 #else
 #define BFLSC_TIMEOUT_MS 200
 #define BITFORCE_TIMEOUT_MS 200
 #define MODMINER_TIMEOUT_MS 100
+#define AVALON_TIMEOUT_MS 200
 #endif
 
 #ifdef USE_BFLSC
@@ -81,6 +87,13 @@ static struct usb_endpoints mmq_eps[] = {
 };
 #endif
 
+#ifdef USE_AVALON
+static struct usb_endpoints ava_eps[] = {
+	{ LIBUSB_TRANSFER_TYPE_BULK,	64,	EPI(1), 0 },
+	{ LIBUSB_TRANSFER_TYPE_BULK,	64,	EPO(2), 0 }
+};
+#endif
+
 // TODO: Add support for (at least) Isochronous endpoints
 static struct usb_find_devices find_dev[] = {
 /*
@@ -129,6 +142,19 @@ static struct usb_find_devices find_dev[] = {
 		.epcount = ARRAY_SIZE(mmq_eps),
 		.eps = mmq_eps },
 #endif
+#ifdef USE_AVALON
+	{
+		.drv = DRV_AVALON,
+		.name = "AVA",
+		.idVendor = 0x0403,
+		.idProduct = 0x6001,
+		.kernel = 0,
+		.config = 1,
+		.interface = 1,
+		.timeout = AVALON_TIMEOUT_MS,
+		.epcount = ARRAY_SIZE(ava_eps),
+		.eps = ava_eps },
+#endif
 #ifdef USE_ZTEX
 // This is here so cgminer -n shows them
 // the ztex driver (as at 201303) doesn't use usbutils
@@ -163,6 +189,10 @@ extern struct device_drv modminer_drv;
 extern struct device_drv icarus_drv;
 #endif
 
+#ifdef USE_AVALON
+extern struct device_drv avalon_drv;
+#endif
+
 #define STRBUFLEN 256
 static const char *BLANK = "";
 
@@ -1327,6 +1357,11 @@ static struct usb_find_devices *usb_check(__maybe_unused struct device_drv *drv,
 		return usb_check_each(DRV_MODMINER, drv, dev);
 #endif
 
+#ifdef USE_AVALON
+	if (drv->drv_id == DRIVER_AVALON)
+		return usb_check_each(DRV_AVALON, drv, dev);
+#endif
+
 	return NULL;
 }
 
@@ -1786,6 +1821,7 @@ void usb_cleanup()
 			case DRIVER_BFLSC:
 			case DRIVER_BITFORCE:
 			case DRIVER_MODMINER:
+			case DRIVER_AVALON:
 				release_cgpu(cgpu);
 				break;
 			default:
@@ -1893,6 +1929,12 @@ void usb_initialise()
 					found = true;
 				}
 #endif
+#ifdef USE_AVALON
+				if (!found && strcasecmp(ptr, avalon_drv.name) == 0) {
+					drv_count[avalon_drv.drv_id].limit = lim;
+					found = true;
+				}
+#endif
 				if (!found)
 					quit(1, "Invalid --usb DRV:limit - unknown DRV='%s'", ptr);