Error with invalid device or vendor values

This commit is contained in:
Marc Di Luzio 2019-01-31 18:25:46 +00:00
parent cee2351c55
commit fe9b5c8744
3 changed files with 25 additions and 5 deletions

View File

@ -261,7 +261,7 @@ static void load_config_files(GameModeConfig *self)
self->inhibit_screensaver = 1; /* Defaults to on */
self->apply_gpu_optimisations = 0;
self->gpu_vendor = 0;
self->gpu_device = 0;
self->gpu_device = -1; /* 0 is a valid device ID so use -1 to indicate no value */
self->nv_core_clock_mhz_offset = 0;
self->nv_mem_clock_mhz_offset = 0;
self->amd_core_clock_percentage = 0;

View File

@ -68,12 +68,31 @@ 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 automatically
/* Get the config parameters */
config_get_gpu_vendor(config, &new_info->vendor);
config_get_gpu_device(config, &new_info->device);
/* TODO: Detect the GPU vendor and device automatically when these aren't set */
/* verify device ID */
if (new_info->device == -1) {
LOG_ERROR("Invalid gpu_device value set in configuration, will not appli optimisations!\n");
free(new_info);
return -1;
}
/* verify GPU vendor */
if (new_info->vendor != Vendor_NVIDIA && new_info->vendor != Vendor_AMD &&
new_info->vendor != Vendor_Intel) {
LOG_ERROR("Invalid gpu_vendor value set in configuration, will not apply optimisations!\n");
LOG_ERROR("Possible values are: 0x%04x (NVIDIA) 0x%04x (AMD) 0x%04x (Intel)\n",
Vendor_NVIDIA,
Vendor_AMD,
Vendor_Intel);
free(new_info);
return -1;
}
/* Load the config based on GPU */
switch (new_info->vendor) {
case Vendor_NVIDIA:
@ -87,6 +106,7 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info)
default:
break;
}
/* TODO : Sanity check these values */
/* Give back the new gpu info */
*info = new_info;

View File

@ -41,8 +41,8 @@ enum GPUVendor {
/* Storage for GPU info*/
struct GameModeGPUInfo {
enum GPUVendor vendor;
int device; /* path to device, ie. /sys/class/drm/card#/ */
long vendor;
long device; /* path to device, ie. /sys/class/drm/card#/ */
long core; /* Core clock to apply */
long mem; /* Mem clock to apply */