From 2ab023f3000d45a66f767ba9020dcd4487995500 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 24 Sep 2013 21:55:47 +1000 Subject: [PATCH] Add BF1 detection code to bitfury driver. --- cgminer.c | 16 ++++++++++++++++ driver-bitfury.c | 16 ++++++++++++++++ usbutils.c | 20 ++++++++++++++++++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/cgminer.c b/cgminer.c index 1677790e..29fd52e4 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 aad2501a..f1fd3de6 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 4ce1c33d..9bf0b174 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;