Browse Source

Remove unnecessary steps in communicating with BF1 and just use USB interface 1.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
8d133706c9
  1. 35
      driver-bitfury.c
  2. 5
      usbutils.c

35
driver-bitfury.c

@ -23,38 +23,25 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury) @@ -23,38 +23,25 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury)
int amount;
do {
usb_read_ii_once(bitfury, 1, buf, 512, &amount, C_BF1_FLUSH);
} while (amount);
}
static void bitfury_empty_intbuf(struct cgpu_info *bitfury)
{
char buf[512];
int amount;
do {
usb_read_ii_once(bitfury, 0, buf, 512, &amount, C_BF1_IFLUSH);
usb_read_once(bitfury, buf, 512, &amount, C_BF1_FLUSH);
} while (amount);
}
static void bitfury_open(struct cgpu_info *bitfury)
{
bitfury_empty_intbuf(bitfury);
bitfury_empty_buffer(bitfury);
}
static void bitfury_close(struct cgpu_info *bitfury)
{
bitfury_empty_buffer(bitfury);
bitfury_empty_intbuf(bitfury);
bitfury_empty_buffer(bitfury);
}
static void bitfury_identify(struct cgpu_info *bitfury)
{
int amount;
usb_write_ii(bitfury, 1, "L", 1, &amount, C_BF1_IDENTIFY);
usb_write(bitfury, "L", 1, &amount, C_BF1_IDENTIFY);
}
static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info)
@ -62,13 +49,13 @@ static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info @@ -62,13 +49,13 @@ static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info
int amount, err;
char buf[16];
err = usb_write_ii(bitfury, 1, "I", 1, &amount, C_BF1_REQINFO);
err = usb_write(bitfury, "I", 1, &amount, C_BF1_REQINFO);
if (err) {
applog(LOG_INFO, "%s %d: Failed to write REQINFO",
bitfury->drv->name, bitfury->device_id);
return false;
}
err = usb_read_ii(bitfury, 1, buf, 14, &amount, C_BF1_GETINFO);
err = usb_read(bitfury, buf, 14, &amount, C_BF1_GETINFO);
if (err) {
applog(LOG_INFO, "%s %d: Failed to read GETINFO",
bitfury->drv->name, bitfury->device_id);
@ -94,13 +81,13 @@ static bool bitfury_reset(struct cgpu_info *bitfury) @@ -94,13 +81,13 @@ static bool bitfury_reset(struct cgpu_info *bitfury)
int amount, err;
char buf[16];
err = usb_write_ii(bitfury, 1, "R", 1, &amount, C_BF1_REQRESET);
err = usb_write(bitfury, "R", 1, &amount, C_BF1_REQRESET);
if (err) {
applog(LOG_INFO, "%s %d: Failed to write REQRESET",
bitfury->drv->name, bitfury->device_id);
return false;
}
err = usb_read_ii_timeout(bitfury, 1, buf, 7, &amount, BF1WAIT, C_BF1_GETRESET);
err = usb_read_timeout(bitfury, buf, 7, &amount, BF1WAIT, C_BF1_GETRESET);
if (err) {
applog(LOG_INFO, "%s %d: Failed to read GETRESET",
bitfury->drv->name, bitfury->device_id);
@ -227,7 +214,7 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work, @@ -227,7 +214,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_ii_timeout(bitfury, 1, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
usb_read_timeout(bitfury, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
info->tot += amount;
}
@ -240,10 +227,10 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work, @@ -240,10 +227,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_ii_once_timeout(bitfury, 1, info->buf + info->tot, 7, &amount, ms_diff, C_BF1_GETRES);
usb_read_once_timeout(bitfury, info->buf + info->tot, 7, &amount, ms_diff, C_BF1_GETRES);
info->tot += amount;
while (amount) {
usb_read_ii_once_timeout(bitfury, 1, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
usb_read_once_timeout(bitfury, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
info->tot += amount;
};
@ -251,10 +238,10 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work, @@ -251,10 +238,10 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
goto cascade;
/* Send work */
usb_write_ii(bitfury, 1, buf, 45, &amount, C_BF1_REQWORK);
usb_write(bitfury, buf, 45, &amount, C_BF1_REQWORK);
cgtime(&info->tv_start);
/* Get response acknowledging work */
usb_read_ii(bitfury, 1, buf, 7, &amount, C_BF1_GETWORK);
usb_read(bitfury, buf, 7, &amount, C_BF1_GETWORK);
/* Only happens on startup */
if (unlikely(!info->prevwork[BF1ARRAY_SIZE]))

5
usbutils.c

@ -140,9 +140,10 @@ static struct usb_epinfo bfu1_epinfos[] = { @@ -140,9 +140,10 @@ static struct usb_epinfo bfu1_epinfos[] = {
{ LIBUSB_TRANSFER_TYPE_BULK, 16, EPO(4), 0, 16, 0 }
};
/* Default to interface 1 */
static struct usb_intinfo bfu_ints[] = {
USB_EPS(0, bfu0_epinfos),
USB_EPS(1, bfu1_epinfos)
USB_EPS(1, bfu1_epinfos),
USB_EPS(0, bfu0_epinfos)
};
#endif

Loading…
Cancel
Save