Skip to content

Commit f5a294b

Browse files
moooyoYu Leng (from Dev Box)claude
authored
[PowerDisplay] Add more log for PowerDisplay (#47270)
Users have reported missing monitors but the existing logs lack the information needed to diagnose. Add discovery-phase logs that record the raw MCCS capabilities string from the monitor, the parsed feature support flags (brightness/contrast/color temperature/volume), the specific reason a monitor is ignored, and DDC/CI API failures. <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: #xxx <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d10203b commit f5a294b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/modules/powerdisplay/PowerDisplay.Lib/Drivers/DDC/DdcCiNative.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Runtime.InteropServices;
8+
using ManagedCommon;
89
using Windows.Win32.Foundation;
910
using static PowerDisplay.Common.Drivers.NativeConstants;
1011
using static PowerDisplay.Common.Drivers.PInvoke;
@@ -27,32 +28,55 @@ public static DdcCiValidationResult FetchCapabilities(IntPtr hPhysicalMonitor)
2728
{
2829
if (hPhysicalMonitor == IntPtr.Zero)
2930
{
31+
Logger.LogWarning("DDC: Monitor ignored - null physical monitor handle");
3032
return DdcCiValidationResult.Invalid;
3133
}
3234

35+
var handleHex = $"0x{hPhysicalMonitor:X}";
36+
3337
try
3438
{
3539
// Try to get capabilities string (slow I2C operation)
3640
var capsString = TryGetCapabilitiesString(hPhysicalMonitor);
3741
if (string.IsNullOrEmpty(capsString))
3842
{
43+
Logger.LogWarning($"DDC: Monitor ignored (handle={handleHex}) - empty capabilities string from DDC/CI");
3944
return DdcCiValidationResult.Invalid;
4045
}
4146

47+
Logger.LogInfo($"DDC: Capabilities raw (handle={handleHex}, length={capsString.Length}): {capsString}");
48+
4249
// Parse the capabilities string
4350
var parseResult = Utils.MccsCapabilitiesParser.Parse(capsString);
4451
var capabilities = parseResult.Capabilities;
52+
4553
if (capabilities == null || capabilities.SupportedVcpCodes.Count == 0)
4654
{
55+
Logger.LogWarning($"DDC: Monitor ignored (handle={handleHex}) - parsed capabilities have no VCP codes (parseErrors={parseResult.Errors.Count})");
4756
return DdcCiValidationResult.Invalid;
4857
}
4958

5059
// Check if brightness (VCP 0x10) is supported - determines DDC/CI validity
5160
bool supportsBrightness = capabilities.SupportsVcpCode(NativeConstants.VcpCodeBrightness);
61+
bool supportsContrast = capabilities.SupportsVcpCode(NativeConstants.VcpCodeContrast);
62+
bool supportsColorTemperature = capabilities.SupportsVcpCode(NativeConstants.VcpCodeSelectColorPreset);
63+
bool supportsVolume = capabilities.SupportsVcpCode(NativeConstants.VcpCodeVolume);
64+
65+
Logger.LogInfo(
66+
$"DDC: Capabilities parsed (handle={handleHex}) - " +
67+
$"Brightness={supportsBrightness} Contrast={supportsContrast} " +
68+
$"ColorTemperature={supportsColorTemperature} Volume={supportsVolume}");
69+
70+
if (!supportsBrightness)
71+
{
72+
Logger.LogWarning($"DDC: Monitor ignored (handle={handleHex}) - brightness (VCP 0x10) not advertised in capabilities");
73+
}
74+
5275
return new DdcCiValidationResult(supportsBrightness, capsString, capabilities);
5376
}
5477
catch (Exception ex) when (ex is not OutOfMemoryException)
5578
{
79+
Logger.LogError($"DDC: Monitor ignored (handle={handleHex}) - exception during FetchCapabilities: {ex.Message}");
5680
return DdcCiValidationResult.Invalid;
5781
}
5882
}
@@ -74,6 +98,7 @@ public static DdcCiValidationResult FetchCapabilities(IntPtr hPhysicalMonitor)
7498
// Get capabilities string length
7599
if (!GetCapabilitiesStringLength(hPhysicalMonitor, out uint length) || length == 0)
76100
{
101+
Logger.LogWarning($"DDC: GetCapabilitiesStringLength failed (handle=0x{hPhysicalMonitor:X}, length={length})");
77102
return null;
78103
}
79104

@@ -83,6 +108,7 @@ public static DdcCiValidationResult FetchCapabilities(IntPtr hPhysicalMonitor)
83108
{
84109
if (!CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, buffer, length))
85110
{
111+
Logger.LogWarning($"DDC: CapabilitiesRequestAndCapabilitiesReply failed (handle=0x{hPhysicalMonitor:X})");
86112
return null;
87113
}
88114

@@ -95,6 +121,7 @@ public static DdcCiValidationResult FetchCapabilities(IntPtr hPhysicalMonitor)
95121
}
96122
catch (Exception ex) when (ex is not OutOfMemoryException)
97123
{
124+
Logger.LogError($"DDC: TryGetCapabilitiesString exception (handle=0x{hPhysicalMonitor:X}): {ex.Message}");
98125
return null;
99126
}
100127
}

0 commit comments

Comments
 (0)