Commit 2ab023f3000d45a66f767ba9020dcd4487995500

Con Kolivas 2013-09-24T21:55:47

Add BF1 detection code to bitfury driver.

diff --git a/cgminer.c b/cgminer.c
index 1677790..29fd52e 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1563,6 +1563,9 @@ static char *opt_verusage_and_exit(const char *extra)
 #ifdef USE_BITFORCE
 		"bitforce "
 #endif
+#ifdef USE_BITFURY
+		"bitfury "
+#endif
 #ifdef HAVE_OPENCL
 		"GPU "
 #endif
@@ -7352,6 +7355,10 @@ extern struct device_drv bflsc_drv;
 extern struct device_drv bitforce_drv;
 #endif
 
+#ifdef USE_BITFURY
+extern struct device_drv bitfury_drv;
+#endif
+
 #ifdef USE_ICARUS
 extern struct device_drv icarus_drv;
 #endif
@@ -7650,6 +7657,10 @@ static void *hotplug_thread(void __maybe_unused *userdata)
 			bitforce_drv.drv_detect();
 #endif
 
+#ifdef USE_BITFURY
+			bitfury_drv.drv_detect();
+#endif
+
 #ifdef USE_MODMINER
 			modminer_drv.drv_detect();
 #endif
@@ -7883,6 +7894,11 @@ int main(int argc, char *argv[])
 		bitforce_drv.drv_detect();
 #endif
 
+#ifdef USE_BITFURY
+	if (!opt_scrypt)
+		bitfury_drv.drv_detect();
+#endif
+
 #ifdef USE_MODMINER
 	if (!opt_scrypt)
 		modminer_drv.drv_detect();
diff --git a/driver-bitfury.c b/driver-bitfury.c
index aad2501..f1fd3de 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -14,8 +14,24 @@
 
 struct device_drv bitfury_drv;
 
+static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
+{
+	struct cgpu_info *bitfury;
+
+	bitfury = usb_alloc_cgpu(&bitfury_drv, 1);
+
+	if (!usb_init(bitfury, dev, found)) {
+		bitfury = usb_free_cgpu(bitfury);
+		return false;
+	}
+	applog(LOG_WARNING, "%s%d: Found at %s", bitfury->drv->name,
+	       bitfury->device_id, bitfury->device_path);
+	return true;
+}
+
 static void bitfury_detect(void)
 {
+	usb_detect(&bitfury_drv, bitfury_detect_one);
 }
 
 static bool bitfury_prepare(struct thr_info __maybe_unused *thr)
diff --git a/usbutils.c b/usbutils.c
index 4ce1c33..9bf0b17 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -124,8 +124,8 @@ static struct usb_intinfo bfl_ints[] = {
 
 #ifdef USE_BITFURY
 static struct usb_epinfo bfu_epinfos[] = {
-	{ LIBUSB_TRANSFER_TYPE_BULK,	64,	EPI(3), 0 },
-	{ LIBUSB_TRANSFER_TYPE_BULK,	64,	EPO(4), 0 }
+	{ LIBUSB_TRANSFER_TYPE_BULK,	16,	EPI(3), 0 },
+	{ LIBUSB_TRANSFER_TYPE_BULK,	16,	EPO(4), 0 }
 };
 
 static struct usb_intinfo bfu_ints[] = {
@@ -407,6 +407,10 @@ extern struct device_drv bflsc_drv;
 extern struct device_drv bitforce_drv;
 #endif
 
+#ifdef USE_BITFURY
+extern struct device_drv bitfury_drv;
+#endif
+
 #ifdef USE_MODMINER
 extern struct device_drv modminer_drv;
 #endif
@@ -2092,6 +2096,11 @@ static struct usb_find_devices *usb_check(__maybe_unused struct device_drv *drv,
 		return usb_check_each(DRV_BITFORCE, drv, dev);
 #endif
 
+#ifdef USE_BITFURY
+	if (drv->drv_id == DRIVER_BITFURY)
+		return usb_check_each(DRV_BITFURY, drv, dev);
+#endif
+
 #ifdef USE_MODMINER
 	if (drv->drv_id == DRIVER_MODMINER)
 		return usb_check_each(DRV_MODMINER, drv, dev);
@@ -3304,6 +3313,7 @@ void usb_cleanup()
 		switch (cgpu->drv->drv_id) {
 			case DRIVER_BFLSC:
 			case DRIVER_BITFORCE:
+			case DRIVER_BITFURY:
 			case DRIVER_MODMINER:
 			case DRIVER_ICARUS:
 			case DRIVER_AVALON:
@@ -3443,6 +3453,12 @@ void usb_initialise()
 					found = true;
 				}
 #endif
+#ifdef USE_BITFURY
+				if (!found && strcasecmp(ptr, bitfury_drv.name) == 0) {
+					drv_count[bitfury_drv.drv_id].limit = lim;
+					found = true;
+				}
+#endif
 #ifdef USE_MODMINER
 				if (!found && strcasecmp(ptr, modminer_drv.name) == 0) {
 					drv_count[modminer_drv.drv_id].limit = lim;