Browse Source

bitfury: Provide read/write access to osc6_bits from the Manage TUI

Luke Dashjr 12 years ago
parent
commit
16a132f853
5 changed files with 69 additions and 2 deletions
  1. 6 0
      driver-bfsb.c
  2. 46 2
      driver-bitfury.c
  3. 5 0
      driver-bitfury.h
  4. 6 0
      driver-metabank.c
  5. 6 0
      driver-nanofury.c

+ 6 - 0
driver-bfsb.c

@@ -210,4 +210,10 @@ struct device_drv bfsb_drv = {
 	.thread_disable = bfsb_disable,
 	.thread_disable = bfsb_disable,
 	.thread_enable = bfsb_enable,
 	.thread_enable = bfsb_enable,
 	.thread_shutdown = bfsb_shutdown,
 	.thread_shutdown = bfsb_shutdown,
+	
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = bitfury_wlogprint_status,
+	.proc_tui_wlogprint_choices = bitfury_tui_wlogprint_choices,
+	.proc_tui_handle_choice = bitfury_tui_handle_choice,
+#endif
 };
 };

+ 46 - 2
driver-bitfury.c

@@ -30,6 +30,7 @@
 #include <sha2.h>
 #include <sha2.h>
 
 
 #include "deviceapi.h"
 #include "deviceapi.h"
+#include "driver-bitfury.h"
 #include "libbitfury.h"
 #include "libbitfury.h"
 #include "util.h"
 #include "util.h"
 #include "spidevc.h"
 #include "spidevc.h"
@@ -713,7 +714,7 @@ char *bitfury_set_device(struct cgpu_info * const proc, char * const option, cha
 	
 	
 	if (!strcasecmp(option, "help"))
 	if (!strcasecmp(option, "help"))
 	{
 	{
-		sprintf(replybuf, "baud: SPI baud rate\nosc6_bits: range 1-55 (slow to fast)");
+		sprintf(replybuf, "baud: SPI baud rate\nosc6_bits: range 1-%d (slow to fast)", BITFURY_MAX_OSC6_BITS);
 		return replybuf;
 		return replybuf;
 	}
 	}
 	
 	
@@ -728,7 +729,7 @@ char *bitfury_set_device(struct cgpu_info * const proc, char * const option, cha
 	if (!strcasecmp(option, "osc6_bits"))
 	if (!strcasecmp(option, "osc6_bits"))
 	{
 	{
 		newval = bitfury->osc6_bits;
 		newval = bitfury->osc6_bits;
-		if (!_bitfury_set_device_parse_setting(&newval, setting, replybuf, 55))
+		if (!_bitfury_set_device_parse_setting(&newval, setting, replybuf, BITFURY_MAX_OSC6_BITS))
 			return replybuf;
 			return replybuf;
 		
 		
 		bitfury->osc6_bits = newval;
 		bitfury->osc6_bits = newval;
@@ -741,6 +742,49 @@ char *bitfury_set_device(struct cgpu_info * const proc, char * const option, cha
 	return replybuf;
 	return replybuf;
 }
 }
 
 
+#ifdef HAVE_CURSES
+void bitfury_tui_wlogprint_choices(struct cgpu_info *cgpu)
+{
+	wlogprint("[O]scillator bits ");
+}
+
+const char *bitfury_tui_handle_choice(struct cgpu_info *cgpu, int input)
+{
+	struct bitfury_device * const bitfury = cgpu->device_data;
+	char buf[0x100];
+	
+	switch (input)
+	{
+		case 'o': case 'O':
+		{
+			int val;
+			char *intvar;
+			
+			sprintf(buf, "Set oscillator bits (range 1-%d; slow to fast)", BITFURY_MAX_OSC6_BITS);
+			intvar = curses_input(buf);
+			if (!intvar)
+				return "Invalid oscillator bits\n";
+			val = atoi(intvar);
+			free(intvar);
+			if (val < 1 || val > BITFURY_MAX_OSC6_BITS)
+				return "Invalid oscillator bits\n";
+			
+			bitfury->osc6_bits = val;
+			bitfury->force_reinit = true;
+			
+			return "Oscillator bits changing\n";
+		}
+	}
+	return NULL;
+}
+
+void bitfury_wlogprint_status(struct cgpu_info *cgpu)
+{
+	struct bitfury_device * const bitfury = cgpu->device_data;
+	wlogprint("Oscillator bits: %d\n", bitfury->osc6_bits);
+}
+#endif
+
 struct device_drv bitfury_drv = {
 struct device_drv bitfury_drv = {
 	.dname = "bitfury_gpio",
 	.dname = "bitfury_gpio",
 	.name = "BFY",
 	.name = "BFY",

+ 5 - 0
driver-bitfury.h

@@ -6,6 +6,8 @@
 
 
 #include "miner.h"
 #include "miner.h"
 
 
+#define BITFURY_MAX_OSC6_BITS  55
+
 extern bool bitfury_prepare(struct thr_info *);
 extern bool bitfury_prepare(struct thr_info *);
 extern bool bitfury_init_chip(struct cgpu_info *);
 extern bool bitfury_init_chip(struct cgpu_info *);
 
 
@@ -18,6 +20,9 @@ extern int64_t bitfury_job_process_results(struct thr_info *, struct work *, boo
 extern struct api_data *bitfury_api_device_detail(struct cgpu_info *);
 extern struct api_data *bitfury_api_device_detail(struct cgpu_info *);
 extern struct api_data *bitfury_api_device_status(struct cgpu_info *);
 extern struct api_data *bitfury_api_device_status(struct cgpu_info *);
 extern char *bitfury_set_device(struct cgpu_info *, char *, char *, char *);
 extern char *bitfury_set_device(struct cgpu_info *, char *, char *, char *);
+extern void bitfury_tui_wlogprint_choices(struct cgpu_info *);
+extern const char *bitfury_tui_handle_choice(struct cgpu_info *, int input);
+extern void bitfury_wlogprint_status(struct cgpu_info *);
 
 
 extern void bitfury_shutdown(struct thr_info *);
 extern void bitfury_shutdown(struct thr_info *);
 
 

+ 6 - 0
driver-metabank.c

@@ -241,4 +241,10 @@ struct device_drv metabank_drv = {
 	.get_api_extra_device_status = metabank_api_extra_device_status,
 	.get_api_extra_device_status = metabank_api_extra_device_status,
 	.get_stats = metabank_get_stats,
 	.get_stats = metabank_get_stats,
 	.set_device = bitfury_set_device,
 	.set_device = bitfury_set_device,
+	
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = bitfury_wlogprint_status,
+	.proc_tui_wlogprint_choices = bitfury_tui_wlogprint_choices,
+	.proc_tui_handle_choice = bitfury_tui_handle_choice,
+#endif
 };
 };

+ 6 - 0
driver-nanofury.c

@@ -293,4 +293,10 @@ struct device_drv nanofury_drv = {
 	.get_api_extra_device_detail = bitfury_api_device_detail,
 	.get_api_extra_device_detail = bitfury_api_device_detail,
 	.get_api_extra_device_status = bitfury_api_device_status,
 	.get_api_extra_device_status = bitfury_api_device_status,
 	.set_device = bitfury_set_device,
 	.set_device = bitfury_set_device,
+	
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = bitfury_wlogprint_status,
+	.proc_tui_wlogprint_choices = bitfury_tui_wlogprint_choices,
+	.proc_tui_handle_choice = bitfury_tui_handle_choice,
+#endif
 };
 };