<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohammed Elsayed Ammar</title>
    <description>The latest articles on DEV Community by Mohammed Elsayed Ammar (@mammar).</description>
    <link>https://dev.to/mammar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3935281%2F9ca82280-924c-4d1a-b1e0-317fae226f0a.jpeg</url>
      <title>DEV Community: Mohammed Elsayed Ammar</title>
      <link>https://dev.to/mammar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mammar"/>
    <language>en</language>
    <item>
      <title>How I fixed a 0..1 brightness slider in vdu_controls (Philips Evnia DDC/CI bug)</title>
      <dc:creator>Mohammed Elsayed Ammar</dc:creator>
      <pubDate>Sat, 16 May 2026 21:11:26 +0000</pubDate>
      <link>https://dev.to/mammar/how-i-fixed-a-01-brightness-slider-in-vducontrols-philips-evnia-ddcci-bug-4fdg</link>
      <guid>https://dev.to/mammar/how-i-fixed-a-01-brightness-slider-in-vducontrols-philips-evnia-ddcci-bug-4fdg</guid>
      <description>&lt;p&gt;I plugged a new monitor into my Kubuntu laptop last week. The brightness slider in the tray utility I use only had two settings: black, and almost-black. Not 0 to 100. Not a continuous gradient. Just two positions.&lt;/p&gt;

&lt;p&gt;The monitor itself was fine. The cable was fine. Every other monitor on the same machine worked normally. So I started pulling on the thread.&lt;/p&gt;

&lt;p&gt;A few hours later I had: a one-line cause, a 21-line patch, a test fixture, and my first open-source PR merged upstream.&lt;/p&gt;

&lt;p&gt;This is a writeup of what the bug actually was, how a monitor talks to a computer at all, and what I learned chasing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;A Philips Evnia 27M2N5500Q reports the same VCP code (the standardized "brightness" control) twice in its &lt;strong&gt;capability string&lt;/strong&gt; — once correctly, then again inside a manufacturer-specific section with garbage values. Combined with an unescaped &lt;code&gt;.&lt;/code&gt; in a regex inside &lt;code&gt;vdu_controls&lt;/code&gt; (a KDE GUI for controlling external monitors), this made the GUI think brightness was a 0..1 control instead of 0..100.&lt;/p&gt;

&lt;p&gt;The fix is in two small parts. The PR was merged into &lt;a href="https://github.com/digitaltrails/vdu_controls/pull/128" rel="noopener noreferrer"&gt;digitaltrails/vdu_controls#128&lt;/a&gt;. Read on for the actually-interesting part.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Laptop:&lt;/strong&gt; Kubuntu 24.04, KDE Plasma 5.27 on X11, Intel iGPU&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The new monitor:&lt;/strong&gt; Philips Evnia 27M2N5500Q, 27" 2560x1440, connected over HDMI&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The tool:&lt;/strong&gt; &lt;code&gt;vdu_controls&lt;/code&gt; — a small Qt tray app that lets you adjust brightness/contrast/etc. on external monitors. It's the closest thing Linux has to Windows' Twinkle Tray.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After plugging the monitor in, the tray UI showed two sliders — one per external monitor. The Lenovo on DisplayPort had a normal 0..100 brightness slider. The Philips on HDMI did not. Its slider had two positions, the value field showed &lt;code&gt;1&lt;/code&gt;, and dragging it from one end to the other produced exactly two states: full off (0) and almost-off (1).&lt;/p&gt;

&lt;h2&gt;
  
  
  First-pass diagnosis: where exactly is it broken?
&lt;/h2&gt;

&lt;p&gt;Before debugging &lt;em&gt;any&lt;/em&gt; GUI bug, the first question is: &lt;strong&gt;is the underlying mechanism broken, or just the UI?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I dropped to the shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ddcutil &lt;span class="nt"&gt;--display&lt;/span&gt; 1 getvcp 10
VCP code 0x10 &lt;span class="o"&gt;(&lt;/span&gt;Brightness&lt;span class="o"&gt;)&lt;/span&gt;: current value &lt;span class="o"&gt;=&lt;/span&gt; 83, max value &lt;span class="o"&gt;=&lt;/span&gt; 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ddcutil&lt;/code&gt; is the canonical command-line tool for talking to monitors over DDC/CI. It reported the brightness correctly — current 83, maximum 100. The monitor itself was reporting a continuous 0..100 range to the OS. The bug had to be somewhere between that response and what the GUI rendered.&lt;/p&gt;

&lt;p&gt;That narrows things down enormously. Whatever was wrong, it was in user-space, in Python, in the parts I could read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background, in four short sections
&lt;/h2&gt;

&lt;p&gt;Before I show what was actually broken, here's the protocol stack involved. If you already know DDC/CI, MCCS, and VCP codes, skip ahead.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. A monitor is a tiny embedded computer
&lt;/h3&gt;

&lt;p&gt;A modern monitor isn't just a glass panel and a backlight. It runs firmware. That firmware controls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The backlight intensity&lt;/li&gt;
&lt;li&gt;Contrast, color balance, gamma curves&lt;/li&gt;
&lt;li&gt;Which physical input is active (HDMI-1 / HDMI-2 / DisplayPort)&lt;/li&gt;
&lt;li&gt;The on-screen menu (OSD) you see when you press the button on the back&lt;/li&gt;
&lt;li&gt;Sometimes audio, USB hub switching, HDR mode, KVM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You normally interact with all this through the OSD menu. The problem with OSD menus is that you have to physically reach around to a button on the back of every monitor you own. So manufacturers and standards bodies agreed on a way for &lt;em&gt;the computer&lt;/em&gt; to control these things over the video cable.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. DDC and DDC/CI
&lt;/h3&gt;

&lt;p&gt;VESA — the same standards body behind DisplayPort and EDID — defined a protocol called &lt;strong&gt;DDC&lt;/strong&gt; (Display Data Channel). It uses spare wires in the video cable to carry a tiny side-channel for the monitor and the computer to talk to each other.&lt;/p&gt;

&lt;p&gt;Originally DDC was one-way: the monitor told the computer about itself (its name, supported resolutions, refresh rates). That packet of self-description is called &lt;strong&gt;EDID&lt;/strong&gt;. It's how your OS knows your monitor is a "Philips 27M2N5500Q" without you typing it in.&lt;/p&gt;

&lt;p&gt;Then VESA extended DDC to be two-way and called the extension &lt;strong&gt;DDC/CI&lt;/strong&gt; — Display Data Channel &lt;strong&gt;Command Interface&lt;/strong&gt;. Now the computer could also &lt;em&gt;send commands&lt;/em&gt;: "set brightness to 50", "switch input to HDMI-2", "what's your current contrast?". That's the protocol everything in this story rides on.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. VCP codes and MCCS
&lt;/h3&gt;

&lt;p&gt;To make DDC/CI useful across manufacturers, VESA also standardized which commands exist, in a document called &lt;strong&gt;MCCS&lt;/strong&gt; (Monitor Control Command Set). Each control gets a numeric code called a &lt;strong&gt;VCP code&lt;/strong&gt; (Virtual Control Panel). A handful of examples:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Code&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Brightness&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x12&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Contrast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x14&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Color preset (sRGB, 6500K, 9300K…)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x60&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Input source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x62&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Audio speaker volume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0xD6&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Power mode&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Crucially, each VCP code has a &lt;strong&gt;type&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Continuous (C):&lt;/strong&gt; a number on a range. Brightness &lt;code&gt;0x10&lt;/code&gt; is C — pick any value between 0 and a maximum the monitor reports (usually 100). Like a slider.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-Continuous (NC):&lt;/strong&gt; pick from a fixed list. Input source &lt;code&gt;0x60&lt;/code&gt; is NC — only specific values like &lt;code&gt;0x11 = HDMI-1&lt;/code&gt;, &lt;code&gt;0x12 = HDMI-2&lt;/code&gt;, &lt;code&gt;0x0F = DisplayPort-1&lt;/code&gt; mean anything. Like a dropdown.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This distinction determines whether a UI should render the control as a slider or as a dropdown. Hold onto it — it matters later.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The capability string
&lt;/h3&gt;

&lt;p&gt;When the computer first talks to a monitor over DDC/CI, it asks: &lt;strong&gt;"which VCP codes do you support?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The monitor replies with a text blob called the &lt;strong&gt;capability string&lt;/strong&gt;. Mine looks like this (trimmed):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Model: 27M2N5500Q
MCCS version: 2.2
VCP Features:
   Feature: 10 (Brightness)
   Feature: 12 (Contrast)
   Feature: 14 (Select color preset)
      Values: 02 04 05 06 08 0B
   Feature: 60 (Input Source)
      Values: 11 12 0F
   ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read that as: "I support brightness (continuous, no value list needed), contrast (continuous), color preset (these specific options), input source (these specific options)…"&lt;/p&gt;

&lt;p&gt;Continuous features have no &lt;code&gt;Values:&lt;/code&gt; line. Non-continuous features have a &lt;code&gt;Values:&lt;/code&gt; line listing the allowed discrete values. The presence or absence of that sub-block is how a parser decides which type each feature is.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. The two tools in this story
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ddcutil&lt;/code&gt;&lt;/strong&gt; — the command-line client. Opens &lt;code&gt;/dev/i2c-N&lt;/code&gt; (the kernel's interface to the tiny serial bus inside your video cable) and speaks DDC/CI directly. Lets you do &lt;code&gt;ddcutil --display 1 setvcp 10 50&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;vdu_controls&lt;/code&gt;&lt;/strong&gt; — a Qt tray GUI built on top of &lt;code&gt;ddcutil&lt;/code&gt;. It calls &lt;code&gt;ddcutil capabilities&lt;/code&gt; once per monitor at startup, parses the capability string, and renders sliders or dropdowns based on what each feature's type turns out to be. When you drag a slider, it shells out to &lt;code&gt;ddcutil setvcp&lt;/code&gt; to push the new value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  So where was the bug?
&lt;/h2&gt;

&lt;p&gt;I ran &lt;code&gt;ddcutil capabilities&lt;/code&gt; on the Philips and the output was 217 lines long. Most of it was unremarkable. But:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Line  18:   Feature: 10 (Brightness)
Line  19:   Feature: 12 (Contrast)
...
Line 178:   Feature: E2 (Manufacturer specific feature)
Line 179:   Feature: A0 (6 axis hue control: Magenta)
Line 180:   Feature: 10 (Brightness)
Line 181:      Values: 00 01 02 03 04 (interpretation unavailable)
Line 182:   Feature: E2 (Manufacturer specific feature)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Feature: 10 (Brightness)&lt;/code&gt; appears &lt;strong&gt;twice&lt;/strong&gt;. The first time, correctly, with no &lt;code&gt;Values:&lt;/code&gt; block — meaning standard continuous brightness, 0..100. The second time, 160 lines later, deep inside what looks like a manufacturer-specific section (between &lt;code&gt;Feature: A0&lt;/code&gt; and another &lt;code&gt;Feature: E2&lt;/code&gt;), it shows up again &lt;em&gt;with&lt;/em&gt; a &lt;code&gt;Values:&lt;/code&gt; line full of garbage: &lt;code&gt;00 01 02 03 04&lt;/code&gt;. Those aren't real values for anything — they're noise from a section of the firmware that should have stayed private.&lt;/p&gt;

&lt;p&gt;That's bug #1: the firmware is leaking manufacturer-internal data into the standardized VCP section of the capability string.&lt;/p&gt;

&lt;p&gt;But buggy firmware on its own doesn't break a GUI. The next question was: how did &lt;code&gt;vdu_controls&lt;/code&gt; react to this?&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the parser
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;vdu_controls&lt;/code&gt;' capability parser lives in &lt;code&gt;_parse_capabilities&lt;/code&gt;. Stripped down, it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;feature_map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;feature_text&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;capabilities_text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; Feature: &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;feature_match&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_FEATURE_PATTERN&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;feature_text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;vcp_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;feature_match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;# ... figure out vcp_type and values ...
&lt;/span&gt;        &lt;span class="n"&gt;feature_map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;vcp_code&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;VcpCapability&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vcp_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;feature_map&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things to notice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;feature_map&lt;/code&gt; is a dict keyed by VCP code. If the same code is parsed twice, &lt;strong&gt;the second assignment silently overwrites the first.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The type-classification logic (Continuous vs Non-Continuous) is based on whether a &lt;code&gt;Values:&lt;/code&gt; block was found &lt;em&gt;for that occurrence&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So when the Philips' cap string was fed in, here's what happened:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First pass through &lt;code&gt;Feature: 10&lt;/code&gt;: no &lt;code&gt;Values:&lt;/code&gt; block → classified as Continuous → stored as "brightness, 0..(max from getvcp)" → good.&lt;/li&gt;
&lt;li&gt;Second pass through &lt;code&gt;Feature: 10&lt;/code&gt;: has a &lt;code&gt;Values:&lt;/code&gt; block → classified as Non-Continuous → stored as "brightness, discrete options 00/01/02/03/04" → &lt;strong&gt;overwrites the first entry.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the time the GUI built its widget, the brightness feature in &lt;code&gt;feature_map&lt;/code&gt; was the corrupted second copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The second bug, hiding in plain sight
&lt;/h2&gt;

&lt;p&gt;That alone would have rendered brightness as a discrete dropdown (with weird options 00–04). But I was seeing a &lt;em&gt;slider&lt;/em&gt; — just stuck at 0..1. Why a slider at all if it was classified as Non-Continuous?&lt;/p&gt;

&lt;p&gt;Because there was a second, completely separate bug.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vdu_controls&lt;/code&gt; has a special case for monitors that report a &lt;em&gt;restricted&lt;/em&gt; continuous range. Some panels physically can't go below 20% brightness without flickering, and they signal this by reporting their &lt;code&gt;Values:&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature: 10 (Brightness)
   Values: 20..90
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's a range, not a list. The parser tries to match it with a regex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_RANGE_PATTERN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Values:\s+([0-9]+)..([0-9]+)&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't see the bug, look harder. The &lt;code&gt;..&lt;/code&gt; in the middle of the pattern was meant to be two literal dots. But in regex syntax, &lt;code&gt;.&lt;/code&gt; is a metacharacter meaning &lt;em&gt;any character whatsoever&lt;/em&gt;. So &lt;code&gt;..&lt;/code&gt; actually matches &lt;strong&gt;any two characters&lt;/strong&gt;, not two dots.&lt;/p&gt;

&lt;p&gt;When that regex was applied to the Philips' garbage &lt;code&gt;Values: 00 01 02 03 04 (interpretation unavailable)&lt;/code&gt;, it matched:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;00&lt;/code&gt; → first capture group&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt; (space + the next &lt;code&gt;0&lt;/code&gt;, both matched by the unescaped &lt;code&gt;..&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1&lt;/code&gt; → second capture group&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The parser then thought: "ah, this is a restricted-range continuous feature, from 0 to 1." That's where the 0..1 slider came from. The monitor was reporting &lt;code&gt;Values: 00 01 02 03 04&lt;/code&gt;, and a regex bug turned that into "range 0..1".&lt;/p&gt;

&lt;p&gt;So the full causal chain is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Philips firmware double-lists &lt;code&gt;Feature: 10&lt;/code&gt; and dumps garbage values on the second copy.&lt;/li&gt;
&lt;li&gt;A regex bug interprets that garbage as a &lt;em&gt;restricted range&lt;/em&gt; of 0..1.&lt;/li&gt;
&lt;li&gt;The dict-overwrite means the corrupted range definition wins over the correct one.&lt;/li&gt;
&lt;li&gt;The widget renders a 0..1 slider.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Three layers of bug stacked on top of each other to produce one terrible UX.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;The PR I sent adds two defensive guards in &lt;code&gt;_parse_capabilities&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Guard A — trust the standard for known-continuous codes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vdu_controls&lt;/code&gt; already has an internal table that maps VCP codes to their MCCS-defined types. It knows &lt;code&gt;0x10&lt;/code&gt; is brightness and that brightness is Continuous. So: if the cap string shows up with a stray &lt;code&gt;Values:&lt;/code&gt; block &lt;em&gt;for a code we already know is continuous&lt;/em&gt;, ignore the values list, trust the standard. Don't let firmware noise reclassify brightness as a dropdown.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Guard B — keep the first occurrence of any duplicate Feature line.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the same &lt;code&gt;Feature: XX&lt;/code&gt; appears twice, keep the first parse and log a warning instead of silently overwriting. For known-supported codes (the user-visible ones), log a &lt;code&gt;WARNING&lt;/code&gt;. For unknown manufacturer codes, log an &lt;code&gt;INFO&lt;/code&gt; so the noise stays out of the warning stream.&lt;/p&gt;

&lt;p&gt;The two guards are complementary: A handles the case where there's only one occurrence but it has bad values; B handles the case where there are duplicates regardless of values.&lt;/p&gt;

&lt;p&gt;Both together, total diff: 21 insertions, 1 deletion. About half of those lines are comments explaining &lt;em&gt;why&lt;/em&gt;, because the next person to look at this code in five years deserves to know what the Philips firmware is doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the maintainer caught
&lt;/h2&gt;

&lt;p&gt;When I submitted the PR, the maintainer (Michael Hamilton) reviewed it within hours. While reading my test fixture's log output, he spotted &lt;em&gt;another&lt;/em&gt; bug — the &lt;code&gt;_RANGE_PATTERN&lt;/code&gt; regex from above. He fixed it independently in a follow-up commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;- _RANGE_PATTERN = re.compile(r'Values:\s+([0-9]+)..([0-9]+)')
&lt;/span&gt;&lt;span class="gi"&gt;+ _RANGE_PATTERN = re.compile(r'Values:\s+([0-9]+)[.][.]([0-9]+)')
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;[.][.]&lt;/code&gt; is a regex idiom for "literal dot followed by literal dot" — a character class containing only one character (the dot) is the same as escaping the dot. Now the pattern only matches actual range syntax (&lt;code&gt;20..90&lt;/code&gt;) and leaves discrete values alone.&lt;/p&gt;

&lt;p&gt;His fix is a one-character change in spirit. Mine is structurally larger. The two are orthogonal — neither is sufficient on its own to handle every variant of this class of firmware quirk, but together they cover the space.&lt;/p&gt;

&lt;p&gt;Open source at its best, honestly: a contributor's test fixture surfaces an unrelated latent bug, and the maintainer catches it in review.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I took away
&lt;/h2&gt;

&lt;p&gt;A few things stuck with me after this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reading code you didn't write is the most underrated programming skill.&lt;/strong&gt; This whole patch is ~10 lines of actual logic. The hours went into reading &lt;code&gt;vdu_controls&lt;/code&gt;' 12,000 lines of Python until I understood the dataflow well enough to know &lt;em&gt;where&lt;/em&gt; the bug had to live.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Always check the boundary between the working layer and the broken one.&lt;/strong&gt; The fact that &lt;code&gt;ddcutil getvcp 10&lt;/code&gt; returned the right answer while the GUI didn't was the most important diagnostic in the whole session. It collapsed the search space from "the entire stack from monitor to pixels" to "Python code I can grep".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firmware lies.&lt;/strong&gt; This isn't a &lt;code&gt;vdu_controls&lt;/code&gt; bug at root — it's a &lt;code&gt;vdu_controls&lt;/code&gt; &lt;em&gt;vulnerability&lt;/em&gt; to a Philips firmware bug. Defensive parsing isn't optional when you're reading data you didn't generate. Half the diff is comments because the right comment in the right place is the difference between "this code is weirdly defensive" and "this code is defensive &lt;em&gt;for a reason and here is the reason&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real OSS maintainers are gracious.&lt;/strong&gt; Michael's review was thoughtful, asked good questions, considered alternatives out loud, credited the contributor, and merged. That's a model worth copying when I'm ever on the other side of a PR.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;PR: &lt;a href="https://github.com/digitaltrails/vdu_controls/pull/128" rel="noopener noreferrer"&gt;https://github.com/digitaltrails/vdu_controls/pull/128&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Bug report: &lt;a href="https://github.com/digitaltrails/vdu_controls/issues/127" rel="noopener noreferrer"&gt;https://github.com/digitaltrails/vdu_controls/issues/127&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Maintainer's follow-up regex fix: &lt;a href="https://github.com/digitaltrails/vdu_controls/commit/6d72a377" rel="noopener noreferrer"&gt;&lt;code&gt;6d72a377&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vdu_controls&lt;/code&gt;: &lt;a href="https://github.com/digitaltrails/vdu_controls" rel="noopener noreferrer"&gt;https://github.com/digitaltrails/vdu_controls&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ddcutil&lt;/code&gt;: &lt;a href="https://www.ddcutil.com/" rel="noopener noreferrer"&gt;https://www.ddcutil.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;VESA MCCS 2.2 spec (paywalled, but described in the ddcutil docs)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>opensource</category>
      <category>python</category>
      <category>debugging</category>
    </item>
  </channel>
</rss>
