fix(camera): read WhiteBalance, not ColorEnable, on Windows - #662
Conversation
Greptile SummaryThis PR corrects the Windows DirectShow white-balance property identifier, changing it from
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| crates/openlogi-camera/src/uvc_windows.rs | Correctly updates the Windows white-balance property ID from 6 to 7 and explains the non-mapped intervening properties. |
Reviews (2): Last reviewed commit: "fix(camera): read WhiteBalance, not Colo..." | Re-trigger Greptile
|
@yuzi-co Thanks for fixing some of the issues, can you ensure the pipeline is passing on the PR? |
VPA_WHITE_BALANCE was 6. In `VideoProcAmpProperty` (strmif.h) 6 is
ColorEnable; WhiteBalance is 7. The constants above it are correct and
contiguous through Sharpness (4), so the value looks like the next id counted
on from Sharpness, skipping the two properties this backend does not map —
Gamma (5) and ColorEnable (6).
The effect depends on the camera, and neither outcome is good:
- If the device does not support ColorEnable, the range read fails and
`read_camera_state` silently drops the control. White balance and its auto
toggle vanish from the CLI and the GUI panel for a camera that supports both.
This is what a C930e does.
- If the device does support ColorEnable, the read succeeds and the control
labelled "white balance" reads and writes an unrelated boolean property.
Only the Windows backend is affected. The macOS UVC path already uses
PU_WHITE_BALANCE_TEMPERATURE_CONTROL (0x0A) and the Linux V4L2 path already
uses V4L2_CID_WHITE_BALANCE_TEMPERATURE (0x0098091a); both are correct.
Verified on a Logitech C930e. Before, `openlogi camera get` listed seven
controls and two auto toggles. After:
white_balance: min=2000 max=7500 default=4000 current=4000
white_balance_auto: current=true default=true
Those bounds match an independent DirectShow probe of the same device, which
also confirms the id: property 6 returns unsupported, property 7 returns
2000..7500 with auto capability — a Kelvin range, which ColorEnable (a 0/1
boolean) could never report.
21c5c03 to
329b1f9
Compare
|
Rebased onto master ( The two clippy failures were not from this change. Both were
Master had already fixed all three in 4975729. This branch was cut 87 commits back, before that landed, so CI's The fix is still needed: master still carries Gate, re-run on the rebased treeLocal MSRV had to move first — master's bump to 1.98 meant 1.97.1 could no longer build the workspace at all. On 1.98.0: Correction to the description aboveThe rustdoc caveat in my original description is now wrong on two counts, so ignore it as written. That gate still fails on Windows, but the crate changed: it is no longer Same bug class as #661, different crate — so #661 does not fix it, and #661 is still open regardless. I confirmed it reproduces on unmodified master by checking out Happy to send that one as its own fix if it is wanted separately. |
VPA_WHITE_BALANCEwas6. InVideoProcAmpProperty(strmif.h),6isColorEnable—WhiteBalanceis7.The constants above it are correct and contiguous through
Sharpness(4), so the value reads like the next id counted on from Sharpness, skipping the two properties this backend does not map:Gamma(5) andColorEnable(6).Effect
Depends on the camera, and neither outcome is good:
read_camera_statedrops any control whose range errors. White balance and its auto toggle silently vanish for a camera that supports both. This is what a C930e does.white_balancereads and writes an unrelated boolean property.Scope
Windows only. I checked the other two backends and both are already correct:
uvc.rs(macOS, raw UVC)(Processing, 0x0A)—PU_WHITE_BALANCE_TEMPERATURE_CONTROLuvc_linux.rs(V4L2)0x0098_091a—V4L2_CID_WHITE_BALANCE_TEMPERATUREuvc_windows.rs(DirectShow)6—ColorEnableThat is likely why it went unnoticed: the id is per-backend by nature (UVC selectors, V4L2 CIDs, and the DirectShow enum are three unrelated namespaces), and Windows is the newest backend.
Verification
On a Logitech C930e. Before — seven controls, two auto toggles, no white balance:
After:
Those bounds are corroborated by an independent DirectShow probe I wrote against the same device, which also pins the id — querying by raw property number:
A 2000..7500 range with auto capability is a Kelvin temperature;
ColorEnableis a 0/1 boolean and could never report it.Gate
Run on Windows 11 x86_64 (rustc 1.97.1):
That last one fails on unmodified master too, for an unrelated reason:
openlogi-hid's module doc links acfg(not(windows))type, so rustdoc cannot build that crate on Windows at all. #661 fixes it. With #661 applied on top of this branch, all four exit 0 — I verified that locally before dropping the cherry-pick so this PR stays independent.Related
While probing, the same device reported four controls that
CameraControlhas no variant for at all — Pan, Tilt, Gain, and BacklightCompensation. Filed separately as an enhancement; not touched here.