Browse Source

usb add transfer_read and commented out in icarus

nfactor-troky
Kano 12 years ago
parent
commit
87d994b6ea
  1. 15
      driver-icarus.c
  2. 41
      usbutils.c
  3. 9
      usbutils.h

15
driver-icarus.c

@ -215,6 +215,21 @@ static int option_offset = -1;
struct device_drv icarus_drv; struct device_drv icarus_drv;
/*
#define ICA_BUFSIZ (0x200)
static void transfer_read(struct cgpu_info *icarus, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, char *buf, int bufsiz, int *amount, enum usb_cmds cmd)
{
int err;
err = usb_transfer_read(icarus, request_type, bRequest, wValue, wIndex, buf, bufsiz, amount, cmd);
applog(LOG_DEBUG, "%s: cgid %d %s got err %d",
icarus->drv->name, icarus->cgminer_id,
usb_cmdname(cmd), err);
}
*/
static void _transfer(struct cgpu_info *icarus, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t *data, int siz, enum usb_cmds cmd) static void _transfer(struct cgpu_info *icarus, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t *data, int siz, enum usb_cmds cmd)
{ {
int err; int err;

41
usbutils.c

@ -49,9 +49,6 @@
#define USB_CONFIG 1 #define USB_CONFIG 1
#define EPI(x) (LIBUSB_ENDPOINT_IN | (unsigned char)(x))
#define EPO(x) (LIBUSB_ENDPOINT_OUT | (unsigned char)(x))
#ifdef WIN32 #ifdef WIN32
#define BFLSC_TIMEOUT_MS 500 #define BFLSC_TIMEOUT_MS 500
#define BITFORCE_TIMEOUT_MS 999 #define BITFORCE_TIMEOUT_MS 999
@ -2216,6 +2213,44 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest
return err; return err;
} }
int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, char *buf, int bufsiz, int *amount, unsigned int timeout, enum usb_cmds cmd)
{
struct cg_usb_device *usbdev = cgpu->usbdev;
#if DO_USB_STATS
struct timeval tv_start, tv_finish;
#endif
int err;
USBDEBUG("USB debug: _usb_transfer_read(%s (nodev=%s),type=%"PRIu8",req=%"PRIu8",value=%"PRIu16",index=%"PRIu16",bufsiz=%d,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), request_type, bRequest, wValue, wIndex, bufsiz, timeout, usb_cmdname(cmd));
if (cgpu->usbinfo.nodev) {
#if DO_USB_STATS
rejected_inc(cgpu);
#endif
return LIBUSB_ERROR_NO_DEVICE;
}
*amount = 0;
STATS_TIMEVAL(&tv_start);
err = libusb_control_transfer(usbdev->handle, request_type,
bRequest, htole16(wValue), htole16(wIndex),
(unsigned char *)buf, (uint16_t)bufsiz,
timeout == DEVTIMEOUT ? usbdev->found->timeout : timeout);
STATS_TIMEVAL(&tv_finish);
USB_STATS(cgpu, &tv_start, &tv_finish, err, cmd, SEQ0);
USBDEBUG("USB debug: @_usb_transfer_read(%s (nodev=%s)) amt/err=%d%s%s%s", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), err, isnodev(err), err > 0 ? " = " : BLANK, err > 0 ? bin2hex((unsigned char *)buf, (size_t)err) : BLANK);
if (err > 0) {
*amount = err;
err = 0;
} else if (NODEV(err))
release_cgpu(cgpu);
return err;
}
void usb_cleanup() void usb_cleanup()
{ {
struct cgpu_info *cgpu; struct cgpu_info *cgpu;

9
usbutils.h

@ -12,6 +12,9 @@
#include <libusb.h> #include <libusb.h>
#define EPI(x) (LIBUSB_ENDPOINT_IN | (unsigned char)(x))
#define EPO(x) (LIBUSB_ENDPOINT_OUT | (unsigned char)(x))
// For 0x0403:0x6014/0x6001 FT232H (and possibly others?) - BFL, BAS, BLT, LLT, AVA // For 0x0403:0x6014/0x6001 FT232H (and possibly others?) - BFL, BAS, BLT, LLT, AVA
#define FTDI_TYPE_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT) #define FTDI_TYPE_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT)
@ -68,6 +71,8 @@
#define PL2303_REQUEST_LINE 0x20 #define PL2303_REQUEST_LINE 0x20
#define PL2303_REQUEST_VENDOR 0x01 #define PL2303_REQUEST_VENDOR 0x01
#define PL2303_REPLY_CTRL 0x21
#define PL2303_VALUE_CTRL (PL2303_CTRL_DTR | PL2303_CTRL_RTS) #define PL2303_VALUE_CTRL (PL2303_CTRL_DTR | PL2303_CTRL_RTS)
#define PL2303_VALUE_LINE 0 #define PL2303_VALUE_LINE 0
#define PL2303_VALUE_LINE0 0x0001c200 #define PL2303_VALUE_LINE0 0x0001c200
@ -222,6 +227,7 @@ void update_usb_stats(struct cgpu_info *cgpu);
int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *processed, unsigned int timeout, const char *end, enum usb_cmds cmd, bool readonce); int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *processed, unsigned int timeout, const char *end, enum usb_cmds cmd, bool readonce);
int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *processed, unsigned int timeout, enum usb_cmds); int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *processed, unsigned int timeout, enum usb_cmds);
int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t *data, int siz, unsigned int timeout, enum usb_cmds cmd); int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t *data, int siz, unsigned int timeout, enum usb_cmds cmd);
int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, char *buf, int bufsiz, int *amount, unsigned int timeout, enum usb_cmds cmd);
void usb_cleanup(); void usb_cleanup();
void usb_initialise(); void usb_initialise();
@ -264,4 +270,7 @@ void usb_initialise();
#define usb_transfer_data(cgpu, typ, req, val, idx, data, len, cmd) \ #define usb_transfer_data(cgpu, typ, req, val, idx, data, len, cmd) \
_usb_transfer(cgpu, typ, req, val, idx, data, len, DEVTIMEOUT, cmd) _usb_transfer(cgpu, typ, req, val, idx, data, len, DEVTIMEOUT, cmd)
#define usb_transfer_read(cgpu, typ, req, val, idx, buf, bufsiz, read, cmd) \
_usb_transfer_read(cgpu, typ, req, val, idx, buf, bufsiz, read, DEVTIMEOUT, cmd)
#endif #endif

Loading…
Cancel
Save