Browse Source

Merge pull request #437 from kanoi/master

usb_ftdi_set_latency
nfactor-troky
kanoi 12 years ago
parent
commit
7b3e921377
  1. 23
      driver-bflsc.c
  2. 8
      driver-icarus.c
  3. 27
      usbutils.c
  4. 4
      usbutils.h

23
driver-bflsc.c

@ -565,25 +565,6 @@ static bool bflsc_qres(struct cgpu_info *bflsc, char *buf, size_t bufsiz, int de @@ -565,25 +565,6 @@ static bool bflsc_qres(struct cgpu_info *bflsc, char *buf, size_t bufsiz, int de
return readok;
}
static void __set_latency(struct cgpu_info *bflsc)
{
int err;
if (bflsc->usbinfo.nodev)
return;
// Latency
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_LATENCY,
bflsc->usbdev->found->latency,
bflsc->usbdev->found->interface, C_LATENCY);
applog(LOG_DEBUG, "%s%i: latency got err %d",
bflsc->drv->name, bflsc->device_id, err);
if (bflsc->usbinfo.nodev)
return;
}
static void __bflsc_initialise(struct cgpu_info *bflsc)
{
int err;
@ -604,7 +585,7 @@ static void __bflsc_initialise(struct cgpu_info *bflsc) @@ -604,7 +585,7 @@ static void __bflsc_initialise(struct cgpu_info *bflsc)
if (bflsc->usbinfo.nodev)
return;
__set_latency(bflsc);
usb_ftdi_set_latency(bflsc);
if (bflsc->usbinfo.nodev)
return;
@ -944,7 +925,7 @@ reinit: @@ -944,7 +925,7 @@ reinit:
if (latency != bflsc->usbdev->found->latency) {
bflsc->usbdev->found->latency = latency;
__set_latency(bflsc);
usb_ftdi_set_latency(bflsc);
}
for (i = 0; i < sc_info->sc_count; i++)

8
driver-icarus.c

@ -256,10 +256,6 @@ static void icarus_initialise(struct cgpu_info *icarus, int baud) @@ -256,10 +256,6 @@ static void icarus_initialise(struct cgpu_info *icarus, int baud)
case IDENT_LLT:
case IDENT_CMR1:
case IDENT_CMR2:
if (icarus->usbdev->found->latency == LATENCY_UNUSED)
quit(1, "%s: cgid %d invalid latency (UNUSED)",
icarus->drv->name, icarus->cgminer_id);
// Reset
transfer(icarus, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, FTDI_VALUE_RESET,
icarus->usbdev->found->interface, C_RESET);
@ -268,9 +264,7 @@ static void icarus_initialise(struct cgpu_info *icarus, int baud) @@ -268,9 +264,7 @@ static void icarus_initialise(struct cgpu_info *icarus, int baud)
return;
// Latency
transfer(icarus, FTDI_TYPE_OUT, FTDI_REQUEST_LATENCY,
icarus->usbdev->found->latency,
icarus->usbdev->found->interface, C_LATENCY);
usb_ftdi_set_latency(icarus);
if (icarus->usbinfo.nodev)
return;

27
usbutils.c

@ -2489,6 +2489,33 @@ int usb_ftdi_cts(struct cgpu_info *cgpu) @@ -2489,6 +2489,33 @@ int usb_ftdi_cts(struct cgpu_info *cgpu)
return (ret & FTDI_RS0_CTS);
}
int usb_ftdi_set_latency(struct cgpu_info *cgpu)
{
int err;
if (cgpu->usbdev->usb_type != USB_TYPE_FTDI) {
applog(LOG_ERR, "%s: cgid %d latency request on non-FTDI device",
cgpu->drv->name, cgpu->cgminer_id);
return LIBUSB_ERROR_NOT_SUPPORTED;
}
if (cgpu->usbdev->found->latency == LATENCY_UNUSED) {
applog(LOG_ERR, "%s: cgid %d invalid latency (UNUSED)",
cgpu->drv->name, cgpu->cgminer_id);
return LIBUSB_ERROR_NOT_SUPPORTED;
}
err = usb_transfer_data(cgpu, FTDI_TYPE_OUT, FTDI_REQUEST_LATENCY,
cgpu->usbdev->found->latency,
cgpu->usbdev->found->interface, NULL, 0, C_LATENCY);
applog(LOG_DEBUG, "%s: cgid %d %s got err %d",
cgpu->drv->name, cgpu->cgminer_id,
usb_cmdname(C_LATENCY), err);
return err;
}
void usb_buffer_enable(struct cgpu_info *cgpu)
{
struct cg_usb_device *cgusb = cgpu->usbdev;

4
usbutils.h

@ -256,11 +256,11 @@ void usb_detect(struct device_drv *drv, bool (*device_detect)(struct libusb_devi @@ -256,11 +256,11 @@ void usb_detect(struct device_drv *drv, bool (*device_detect)(struct libusb_devi
struct api_data *api_usb_stats(int *count);
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_ftdi_cts(struct cgpu_info *cgpu);
int usb_ftdi_ctw(struct cgpu_info *cgpu);
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_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);
int usb_ftdi_cts(struct cgpu_info *cgpu);
int usb_ftdi_set_latency(struct cgpu_info *cgpu);
void usb_buffer_enable(struct cgpu_info *cgpu);
void usb_buffer_disable(struct cgpu_info *cgpu);
void usb_buffer_clear(struct cgpu_info *cgpu);

Loading…
Cancel
Save