Skip to content

Commit 0b5033f

Browse files
authored
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 <[email protected]>
1 parent d07bedb commit 0b5033f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Config struct {
2222
LocalAuthToken string `json:"local_auth_token"`
2323
LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration
2424
WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"`
25+
EdidString string `json:"hdmi_edid_string"`
2526
}
2627

2728
const configPath = "/userdata/kvm_config.json"

jsonrpc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ func rpcSetEDID(edid string) error {
183183
if err != nil {
184184
return err
185185
}
186+
187+
// Save EDID to config, allowing it to be restored on reboot.
188+
LoadConfig()
189+
config.EdidString = edid
190+
SaveConfig()
191+
186192
return nil
187193
}
188194

native.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ func handleCtrlClient(conn net.Conn) {
152152

153153
ctrlSocketConn = conn
154154

155+
// Restore HDMI EDID if applicable
156+
go restoreHdmiEdid()
157+
155158
readBuf := make([]byte, 4096)
156159
for {
157160
n, err := conn.Read(readBuf)
@@ -304,3 +307,16 @@ func ensureBinaryUpdated(destPath string) error {
304307

305308
return nil
306309
}
310+
311+
// Restore the HDMI EDID value from the config.
312+
// Called after successful connection to jetkvm_native.
313+
func restoreHdmiEdid() {
314+
LoadConfig()
315+
if config.EdidString != "" {
316+
logger.Infof("Restoring HDMI EDID to %v", config.EdidString)
317+
_, err := CallCtrlAction("set_edid", map[string]interface{}{"edid": config.EdidString})
318+
if err != nil {
319+
logger.Errorf("Failed to restore HDMI EDID: %v", err)
320+
}
321+
}
322+
}

0 commit comments

Comments
 (0)