|
|
|
@ -50,7 +50,8 @@
@@ -50,7 +50,8 @@
|
|
|
|
|
#define CAPABILITY_MULTI_FPGA 0,7 |
|
|
|
|
|
|
|
|
|
static int libztex_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_t desc_index, |
|
|
|
|
unsigned char *data, int length) { |
|
|
|
|
unsigned char *data, int length) |
|
|
|
|
{ |
|
|
|
|
int i, cnt; |
|
|
|
|
uint16_t langid; |
|
|
|
|
unsigned char buf[260]; |
|
|
|
@ -91,7 +92,8 @@ static int libztex_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_
@@ -91,7 +92,8 @@ static int libztex_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_
|
|
|
|
|
return LIBUSB_SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enum check_result { |
|
|
|
|
enum check_result |
|
|
|
|
{ |
|
|
|
|
CHECK_ERROR, |
|
|
|
|
CHECK_IS_NOT_ZTEX, |
|
|
|
|
CHECK_OK, |
|
|
|
@ -495,9 +497,11 @@ int libztex_configureFpga(struct libztex_device *ztex)
@@ -495,9 +497,11 @@ int libztex_configureFpga(struct libztex_device *ztex)
|
|
|
|
|
return rv; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int libztex_numberOfFpgas(struct libztex_device *ztex) { |
|
|
|
|
int libztex_numberOfFpgas(struct libztex_device *ztex) |
|
|
|
|
{ |
|
|
|
|
int cnt; |
|
|
|
|
unsigned char buf[3]; |
|
|
|
|
|
|
|
|
|
if (ztex->numberOfFpgas < 0) { |
|
|
|
|
if (libztex_checkCapability(ztex, CAPABILITY_MULTI_FPGA)) { |
|
|
|
|
cnt = libusb_control_transfer(ztex->hndl, 0xc0, 0x50, 0, 0, buf, 3, 1000); |
|
|
|
@ -517,9 +521,11 @@ int libztex_numberOfFpgas(struct libztex_device *ztex) {
@@ -517,9 +521,11 @@ int libztex_numberOfFpgas(struct libztex_device *ztex) {
|
|
|
|
|
return ztex->numberOfFpgas; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int libztex_selectFpga(struct libztex_device *ztex) { |
|
|
|
|
int libztex_selectFpga(struct libztex_device *ztex) |
|
|
|
|
{ |
|
|
|
|
int cnt, fpgacnt = libztex_numberOfFpgas(ztex->root); |
|
|
|
|
int16_t number = ztex->fpgaNum; |
|
|
|
|
|
|
|
|
|
if (number < 0 || number >= fpgacnt) { |
|
|
|
|
applog(LOG_WARNING, "%s: Trying to select wrong fpga (%d in %d)", ztex->repr, number, fpgacnt); |
|
|
|
|
return 1; |
|
|
|
@ -535,7 +541,8 @@ int libztex_selectFpga(struct libztex_device *ztex) {
@@ -535,7 +541,8 @@ int libztex_selectFpga(struct libztex_device *ztex) {
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int libztex_setFreq(struct libztex_device *ztex, uint16_t freq) { |
|
|
|
|
int libztex_setFreq(struct libztex_device *ztex, uint16_t freq) |
|
|
|
|
{ |
|
|
|
|
int cnt; |
|
|
|
|
uint16_t oldfreq = ztex->freqM; |
|
|
|
|
|
|
|
|
@ -563,7 +570,8 @@ int libztex_resetFpga(struct libztex_device *ztex)
@@ -563,7 +570,8 @@ int libztex_resetFpga(struct libztex_device *ztex)
|
|
|
|
|
return libusb_control_transfer(ztex->hndl, 0x40, 0x31, 0, 0, NULL, 0, 1000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int libztex_suspend(struct libztex_device *ztex) { |
|
|
|
|
int libztex_suspend(struct libztex_device *ztex) |
|
|
|
|
{ |
|
|
|
|
if (ztex->suspendSupported) { |
|
|
|
|
return libusb_control_transfer(ztex->hndl, 0x40, 0x84, 0, 0, NULL, 0, 1000); |
|
|
|
|
} else { |
|
|
|
@ -571,7 +579,8 @@ int libztex_suspend(struct libztex_device *ztex) {
@@ -571,7 +579,8 @@ int libztex_suspend(struct libztex_device *ztex) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** ztex) { |
|
|
|
|
int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** ztex) |
|
|
|
|
{ |
|
|
|
|
struct libztex_device *newdev = *ztex; |
|
|
|
|
int i, cnt, err; |
|
|
|
|
unsigned char buf[64]; |
|
|
|
@ -827,7 +836,8 @@ int libztex_sendHashData(struct libztex_device *ztex, unsigned char *sendbuf)
@@ -827,7 +836,8 @@ int libztex_sendHashData(struct libztex_device *ztex, unsigned char *sendbuf)
|
|
|
|
|
return cnt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int libztex_readHashData(struct libztex_device *ztex, struct libztex_hash_data nonces[]) { |
|
|
|
|
int libztex_readHashData(struct libztex_device *ztex, struct libztex_hash_data nonces[]) |
|
|
|
|
{ |
|
|
|
|
int bufsize = 12 + ztex->extraSolutions * 4; |
|
|
|
|
int cnt = 0, i, j, ret, len; |
|
|
|
|
unsigned char *rbuf; |
|
|
|
@ -888,3 +898,4 @@ void libztex_freeDevList(struct libztex_dev_list **devs)
@@ -888,3 +898,4 @@ void libztex_freeDevList(struct libztex_dev_list **devs)
|
|
|
|
|
} |
|
|
|
|
free(devs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|