INI option to limit display refresh rate.

This commit is contained in:
sorgelig
2020-03-12 00:40:19 +08:00
parent a9d1f70265
commit dda937af89
4 changed files with 24 additions and 0 deletions

View File

@@ -82,6 +82,13 @@ video_info=0
; modes as a base even for 50Hz systems.
vsync_adjust=0
; If you monitor doesn't support either very low (NTSC monitors may not support PAL) or
; very high (PAL monitors may not support NTSC) then you can set refresh_min and/or refresh_max
; parameters, so vsync_adjust won't be applied for refreshes outside specified.
; These parameters are valid only when vsync_adjust is non-zero.
refresh_min=0
refresh_max=0
; These parameters have the same format as video_mode.
; You need to supply both PAL and NTSC modes if you want vsync_adjust to switch between
; predefined modes as a base. This will reduce the range of pixel clock.

View File

@@ -61,6 +61,8 @@ const ini_var_t ini_vars[] = {
{ "GAMEPAD_DEFAULTS", (void*)(&(cfg.gamepad_defaults)), UINT8, 0, 1 },
{ "RECENTS", (void*)(&(cfg.recents)), UINT8, 0, 1 },
{ "CONTROLLER_INFO", (void*)(&(cfg.controller_info)), UINT8, 0, 10 },
{ "REFRESH_MIN", (void*)(&(cfg.refresh_min)), UINT8, 0, 150 },
{ "REFRESH_MAX", (void*)(&(cfg.refresh_max)), UINT8, 0, 150 },
};
// mist ini config

2
cfg.h
View File

@@ -26,6 +26,8 @@ typedef struct {
uint8_t hdmi_limited;
uint8_t direct_video;
uint8_t video_info;
uint8_t refresh_min;
uint8_t refresh_max;
uint8_t controller_info;
uint8_t vsync_adjust;
uint8_t kbd_nomouse;

View File

@@ -737,6 +737,19 @@ void video_mode_adjust()
printf("Estimated Fpix(%.4f MHz) is outside supported range. Canceling auto-adjust.\n", Fpix);
Fpix = 0;
}
uint32_t hz = 100000000 / vtime;
if (cfg.refresh_min && hz < cfg.refresh_min)
{
printf("Estimated frame rate (%d Hz) is less than MONITOR_HZ_MIN(%d Hz). Canceling auto-adjust.\n", hz, cfg.refresh_min);
Fpix = 0;
}
if (cfg.refresh_max && hz > cfg.refresh_max)
{
printf("Estimated frame rate (%d Hz) is more than MONITOR_HZ_MAX(%d Hz). Canceling auto-adjust.\n", hz, cfg.refresh_max);
Fpix = 0;
}
}
set_video(v, Fpix);