icarus set default options/timing based on device
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
diff --git a/driver-icarus.c b/driver-icarus.c
index c5e1a1e..12b0ca2 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -89,6 +89,8 @@ ASSERT1(sizeof(uint32_t) == 4);
#define ICARUS_REV3_HASH_TIME 0.0000000026316
#define LANCELOT_HASH_TIME 0.0000000025000
#define ASICMINERUSB_HASH_TIME 0.0000000029761
+// TODO: What is it?
+#define CAIRNSMORE1_HASH_TIME 0.0000000026316
#define NANOSEC 1000000000.0
// Icarus Rev3 doesn't send a completion message when it finishes
@@ -423,17 +425,34 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
buf[max] = '\0';
}
- info->Hs = 0;
+ switch (icarus->usbdev->ident) {
+ case IDENT_ICA:
+ info->Hs = ICARUS_REV3_HASH_TIME;
+ break;
+ case IDENT_BLT:
+ case IDENT_LLT:
+ info->Hs = LANCELOT_HASH_TIME;
+ break;
+ case IDENT_AMU:
+ info->Hs = ASICMINERUSB_HASH_TIME;
+ break;
+ case IDENT_CMR:
+ info->Hs = CAIRNSMORE1_HASH_TIME;
+ break;
+ default:
+ quit(1, "Icarus get_options() called with invalid %s ident=%d",
+ icarus->drv->name, icarus->usbdev->ident);
+ }
+
info->read_time = 0;
+ // TODO: allow short=N and long=N
if (strcasecmp(buf, MODE_SHORT_STR) == 0) {
- info->Hs = ICARUS_REV3_HASH_TIME;
info->read_time = ICARUS_READ_COUNT_TIMING;
info->timing_mode = MODE_SHORT;
info->do_icarus_timing = true;
} else if (strcasecmp(buf, MODE_LONG_STR) == 0) {
- info->Hs = ICARUS_REV3_HASH_TIME;
info->read_time = ICARUS_READ_COUNT_TIMING;
info->timing_mode = MODE_LONG;
@@ -456,7 +475,6 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
} else {
// Anything else in buf just uses DEFAULT mode
- info->Hs = ICARUS_REV3_HASH_TIME;
info->fullnonce = info->Hs * (((double)0xffffffff) + 1);
if ((eq = strchr(buf, '=')) != NULL)
@@ -505,7 +523,7 @@ static uint32_t mask(int work_division)
return nonce_mask;
}
-static void get_options(int this_option_offset, int *baud, int *work_division, int *fpga_count)
+static void get_options(int this_option_offset, struct cgpu_info *icarus, int *baud, int *work_division, int *fpga_count)
{
char err_buf[BUFSIZ+1];
char buf[BUFSIZ+1];
@@ -536,9 +554,28 @@ static void get_options(int this_option_offset, int *baud, int *work_division, i
buf[max] = '\0';
}
- *baud = ICARUS_IO_SPEED;
- *work_division = 2;
- *fpga_count = 2;
+ switch (icarus->usbdev->ident) {
+ case IDENT_ICA:
+ case IDENT_BLT:
+ case IDENT_LLT:
+ *baud = ICARUS_IO_SPEED;
+ *work_division = 2;
+ *fpga_count = 2;
+ break;
+ case IDENT_AMU:
+ *baud = ICARUS_IO_SPEED;
+ *work_division = 1;
+ *fpga_count = 1;
+ break;
+ case IDENT_CMR:
+ *baud = ICARUS_IO_SPEED;
+ *work_division = 2;
+ *fpga_count = 2;
+ break;
+ default:
+ quit(1, "Icarus get_options() called with invalid %s ident=%d",
+ icarus->drv->name, icarus->usbdev->ident);
+ }
if (*buf) {
colon = strchr(buf, ':');
@@ -614,8 +651,6 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices
struct cgpu_info *icarus;
int ret, err, amount, tries;
- get_options(this_option_offset, &baud, &work_division, &fpga_count);
-
icarus = calloc(1, sizeof(struct cgpu_info));
if (unlikely(!icarus))
quit(1, "Failed to calloc icarus in icarus_detect_one");
@@ -626,8 +661,7 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices
if (!usb_init(icarus, dev, found))
goto shin;
- // TODO: set options based on ident if options not supplied
- // add a flag to say options were set by parameters
+ get_options(this_option_offset, icarus, &baud, &work_division, &fpga_count);
sprintf(devpath, "%d:%d",
(int)(icarus->usbinfo.bus_number),