Commit 7deaa91b2684a30c63ad955f303fc518483e2ea4

Con Kolivas 2013-09-27T10:36:23

Add information for 2nd USB interface on BF1 devices and choose interface 1 for bulk transfers.

diff --git a/driver-bitfury.c b/driver-bitfury.c
index bd2835c..5952501 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -23,7 +23,7 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury)
 	int amount;
 
 	do {
-		usb_read(bitfury, buf, 512, &amount, C_BF1_FLUSH);
+		usb_read_ii(bitfury, 1, buf, 512, &amount, C_BF1_FLUSH);
 	} while (amount);
 }
 
@@ -48,7 +48,7 @@ static void bitfury_identify(struct cgpu_info *bitfury)
 {
 	int amount;
 
-	usb_write(bitfury, "L", 1, &amount, C_BF1_IDENTIFY);
+	usb_write_ii(bitfury, 1, "L", 1, &amount, C_BF1_IDENTIFY);
 }
 
 static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info)
@@ -56,8 +56,8 @@ static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info
 	char buf[512];
 	int amount;
 
-	usb_write(bitfury, "I", 1, &amount, C_BF1_REQINFO);
-	usb_read(bitfury, buf, 14, &amount, C_BF1_GETINFO);
+	usb_write_ii(bitfury, 1, "I", 1, &amount, C_BF1_REQINFO);
+	usb_read_ii(bitfury, 1, buf, 14, &amount, C_BF1_GETINFO);
 	if (amount != 14) {
 		applog(LOG_INFO, "%s %d: Getinfo received %d bytes",
 		       bitfury->drv->name, bitfury->device_id, amount);
@@ -78,8 +78,8 @@ static bool bitfury_reset(struct cgpu_info *bitfury)
 	char buf[512];
 	int amount;
 
-	usb_write(bitfury, "R", 1, &amount, C_BF1_REQRESET);
-	usb_read_timeout(bitfury, buf, 7, &amount, BF1WAIT, C_BF1_GETRESET);
+	usb_write_ii(bitfury, 1, "R", 1, &amount, C_BF1_REQRESET);
+	usb_read_ii_timeout(bitfury, 1, buf, 7, &amount, BF1WAIT, C_BF1_GETRESET);
 
 	if (amount != 7) {
 		applog(LOG_INFO, "%s %d: Getreset received %d bytes",
@@ -202,7 +202,7 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
 	cgtime(&tv_now);
 	ms_diff = 600 - ms_tdiff(&tv_now, &info->tv_start);
 	if (ms_diff > 0) {
-		usb_read_timeout(bitfury, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
+		usb_read_ii_timeout(bitfury, 1, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
 		info->tot += amount;
 	}
 
@@ -215,10 +215,10 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
 	ms_diff = BF1WAIT - ms_tdiff(&tv_now, &info->tv_start);
 	if (unlikely(ms_diff < 10))
 		ms_diff = 10;
-	usb_read_once_timeout(bitfury, info->buf + info->tot, 7, &amount, ms_diff, C_BF1_GETRES);
+	usb_read_ii_once_timeout(bitfury, 1, info->buf + info->tot, 7, &amount, ms_diff, C_BF1_GETRES);
 	info->tot += amount;
 	while (amount) {
-		usb_read_once_timeout(bitfury, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
+		usb_read_ii_once_timeout(bitfury, 1, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
 		info->tot += amount;
 	};
 
@@ -226,10 +226,10 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
 		goto cascade;
 
 	/* Send work */
-	usb_write(bitfury, buf, 45, &amount, C_BF1_REQWORK);
+	usb_write_ii(bitfury, 1, buf, 45, &amount, C_BF1_REQWORK);
 	cgtime(&info->tv_start);
 	/* Get response acknowledging work */
-	usb_read(bitfury, buf, 7, &amount, C_BF1_GETWORK);
+	usb_read_ii(bitfury, 1, buf, 7, &amount, C_BF1_GETWORK);
 
 	/* Only happens on startup */
 	if (unlikely(!info->prevwork[BF1ARRAY_SIZE]))
diff --git a/driver-bitfury.h b/driver-bitfury.h
index db13323..9cbe420 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -16,6 +16,7 @@
 #define BF1ARRAY_SIZE 2
 
 struct bitfury_info {
+	struct cgpu_info *base_cgpu;
 	uint8_t version;
 	char product[8];
 	uint32_t serial;
diff --git a/usbutils.c b/usbutils.c
index a79e556..ee36404 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -131,13 +131,18 @@ static struct usb_intinfo bfl_ints[] = {
 #endif
 
 #ifdef USE_BITFURY
-static struct usb_epinfo bfu_epinfos[] = {
+static struct usb_epinfo bfu0_epinfos[] = {
+	{ LIBUSB_TRANSFER_TYPE_INTERRUPT,	8,	EPI(2), 0 }
+};
+
+static struct usb_epinfo bfu1_epinfos[] = {
 	{ LIBUSB_TRANSFER_TYPE_BULK,	16,	EPI(3), 0 },
 	{ LIBUSB_TRANSFER_TYPE_BULK,	16,	EPO(4), 0 }
 };
 
 static struct usb_intinfo bfu_ints[] = {
-	USB_EPS(1,  bfu_epinfos)
+	USB_EPS(0,  bfu0_epinfos),
+	USB_EPS(1,  bfu1_epinfos)
 };
 #endif