Skip to content

Commit

Permalink
Fix for UI/API intensity changes
Browse files Browse the repository at this point in the history
The API and UI functions to change intensity would update the gpu
settings directly without updating the config option strings. This
resulted in the intensity updates not saving in config files. This
update should resolve that problem.

Also added API functions to change xintensity and rawintensity.
  • Loading branch information
ystarnaud authored and troky committed Nov 19, 2014
1 parent 42737ac commit 8a6168f
Show file tree
Hide file tree
Showing 9 changed files with 372 additions and 47 deletions.
67 changes: 67 additions & 0 deletions api.c
Expand Up @@ -143,6 +143,10 @@ struct CODES codes[] = {
{ SEVERITY_ERR, MSG_NOGPUADL,PARAM_GPU, "GPU %d does not have ADL" },
{ SEVERITY_ERR, MSG_INVINT, PARAM_STR, "Invalid intensity (%s) - must be '" _DYNAMIC "' or range " MIN_INTENSITY_STR " - " MAX_INTENSITY_STR },
{ SEVERITY_INFO, MSG_GPUINT, PARAM_BOTH, "GPU %d set new intensity to %s" },
{ SEVERITY_ERR, MSG_INVXINT, PARAM_STR, "Invalid xintensity (%s) - must be range " MIN_XINTENSITY_STR " - " MAX_XINTENSITY_STR },
{ SEVERITY_INFO, MSG_GPUXINT, PARAM_BOTH, "GPU %d set new xintensity to %s" },
{ SEVERITY_ERR, MSG_INVRAWINT, PARAM_STR, "Invalid rawintensity (%s) - must be range " MIN_RAWINTENSITY_STR " - " MAX_RAWINTENSITY_STR },
{ SEVERITY_INFO, MSG_GPURAWINT, PARAM_BOTH, "GPU %d set new rawintensity to %s" },
{ SEVERITY_SUCC, MSG_MINECONFIG,PARAM_NONE, "sgminer config" },
{ SEVERITY_ERR, MSG_GPUMERR, PARAM_BOTH, "Setting GPU %d memoryclock to (%s) reported failure" },
{ SEVERITY_SUCC, MSG_GPUMEM, PARAM_BOTH, "Setting GPU %d memoryclock to (%s) reported success" },
Expand Down Expand Up @@ -2329,12 +2333,73 @@ static void gpuintensity(struct io_data *io_data, __maybe_unused SOCKETTYPE c, c

gpus[id].dynamic = false;
gpus[id].intensity = intensity;
gpus[id].xintensity = 0;
gpus[id].rawintensity = 0;
sprintf(intensitystr, "%d", intensity);
}

// fix config with new settings so that we can save them
update_config_intensity(get_gpu_profile(id));

message(io_data, MSG_GPUINT, id, intensitystr, isjson);
}

static void gpuxintensity(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
{
int id;
char *value;
int intensity;
char intensitystr[7];

if (!splitgpuvalue(io_data, param, &id, &value, isjson))
return;

intensity = atoi(value);
if (intensity < MIN_XINTENSITY || intensity > MAX_XINTENSITY) {
message(io_data, MSG_INVXINT, 0, value, isjson);
return;
}

gpus[id].dynamic = false;
gpus[id].intensity = 0;
gpus[id].xintensity = intensity;
gpus[id].rawintensity = 0;
sprintf(intensitystr, "%d", intensity);

// fix config with new settings so that we can save them
update_config_xintensity(get_gpu_profile(id));

message(io_data, MSG_GPUXINT, id, intensitystr, isjson);
}

static void gpurawintensity(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
{
int id;
char *value;
int intensity;
char intensitystr[16];

if (!splitgpuvalue(io_data, param, &id, &value, isjson))
return;

intensity = atoi(value);
if (intensity < MIN_RAWINTENSITY || intensity > MAX_RAWINTENSITY) {
message(io_data, MSG_INVRAWINT, 0, value, isjson);
return;
}

gpus[id].dynamic = false;
gpus[id].intensity = 0;
gpus[id].xintensity = 0;
gpus[id].rawintensity = intensity;
sprintf(intensitystr, "%d", intensity);

// fix config with new settings so that we can save them
update_config_rawintensity(get_gpu_profile(id));

message(io_data, MSG_GPURAWINT, id, intensitystr, isjson);
}

static void gpumem(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
{
#ifdef HAVE_ADL
Expand Down Expand Up @@ -2929,6 +2994,8 @@ struct CMDS {
{ "addprofile", api_profile_add, true, false },
{ "removeprofile", api_profile_remove, true, false },
{ "gpuintensity", gpuintensity, true, false },
{ "gpuxintensity", gpuxintensity, true, false },
{ "gpurawintensity", gpurawintensity, true, false },
{ "gpumem", gpumem, true, false },
{ "gpuengine", gpuengine, true, false },
{ "gpufan", gpufan, true, false },
Expand Down
5 changes: 5 additions & 0 deletions api.h
Expand Up @@ -181,6 +181,11 @@

#define MSG_CHPOOLPR 139

#define MSG_INVXINT 140
#define MSG_GPUXINT 141
#define MSG_INVRAWINT 142
#define MSG_GPURAWINT 143

enum code_severity {
SEVERITY_ERR,
SEVERITY_WARN,
Expand Down

0 comments on commit 8a6168f

Please sign in to comment.