Set BFLSC fan speed coarsely to keep it under 60 or auto as per specs saying it tries to stay below 60.
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
diff --git a/driver-bflsc.c b/driver-bflsc.c
index d74085f..9cef357 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -116,6 +116,7 @@ struct bflsc_info {
bool shutdown;
bool flash_led;
bool not_first_work; // allow ignoring the first nonce error
+ bool fanauto;
};
#define BFLSC_XLINKHDR '@'
@@ -1799,6 +1800,29 @@ static int64_t bflsc_scanwork(struct thr_info *thr)
return ret;
}
+static void bflsc_set_fanspeed(struct cgpu_info *bflsc)
+{
+ struct bflsc_info *sc_info = (struct bflsc_info *)bflsc->device_data;
+ int amount, err;
+
+ if ((bflsc->temp <= 60 && sc_info->fanauto) ||
+ (bflsc->temp > 60 && !sc_info->fanauto))
+ return;
+
+ mutex_lock(&bflsc->device_mutex);
+ if (bflsc->temp > 60) {
+ write_to_dev(bflsc, 0, BFLSC_FAN4, BFLSC_FAN4_LEN, &amount,
+ C_SETFAN);
+ sc_info->fanauto = false;
+ } else {
+ write_to_dev(bflsc, 0, BFLSC_FANAUTO, BFLSC_FANOUT_LEN,
+ &amount, C_SETFAN);
+ sc_info->fanauto = true;
+ }
+ getok(bflsc, C_FANREPLY, &err, &amount);
+ mutex_unlock(&bflsc->device_mutex);
+}
+
static bool bflsc_get_stats(struct cgpu_info *bflsc)
{
struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
@@ -1821,6 +1845,8 @@ static bool bflsc_get_stats(struct cgpu_info *bflsc)
nmsleep(BFLSC_TEMP_SLEEPMS);
}
+ bflsc_set_fanspeed(bflsc);
+
return allok;
}
diff --git a/usbutils.c b/usbutils.c
index e1ff875..53430fa 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -517,6 +517,8 @@ static const char *C_SENDTESTWORK_S = "SendTestWork";
static const char *C_LATENCY_S = "SetLatency";
static const char *C_SETLINE_S = "SetLine";
static const char *C_VENDOR_S = "Vendor";
+static const char *C_SETFAN_S = "SetFan";
+static const char *C_FANREPLY_S = "GetFan";
static const char *C_AVALON_TASK_S = "AvalonTask";
static const char *C_AVALON_READ_S = "AvalonRead";
static const char *C_GET_AVALON_READY_S = "AvalonReady";
@@ -1002,6 +1004,8 @@ static void cgusb_check_init()
usb_commands[C_LATENCY] = C_LATENCY_S;
usb_commands[C_SETLINE] = C_SETLINE_S;
usb_commands[C_VENDOR] = C_VENDOR_S;
+ usb_commands[C_SETFAN] = C_SETFAN_S;
+ usb_commands[C_FANREPLY] = C_FANREPLY_S;
usb_commands[C_AVALON_TASK] = C_AVALON_TASK_S;
usb_commands[C_AVALON_READ] = C_AVALON_READ_S;
usb_commands[C_GET_AVALON_READY] = C_GET_AVALON_READY_S;
diff --git a/usbutils.h b/usbutils.h
index 2579dcd..199cbb1 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -240,6 +240,8 @@ enum usb_cmds {
C_LATENCY,
C_SETLINE,
C_VENDOR,
+ C_SETFAN,
+ C_FANREPLY,
C_AVALON_TASK,
C_AVALON_READ,
C_GET_AVALON_READY,