Browse Source

Add config for vendor and device

Marc Di Luzio 6 years ago
parent
commit
cee2351c55
6 changed files with 33 additions and 5 deletions
  1. 18 0
      daemon/daemon_config.c
  2. 2 0
      daemon/daemon_config.h
  3. 5 1
      daemon/gamemode-gpu.c
  4. 2 2
      daemon/gpu-query.c
  5. 2 2
      daemon/gpu-query.h
  6. 4 0
      example/gamemode.ini

+ 18 - 0
daemon/daemon_config.c

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

+ 2 - 0
daemon/daemon_config.h

@@ -134,6 +134,8 @@ void config_get_ioprio_value(GameModeConfig *self, int *value);
  * Get various config info for gpu optimisations
  */
 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_mem_clock_mhz_offset(GameModeConfig *self, long *value);
 void config_get_amd_core_clock_percentage(GameModeConfig *self, long *value);

+ 5 - 1
daemon/gamemode-gpu.c

@@ -68,7 +68,11 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
 	GameModeGPUInfo *new_info = malloc(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 */
 	switch (new_info->vendor) {

+ 2 - 2
daemon/gpu-query.c

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

+ 2 - 2
daemon/gpu-query.h

@@ -52,10 +52,10 @@ struct GameModeGPUInfo {
  * Get the gpu state
  * 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
  * Only works when run as root
  */
-int set_gpu_state( struct GameModeGPUInfo* info );
+int set_gpu_state(struct GameModeGPUInfo *info);

+ 4 - 0
example/gamemode.ini

@@ -42,6 +42,10 @@ inhibit_screensaver=1
 ; Setting this to 1 will allow gamemode to attempt to apply GPU optimisations such as overclocks
 ;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)
 ;nv_core_clock_mhz_offset=0
 ;nv_mem_clock_mhz_offset=0