mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
edidconf presets
This commit is contained in:
parent
233bf6d60a
commit
5088e7d645
2
PKGBUILD
2
PKGBUILD
@ -248,7 +248,7 @@ for _variant in "${_variants[@]}"; do
|
|||||||
|
|
||||||
if [[ $_platform =~ ^.*-hdmi$ ]]; then
|
if [[ $_platform =~ ^.*-hdmi$ ]]; then
|
||||||
backup=(\"\${backup[@]}\" etc/kvmd/tc358743-edid.hex)
|
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
|
fi
|
||||||
|
|
||||||
mkdir -p \"\$pkgdir/usr/share/kvmd\"
|
mkdir -p \"\$pkgdir/usr/share/kvmd\"
|
||||||
|
|||||||
16
configs/kvmd/edid/_1080p-by-default.hex
Normal file
16
configs/kvmd/edid/_1080p-by-default.hex
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
00FFFFFFFFFFFF0031D8717701010101
|
||||||
|
231A010380351E780E0565A756529C27
|
||||||
|
0F50543FED00B300A9C0950090408180
|
||||||
|
814081C0714FEE2C80A070381A403020
|
||||||
|
3500404421000002000000FF00434146
|
||||||
|
45424142452020202020000000FD0032
|
||||||
|
4B0F5211000A202020202020000000FC
|
||||||
|
0050694B564D2056330A20202020012B
|
||||||
|
020317314A049F13223E213D203C0167
|
||||||
|
030C001000802DEE2C80A070381A4030
|
||||||
|
203500404421000002011D007251D01E
|
||||||
|
206E2835000F282100001E0000000000
|
||||||
|
00000000000000000000000000000000
|
||||||
|
00000000000000000000000000000000
|
||||||
|
00000000000000000000000000000000
|
||||||
|
000000000000000000000000000000CD
|
||||||
16
configs/kvmd/edid/_no-1920x1200.hex
Normal file
16
configs/kvmd/edid/_no-1920x1200.hex
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
00FFFFFFFFFFFF0031D8737701010101
|
||||||
|
231A010380351E780E0565A756529C27
|
||||||
|
0F50543FED00B300A9C0950090408180
|
||||||
|
814081C0714F023A801871382D40582C
|
||||||
|
45000F282100001E000000FF00434146
|
||||||
|
45424142452020202020000000FD0032
|
||||||
|
4B0F5211000A202020202020000000FC
|
||||||
|
0050694B564D20563420506C7573012D
|
||||||
|
020320714B90041F13223E213D203C01
|
||||||
|
67030C001000802D23097F0783010000
|
||||||
|
023A801871382D40582C45000F282100
|
||||||
|
001E011D007251D01E206E2855000F28
|
||||||
|
2100001E023A80D072382D40102C4580
|
||||||
|
0F282100001E00000000000000000000
|
||||||
|
00000000000000000000000000000000
|
||||||
|
00000000000000000000000000000042
|
||||||
@ -283,6 +283,21 @@ def _make_format_hex(size: int) -> Callable[[int], str]:
|
|||||||
return (lambda value: ("0x{:0%dX} ({})" % (size * 2)).format(value, value))
|
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
|
def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-branches,too-many-statements
|
||||||
# (parent_parser, argv, _) = init(
|
# (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",
|
description="A simple and primitive KVMD EDID editor",
|
||||||
# parents=[parent_parser],
|
# 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",
|
parser.add_argument("-f", "--edid", dest="edid_path", default="/etc/kvmd/tc358743-edid.hex",
|
||||||
help="The hex/bin EDID file path", metavar="<file>")
|
help="The hex/bin EDID file path", metavar="<file>")
|
||||||
parser.add_argument("--export-hex",
|
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>")
|
help="Export [--edid] file to the new file as a bin data", metavar="<file>")
|
||||||
parser.add_argument("--import", dest="imp",
|
parser.add_argument("--import", dest="imp",
|
||||||
help="Import the specified bin/hex EDID to the [--edid] file as a hex text", metavar="<file>")
|
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"],
|
parser.add_argument("--import-preset", choices=presets,
|
||||||
help="Restore default edid for the given PiKVM build")
|
help="Restore default EDID or choose the preset", metavar=f"{{ {' | '.join(presets)} }}",)
|
||||||
parser.add_argument("--set-audio", type=valid_bool,
|
parser.add_argument("--set-audio", type=valid_bool,
|
||||||
help="Enable or disable audio", metavar="<yes|no>")
|
help="Enable or disable audio", metavar="<yes|no>")
|
||||||
parser.add_argument("--set-mfc-id",
|
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]")
|
help="Apply [--edid] on the [--device]")
|
||||||
parser.add_argument("--device", dest="device_path", default="/dev/kvmd-video",
|
parser.add_argument("--device", dest="device_path", default="/dev/kvmd-video",
|
||||||
help="The video device", metavar="<device>")
|
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:])
|
options = parser.parse_args(argv[1:])
|
||||||
|
|
||||||
if options.restore_default:
|
base: (_Edid | None) = None
|
||||||
options.imp = f"/usr/share/kvmd/configs.default/kvmd/edid/{options.restore_default}-hdmi.hex"
|
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
|
orig_edid_path = options.edid_path
|
||||||
if options.imp:
|
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):
|
for cmd in dir(_Edid):
|
||||||
if cmd.startswith("set_"):
|
if cmd.startswith("set_"):
|
||||||
value = getattr(options, cmd)
|
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:
|
if value is not None:
|
||||||
getattr(edid, cmd)(value)
|
getattr(edid, cmd)(value)
|
||||||
changed = True
|
changed = True
|
||||||
@ -351,18 +384,7 @@ def main(argv: (list[str] | None)=None) -> None: # pylint: disable=too-many-bra
|
|||||||
elif changed:
|
elif changed:
|
||||||
edid.write_hex(options.edid_path)
|
edid.write_hex(options.edid_path)
|
||||||
|
|
||||||
for (key, get, fmt) in [
|
_print_edid(edid)
|
||||||
("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
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if options.clear:
|
if options.clear:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user