diff options
author | Maxim Devaev <[email protected]> | 2024-04-06 21:52:34 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2024-04-06 21:52:34 +0300 |
commit | 5088e7d645d4d3685e5e34991e27cca6a693e712 (patch) | |
tree | f4babbb1e9ea2c11662b4230da1872f27deaa37a | |
parent | 233bf6d60a142a116b6c0ea14f06069a7faac626 (diff) |
edidconf presets
-rw-r--r-- | PKGBUILD | 2 | ||||
-rw-r--r-- | configs/kvmd/edid/_1080p-by-default.hex | 16 | ||||
-rw-r--r-- | configs/kvmd/edid/_no-1920x1200.hex | 16 | ||||
-rw-r--r-- | configs/kvmd/edid/v0.hex (renamed from configs/kvmd/edid/v0-hdmi.hex) | 0 | ||||
-rw-r--r-- | configs/kvmd/edid/v1.hex (renamed from configs/kvmd/edid/v1-hdmi.hex) | 0 | ||||
-rw-r--r-- | configs/kvmd/edid/v2.hex (renamed from configs/kvmd/edid/v2-hdmi.hex) | 0 | ||||
-rw-r--r-- | configs/kvmd/edid/v3.hex (renamed from configs/kvmd/edid/v3-hdmi.hex) | 0 | ||||
-rw-r--r-- | configs/kvmd/edid/v4mini.hex (renamed from configs/kvmd/edid/v4mini-hdmi.hex) | 0 | ||||
-rw-r--r-- | configs/kvmd/edid/v4plus.hex (renamed from configs/kvmd/edid/v4plus-hdmi.hex) | 0 | ||||
-rw-r--r-- | kvmd/apps/edidconf/__init__.py | 54 |
10 files changed, 71 insertions, 17 deletions
@@ -248,7 +248,7 @@ for _variant in "${_variants[@]}"; do if [[ $_platform =~ ^.*-hdmi$ ]]; then backup=(\"\${backup[@]}\" etc/kvmd/tc358743-edid.hex) - install -DTm444 configs/kvmd/edid/$_platform.hex \"\$pkgdir/etc/kvmd/tc358743-edid.hex\" + install -DTm444 configs/kvmd/edid/$_base.hex \"\$pkgdir/etc/kvmd/tc358743-edid.hex\" fi mkdir -p \"\$pkgdir/usr/share/kvmd\" diff --git a/configs/kvmd/edid/_1080p-by-default.hex b/configs/kvmd/edid/_1080p-by-default.hex new file mode 100644 index 00000000..f4238bec --- /dev/null +++ b/configs/kvmd/edid/_1080p-by-default.hex @@ -0,0 +1,16 @@ +00FFFFFFFFFFFF0031D8717701010101 +231A010380351E780E0565A756529C27 +0F50543FED00B300A9C0950090408180 +814081C0714FEE2C80A070381A403020 +3500404421000002000000FF00434146 +45424142452020202020000000FD0032 +4B0F5211000A202020202020000000FC +0050694B564D2056330A20202020012B +020317314A049F13223E213D203C0167 +030C001000802DEE2C80A070381A4030 +203500404421000002011D007251D01E +206E2835000F282100001E0000000000 +00000000000000000000000000000000 +00000000000000000000000000000000 +00000000000000000000000000000000 +000000000000000000000000000000CD diff --git a/configs/kvmd/edid/_no-1920x1200.hex b/configs/kvmd/edid/_no-1920x1200.hex new file mode 100644 index 00000000..c89278e5 --- /dev/null +++ b/configs/kvmd/edid/_no-1920x1200.hex @@ -0,0 +1,16 @@ +00FFFFFFFFFFFF0031D8737701010101 +231A010380351E780E0565A756529C27 +0F50543FED00B300A9C0950090408180 +814081C0714F023A801871382D40582C +45000F282100001E000000FF00434146 +45424142452020202020000000FD0032 +4B0F5211000A202020202020000000FC +0050694B564D20563420506C7573012D +020320714B90041F13223E213D203C01 +67030C001000802D23097F0783010000 +023A801871382D40582C45000F282100 +001E011D007251D01E206E2855000F28 +2100001E023A80D072382D40102C4580 +0F282100001E00000000000000000000 +00000000000000000000000000000000 +00000000000000000000000000000042 diff --git a/configs/kvmd/edid/v0-hdmi.hex b/configs/kvmd/edid/v0.hex index 6c53d8d6..6c53d8d6 100644 --- a/configs/kvmd/edid/v0-hdmi.hex +++ b/configs/kvmd/edid/v0.hex diff --git a/configs/kvmd/edid/v1-hdmi.hex b/configs/kvmd/edid/v1.hex index 6c53d8d6..6c53d8d6 100644 --- a/configs/kvmd/edid/v1-hdmi.hex +++ b/configs/kvmd/edid/v1.hex diff --git a/configs/kvmd/edid/v2-hdmi.hex b/configs/kvmd/edid/v2.hex index 6c53d8d6..6c53d8d6 100644 --- a/configs/kvmd/edid/v2-hdmi.hex +++ b/configs/kvmd/edid/v2.hex diff --git a/configs/kvmd/edid/v3-hdmi.hex b/configs/kvmd/edid/v3.hex index aeb8dc29..aeb8dc29 100644 --- a/configs/kvmd/edid/v3-hdmi.hex +++ b/configs/kvmd/edid/v3.hex diff --git a/configs/kvmd/edid/v4mini-hdmi.hex b/configs/kvmd/edid/v4mini.hex index a38e70d2..a38e70d2 100644 --- a/configs/kvmd/edid/v4mini-hdmi.hex +++ b/configs/kvmd/edid/v4mini.hex diff --git a/configs/kvmd/edid/v4plus-hdmi.hex b/configs/kvmd/edid/v4plus.hex index 9be030c2..9be030c2 100644 --- a/configs/kvmd/edid/v4plus-hdmi.hex +++ b/configs/kvmd/edid/v4plus.hex diff --git a/kvmd/apps/edidconf/__init__.py b/kvmd/apps/edidconf/__init__.py index 141cc1a3..66136cb3 100644 --- a/kvmd/apps/edidconf/__init__.py +++ b/kvmd/apps/edidconf/__init__.py @@ -283,6 +283,21 @@ def _make_format_hex(size: int) -> Callable[[int], str]: return (lambda value: ("0x{:0%dX} ({})" % (size * 2)).format(value, value)) +def _print_edid(edid: _Edid) -> None: + for (key, get, fmt) in [ + ("Manufacturer ID:", edid.get_mfc_id, str), + ("Product ID: ", edid.get_product_id, _make_format_hex(2)), + ("Serial number: ", edid.get_serial, _make_format_hex(4)), + ("Monitor name: ", edid.get_monitor_name, str), + ("Monitor serial: ", edid.get_monitor_serial, str), + ("Audio: ", edid.get_audio, _format_bool), + ]: + try: + print(key, fmt(get()), file=sys.stderr) # type: ignore + except NoBlockError: + pass + + # ===== def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-branches,too-many-statements # (parent_parser, argv, _) = init( @@ -296,6 +311,11 @@ def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-bra description="A simple and primitive KVMD EDID editor", # parents=[parent_parser], ) + + lane2 = ["v0", "v1", "v2", "v3"] + lane4 = ["v4mini", "v4plus"] + presets = lane2 + lane4 + [f"{name}.1080p-by-default" for name in lane2] + [f"{name}.no-1920x1200" for name in lane4] + parser.add_argument("-f", "--edid", dest="edid_path", default="/etc/kvmd/tc358743-edid.hex", help="The hex/bin EDID file path", metavar="<file>") parser.add_argument("--export-hex", @@ -304,8 +324,8 @@ def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-bra help="Export [--edid] file to the new file as a bin data", metavar="<file>") parser.add_argument("--import", dest="imp", help="Import the specified bin/hex EDID to the [--edid] file as a hex text", metavar="<file>") - parser.add_argument("--restore-default", choices=["v0", "v1", "v2", "v3", "v4mini", "v4plus"], - help="Restore default edid for the given PiKVM build") + parser.add_argument("--import-preset", choices=presets, + help="Restore default EDID or choose the preset", metavar=f"{{ {' | '.join(presets)} }}",) parser.add_argument("--set-audio", type=valid_bool, help="Enable or disable audio", metavar="<yes|no>") parser.add_argument("--set-mfc-id", @@ -324,10 +344,18 @@ def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-bra help="Apply [--edid] on the [--device]") parser.add_argument("--device", dest="device_path", default="/dev/kvmd-video", help="The video device", metavar="<device>") + parser.add_argument("--presets", dest="presets_path", default="/usr/share/kvmd/configs.default/kvmd/edid", + help="Presets directory", metavar="<dir>") options = parser.parse_args(argv[1:]) - if options.restore_default: - options.imp = f"/usr/share/kvmd/configs.default/kvmd/edid/{options.restore_default}-hdmi.hex" + base: (_Edid | None) = None + if options.import_preset: + imp = options.import_preset + if "." in imp: + (base_name, imp) = imp.split(".", 1) # v3.1080p-by-default + base = _Edid(os.path.join(options.presets_path, f"{base_name}.hex")) + imp = f"_{imp}" + options.imp = os.path.join(options.presets_path, f"{imp}.hex") orig_edid_path = options.edid_path if options.imp: @@ -340,6 +368,11 @@ def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-bra for cmd in dir(_Edid): if cmd.startswith("set_"): value = getattr(options, cmd) + if value is None and base is not None: + try: + value = getattr(base, cmd.replace("set_", "get_"))() + except NoBlockError: + pass if value is not None: getattr(edid, cmd)(value) changed = True @@ -351,18 +384,7 @@ def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-bra elif changed: edid.write_hex(options.edid_path) - for (key, get, fmt) in [ - ("Manufacturer ID:", edid.get_mfc_id, str), - ("Product ID: ", edid.get_product_id, _make_format_hex(2)), - ("Serial number: ", edid.get_serial, _make_format_hex(4)), - ("Monitor name: ", edid.get_monitor_name, str), - ("Monitor serial: ", edid.get_monitor_serial, str), - ("Audio: ", edid.get_audio, _format_bool), - ]: - try: - print(key, fmt(get()), file=sys.stderr) # type: ignore - except NoBlockError: - pass + _print_edid(edid) try: if options.clear: |