1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 07:17:58 +00:00

Use the USB wrappers for avalon, telling usbutils that we want the raw data.

This commit is contained in:
Con Kolivas 2013-05-29 00:33:56 +10:00
parent d1337427fd
commit 0177b41010
3 changed files with 13 additions and 10 deletions

View File

@ -236,15 +236,13 @@ static void wait_avalon_ready(struct cgpu_info *avalon)
}
static int avalon_read(struct cgpu_info *avalon, unsigned char *buf,
size_t bufsize, int timeout)
size_t bufsize, int timeout, int ep)
{
struct cg_usb_device *usbdev = avalon->usbdev;
unsigned char readbuf[AVALON_READBUF_SIZE];
size_t total = 0, readsize = bufsize + 2;
char readbuf[AVALON_READBUF_SIZE];
int err, amount, ofs = 2, cp;
err = libusb_bulk_transfer(usbdev->handle, usbdev->found->eps[DEFAULT_EP_IN].ep,
readbuf, readsize, &amount, timeout);
err = usb_read_once_timeout(avalon, readbuf, readsize, &amount, timeout, ep);
applog(LOG_DEBUG, "%s%i: Get avalon read got err %d",
avalon->drv->name, avalon->device_id, err);
@ -289,7 +287,7 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
}
ret = avalon_read(avalon, (unsigned char *)&ar, AVALON_READ_SIZE,
AVALON_RESET_TIMEOUT);
AVALON_RESET_TIMEOUT, C_GET_AVALON_RESET);
/* What do these sleeps do?? */
p.tv_sec = 0;
@ -586,6 +584,10 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
if (!usb_init(avalon, dev, found))
return false;
/* Even though this is an FTDI type chip, we want to do the parsing
* all ourselves so set it to std usb type */
avalon->usbdev->usb_type = USB_TYPE_STD;
/* We have a real Avalon! */
sprintf(devpath, "%d:%d",
(int)(avalon->usbinfo.bus_number),
@ -762,7 +764,8 @@ static void *avalon_get_results(void *userdata)
}
cgtime(&tv_start);
ret = avalon_read(avalon, buf, rsize, AVALON_READ_TIMEOUT);
ret = avalon_read(avalon, buf, rsize, AVALON_READ_TIMEOUT,
C_AVALON_READ);
if (ret < 1) {
int us_delay;

View File

@ -499,7 +499,7 @@ static const char *C_AVALON_TASK_S = "AvalonTask";
static const char *C_AVALON_READ_S = "AvalonRead";
static const char *C_GET_AVALON_READY_S = "AvalonReady";
static const char *C_AVALON_RESET_S = "AvalonReset";
static const char *C_GET_AR_S = "AvalonResult";
static const char *C_GET_AVALON_RESET_S = "GetAvalonReset";
static const char *C_FTDI_STATUS_S = "FTDIStatus";
#ifdef EOL
@ -983,7 +983,7 @@ static void cgusb_check_init()
usb_commands[C_AVALON_READ] = C_AVALON_READ_S;
usb_commands[C_GET_AVALON_READY] = C_GET_AVALON_READY_S;
usb_commands[C_AVALON_RESET] = C_AVALON_RESET_S;
usb_commands[C_GET_AR] = C_GET_AR_S;
usb_commands[C_GET_AVALON_RESET] = C_GET_AVALON_RESET_S;
usb_commands[C_FTDI_STATUS] = C_FTDI_STATUS_S;
stats_initialised = true;

View File

@ -229,7 +229,7 @@ enum usb_cmds {
C_AVALON_READ,
C_GET_AVALON_READY,
C_AVALON_RESET,
C_GET_AR,
C_GET_AVALON_RESET,
C_FTDI_STATUS,
C_MAX
};