I successfully managed to get the display configuration using the NvAPI_DISP_GetDisplayConfig function three times in a row (as explained in another thread), and would now like to change the scaling option of one of my displays.
However even if I try not to change any setting (or just change the scaling option) and simply apply the retrieved pathInfo back, the NvAPI_DISP_SetDisplayConfig fails. Does someone have an idea why?
NvAPI_Status status = NVAPI_OK;
NvU32 deviceCount = 0;
NV_DISPLAYCONFIG_PATH_INFO_V2 * pathInfo = NULL;
status = NvAPI_Initialize();
if (status == NVAPI_OK) {
status = NvAPI_DISP_GetDisplayConfig(&deviceCount, pathInfo);
if ((status == NVAPI_OK) && (deviceCount > 0)) {
printf("\nFirst pass ok. \n");
pathInfo = new NV_DISPLAYCONFIG_PATH_INFO_V2[deviceCount];
for (int i = 0; i < deviceCount; i++)
{
pathInfo[i].targetInfo = 0;
pathInfo[i].targetInfoCount = 0;
pathInfo[i].version = NV_DISPLAYCONFIG_PATH_INFO_VER2;
pathInfo[i].sourceModeInfo = 0;
pathInfo[i].reserved = 0;
}
status = NvAPI_DISP_GetDisplayConfig(&deviceCount, pathInfo);
if (status == NVAPI_OK) {
printf("\nSecond pass ok. \n");
for (int i = 0; i < deviceCount; i++)
{
pathInfo[i].sourceModeInfo = new NV_DISPLAYCONFIG_SOURCE_MODE_INFO_V1;
pathInfo[i].sourceModeInfo->reserved = 0;
pathInfo[i].targetInfo = new NV_DISPLAYCONFIG_PATH_TARGET_INFO_V2[pathInfo[i].targetInfoCount];
for (int j = 0; j < pathInfo[i].targetInfoCount; j++) {
pathInfo[i].targetInfo[j].details = new NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_V1;
pathInfo[i].targetInfo[j].details->version = NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_VER1;
pathInfo[i].targetInfo[j].details->reserved = 0;
}
}
}
status = NvAPI_DISP_GetDisplayConfig(&deviceCount, pathInfo);
if (status == NVAPI_OK) {
printf("\nThird pass ok. \n");
}
for (int i = 0; i < deviceCount; i++)
{
for (int j = 0; j < pathInfo[i].targetInfoCount; j++) {
switch(pathInfo[i].targetInfo[j].details->scaling)
{
case NV_SCALING_DEFAULT:
printf("Default");
break;
case NV_SCALING_GPU_SCALING_TO_CLOSEST:
printf("GPU Scaling to closest");
break;
case NV_SCALING_GPU_SCALING_TO_NATIVE :
printf("GPU scaling to native");
break;
case NV_SCALING_GPU_SCANOUT_TO_NATIVE :
printf("Gpu scanout to native");
break;
case NV_SCALING_GPU_SCALING_TO_ASPECT_SCANOUT_TO_NATIVE :
printf("GPU scaling to aspect scanout to native");
break;
case NV_SCALING_GPU_SCALING_TO_ASPECT_SCANOUT_TO_CLOSEST :
printf("Gpu scaling to aspect scanout to closest");
break;
case NV_SCALING_GPU_SCANOUT_TO_CLOSEST :
printf("Gpu scanout to closest");
break;
case NV_SCALING_CUSTOMIZED :
printf("Scaling customized");
default:
printf("Nothing");
break;
}
}
}
//FAILS !!!!!!!!!!
status = NvAPI_DISP_SetDisplayConfig(deviceCount,pathInfo,NV_DISPLAYCONFIG_VALIDATE_ONLY );
}
}
Any help would be greatly apreciated, thank you very much!