Repository: xbmc/xbmc
File: xbmc/platform/win32/WIN32Util.cpp (C++)

Code before:
      {
        const auto& mode = modes.at(path.targetInfo.modeInfoIdx);

        getColorInfo.header.adapterId.HighPart = mode.adapterId.HighPart;
        getColorInfo.header.adapterId.LowPart = mode.adapterId.LowPart;
        getColorInfo.header.id = mode.id;

        if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(&getColorInfo.header))
        {
          // DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO documentation is lacking and field
          // names are confusing. Through experimentation and deductions from equivalent WinRT API:
          // 
          // SDR screen, advanced color not supported (Win 10, Win 11 < 22H2)
          // > advancedColorSupported = 0 and wideColorEnforced = 0
          // SDR screen, advanced color is supported (Win 11 >= 22H2)
          // > advancedColorSupported = 1 and wideColorEnforced = 1
          // HDR screen
          // > advancedColorSupported = 1 and wideColorEnforced = 0
          // 
          // advancedColorForceDisabled: maybe equivalent of advancedColorLimitedByPolicy?
          // 
          // advancedColorEnabled = 1:
          // For HDR screens means HDR is on
          // For SDR screens means ACM (Automatic Color Management, Win 11 >= 22H2) is on

          if (getColorInfo.advancedColorSupported && !getColorInfo.wideColorEnforced)
            hdrSupported = true;

          if (hdrSupported && getColorInfo.advancedColorEnabled)
            hdrEnabled = true;
        }

        if (g_hWnd != nullptr)
          break;
      }
    }
  }
#endif

  if (!hdrSupported)
  {
    status = HDR_STATUS::HDR_UNSUPPORTED;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is not HDR capable or cannot be detected");
  }
  else
  {
    status = hdrEnabled ? HDR_STATUS::HDR_ON : HDR_STATUS::HDR_OFF;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is HDR capable and current HDR status is {}",
                 hdrEnabled ? "ON" : "OFF");

Review comment (suggestion):
This would break HDR detection on my system:

![advanced_color_info](https://github.com/user-attachments/assets/5a14d03d-4583-43bd-891b-efb9c723e28a)

HDR is supported Sony TV and ACM is enabled. At time of screenshot HDR is disabled.

This is the info with new ADVANCED_COLOR_INFO_2:

![advanced_color_info2](https://github.com/user-attachments/assets/7f716ed8-7349-4efd-b811-fc8df8a903a1)

Conclusion --> With old API you can not discriminate if HDR is supported/enabled when WCG is in use.

That is probably the reason that prompted Microsoft to create a new API instead of fixing or better documenting the old one.




Code after:
      {
        const auto& mode = modes.at(path.targetInfo.modeInfoIdx);

        getColorInfo.header.adapterId.HighPart = mode.adapterId.HighPart;
        getColorInfo.header.adapterId.LowPart = mode.adapterId.LowPart;
        getColorInfo.header.id = mode.id;

        if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(&getColorInfo.header))
        {
          // DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO documentation is lacking and field
          // names are confusing. Through experimentation and deductions from equivalent WinRT API:
          //
          // SDR screen, advanced color not supported (Win 10, Win 11 < 22H2)
          // > advancedColorSupported = 0 and wideColorEnforced = 0
          // SDR screen, advanced color is supported (Win 11 >= 22H2)
          // > advancedColorSupported = 1 and wideColorEnforced = 1
          // HDR screen
          // > advancedColorSupported = 1 and wideColorEnforced = 0
          //
          // advancedColorForceDisabled: maybe equivalent of advancedColorLimitedByPolicy?
          //
          // advancedColorEnabled = 1:
          // For HDR screens means HDR is on
          // For SDR screens means ACM (Automatic Color Management, Win 11 >= 22H2) is on

          if (getColorInfo.advancedColorSupported && !getColorInfo.wideColorEnforced)
            hdrSupported = true;

          if (hdrSupported && getColorInfo.advancedColorEnabled)
            hdrEnabled = true;
        }

        if (g_hWnd != nullptr)
          break;
      }
    }
  }
#endif

  if (!hdrSupported)
  {
    status = HDR_STATUS::HDR_UNSUPPORTED;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is not HDR capable or cannot be detected");
  }
  else
  {
    status = hdrEnabled ? HDR_STATUS::HDR_ON : HDR_STATUS::HDR_OFF;
    if (CServiceBroker::IsServiceManagerUp())
      CLog::LogF(LOGDEBUG, "Display is HDR capable and current HDR status is {}",
                 hdrEnabled ? "ON" : "OFF");