Commit 8ae273c56c22b1ec5cfa06391e03f7ec52abf94d

Con Kolivas 2011-09-04T22:08:42

Implement setting the GPU voltage of all devices or each device as a comma separated value.

diff --git a/adl.c b/adl.c
index c8dd290..49aa7e0 100644
--- a/adl.c
+++ b/adl.c
@@ -230,6 +230,11 @@ void init_adl(int nDevs)
 			applog(LOG_INFO, "Setting GPU %d memory clock to %d", gpu, gpus[gpu].gpu_memclock);
 			ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels);
 		}
+		if (gpus[gpu].gpu_vddc) {
+			lpOdPerformanceLevels->aLevels[lev].iVddc = gpus[gpu].gpu_vddc * 1000;
+			applog(LOG_INFO, "Setting GPU %d voltage to %.3f", gpu, gpus[gpu].gpu_vddc);
+			ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels);
+		}
 		ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 0, lpOdPerformanceLevels);
 		ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
 		ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
diff --git a/main.c b/main.c
index 4cbad3f..c938aeb 100644
--- a/main.c
+++ b/main.c
@@ -1166,6 +1166,34 @@ static char *set_gpu_memclock(char *arg)
 	return NULL;
 }
 
+static char *set_gpu_vddc(char *arg)
+{
+	int i, device = 0;
+	float val = 0;
+	char *saveptr = NULL, *nextptr;
+
+	nextptr = strtok_r(arg, ",", &saveptr);
+	if (nextptr == NULL)
+		return "Invalid parameters for set gpu vddc";
+	val = atof(nextptr);
+	if (val <= 0 || val >= 9999)
+		return "Invalid value passed to set_gpu_vddc";
+
+	gpus[device++].gpu_vddc = val;
+
+	while ((nextptr = strtok_r(NULL, ",", &saveptr)) != NULL) {
+		val = atoi(nextptr);
+		if (val <= 0 || val >= 9999)
+			return "Invalid value passed to set_gpu_vddc";
+
+		gpus[device++].gpu_vddc = val;
+	}
+	for (i = device; i < 16; i++)
+		gpus[i].gpu_vddc = val;
+
+	return NULL;
+}
+
 #endif
 
 /* These options are available from config file or commandline */
@@ -1235,6 +1263,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--gpu-memclock",
 		     set_gpu_memclock, NULL, NULL,
 		     "Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card."),
+	OPT_WITH_ARG("--gpu-vddc",
+		     set_gpu_vddc, NULL, NULL,
+		     "Set the GPU voltage in Volts - one value for all or separate by commas for per card."),
 #endif
 	OPT_WITH_ARG("--intensity|-I",
 		     forced_int_1010, NULL, &scan_intensity,
diff --git a/miner.h b/miner.h
index 6988be4..c5477e5 100644
--- a/miner.h
+++ b/miner.h
@@ -200,6 +200,7 @@ struct cgpu_info {
 	struct gpu_adl adl;
 	int gpu_engine;
 	int gpu_memclock;
+	float gpu_vddc;
 #endif
 };