Add video_mode FIFO command for CRT video mode switching (#1107)

* Add video_mode FIFO command for CRT video mode switching

- video.cpp: Add video_mode_cmd() that parses custom modelines and
  applies them via video_set_mode(), with hfreq safety check blocking
  modes outside 15625-16500Hz to protect 15kHz CRT monitors
- video.h: Declare video_mode_cmd()
- input.cpp: Dispatch "video_mode" commands from MiSTer_cmd FIFO
  to video_mode_cmd()

* Remove hfreq guard from video_mode_cmd

The horizontal frequency check was limiting the command to 15kHz modes only. Removing it allows custom modelines with any frequency to be applied. Software at the other end must take care of not calling this API with unsafe frequencies.
This commit is contained in:
José Manuel Barroso Galindo
2026-03-04 07:39:07 +01:00
committed by GitHub
parent 1bc3356df5
commit 7a7bef3d06
3 changed files with 19 additions and 0 deletions

View File

@@ -5864,6 +5864,7 @@ int input_test(int getchar)
cmd[len] = 0;
printf("MiSTer_cmd: %s\n", cmd);
if (!strncmp(cmd, "fb_cmd", 6)) video_cmd(cmd);
else if (!strncmp(cmd, "video_mode ", 11)) video_mode_cmd(cmd + 11);
else if (!strncmp(cmd, "load_core ", 10))
{
if(isXmlName(cmd)) xml_load(cmd + 10);

View File

@@ -3900,6 +3900,23 @@ void video_cmd(char *cmd)
}
}
void video_mode_cmd(char *cmd)
{
vmode_custom_t v = {};
int ret = parse_custom_video_mode(cmd, &v);
if (ret != -2)
{
printf("video_mode_cmd: only custom modelines are supported, got \"%s\"\n", cmd);
return;
}
v_def = v;
v_cur = v;
video_set_mode(&v, v.Fpix);
user_io_send_buttons(1);
printf("video_mode_cmd: applied mode \"%s\"\n", cmd);
}
static constexpr int CELL_GRAN_RND = 4;
static int determine_vsync(int w, int h)

View File

@@ -67,6 +67,7 @@ void video_menu_bg(int n, int idle = 0);
int video_bg_has_picture();
int video_chvt(int num);
void video_cmd(char *cmd);
void video_mode_cmd(char *cmd);
void video_core_description(char *str, size_t len);
void video_scaler_description(char *str, size_t len);