Add an hfa-options command line that allows the clockspeed to be chosen per device by name comma separated, with a function that can be expanded with more options in the future.
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 120 121 122 123 124 125 126 127 128
diff --git a/cgminer.c b/cgminer.c
index e3b401d..a15818e 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1114,6 +1114,15 @@ static char *set_bitburner_fury_options(const char *arg)
}
#endif
+#ifdef USE_HASHFAST
+static char *set_hfa_options(const char *arg)
+{
+ opt_set_charp(arg, &opt_hfa_options);
+
+ return NULL;
+}
+#endif
+
#ifdef USE_KLONDIKE
static char *set_klondike_options(const char *arg)
{
@@ -1365,6 +1374,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--hfa-ntime-roll",
opt_set_intval, NULL, &opt_hfa_ntime_roll,
opt_hidden),
+ OPT_WITH_ARG("--hfa-options",
+ set_hfa_options, NULL, NULL,
+ "Set hashfast options name:clock (comma separated)"),
OPT_WITHOUT_ARG("--hfa-pll-bypass",
opt_set_bool, &opt_hfa_pll_bypass,
opt_hidden),
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 15bf6d4..9ba1d9a 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -31,6 +31,7 @@ int opt_hfa_fail_drop = 10;
bool opt_hfa_noshed;
char *opt_hfa_name;
+char *opt_hfa_options;
////////////////////////////////////////////////////////////////////////////////
// Support for the CRC's used in header (CRC-8) and packet body (CRC-32)
@@ -627,6 +628,60 @@ static void hfa_set_clock(struct cgpu_info *hashfast, struct hashfast_info *info
info->die_data[i].hash_clock = info->base_clock;
}
+/* Look for an op name match and apply any options to its first attempted
+ * init sequence. This function allows any arbitrary number of extra parameters
+ * to be added in the future. */
+static void hfa_check_options(struct hashfast_info *info)
+{
+ char *p, *options, *found = NULL;
+ int maxlen, option = 0;
+
+ if (!opt_hfa_options)
+ return;
+
+ if (!info->op_name)
+ return;
+
+ maxlen = strlen(info->op_name);
+
+ options = strdup(opt_hfa_options);
+ for (p = strtok(options, ","); p; p = strtok(NULL, ",")) {
+ int cmplen = strlen(p);
+
+ if (maxlen < cmplen)
+ cmplen = maxlen;
+ if (cmplen < maxlen)
+ continue;
+ if (!strncmp(info->op_name, p, cmplen)) {
+ found = strdup(p);
+ break;
+ }
+ }
+ free(options);
+ if (!found)
+ return;
+
+ for (p = strtok(found, ":"); p; p = strtok(NULL, ":")) {
+ long lval;
+
+ /* Parse each option in order, leaving room to add more */
+ switch(option++) {
+ default:
+ break;
+ case 1:
+ lval = strtol(p, NULL, 10);
+ if (lval < HFA_CLOCK_MIN || lval > HFA_CLOCK_MAX) {
+ applog(LOG_ERR, "Invalid clock speed %ld set with hashfast option for %s",
+ lval, info->op_name);
+ break;
+ }
+ info->hash_clock_rate = lval;
+ break;
+ }
+ }
+ free(found);
+}
+
static bool hfa_detect_common(struct cgpu_info *hashfast)
{
struct hashfast_info *info;
@@ -700,6 +755,7 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
} else {
applog(LOG_NOTICE, "%s: Found device with name %s", hashfast->drv->name,
info->op_name);
+ hfa_check_options(info);
}
}
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 1a71f58..d204c83 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -30,10 +30,12 @@ bool opt_hfa_noshed;
char *set_hfa_fan(char *arg);
char *opt_hfa_name;
+char *opt_hfa_options;
#define HASHFAST_MINER_THREADS 1
#define HFA_CLOCK_DEFAULT 550
#define HFA_CLOCK_MIN 125
+#define HFA_CLOCK_MAX 1000
#define HFA_CLOCK_MAXDIFF 100
#define HFA_TEMP_OVERHEAT 95
#define HFA_TEMP_TARGET 88