Browse Source

gridseed: Add the ability to set clock speed via the TUI

Nate Woolls 11 years ago
parent
commit
8bc08057ee
1 changed files with 54 additions and 3 deletions
  1. 54 3
      driver-gridseed.c

+ 54 - 3
driver-gridseed.c

@@ -350,23 +350,28 @@ int64_t gridseed_scanhash(struct thr_info *thr, struct work *work, int64_t __may
 }
 }
 
 
 /*
 /*
- * specify settings / options
+ * specify settings / options via RPC or command line
  */
  */
 
 
 // support for --set-device
 // support for --set-device
 // must be set before probing the device
 // must be set before probing the device
 
 
 static
 static
-const char *gridseed_set_clock(struct cgpu_info * const device, const char * const option, const char * const setting, char * const replybuf, enum bfg_set_device_replytype * const success)
+void gridseed_set_clock_freq(struct cgpu_info * const device, int const val)
 {
 {
 	struct gc3355_info * const info = device->device_data;
 	struct gc3355_info * const info = device->device_data;
-	int val = atoi(setting);
 
 
 	if ((info->freq != val) &&                          // method called for each processor, we only want to set pll once
 	if ((info->freq != val) &&                          // method called for each processor, we only want to set pll once
 	    (device->device_fd > 0))                        // we may not be mining yet, in which case just store freq
 	    (device->device_fd > 0))                        // we may not be mining yet, in which case just store freq
 	    gc3355_set_pll_freq(device->device_fd, val);    // clock was set via RPC or TUI
 	    gc3355_set_pll_freq(device->device_fd, val);    // clock was set via RPC or TUI
 
 
 	info->freq = val;
 	info->freq = val;
+}
+
+static
+const char *gridseed_set_clock(struct cgpu_info * const device, const char * const option, const char * const setting, char * const replybuf, enum bfg_set_device_replytype * const success)
+{
+	gridseed_set_clock_freq(device, atoi(setting));
 
 
 	return NULL;
 	return NULL;
 }
 }
@@ -397,6 +402,45 @@ const struct bfg_set_device_definition gridseed_set_device_funcs_live[] = {
 	{ NULL },
 	{ NULL },
 };
 };
 
 
+/*
+ * specify settings / options via TUI
+ */
+
+#ifdef HAVE_CURSES
+static
+void gridseed_tui_wlogprint_choices(struct cgpu_info * const device)
+{
+	wlogprint("[C]lock speed ");
+}
+
+static
+const char *gridseed_tui_handle_choice(struct cgpu_info * const device, const int input)
+{
+	static char buf[0x100];  // Static for replies
+
+	switch (input)
+	{
+		case 'c': case 'C':
+		{
+			sprintf(buf, "Set clock speed");
+			char * const setting = curses_input(buf);
+
+			gridseed_set_clock_freq(device, atoi(setting));
+
+			return "Clock speed changed\n";
+		}
+	}
+	return NULL;
+}
+
+static
+void gridseed_wlogprint_status(struct cgpu_info * const device)
+{
+	struct gc3355_info * const info = device->device_data;
+	wlogprint("Clock speed: %d\n", info->freq);
+}
+#endif
+
 struct device_drv gridseed_drv =
 struct device_drv gridseed_drv =
 {
 {
 	// metadata
 	// metadata
@@ -418,4 +462,11 @@ struct device_drv gridseed_drv =
 	
 	
 	// teardown device
 	// teardown device
 	.thread_shutdown = gridseed_thread_shutdown,
 	.thread_shutdown = gridseed_thread_shutdown,
+
+	// TUI support - e.g. setting clock via UI
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = gridseed_wlogprint_status,
+	.proc_tui_wlogprint_choices = gridseed_tui_wlogprint_choices,
+	.proc_tui_handle_choice = gridseed_tui_handle_choice,
+#endif
 };
 };