Debian Codegraph @

crates/ddccontrol-caps/README.md

raw symbols SCIP
1 # ddccontrol-caps
2
3 `ddccontrol-caps` is a minimal Rust parser for the subset of monitor capability
4 strings that the current C-based `ddccontrol` code uses.
5
6 This crate is not a full ACCESS.bus or MCCS capability parser. It intentionally
7 starts with the behavior needed by the existing `ddccontrol` database and CLI
8 paths, so the Rust port has a small and testable compatibility surface.
9
10 ## Ported Behavior
11
12 The previous C parser was implemented in `src/lib/ddcci.c` as
13 `ddcci_parse_caps`. Its primary consumers used two pieces of parsed data:
14
15 - monitor type, used to choose LCD/CRT/VESA fallback profiles
16 - the VCP support table, used to decide whether controls from the monitor
17 database should be kept or discarded
18
19 This crate currently ports that behavior.
20
21 ## Monitor Type
22
23 The parser recognizes:
24
25 - `type(lcd)`
26 - `type(crt)`
27
28 Matching is case-insensitive, so `type(LCD)` and `type(CRT)` are accepted. An
29 unknown type is ignored and does not overwrite an existing parsed type.
30
31 ## VCP Controls
32
33 The parser recognizes `vcp(...)` sections and records supported VCP feature
34 codes as 8-bit values.
35
36 Both styles used by real monitors are supported:
37
38 ```text
39 vcp(10 12 14)
40 vcp(101214)
41 ```
42
43 In both cases, the result is equivalent to the C code's `caps.vcp[code] != NULL`
44 check.
45
46 ## VCP Value Lists
47
48 The parser supports value lists attached to a VCP code:
49
50 ```text
51 vcp(14(05 08 0B) 60(01 03))
52 ```
53
54 Values are stored as `u16`, matching the C parser's `unsigned short` value
55 storage. A VCP entry distinguishes between:
56
57 - a supported control with no explicit value list
58 - a supported control with a parsed list of allowed values
59
60 Nested value groups are tolerated and skipped. This matches the practical
61 behavior of the C parser, which only records values at the direct VCP value-list
62 level.
63
64 ## Add And Remove
65
66 The C parser accepts an `add` flag and is also used by monitor database
67 `<caps add="..." remove="..."/>` profile patches.
68
69 This crate exposes equivalent operations:
70
71 - `Caps::parse(...)` for initial add-style parsing
72 - `Caps::apply_add(...)` for adding controls or value lists
73 - `Caps::apply_remove(...)` for removing controls or values
74
75 Remove behavior follows the C code:
76
77 - `vcp(10)` removes the whole VCP control
78 - `vcp(10(01))` removes only value `0x01`
79 - if the last explicit value is removed, the VCP control is removed
80 - removing a nonexistent control is allowed
81
82 ## Ignored Sections
83
84 Unknown sections are skipped so they do not prevent later `vcp(...)` or
85 `type(...)` sections from being parsed.
86
87 Examples of ignored sections include:
88
89 - `prot(...)`
90 - `cmds(...)`
91 - `model(...)`
92 - `mccs_ver(...)`
93 - `mswhql(...)`
94 - `edid bin(...)`
95 - `vdif bin(...)`
96
97 ## Validation
98
99 The parser reports errors for the invalid input cases that matter for the
100 current port:
101
102 - invalid VCP feature codes
103 - invalid value-list entries
104 - value lists without a preceding VCP code
105 - unbalanced or unexpected parentheses
106
107 ## Not Implemented Yet
108
109 The following capability data is intentionally not parsed yet:
110
111 - protocol information from `prot(...)`
112 - command support from `cmds(...)`
113 - model names from `model(...)`
114 - MCCS version from `mccs_ver(...)`
115 - EDID or VDIF binary payloads
116 - VCP names or localized value names
117 - full ACCESS.bus grammar coverage
118
119 These can be added later when Rust code needs them directly.