mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-11-09 17:44:43 -06:00
feature: provide HDMI status in /api/vm/hdmi (#859)
* feature: provide HDMI status in /api/vm/hdmi * fix: return false when HDMI idle in /api/vm/hdmi
This commit is contained in:
@@ -116,6 +116,16 @@ func (k *KvmVision) SetHDMI(enable bool) int {
|
||||
return result
|
||||
}
|
||||
|
||||
func (k *KvmVision) HasHDMISignal() bool {
|
||||
k.mutex.RLock()
|
||||
defer k.mutex.RUnlock()
|
||||
if k.closed {
|
||||
return false
|
||||
}
|
||||
|
||||
return C.kvmv_hdmi_signal_active() != 0
|
||||
}
|
||||
|
||||
func (k *KvmVision) SetGop(gop uint8) {
|
||||
k.mutex.RLock()
|
||||
defer k.mutex.RUnlock()
|
||||
|
||||
Binary file not shown.
@@ -21,6 +21,7 @@ require (
|
||||
github.com/spf13/viper v1.19.0
|
||||
github.com/unrolled/secure v1.15.0
|
||||
golang.org/x/crypto v0.45.0
|
||||
golang.org/x/sys v0.41.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
@@ -79,7 +80,6 @@ require (
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
||||
golang.org/x/net v0.47.0 // indirect
|
||||
golang.org/x/oauth2 v0.35.0 // indirect
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
|
||||
@@ -66,6 +66,7 @@ void set_h264_gop(uint8_t _gop);
|
||||
void set_frame_detact(uint8_t _frame_detact);
|
||||
void kvmv_deinit();
|
||||
uint8_t kvmv_hdmi_control(uint8_t _en);
|
||||
uint8_t kvmv_hdmi_signal_active(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ type GetOLEDRsp struct {
|
||||
|
||||
type GetGetHdmiStateRsp struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Signal bool `json:"signal"`
|
||||
IdleTimeout int `json:"idleTimeout"`
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ var (
|
||||
setHDMI = func(enabled bool) { common.GetKvmVision().SetHDMI(enabled) }
|
||||
isHdmiDisabled = utils.IsHdmiDisabled
|
||||
getHdmiIdleTimeout = utils.GetHDMIIdleTimeout
|
||||
getHdmiSignal = func() bool { return common.GetKvmVision().HasHDMISignal() }
|
||||
)
|
||||
|
||||
func (s *Service) ResetHdmi(c *gin.Context) {
|
||||
@@ -63,10 +64,12 @@ func (s *Service) DisableHdmi(c *gin.Context) {
|
||||
|
||||
func (s *Service) GetHdmiState(c *gin.Context) {
|
||||
var rsp proto.Response
|
||||
enabled := !isHdmiDisabled()
|
||||
|
||||
rsp.OkRspWithData(c, &proto.GetGetHdmiStateRsp{
|
||||
Enabled: !utils.IsHdmiDisabled(),
|
||||
IdleTimeout: utils.GetHDMIIdleTimeout(),
|
||||
Enabled: enabled,
|
||||
Signal: enabled && getHdmiSignal(),
|
||||
IdleTimeout: getHdmiIdleTimeout(),
|
||||
})
|
||||
|
||||
log.Debug("get hdmi state")
|
||||
|
||||
Reference in New Issue
Block a user