Commit 49482b1b0cdcfe6b4a7ed6f16542abb65440f07b

ckolivas 2014-02-05T11:37:11

Allow hfa fanspeed to be set via command line.

diff --git a/cgminer.c b/cgminer.c
index 3df3b53..f45d469 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1228,6 +1228,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--hfa-hash-clock",
 		     set_int_0_to_9999, opt_show_intval, &opt_hfa_hash_clock,
 		     "Set hashfast clock speed"),
+	OPT_WITH_ARG("--hfa-fan",
+		     set_hfa_fan, NULL, NULL,
+		     "Set fanspeed percentage for hashfast, single value or range (default: 10-85)"),
 	OPT_WITH_ARG("--hfa-ntime-roll",
 		     opt_set_intval, NULL, &opt_hfa_ntime_roll,
 		     opt_hidden),
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 3050067..afd8f65 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -36,6 +36,26 @@ int opt_hfa_fan_min = HFA_FAN_MIN;
 #define DI8  0x07
 
 static bool hfa_crc8_set;
+
+char *set_hfa_fan(char *arg)
+{
+	int val1, val2, ret;
+
+	ret = sscanf(arg, "%d-%d", &val1, &val2);
+	if (ret < 1)
+		return "No values passed to hfa-fan";
+	if (ret == 1)
+		val2 = val1;
+
+	if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100 || val2 < val1)
+		return "Invalid value passed to hfa-fan";
+
+	opt_hfa_fan_min = val1;
+	opt_hfa_fan_max = val2;
+
+	return NULL;
+}
+
 static unsigned char crc8_table[256];	/* CRC-8 table */
 
 static void hfa_init_crc8(void)
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 4aaf5ba..c2fa608 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -26,6 +26,8 @@ int opt_hfa_fan_default;
 int opt_hfa_fan_max;
 int opt_hfa_fan_min;
 
+char *set_hfa_fan(char *arg);
+
 #define HASHFAST_MINER_THREADS 1
 #define HFA_CLOCK_DEFAULT 550
 #define HFA_CLOCK_MIN 125