From cb31cc55b76ded9af54beea1d1968fe2d821e907 Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Sat, 16 May 2026 01:49:04 +0800 Subject: [PATCH] Add hdmi_off ini option. --- MiSTer.ini | 15 ++++++++++----- cfg.cpp | 2 +- cfg.h | 2 +- menu.cpp | 4 +--- user_io.cpp | 26 ++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/MiSTer.ini b/MiSTer.ini index eb807c2..ed960f6 100644 --- a/MiSTer.ini +++ b/MiSTer.ini @@ -22,11 +22,11 @@ rbf_hide_datecode=0 ; 1 - hides datecodes from rbf file names. Press F2 for q menu_pal=0 ; 1 - PAL mode for menu core hdmi_limited=0 ; 1 - use limited (16..235) color range over HDMI ; 2 - use limited (16..255) color range over HDMI, for VGA converters. -hdmi_cec=0 ; 1 - enable HDMI-CEC via ADV7513, 0 - disable. -hdmi_cec_input_mode=1 ; 0 - ignore CEC remote input, 1 - accept mapped CEC keys. -hdmi_cec_power_on=1 ; 1 - on power-on, try once to make MiSTer the active HDMI input once EDID provides its CEC address. -hdmi_cec_sleep=0 ; 1 - send CEC STANDBY after video_off minutes of no input activity. Requires video_off>0. -hdmi_cec_wake=0 ; 1 - on input after that idle period, send wake (ImageViewOn/TextViewOn/ActiveSource). +hdmi_cec=0 ; 1 - enable HDMI-CEC via ADV7513, 0 - disable. +hdmi_cec_input_mode=1 ; 0 - ignore CEC remote input, 1 - accept mapped CEC keys. +hdmi_cec_power_on=1 ; 1 - on power-on, try once to make MiSTer the active HDMI input once EDID provides its CEC address. +hdmi_cec_sleep=0 ; 1 - send CEC STANDBY after video_off minutes of no input activity. Requires video_off>0. +hdmi_cec_wake=0 ; 1 - on input after that idle period, send wake (ImageViewOn/TextViewOn/ActiveSource). hdmi_cec_clock=0 ; 0 - default clock 12MHz, otherwise floating point value from 3.0 to 100.0 (3-100MHz). ; direct_video=0 ; 1 - enable core video timing over HDMI, use only with VGA converters. @@ -396,3 +396,8 @@ osd_lock_time=5 ; 2 - Additionally don't send new SPD upon OSD open/close ; 3 - Don't send SPD at all. ;spd_quirk=0 + +; 1...1440 - minutes till HDMI off if no user activity detected (no input from mouse/keyboard/joystick). +; unlike video_off which works only in Menu core, this option works in all cores. +; 0 (default) - don't turn HDMI off. +hdmi_off=0 diff --git a/cfg.cpp b/cfg.cpp index eb89180..c483f8f 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -113,7 +113,6 @@ static const ini_var_t ini_vars[] = { "VRR_MODE", (void *)(&(cfg.vrr_mode)), UINT8, 0, 4 }, { "VRR_VESA_FRAMERATE", (void *)(&(cfg.vrr_vesa_framerate)), UINT8, 0, 255 }, { "VIDEO_OFF", (void*)(&(cfg.video_off)), INT16, 0, 3600 }, - { "VIDEO_OFF_HDMI", (void*)(&(cfg.video_off_hdmi)), UINT8, 0, 1 }, { "VIDEO_OFF_LOGO", (void*)(&(cfg.video_off_logo)), UINT8, 0, 1 }, { "PLAYER_1_CONTROLLER", (void*)(&(cfg.player_controller[0])), STRINGARR, sizeof(cfg.player_controller[0]) / sizeof(cfg.player_controller[0][0]), sizeof(cfg.player_controller[0][0]) }, { "PLAYER_2_CONTROLLER", (void*)(&(cfg.player_controller[1])), STRINGARR, sizeof(cfg.player_controller[0]) / sizeof(cfg.player_controller[0][0]), sizeof(cfg.player_controller[0][0]) }, @@ -144,6 +143,7 @@ static const ini_var_t ini_vars[] = { "SCREENSHOT_IMAGE_FORMAT", (void *)(&(cfg.screenshot_image_format)), STRING, 0, sizeof(cfg.screenshot_image_format) - 1 }, { "XBE2_SHIFT", (void*)(&(cfg.xbe2_shift)), UINT16, 0, 0x22F }, { "SPD_QUIRK", (void*)(&(cfg.spd_quirk)), UINT8, 0, 3 }, + { "HDMI_OFF", (void*)(&(cfg.hdmi_off)), UINT16, 0, 1440 }, }; static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t)); diff --git a/cfg.h b/cfg.h index 7022425..f7873c8 100644 --- a/cfg.h +++ b/cfg.h @@ -86,7 +86,6 @@ typedef struct { uint8_t vrr_mode; uint8_t vrr_vesa_framerate; uint16_t video_off; - uint8_t video_off_hdmi; uint8_t video_off_logo; uint8_t disable_autofire; uint8_t video_brightness; @@ -112,6 +111,7 @@ typedef struct { char screenshot_image_format[16]; uint16_t xbe2_shift; uint8_t spd_quirk; + uint16_t hdmi_off; } cfg_t; extern cfg_t cfg; diff --git a/menu.cpp b/menu.cpp index de14583..6d125a3 100644 --- a/menu.cpp +++ b/menu.cpp @@ -1238,8 +1238,7 @@ void HandleUI(void) { off_timeout = 0; video_menu_bg(user_io_status_get("[3:1]"), cfg.video_off_logo ? 4 : 3); - if (cfg.video_off_hdmi) video_hdmi_power(0); - else if (cfg.video_off_logo) off_timeout = GetTimer(10000); + if (cfg.video_off_logo) off_timeout = GetTimer(10000); } if (c || menustate != MENU_FILE_SELECT2) @@ -1249,7 +1248,6 @@ void HandleUI(void) { c = 0; menu_visible = 1; - if (cfg.video_off_hdmi) video_hdmi_power(1); video_menu_bg(user_io_status_get("[3:1]")); OsdMenuCtl(1); off_timeout = 0; diff --git a/user_io.cpp b/user_io.cpp index 1626632..1071eff 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -3751,6 +3751,32 @@ void user_io_poll() if (is_atari5200()) atari5200_poll(); if (is_3do()) p3do_poll(); process_ss(0); + + if (cfg.hdmi_off) + { + static uint32_t hdmi_timeout = 0; + static uint32_t seq = 0; + static int hdmi_on = 1; + + if (!hdmi_timeout || seq != user_io_get_activity_seq() || !input_state()) + { + seq = user_io_get_activity_seq(); + hdmi_timeout = GetTimer(cfg.hdmi_off * 60000); + if (!hdmi_on) + { + printf("hdmi_on\n"); + hdmi_on = 1; + video_hdmi_power(1); + } + } + + if (CheckTimer(hdmi_timeout) && hdmi_on) + { + printf("hdmi_off\n"); + hdmi_on = 0; + video_hdmi_power(0); + } + } } static void send_keycode(unsigned short key, int press)