Browse Source

Remove magic control sequences on open/close on BF1 and just flush the read buffers.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
ce16bd2ba4
  1. 28
      driver-bitfury.c
  2. 3
      usbutils.h

28
driver-bitfury.c

@ -23,39 +23,31 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury)
int amount; int amount;
do { do {
usb_read_ii(bitfury, 1, buf, 512, &amount, C_BF1_FLUSH); usb_read_ii_once(bitfury, 1, buf, 512, &amount, C_BF1_FLUSH);
} while (amount); } while (amount);
} }
static void bitfury_empty_intbuf(struct cgpu_info *bitfury) static void bitfury_empty_intbuf(struct cgpu_info *bitfury)
{ {
char buf[8]; char buf[512];
int amount; int amount;
usb_read_ii(bitfury, 0, buf, 8, &amount, C_BF1_IFLUSH); do {
usb_read_ii_once(bitfury, 0, buf, 512, &amount, C_BF1_IFLUSH);
} while (amount);
} }
static bool bitfury_open(struct cgpu_info *bitfury) static void bitfury_open(struct cgpu_info *bitfury)
{ {
int err;
bitfury_empty_intbuf(bitfury); bitfury_empty_intbuf(bitfury);
/* Magic open sequence */ bitfury_empty_buffer(bitfury);
err = usb_transfer(bitfury, 0x21, 0x22, 0x0003, 0, C_BF1_OPEN);
if (!err)
bitfury_empty_buffer(bitfury);
return !err;
} }
static void bitfury_close(struct cgpu_info *bitfury) static void bitfury_close(struct cgpu_info *bitfury)
{ {
bitfury_empty_buffer(bitfury); bitfury_empty_buffer(bitfury);
/* Magic close sequence */
usb_transfer(bitfury, 0x21, 0x22, 0, 0, C_BF1_CLOSE);
bitfury_empty_intbuf(bitfury); bitfury_empty_intbuf(bitfury);
bitfury_empty_buffer(bitfury); bitfury_empty_buffer(bitfury);
usb_transfer(bitfury, 0x23, 0x08, 0x9053, 1, C_BF1_CLOSE);
bitfury_empty_buffer(bitfury);
} }
static void bitfury_identify(struct cgpu_info *bitfury) static void bitfury_identify(struct cgpu_info *bitfury)
@ -144,11 +136,7 @@ static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_device
usb_buffer_enable(bitfury); usb_buffer_enable(bitfury);
if (!bitfury_open(bitfury)) { bitfury_open(bitfury);
applog(LOG_INFO, "%s %d: Failed to open", bitfury->drv->name,
bitfury->device_id);
goto out_close;
}
/* Send getinfo request */ /* Send getinfo request */
if (!bitfury_getinfo(bitfury, info)) if (!bitfury_getinfo(bitfury, info))

3
usbutils.h

@ -393,6 +393,9 @@ void *usb_resource_thread(void *userdata);
#define usb_read_once(cgpu, buf, bufsiz, read, cmd) \ #define usb_read_once(cgpu, buf, bufsiz, read, cmd) \
_usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, DEVTIMEOUT, NULL, cmd, true) _usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, DEVTIMEOUT, NULL, cmd, true)
#define usb_read_ii_once(cgpu, intinfo, buf, bufsiz, read, cmd) \
_usb_read(cgpu, intinfo, DEFAULT_EP_IN, buf, bufsiz, read, DEVTIMEOUT, NULL, cmd, true)
#define usb_read_once_timeout(cgpu, buf, bufsiz, read, timeout, cmd) \ #define usb_read_once_timeout(cgpu, buf, bufsiz, read, timeout, cmd) \
_usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, timeout, NULL, cmd, true) _usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, timeout, NULL, cmd, true)

Loading…
Cancel
Save