Browse Source

minion: TUI clock speed control

Luke Dashjr 11 years ago
parent
commit
ce3ae49119
1 changed files with 51 additions and 0 deletions
  1. 51 0
      driver-minion.c

+ 51 - 0
driver-minion.c

@@ -552,6 +552,51 @@ static const struct bfg_set_device_definition minion_set_device_funcs[] = {
 	{NULL},
 };
 
+#ifdef HAVE_CURSES
+static
+void minion_tui_wlogprint_choices(struct cgpu_info * const proc)
+{
+	wlogprint("[C]lock speed ");
+}
+
+static
+const char *minion_tui_handle_choice(struct cgpu_info * const proc, const int input)
+{
+	struct thr_info * const thr = proc->thr[0];
+	struct minion_chip * const chip = thr->cgpu_data;
+	char buf[0x100];
+	
+	switch (input)
+	{
+		case 'c': case 'C':
+		{
+			sprintf(buf, "Set clock speed (range %d-%d)", minion_min_clock, minion_max_clock);
+			const int nv = curses_int(buf);
+			if (nv < minion_min_clock || nv > minion_max_clock)
+				return "Invalid clock speed\n";
+			
+			const uint32_t pllcfg = minion_freq_to_pllcfg(nv);
+			chip->pllcfg_desired = pllcfg;
+			
+			return "Clock speed changed\n";
+		}
+	}
+	
+	return NULL;
+}
+
+static
+void minion_wlogprint_status(struct cgpu_info * const proc)
+{
+	struct thr_info * const thr = proc->thr[0];
+	struct minion_chip * const chip = thr->cgpu_data;
+	
+	const unsigned freq = minion_pllcfg_to_freq(chip->pllcfg_asserted);
+	if (freq)
+		wlogprint("Clock speed: %u\n", freq);
+}
+#endif
+
 BFG_REGISTER_DRIVER(minion_drv)
 
 static
@@ -622,4 +667,10 @@ struct device_drv minion_drv = {
 	.poll = minion_poll,
 	
 	.get_api_extra_device_status = minion_get_api_extra_device_status,
+	
+#ifdef HAVE_CURSES
+	.proc_wlogprint_status = minion_wlogprint_status,
+	.proc_tui_wlogprint_choices = minion_tui_wlogprint_choices,
+	.proc_tui_handle_choice = minion_tui_handle_choice,
+#endif
 };