Fixed inconsistent NVIDIA HDR display setting

THere was an unneeded check that prevented the NVIDIA HDR settings being applied when it should have been. This in turn meant that the display profile equality matching wasn't working as the applied display profile was sufficiently different to the one selected and applied that it wouldn't match, and would instead display the brand new profile interface. This has been corrected now.
This commit is contained in:
Terry MacDonald 2021-09-09 09:21:53 +12:00
parent 28a8f131b3
commit 6bd9898ea8
2 changed files with 31 additions and 35 deletions

View File

@ -56,8 +56,8 @@ namespace DisplayMagician.UIForms
// Apply the Profile // Apply the Profile
if (ProfileRepository.ApplyProfile(_selectedProfile) == ApplyProfileResult.Successful) if (ProfileRepository.ApplyProfile(_selectedProfile) == ApplyProfileResult.Successful)
{ {
/*logger.Error($"DisplayProfileForm/Apply_Click: Waiting 0.5 sec for the display to apply"); logger.Error($"DisplayProfileForm/Apply_Click: Waiting 0.5 sec for the display to apply");
System.Threading.Thread.Sleep(500);*/ System.Threading.Thread.Sleep(500);
ChangeSelectedProfile(_selectedProfile); ChangeSelectedProfile(_selectedProfile);
} }
} }

View File

@ -1250,40 +1250,36 @@ namespace DisplayMagicianShared.NVIDIA
// Now, we have the current HDR settings, and the existing HDR settings, so we go through and we attempt to set each display color settings // Now, we have the current HDR settings, and the existing HDR settings, so we go through and we attempt to set each display color settings
foreach (var wantedHdrColorData in displayConfig.HdrConfig.HdrColorData) foreach (var wantedHdrColorData in displayConfig.HdrConfig.HdrColorData)
{ {
// If we have HDR settings stored for the display, then attempt to set them // Now we set the HDR colour settings of the display
if (currentDisplayConfig.HdrConfig.HdrColorData.ContainsKey(wantedHdrColorData.Key)) NV_HDR_COLOR_DATA_V2 hdrColorData = wantedHdrColorData.Value;
NVStatus = NVImport.NvAPI_Disp_HdrColorControl(wantedHdrColorData.Key, ref hdrColorData);
if (NVStatus == NVAPI_STATUS.NVAPI_OK)
{ {
// Now we set the HDR colour settings of the display SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: NvAPI_Disp_HdrColorControl returned OK. We just successfully set the HDR mode to {hdrColorData.HdrMode.ToString("G")}");
NV_HDR_COLOR_DATA_V2 hdrColorData = wantedHdrColorData.Value; }
NVStatus = NVImport.NvAPI_Disp_HdrColorControl(wantedHdrColorData.Key, ref hdrColorData); else if (NVStatus == NVAPI_STATUS.NVAPI_INSUFFICIENT_BUFFER)
if (NVStatus == NVAPI_STATUS.NVAPI_OK) {
{ SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input buffer is not large enough to hold it's contents. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}");
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: NvAPI_Disp_HdrColorControl returned OK. We just successfully set the HDR mode to {hdrColorData.HdrMode.ToString("G")}"); }
} else if (NVStatus == NVAPI_STATUS.NVAPI_INVALID_DISPLAY_ID)
else if (NVStatus == NVAPI_STATUS.NVAPI_INSUFFICIENT_BUFFER) {
{ SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input monitor is either not connected or is not a DP or HDMI panel. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}");
SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input buffer is not large enough to hold it's contents. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); }
} else if (NVStatus == NVAPI_STATUS.NVAPI_API_NOT_INITIALIZED)
else if (NVStatus == NVAPI_STATUS.NVAPI_INVALID_DISPLAY_ID) {
{ SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The NvAPI API needs to be initialized first. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}");
SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input monitor is either not connected or is not a DP or HDMI panel. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); }
} else if (NVStatus == NVAPI_STATUS.NVAPI_NO_IMPLEMENTATION)
else if (NVStatus == NVAPI_STATUS.NVAPI_API_NOT_INITIALIZED) {
{ SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: This entry point not available in this NVIDIA Driver. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}");
SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The NvAPI API needs to be initialized first. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); }
} else if (NVStatus == NVAPI_STATUS.NVAPI_ERROR)
else if (NVStatus == NVAPI_STATUS.NVAPI_NO_IMPLEMENTATION) {
{ SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: A miscellaneous error occurred. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}");
SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: This entry point not available in this NVIDIA Driver. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); }
} else
else if (NVStatus == NVAPI_STATUS.NVAPI_ERROR) {
{ SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: Some non standard error occurred while getting Mosaic Topology! NvAPI_Disp_HdrColorControl() returned error code {NVStatus}. It's most likely that your monitor {wantedHdrColorData.Key} doesn't support HDR.");
SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: A miscellaneous error occurred. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}");
}
else
{
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: Some non standard error occurred while getting Mosaic Topology! NvAPI_Disp_HdrColorControl() returned error code {NVStatus}. It's most likely that your monitor {wantedHdrColorData.Key} doesn't support HDR.");
}
} }
} }