Browse Source

Merge branch 'tui_clock' into bfgminer

Luke Dashjr 10 years ago
parent
commit
148b0e8057
6 changed files with 131 additions and 0 deletions
  1. 30 0
      driver-aan.c
  2. 4 0
      driver-aan.h
  3. 26 0
      driver-antminer.c
  4. 42 0
      driver-avalon.c
  5. 23 0
      driver-hashfast.c
  6. 6 0
      driver-jingtian.c

+ 30 - 0
driver-aan.c

@@ -643,3 +643,33 @@ const struct bfg_set_device_definition aan_set_device_funcs[] = {
 	{"diff", aan_set_diff, "desired nonce difficulty"},
 	{NULL},
 };
+
+#ifdef HAVE_CURSES
+void aan_wlogprint_status(struct cgpu_info * const proc)
+{
+	struct thr_info * const thr = proc->thr[0];
+	struct aan_chip_data * const chip = thr->cgpu_data;
+	
+	const double mhz = aan_pll2freq(chip->current_pllreg);
+	wlogprint("Clock speed: %lu\n", (unsigned long)mhz);
+}
+
+void aan_tui_wlogprint_choices(struct cgpu_info * const proc)
+{
+	wlogprint("[C]lock speed ");
+}
+
+const char *aan_tui_handle_choice(struct cgpu_info * const proc, const int input)
+{
+	switch (input)
+	{
+		case 'c': case 'C':
+		{
+			char prompt[0x80];
+			snprintf(prompt, sizeof(prompt), "Set clock speed (%u-%lu)", 1, (unsigned long)AAN_MAX_FREQ);
+			return proc_set_device_tui_wrapper(proc, NULL, aan_set_clock, prompt, NULL);
+		}
+	}
+	return NULL;
+}
+#endif

+ 4 - 0
driver-aan.h

@@ -47,4 +47,8 @@ extern const struct bfg_set_device_definition aan_set_device_funcs[];
 
 extern struct api_data *aan_api_device_status(struct cgpu_info *);
 
+extern void aan_wlogprint_status(struct cgpu_info *proc);
+extern void aan_tui_wlogprint_choices(struct cgpu_info *proc);
+extern const char *aan_tui_handle_choice(struct cgpu_info *proc, int input);
+
 #endif

+ 26 - 0
driver-antminer.c

@@ -312,6 +312,28 @@ const struct bfg_set_device_definition antminer_set_device_funcs[] = {
 	{NULL},
 };
 
+#ifdef HAVE_CURSES
+static
+void antminer_tui_wlogprint_choices(struct cgpu_info * const proc)
+{
+	struct ICARUS_INFO * const info = proc->device_data;
+	
+	if (info->has_bm1382_freq_register)
+		wlogprint("[C]lock speed ");
+}
+
+static
+const char *antminer_tui_handle_choice(struct cgpu_info * const proc, const int input)
+{
+	switch (input)
+	{
+		case 'c': case 'C':
+			return proc_set_device_tui_wrapper(proc, NULL, antminer_set_clock, "Set clock speed", NULL);
+	}
+	return NULL;
+}
+#endif
+
 static
 bool compac_lowl_match(const struct lowlevel_device_info * const info)
 {
@@ -338,6 +360,10 @@ void antminer_drv_init()
 	antminer_drv.lowl_match = antminer_lowl_match;
 	antminer_drv.lowl_probe = antminer_lowl_probe;
 	antminer_drv.identify_device = antminer_identify;
+#ifdef HAVE_CURSES
+	antminer_drv.proc_tui_wlogprint_choices = antminer_tui_wlogprint_choices;
+	antminer_drv.proc_tui_handle_choice = antminer_tui_handle_choice;
+#endif
 	++antminer_drv.probe_priority;
 	
 	compac_drv = antminer_drv;

+ 42 - 0
driver-avalon.c

@@ -494,6 +494,42 @@ const struct bfg_set_device_definition avalon_set_device_funcs[] = {
 	{NULL},
 };
 
+#ifdef HAVE_CURSES
+static
+void avalon_wlogprint_status(struct cgpu_info * const proc)
+{
+	struct avalon_info *info = proc->device_data;
+	
+	if (((info->temp0?1:0) + (info->temp1?1:0) + (info->temp2?1:0)) > 1)
+	{
+		wlogprint("Temperatures:");
+		if (info->temp0)  wlogprint(" %uC", (unsigned)info->temp0);
+		if (info->temp1)  wlogprint(" %uC", (unsigned)info->temp1);
+		if (info->temp2)  wlogprint(" %uC", (unsigned)info->temp2);
+	}
+	wlogprint("\n");
+	
+	wlogprint("Clock speed: %d\n", info->frequency);
+}
+
+static
+void avalon_tui_wlogprint_choices(struct cgpu_info * const proc)
+{
+	wlogprint("[C]lock speed ");
+}
+
+static
+const char *avalon_tui_handle_choice(struct cgpu_info * const proc, const int input)
+{
+	switch (input)
+	{
+		case 'c': case 'C':
+			return proc_set_device_tui_wrapper(proc, NULL, avalon_set_clock, "Set clock speed (256, 270, 282, 300, 325, 350, or 375)", NULL);
+	}
+	return NULL;
+}
+#endif
+
 /* Non blocking clearing of anything in the buffer */
 static void avalon_clear_readbuf(int fd)
 {
@@ -1006,4 +1042,10 @@ struct device_drv avalon_drv = {
 	.get_api_stats = avalon_api_stats,
 	.reinit_device = avalon_init,
 	.thread_shutdown = avalon_shutdown,
+	
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = avalon_wlogprint_status,
+	.proc_tui_wlogprint_choices = avalon_tui_wlogprint_choices,
+	.proc_tui_handle_choice = avalon_tui_handle_choice,
+#endif
 };

+ 23 - 0
driver-hashfast.c

@@ -844,6 +844,27 @@ void hashfast_wlogprint_status(struct cgpu_info * const proc)
 		}
 	}
 }
+
+static
+void hashfast_tui_wlogprint_choices(struct cgpu_info * const proc)
+{
+	wlogprint("[C]lock speed ");
+}
+
+static
+const char *hashfast_tui_handle_choice(struct cgpu_info * const proc, const int input)
+{
+	switch (input)
+	{
+		case 'c': case 'C':
+		{
+			char prompt[0x80];
+			snprintf(prompt, sizeof(prompt), "Set clock speed (%u-%u)", 1, 0xffe);
+			return proc_set_device_tui_wrapper(proc, NULL, hashfast_set_clock_runtime, prompt, NULL);
+		}
+	}
+	return NULL;
+}
 #endif
 
 struct device_drv hashfast_ums_drv = {
@@ -865,5 +886,7 @@ struct device_drv hashfast_ums_drv = {
 	
 #ifdef HAVE_CURSES
 	.proc_wlogprint_status = hashfast_wlogprint_status,
+	.proc_tui_wlogprint_choices = hashfast_tui_wlogprint_choices,
+	.proc_tui_handle_choice = hashfast_tui_handle_choice,
 #endif
 };

+ 6 - 0
driver-jingtian.c

@@ -245,4 +245,10 @@ struct device_drv jingtian_drv = {
 	.poll = aan_poll,
 	
 	.get_api_extra_device_status = aan_api_device_status,
+	
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = aan_wlogprint_status,
+	.proc_tui_wlogprint_choices = aan_tui_wlogprint_choices,
+	.proc_tui_handle_choice = aan_tui_handle_choice,
+#endif
 };