Skip to content

Commit 8a6168f

Browse files
ystarnaudtroky
authored andcommitted
Fix for UI/API intensity changes
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.
1 parent 42737ac commit 8a6168f

9 files changed

+372
-47
lines changed

api.c

+67
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ struct CODES codes[] = {
143143
{ SEVERITY_ERR, MSG_NOGPUADL,PARAM_GPU, "GPU %d does not have ADL" },
144144
{ SEVERITY_ERR, MSG_INVINT, PARAM_STR, "Invalid intensity (%s) - must be '" _DYNAMIC "' or range " MIN_INTENSITY_STR " - " MAX_INTENSITY_STR },
145145
{ SEVERITY_INFO, MSG_GPUINT, PARAM_BOTH, "GPU %d set new intensity to %s" },
146+
{ SEVERITY_ERR, MSG_INVXINT, PARAM_STR, "Invalid xintensity (%s) - must be range " MIN_XINTENSITY_STR " - " MAX_XINTENSITY_STR },
147+
{ SEVERITY_INFO, MSG_GPUXINT, PARAM_BOTH, "GPU %d set new xintensity to %s" },
148+
{ SEVERITY_ERR, MSG_INVRAWINT, PARAM_STR, "Invalid rawintensity (%s) - must be range " MIN_RAWINTENSITY_STR " - " MAX_RAWINTENSITY_STR },
149+
{ SEVERITY_INFO, MSG_GPURAWINT, PARAM_BOTH, "GPU %d set new rawintensity to %s" },
146150
{ SEVERITY_SUCC, MSG_MINECONFIG,PARAM_NONE, "sgminer config" },
147151
{ SEVERITY_ERR, MSG_GPUMERR, PARAM_BOTH, "Setting GPU %d memoryclock to (%s) reported failure" },
148152
{ SEVERITY_SUCC, MSG_GPUMEM, PARAM_BOTH, "Setting GPU %d memoryclock to (%s) reported success" },
@@ -2329,12 +2333,73 @@ static void gpuintensity(struct io_data *io_data, __maybe_unused SOCKETTYPE c, c
23292333

23302334
gpus[id].dynamic = false;
23312335
gpus[id].intensity = intensity;
2336+
gpus[id].xintensity = 0;
2337+
gpus[id].rawintensity = 0;
23322338
sprintf(intensitystr, "%d", intensity);
23332339
}
23342340

2341+
// fix config with new settings so that we can save them
2342+
update_config_intensity(get_gpu_profile(id));
2343+
23352344
message(io_data, MSG_GPUINT, id, intensitystr, isjson);
23362345
}
23372346

2347+
static void gpuxintensity(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
2348+
{
2349+
int id;
2350+
char *value;
2351+
int intensity;
2352+
char intensitystr[7];
2353+
2354+
if (!splitgpuvalue(io_data, param, &id, &value, isjson))
2355+
return;
2356+
2357+
intensity = atoi(value);
2358+
if (intensity < MIN_XINTENSITY || intensity > MAX_XINTENSITY) {
2359+
message(io_data, MSG_INVXINT, 0, value, isjson);
2360+
return;
2361+
}
2362+
2363+
gpus[id].dynamic = false;
2364+
gpus[id].intensity = 0;
2365+
gpus[id].xintensity = intensity;
2366+
gpus[id].rawintensity = 0;
2367+
sprintf(intensitystr, "%d", intensity);
2368+
2369+
// fix config with new settings so that we can save them
2370+
update_config_xintensity(get_gpu_profile(id));
2371+
2372+
message(io_data, MSG_GPUXINT, id, intensitystr, isjson);
2373+
}
2374+
2375+
static void gpurawintensity(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
2376+
{
2377+
int id;
2378+
char *value;
2379+
int intensity;
2380+
char intensitystr[16];
2381+
2382+
if (!splitgpuvalue(io_data, param, &id, &value, isjson))
2383+
return;
2384+
2385+
intensity = atoi(value);
2386+
if (intensity < MIN_RAWINTENSITY || intensity > MAX_RAWINTENSITY) {
2387+
message(io_data, MSG_INVRAWINT, 0, value, isjson);
2388+
return;
2389+
}
2390+
2391+
gpus[id].dynamic = false;
2392+
gpus[id].intensity = 0;
2393+
gpus[id].xintensity = 0;
2394+
gpus[id].rawintensity = intensity;
2395+
sprintf(intensitystr, "%d", intensity);
2396+
2397+
// fix config with new settings so that we can save them
2398+
update_config_rawintensity(get_gpu_profile(id));
2399+
2400+
message(io_data, MSG_GPURAWINT, id, intensitystr, isjson);
2401+
}
2402+
23382403
static void gpumem(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
23392404
{
23402405
#ifdef HAVE_ADL
@@ -2929,6 +2994,8 @@ struct CMDS {
29292994
{ "addprofile", api_profile_add, true, false },
29302995
{ "removeprofile", api_profile_remove, true, false },
29312996
{ "gpuintensity", gpuintensity, true, false },
2997+
{ "gpuxintensity", gpuxintensity, true, false },
2998+
{ "gpurawintensity", gpurawintensity, true, false },
29322999
{ "gpumem", gpumem, true, false },
29333000
{ "gpuengine", gpuengine, true, false },
29343001
{ "gpufan", gpufan, true, false },

api.h

+5
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@
181181

182182
#define MSG_CHPOOLPR 139
183183

184+
#define MSG_INVXINT 140
185+
#define MSG_GPUXINT 141
186+
#define MSG_INVRAWINT 142
187+
#define MSG_GPURAWINT 143
188+
184189
enum code_severity {
185190
SEVERITY_ERR,
186191
SEVERITY_WARN,

0 commit comments

Comments
 (0)