Commit c4b20cffdc44dae884dacf1c64fd0c108824ce93

Con Kolivas 2014-07-28T13:12:33

Store fan percentage and display temp and fan percent for ava2

diff --git a/driver-avalon2.c b/driver-avalon2.c
index ee9e0de..211bd9a 100644
--- a/driver-avalon2.c
+++ b/driver-avalon2.c
@@ -216,24 +216,23 @@ static void adjust_fan(struct avalon2_info *info)
 	int t;
 
 	if (unlikely(info->first < 2) || opt_avalon2_fan_fixed == FAN_FIXED) {
-		info->fan_pwm = get_fan_pwm(AVA2_DEFAULT_FAN_PWM);
+		info->fan_pct = AVA2_DEFAULT_FAN_PWM;
+		info->fan_pwm = get_fan_pwm(info->fan_pct);
 		return;
 	}
 
 	t = get_current_temp_max(info);
 
 	/* TODO: Add options for temperature range and fan adjust function */
-	if (t < 50) {
-		info->fan_pwm = get_fan_pwm(40);
-		return;
-	}
-
-	if (t > 70) {
-		info->fan_pwm = get_fan_pwm(100);
-		return;
-	}
+	if (t < 50)
+		info->fan_pct = 40;
+	else if (t > 70)
+		info->fan_pct = 70;
+	else
+		info->fan_pct = 3 * t - 110;
 
-	info->fan_pwm = get_fan_pwm(3 * t - 110);
+	info->fan_pwm = get_fan_pwm(info->fan_pct);
+	applog(LOG_ERR, "Fan pct %d", info->fan_pct);
 }
 
 static inline int mm_cmp_1404(struct avalon2_info *info, int modular)
@@ -1006,6 +1005,14 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 	return root;
 }
 
+static void avalon2_statline_before(char *buf, size_t bufsiz, struct cgpu_info *avalon2)
+{
+	struct avalon2_info *info = avalon2->device_data;
+	int temp = get_temp_max(info);
+
+	tailsprintf(buf, bufsiz, "%2dC %3d%%", temp, info->fan_pct);
+}
+
 static char *avalon2_set_device(struct cgpu_info *avalon2, char *option, char *setting, char *replybuf)
 {
 	int val;
@@ -1055,6 +1062,7 @@ struct device_drv avalon2_drv = {
 	.dname = "avalon2",
 	.name = "AV2",
 	.get_api_stats = avalon2_api_stats,
+	.get_statline_before = avalon2_statline_before,
 	.set_device = avalon2_set_device,
 	.drv_detect = avalon2_detect,
 	.reinit_device = avalon2_init,
diff --git a/driver-avalon2.h b/driver-avalon2.h
index 541e789..11b92c5 100644
--- a/driver-avalon2.h
+++ b/driver-avalon2.h
@@ -123,6 +123,7 @@ struct avalon2_info {
 	int power_good[AVA2_DEFAULT_MODULARS];
 
 	int fan_pwm;
+	int fan_pct;
 	int temp_max;
 
 	int fan[2 * AVA2_DEFAULT_MODULARS];