edidgen 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
edidgen-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrew Simmons
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
edidgen-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: edidgen
3
+ Version: 0.1.0
4
+ Summary: Generate EDID binaries (base block + CTA-861 extension) from a validated TOML config
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.14
8
+ Project-URL: Repository, https://github.com/agsimmons/edidgen
9
+ Project-URL: Changelog, https://github.com/agsimmons/edidgen/blob/main/CHANGELOG.md
10
+ Description-Content-Type: text/markdown
11
+
12
+ # edidgen
13
+
14
+ Generate EDID binaries (128-byte base block + CTA-861 extension) from a TOML config.
15
+ The config is fully validated first, and every problem is reported with its location
16
+ (`modes[2].timing: must be one of ...`). The `.bin` is only written when there are no errors.
17
+
18
+ Built for faking a monitor on an unused GPU output (`drm.edid_firmware=` +
19
+ `video=<connector>:e`), e.g. a virtual display for Sunshine game streaming.
20
+
21
+ No runtime dependencies (Python ≥ 3.14 standard library only).
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ uv run edidgen examples/virtual-display.toml # validate, then write the .bin
27
+ uv run edidgen examples/virtual-display.toml --check # validate only
28
+ uv run edidgen examples/virtual-display.toml --decode # write, then run edid-decode on it
29
+ uv run edidgen config.toml -o out.bin # override the output path
30
+ uv run edidgen config.toml --allow-invalid # write it even if it breaks the spec
31
+ ```
32
+
33
+ Exit codes: `0` written (or valid, with `--check`), `1` config errors (nothing written),
34
+ `2` file read/write failure. Warnings (duplicate modes, modes outside the declared range
35
+ limits, …) are printed but don't block output.
36
+
37
+ `--allow-invalid` is for deliberately broken EDIDs, e.g. to test how a driver or parser
38
+ copes. It writes the file despite *spec violations*: values the format can hold but the
39
+ spec or decoders reject. Those are modes or VICs above `hdmi.max_tmds_mhz`, DTD pixel
40
+ clocks below 10 MHz, `hdr.max_frame_avg_nits` above `max_luminance_nits`, and range limits
41
+ with min > max. They're reported as `invalid (allowed)` and the summary says `INVALID`.
42
+ Anything that can't be encoded at all (a name that doesn't fit, bit depth 9, porches wider
43
+ than their bit fields, typos, wrong types) is still an error.
44
+
45
+ ## Config
46
+
47
+ [`examples/virtual-display.toml`](examples/virtual-display.toml) documents every option. In short:
48
+
49
+ ```toml
50
+ output = "virtual-display.bin" # top-level keys go before the first [table]
51
+ vics = [97, 16, 63, 4, 1] # standard CTA-861 modes by VIC
52
+
53
+ [display] # name, manufacturer, size, bit depth, interface, ...
54
+ name = "VirtDisplay"
55
+ bit_depth = 10
56
+ interface = "hdmi-a"
57
+
58
+ [hdmi] # HDMI VSDB + HDMI Forum VSDB
59
+ max_tmds_mhz = 600
60
+
61
+ [hdr] # HDR static metadata + BT.2020 colorimetry
62
+ enabled = true
63
+
64
+ [range] # display range limits (derived if omitted)
65
+ vrefresh_hz = [24, 120]
66
+
67
+ [[modes]] # first mode = preferred
68
+ width = 2560
69
+ height = 1440
70
+ refresh = 60 # timing = "cvt-rb" (default) | "cvt-rb2" | "cvt-rb3"
71
+ # | "cvt" | "explicit"
72
+ ```
73
+
74
+ Modes can use generated VESA CVT timings (standard `cvt`, or reduced blanking `cvt-rb`,
75
+ `cvt-rb2`, `cvt-rb3`), or fully explicit timings. CVT modes also take `interlaced`,
76
+ `margins`, `video_optimized` (RB2) and `h_blank` / `v_blank_us` / `early_vsync` (RB3); the
77
+ example config describes each. Generated timings match `edid-decode --cvt` for every
78
+ variant. CVT rounds the pixel clock to a fixed step, and edidgen does that in exact
79
+ arithmetic, so where edid-decode's floating-point rounding is one step off on an exact
80
+ boundary, edidgen has the exact value.
81
+
82
+ Each DTD's image size is the display size fitted to that mode's aspect ratio, so modes
83
+ of other shapes don't contradict their reported size. Range limits left out of `[range]`
84
+ are derived from every advertised timing: the DTDs, the VICs and the always-present
85
+ 640x480.
86
+
87
+ How the display is named in desktop settings comes from `[display]`:
88
+
89
+ - `manufacturer` (default `XXX`) is looked up in hwdata's `pnp.ids`, and a registered code
90
+ shows that company's name. Unregistered codes are shown as-is.
91
+ - `serial` defaults to `0` (none). KWin then adds the connector to the model name
92
+ (`XXX HDMI-A-1-VirtDisplay`) and ties the display's saved settings to that port. Set any
93
+ nonzero serial to get `XXX VirtDisplay`.
94
+
95
+ What gets checked includes types and ranges of every field, unknown keys (typos), the
96
+ field-width limits of an 18-byte detailed timing descriptor (pixel clock 10–655.35 MHz,
97
+ porch and border sizes, even interlaced heights), modes and VICs that need more than
98
+ `hdmi.max_tmds_mhz`, and whether all modes fit in the extension block.
99
+
100
+ ## Development
101
+
102
+ ```bash
103
+ uv sync
104
+ uv run pytest
105
+ uv run ruff check && uv run ruff format --check
106
+ uv run pre-commit install # ruff check --fix + ruff format on every commit
107
+ uv run ty check
108
+ ```
109
+
110
+ Tests that compare against `edid-decode` are skipped when it isn't installed.
111
+
112
+ ## License
113
+
114
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,103 @@
1
+ # edidgen
2
+
3
+ Generate EDID binaries (128-byte base block + CTA-861 extension) from a TOML config.
4
+ The config is fully validated first, and every problem is reported with its location
5
+ (`modes[2].timing: must be one of ...`). The `.bin` is only written when there are no errors.
6
+
7
+ Built for faking a monitor on an unused GPU output (`drm.edid_firmware=` +
8
+ `video=<connector>:e`), e.g. a virtual display for Sunshine game streaming.
9
+
10
+ No runtime dependencies (Python ≥ 3.14 standard library only).
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ uv run edidgen examples/virtual-display.toml # validate, then write the .bin
16
+ uv run edidgen examples/virtual-display.toml --check # validate only
17
+ uv run edidgen examples/virtual-display.toml --decode # write, then run edid-decode on it
18
+ uv run edidgen config.toml -o out.bin # override the output path
19
+ uv run edidgen config.toml --allow-invalid # write it even if it breaks the spec
20
+ ```
21
+
22
+ Exit codes: `0` written (or valid, with `--check`), `1` config errors (nothing written),
23
+ `2` file read/write failure. Warnings (duplicate modes, modes outside the declared range
24
+ limits, …) are printed but don't block output.
25
+
26
+ `--allow-invalid` is for deliberately broken EDIDs, e.g. to test how a driver or parser
27
+ copes. It writes the file despite *spec violations*: values the format can hold but the
28
+ spec or decoders reject. Those are modes or VICs above `hdmi.max_tmds_mhz`, DTD pixel
29
+ clocks below 10 MHz, `hdr.max_frame_avg_nits` above `max_luminance_nits`, and range limits
30
+ with min > max. They're reported as `invalid (allowed)` and the summary says `INVALID`.
31
+ Anything that can't be encoded at all (a name that doesn't fit, bit depth 9, porches wider
32
+ than their bit fields, typos, wrong types) is still an error.
33
+
34
+ ## Config
35
+
36
+ [`examples/virtual-display.toml`](examples/virtual-display.toml) documents every option. In short:
37
+
38
+ ```toml
39
+ output = "virtual-display.bin" # top-level keys go before the first [table]
40
+ vics = [97, 16, 63, 4, 1] # standard CTA-861 modes by VIC
41
+
42
+ [display] # name, manufacturer, size, bit depth, interface, ...
43
+ name = "VirtDisplay"
44
+ bit_depth = 10
45
+ interface = "hdmi-a"
46
+
47
+ [hdmi] # HDMI VSDB + HDMI Forum VSDB
48
+ max_tmds_mhz = 600
49
+
50
+ [hdr] # HDR static metadata + BT.2020 colorimetry
51
+ enabled = true
52
+
53
+ [range] # display range limits (derived if omitted)
54
+ vrefresh_hz = [24, 120]
55
+
56
+ [[modes]] # first mode = preferred
57
+ width = 2560
58
+ height = 1440
59
+ refresh = 60 # timing = "cvt-rb" (default) | "cvt-rb2" | "cvt-rb3"
60
+ # | "cvt" | "explicit"
61
+ ```
62
+
63
+ Modes can use generated VESA CVT timings (standard `cvt`, or reduced blanking `cvt-rb`,
64
+ `cvt-rb2`, `cvt-rb3`), or fully explicit timings. CVT modes also take `interlaced`,
65
+ `margins`, `video_optimized` (RB2) and `h_blank` / `v_blank_us` / `early_vsync` (RB3); the
66
+ example config describes each. Generated timings match `edid-decode --cvt` for every
67
+ variant. CVT rounds the pixel clock to a fixed step, and edidgen does that in exact
68
+ arithmetic, so where edid-decode's floating-point rounding is one step off on an exact
69
+ boundary, edidgen has the exact value.
70
+
71
+ Each DTD's image size is the display size fitted to that mode's aspect ratio, so modes
72
+ of other shapes don't contradict their reported size. Range limits left out of `[range]`
73
+ are derived from every advertised timing: the DTDs, the VICs and the always-present
74
+ 640x480.
75
+
76
+ How the display is named in desktop settings comes from `[display]`:
77
+
78
+ - `manufacturer` (default `XXX`) is looked up in hwdata's `pnp.ids`, and a registered code
79
+ shows that company's name. Unregistered codes are shown as-is.
80
+ - `serial` defaults to `0` (none). KWin then adds the connector to the model name
81
+ (`XXX HDMI-A-1-VirtDisplay`) and ties the display's saved settings to that port. Set any
82
+ nonzero serial to get `XXX VirtDisplay`.
83
+
84
+ What gets checked includes types and ranges of every field, unknown keys (typos), the
85
+ field-width limits of an 18-byte detailed timing descriptor (pixel clock 10–655.35 MHz,
86
+ porch and border sizes, even interlaced heights), modes and VICs that need more than
87
+ `hdmi.max_tmds_mhz`, and whether all modes fit in the extension block.
88
+
89
+ ## Development
90
+
91
+ ```bash
92
+ uv sync
93
+ uv run pytest
94
+ uv run ruff check && uv run ruff format --check
95
+ uv run pre-commit install # ruff check --fix + ruff format on every commit
96
+ uv run ty check
97
+ ```
98
+
99
+ Tests that compare against `edid-decode` are skipped when it isn't installed.
100
+
101
+ ## License
102
+
103
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "edidgen"
3
+ version = "0.1.0"
4
+ description = "Generate EDID binaries (base block + CTA-861 extension) from a validated TOML config"
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = []
10
+
11
+ [project.urls]
12
+ Repository = "https://github.com/agsimmons/edidgen"
13
+ Changelog = "https://github.com/agsimmons/edidgen/blob/main/CHANGELOG.md"
14
+
15
+ [project.scripts]
16
+ edidgen = "edidgen.cli:main"
17
+
18
+ [dependency-groups]
19
+ dev = [
20
+ "pre-commit>=4.2.0,<5",
21
+ "pytest>=9.2.0,<=10",
22
+ "pytest-cov>=7.1.0,<8",
23
+ "pytest-xdist>=3.8.0,<4",
24
+ "ruff>=0.17.5",
25
+ "ty>=0.0.107",
26
+ ]
27
+
28
+ [tool.pytest.ini_options]
29
+ addopts = [
30
+ "-n",
31
+ "auto",
32
+ "--maxprocesses",
33
+ "8",
34
+ ]
35
+
36
+ [tool.ruff.lint]
37
+ extend-select = [
38
+ "I",
39
+ "ANN",
40
+ ]
41
+ ignore = [
42
+ "ANN401",
43
+ "RUF012",
44
+ ]
45
+
46
+ [tool.ruff.lint.isort]
47
+ lines-after-imports = 2
48
+
49
+ [build-system]
50
+ requires = ["uv_build>=0.9,<0.14"]
51
+ build-backend = "uv_build"
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "edidgen"
3
+ version = "0.1.0"
4
+ description = "Generate EDID binaries (base block + CTA-861 extension) from a validated TOML config"
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = []
10
+
11
+ [project.urls]
12
+ Repository = "https://github.com/agsimmons/edidgen"
13
+ Changelog = "https://github.com/agsimmons/edidgen/blob/main/CHANGELOG.md"
14
+
15
+ [dependency-groups]
16
+ dev = [
17
+ "pre-commit>=4.2.0,<5",
18
+ "pytest>=9.2.0,<=10",
19
+ "pytest-cov>=7.1.0,<8",
20
+ "pytest-xdist>=3.8.0,<4",
21
+ "ruff>=0.17.5",
22
+ "ty>=0.0.107",
23
+ ]
24
+
25
+ [project.scripts]
26
+ edidgen = "edidgen.cli:main"
27
+
28
+ [tool.pytest.ini_options]
29
+ # Parallel by default: the edid-decode tests spend their time in subprocesses.
30
+ # More than ~8 workers is slower again (startup cost). Use `-n 0` to run serially,
31
+ # e.g. when debugging with breakpoints.
32
+ addopts = ["-n", "auto", "--maxprocesses", "8"]
33
+
34
+ [tool.ruff.lint]
35
+ extend-select = ["I", "ANN"]
36
+ ignore = ["ANN401", "RUF012"]
37
+
38
+ [tool.ruff.lint.isort]
39
+ lines-after-imports = 2
40
+
41
+ [build-system]
42
+ requires = ["uv_build>=0.9,<0.14"]
43
+ build-backend = "uv_build"
@@ -0,0 +1,23 @@
1
+ """Generate EDID binaries from a validated TOML config."""
2
+
3
+ from edidgen.config import parse_config
4
+ from edidgen.encode import build_edid
5
+ from edidgen.model import Config, Display, Hdmi, Hdr, RangeLimits, Timing, TimingKind
6
+ from edidgen.reader import Diagnostics
7
+ from edidgen.timing import cvt_rb, cvt_rb2
8
+
9
+
10
+ __all__ = [
11
+ "Config",
12
+ "Diagnostics",
13
+ "Display",
14
+ "Hdmi",
15
+ "Hdr",
16
+ "RangeLimits",
17
+ "Timing",
18
+ "TimingKind",
19
+ "build_edid",
20
+ "cvt_rb",
21
+ "cvt_rb2",
22
+ "parse_config",
23
+ ]
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from edidgen.cli import main
4
+
5
+
6
+ sys.exit(main())
@@ -0,0 +1,123 @@
1
+ """Command-line interface."""
2
+
3
+ import argparse
4
+ import shutil
5
+ import subprocess
6
+ import sys
7
+ import tomllib
8
+ from pathlib import Path
9
+ from typing import TYPE_CHECKING
10
+
11
+ from edidgen.config import parse_config
12
+ from edidgen.encode import build_edid
13
+ from edidgen.reader import Diagnostics
14
+ from edidgen.tables import VICS
15
+
16
+
17
+ if TYPE_CHECKING:
18
+ from collections.abc import Sequence
19
+
20
+ from edidgen.model import Config
21
+
22
+
23
+ def summarize(cfg: Config) -> list[str]:
24
+ lines = [
25
+ f" {'*' if i == 0 else ' '} DTD {t.label():>18} {t.pclk_mhz:8.2f} MHz "
26
+ f"{t.hfreq_khz:6.1f} kHz"
27
+ for i, t in enumerate(cfg.modes)
28
+ ]
29
+ lines += [
30
+ f" VIC {v:<3}{VICS[v].width}x{VICS[v].height}@{VICS[v].refresh:g}"
31
+ f"{'i' if VICS[v].interlaced else ''}{' (native)' if v == cfg.native_vic else ''}"
32
+ for v in cfg.vics
33
+ ]
34
+ return lines
35
+
36
+
37
+ def main(argv: Sequence[str] | None = None) -> int:
38
+ ap = argparse.ArgumentParser(
39
+ description="Generate an EDID binary from a TOML config."
40
+ )
41
+ ap.add_argument("config", type=Path, help="TOML config file")
42
+ ap.add_argument(
43
+ "-o",
44
+ "--output",
45
+ type=Path,
46
+ help="output .bin (default: `output` in the config, else the config name with .bin)",
47
+ )
48
+ ap.add_argument(
49
+ "--check", action="store_true", help="validate only; don't write anything"
50
+ )
51
+ ap.add_argument(
52
+ "--decode", action="store_true", help="run edid-decode on the result"
53
+ )
54
+ ap.add_argument(
55
+ "--allow-invalid",
56
+ action="store_true",
57
+ help="write the EDID even if it breaks the spec (e.g. modes above the HDMI "
58
+ "TMDS limit); values that can't be encoded at all are still errors",
59
+ )
60
+ args = ap.parse_args(argv)
61
+
62
+ try:
63
+ with args.config.open("rb") as f:
64
+ data = tomllib.load(f)
65
+ except OSError as e:
66
+ print(f"error: cannot read {args.config}: {e.strerror}", file=sys.stderr)
67
+ return 2
68
+ except tomllib.TOMLDecodeError as e:
69
+ print(f"{args.config}: TOML syntax error: {e}", file=sys.stderr)
70
+ return 1
71
+
72
+ diag = Diagnostics(allow_invalid=args.allow_invalid)
73
+ cfg = parse_config(data, diag)
74
+ for w in diag.warnings:
75
+ print(f"{args.config}: warning: {w}", file=sys.stderr)
76
+ for v in diag.allowed_violations:
77
+ print(f"{args.config}: invalid (allowed): {v}", file=sys.stderr)
78
+ if cfg is None:
79
+ for err in diag.errors:
80
+ print(f"{args.config}: error: {err}", file=sys.stderr)
81
+ n = len(diag.errors)
82
+ print(f"{n} error{'s' * (n != 1)}; no file written.", file=sys.stderr)
83
+ k = diag.blocking_violations
84
+ if k == n:
85
+ hint = "--allow-invalid would write the EDID anyway (these are spec violations)."
86
+ elif k:
87
+ are = "is a spec violation" if k == 1 else "are spec violations"
88
+ hint = f"{k} of these {are} that --allow-invalid accepts; the rest must be fixed."
89
+ if k:
90
+ print(hint, file=sys.stderr)
91
+ return 1
92
+
93
+ edid = build_edid(cfg)
94
+ n_bad = len(diag.allowed_violations)
95
+ status = (
96
+ f"INVALID ({n_bad} allowed violation{'s' * (n_bad != 1)})" if n_bad else "valid"
97
+ )
98
+ print(
99
+ f"{args.config}: {status} ({len(cfg.modes)} detailed modes, {len(cfg.vics)} VICs)"
100
+ )
101
+ for line in summarize(cfg):
102
+ print(line)
103
+ if args.check:
104
+ return 0
105
+
106
+ out: Path = args.output or (
107
+ args.config.parent / cfg.output
108
+ if cfg.output
109
+ else args.config.with_suffix(".bin")
110
+ )
111
+ try:
112
+ out.write_bytes(edid)
113
+ except OSError as e:
114
+ print(f"error: cannot write {out}: {e.strerror}", file=sys.stderr)
115
+ return 2
116
+ print(f"wrote {out} ({len(edid)} bytes)")
117
+
118
+ if args.decode:
119
+ if shutil.which("edid-decode") is None:
120
+ print("edid-decode not installed; skipping", file=sys.stderr)
121
+ else:
122
+ subprocess.run(["edid-decode", "-c", str(out)], check=False)
123
+ return 0