mirror of https://github.com/jetkvm/kvm.git
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:
parent
d07bedb323
commit
0b5033f798
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
native.go
16
native.go
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue