Add config for vendor and device

This commit is contained in:
Marc Di Luzio 2019-01-31 17:35:18 +00:00
parent 8d4e9ac54e
commit cee2351c55
6 changed files with 33 additions and 5 deletions

View File

@ -77,6 +77,8 @@ struct GameModeConfig {
long reaper_frequency; long reaper_frequency;
long apply_gpu_optimisations; long apply_gpu_optimisations;
long gpu_vendor;
long gpu_device;
long nv_core_clock_mhz_offset; long nv_core_clock_mhz_offset;
long nv_mem_clock_mhz_offset; long nv_mem_clock_mhz_offset;
long amd_core_clock_percentage; long amd_core_clock_percentage;
@ -183,6 +185,10 @@ static int inih_handler(void *user, const char *section, const char *name, const
/* GPU subsection */ /* GPU subsection */
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) {
valid = get_long_value(name, value, &self->gpu_device);
} else if (strcmp(name, "gpu_device") == 0) {
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) {
valid = get_long_value(name, value, &self->nv_core_clock_mhz_offset); valid = get_long_value(name, value, &self->nv_core_clock_mhz_offset);
} else if (strcmp(name, "nv_mem_clock_mhz_offset") == 0) { } else if (strcmp(name, "nv_mem_clock_mhz_offset") == 0) {
@ -254,6 +260,8 @@ static void load_config_files(GameModeConfig *self)
self->reaper_frequency = DEFAULT_REAPER_FREQ; self->reaper_frequency = DEFAULT_REAPER_FREQ;
self->inhibit_screensaver = 1; /* Defaults to on */ self->inhibit_screensaver = 1; /* Defaults to on */
self->apply_gpu_optimisations = 0; self->apply_gpu_optimisations = 0;
self->gpu_vendor = 0;
self->gpu_device = 0;
self->nv_core_clock_mhz_offset = 0; self->nv_core_clock_mhz_offset = 0;
self->nv_mem_clock_mhz_offset = 0; self->nv_mem_clock_mhz_offset = 0;
self->amd_core_clock_percentage = 0; self->amd_core_clock_percentage = 0;
@ -494,6 +502,16 @@ void config_get_apply_gpu_optimisations(GameModeConfig *self, long *value)
memcpy_locked_config(self, value, &self->apply_gpu_optimisations, sizeof(long)); memcpy_locked_config(self, value, &self->apply_gpu_optimisations, sizeof(long));
} }
void config_get_gpu_vendor(GameModeConfig *self, long *value)
{
memcpy_locked_config(self, value, &self->gpu_vendor, sizeof(long));
}
void config_get_gpu_device(GameModeConfig *self, long *value)
{
memcpy_locked_config(self, value, &self->gpu_device, sizeof(long));
}
void config_get_nv_core_clock_mhz_offset(GameModeConfig *self, long *value) void config_get_nv_core_clock_mhz_offset(GameModeConfig *self, long *value)
{ {
memcpy_locked_config(self, value, &self->nv_core_clock_mhz_offset, sizeof(long)); memcpy_locked_config(self, value, &self->nv_core_clock_mhz_offset, sizeof(long));

View File

@ -134,6 +134,8 @@ void config_get_ioprio_value(GameModeConfig *self, int *value);
* Get various config info for gpu optimisations * Get various config info for gpu optimisations
*/ */
void config_get_apply_gpu_optimisations(GameModeConfig *self, long *value); void config_get_apply_gpu_optimisations(GameModeConfig *self, long *value);
void config_get_gpu_vendor(GameModeConfig *self, long *value);
void config_get_gpu_device(GameModeConfig *self, long *value);
void config_get_nv_core_clock_mhz_offset(GameModeConfig *self, long *value); void config_get_nv_core_clock_mhz_offset(GameModeConfig *self, long *value);
void config_get_nv_mem_clock_mhz_offset(GameModeConfig *self, long *value); void config_get_nv_mem_clock_mhz_offset(GameModeConfig *self, long *value);
void config_get_amd_core_clock_percentage(GameModeConfig *self, long *value); void config_get_amd_core_clock_percentage(GameModeConfig *self, long *value);

View File

@ -68,7 +68,11 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
GameModeGPUInfo *new_info = malloc(sizeof(GameModeGPUInfo)); GameModeGPUInfo *new_info = malloc(sizeof(GameModeGPUInfo));
memset(new_info, 0, sizeof(GameModeGPUInfo)); memset(new_info, 0, sizeof(GameModeGPUInfo));
// TODO: Fill in the GPU vendor and device // TODO: Fill in the GPU vendor and device automatically
/* Get the config parameters */
config_get_gpu_vendor(config, &new_info->vendor);
config_get_gpu_device(config, &new_info->device);
/* Load the config based on GPU */ /* Load the config based on GPU */
switch (new_info->vendor) { switch (new_info->vendor) {

View File

@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
* Get the gpu state * Get the gpu state
* Populates the struct with the GPU info on the system * Populates the struct with the GPU info on the system
*/ */
int get_gpu_state( struct GameModeGPUInfo* info ) int get_gpu_state(struct GameModeGPUInfo *info)
{ {
return 0; return 0;
} }
@ -58,7 +58,7 @@ int get_gpu_state( struct GameModeGPUInfo* info )
* Set the gpu state based on input parameters * Set the gpu state based on input parameters
* Only works when run as root * Only works when run as root
*/ */
int set_gpu_state( struct GameModeGPUInfo* info ) int set_gpu_state(struct GameModeGPUInfo *info)
{ {
return 0; return 0;
} }

View File

@ -52,10 +52,10 @@ struct GameModeGPUInfo {
* Get the gpu state * Get the gpu state
* Populates the struct with the GPU info on the system * Populates the struct with the GPU info on the system
*/ */
int get_gpu_state( struct GameModeGPUInfo* info ); int get_gpu_state(struct GameModeGPUInfo *info);
/** /**
* Set the gpu state based on input parameters * Set the gpu state based on input parameters
* Only works when run as root * Only works when run as root
*/ */
int set_gpu_state( struct GameModeGPUInfo* info ); int set_gpu_state(struct GameModeGPUInfo *info);

View File

@ -42,6 +42,10 @@ inhibit_screensaver=1
; Setting this to 1 will allow gamemode to attempt to apply GPU optimisations such as overclocks ; Setting this to 1 will allow gamemode to attempt to apply GPU optimisations such as overclocks
;apply_gpu_optimisations=0 ;apply_gpu_optimisations=0
; Set these to specify which vendor and device ID you want apply optimisations to
;gpu_vendor=0x0000
;gpu_device=0
; Nvidia specific settings (these are Mhz offsets from the baseline, ie. 0 applies no change) ; Nvidia specific settings (these are Mhz offsets from the baseline, ie. 0 applies no change)
;nv_core_clock_mhz_offset=0 ;nv_core_clock_mhz_offset=0
;nv_mem_clock_mhz_offset=0 ;nv_mem_clock_mhz_offset=0