feat: restore EDID on reboot (#34)

This commit adds the config entry "EdidString" and saves the EDID string
when it's modified via the RPC.

The EDID is restored when the jetkvm_native control socket connects
(usually at boot)

Signed-off-by: Cameron Fleming <cameron@nevexo.space>
This commit is contained in:
Cameron Fleming 2025-02-13 13:42:07 +00:00 committed by GitHub
parent d07bedb323
commit 0b5033f798
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View File

@ -22,6 +22,7 @@ type Config struct {
LocalAuthToken string `json:"local_auth_token"` LocalAuthToken string `json:"local_auth_token"`
LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration
WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"` WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"`
EdidString string `json:"hdmi_edid_string"`
} }
const configPath = "/userdata/kvm_config.json" const configPath = "/userdata/kvm_config.json"

View File

@ -183,6 +183,12 @@ func rpcSetEDID(edid string) error {
if err != nil { if err != nil {
return err return err
} }
// Save EDID to config, allowing it to be restored on reboot.
LoadConfig()
config.EdidString = edid
SaveConfig()
return nil return nil
} }

View File

@ -152,6 +152,9 @@ func handleCtrlClient(conn net.Conn) {
ctrlSocketConn = conn ctrlSocketConn = conn
// Restore HDMI EDID if applicable
go restoreHdmiEdid()
readBuf := make([]byte, 4096) readBuf := make([]byte, 4096)
for { for {
n, err := conn.Read(readBuf) n, err := conn.Read(readBuf)
@ -304,3 +307,16 @@ func ensureBinaryUpdated(destPath string) error {
return nil return nil
} }
// Restore the HDMI EDID value from the config.
// Called after successful connection to jetkvm_native.
func restoreHdmiEdid() {
LoadConfig()
if config.EdidString != "" {
logger.Infof("Restoring HDMI EDID to %v", config.EdidString)
_, err := CallCtrlAction("set_edid", map[string]interface{}{"edid": config.EdidString})
if err != nil {
logger.Errorf("Failed to restore HDMI EDID: %v", err)
}
}
}