mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 23:57:22 +02:00
Allow setting the device value with a hex string
Also stops erroring on 0 value longs
This commit is contained in:
parent
fe9b5c8744
commit
ad2c218ab3
@ -119,7 +119,7 @@ static bool append_value_to_list(const char *list_name, const char *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get a positive long value from a string
|
* Get a long value from a string
|
||||||
*/
|
*/
|
||||||
static bool get_long_value(const char *value_name, const char *value, long *output)
|
static bool get_long_value(const char *value_name, const char *value, long *output)
|
||||||
{
|
{
|
||||||
@ -129,7 +129,27 @@ static bool get_long_value(const char *value_name, const char *value, long *outp
|
|||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
LOG_ERROR("Config: %s overflowed, given [%s]\n", value_name, value);
|
LOG_ERROR("Config: %s overflowed, given [%s]\n", value_name, value);
|
||||||
return false;
|
return false;
|
||||||
} else if (config_value <= 0 || !(*value != '\0' && end && *end == '\0')) {
|
} else if (!(*value != '\0' && end && *end == '\0')) {
|
||||||
|
LOG_ERROR("Config: %s was invalid, given [%s]\n", value_name, value);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
*output = config_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Get a long value from a hex string
|
||||||
|
*/
|
||||||
|
static bool get_long_value_hex(const char *value_name, const char *value, long *output)
|
||||||
|
{
|
||||||
|
char *end = NULL;
|
||||||
|
long config_value = strtol(value, &end, 16);
|
||||||
|
|
||||||
|
if (errno == ERANGE) {
|
||||||
|
LOG_ERROR("Config: %s overflowed, given [%s]\n", value_name, value);
|
||||||
|
return false;
|
||||||
|
} else if (!(*value != '\0' && end && *end == '\0')) {
|
||||||
LOG_ERROR("Config: %s was invalid, given [%s]\n", value_name, value);
|
LOG_ERROR("Config: %s was invalid, given [%s]\n", value_name, value);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -186,7 +206,7 @@ static int inih_handler(void *user, const char *section, const char *name, const
|
|||||||
if (strcmp(name, "apply_gpu_optimisations") == 0) {
|
if (strcmp(name, "apply_gpu_optimisations") == 0) {
|
||||||
valid = get_long_value(name, value, &self->apply_gpu_optimisations);
|
valid = get_long_value(name, value, &self->apply_gpu_optimisations);
|
||||||
} else if (strcmp(name, "gpu_vendor") == 0) {
|
} else if (strcmp(name, "gpu_vendor") == 0) {
|
||||||
valid = get_long_value(name, value, &self->gpu_device);
|
valid = get_long_value_hex(name, value, &self->gpu_vendor);
|
||||||
} else if (strcmp(name, "gpu_device") == 0) {
|
} else if (strcmp(name, "gpu_device") == 0) {
|
||||||
valid = get_long_value(name, value, &self->gpu_device);
|
valid = get_long_value(name, value, &self->gpu_device);
|
||||||
} else if (strcmp(name, "nv_core_clock_mhz_offset") == 0) {
|
} else if (strcmp(name, "nv_core_clock_mhz_offset") == 0) {
|
||||||
|
@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "gpu-query.h"
|
#include "gpu-query.h"
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// Gather GPU type and information
|
// Gather GPU type and information automatically
|
||||||
// Allow override of vendor and device
|
|
||||||
// Apply Nvidia GPU settings (CoolBits will be needed)
|
// Apply Nvidia GPU settings (CoolBits will be needed)
|
||||||
// Apply AMD GPU settings (Will need user changing pwm1_enable)
|
// Apply AMD GPU settings (Will need user changing pwm1_enable)
|
||||||
// Intel?
|
// Intel?
|
||||||
@ -76,15 +75,18 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
|
|||||||
|
|
||||||
/* verify device ID */
|
/* verify device ID */
|
||||||
if (new_info->device == -1) {
|
if (new_info->device == -1) {
|
||||||
LOG_ERROR("Invalid gpu_device value set in configuration, will not appli optimisations!\n");
|
LOG_ERROR("Invalid gpu_device value set in configuration, will not apply optimisations!\n");
|
||||||
free(new_info);
|
free(new_info);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* verify GPU vendor */
|
/* verify GPU vendor */
|
||||||
if (new_info->vendor != Vendor_NVIDIA && new_info->vendor != Vendor_AMD &&
|
if (!(new_info->vendor == Vendor_NVIDIA || new_info->vendor == Vendor_AMD ||
|
||||||
new_info->vendor != Vendor_Intel) {
|
new_info->vendor == Vendor_Intel)) {
|
||||||
LOG_ERROR("Invalid gpu_vendor value set in configuration, will not apply optimisations!\n");
|
LOG_ERROR(
|
||||||
|
"Invalid gpu_vendor value (0x%04x) set in configuration, will not apply "
|
||||||
|
"optimisations!\n",
|
||||||
|
(unsigned int)new_info->vendor);
|
||||||
LOG_ERROR("Possible values are: 0x%04x (NVIDIA) 0x%04x (AMD) 0x%04x (Intel)\n",
|
LOG_ERROR("Possible values are: 0x%04x (NVIDIA) 0x%04x (AMD) 0x%04x (Intel)\n",
|
||||||
Vendor_NVIDIA,
|
Vendor_NVIDIA,
|
||||||
Vendor_AMD,
|
Vendor_AMD,
|
||||||
|
@ -43,6 +43,7 @@ inhibit_screensaver=1
|
|||||||
;apply_gpu_optimisations=0
|
;apply_gpu_optimisations=0
|
||||||
|
|
||||||
; Set these to specify which vendor and device ID you want apply optimisations to
|
; Set these to specify which vendor and device ID you want apply optimisations to
|
||||||
|
; Vendor must be one of 0x10de (NVIDIA), 0x1002 (AMD) or 0x8086 (Intel)
|
||||||
;gpu_vendor=0x0000
|
;gpu_vendor=0x0000
|
||||||
;gpu_device=0
|
;gpu_device=0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user