Skip to content

Commit

Permalink
rename, use float refreshrate
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltanvb committed Jun 16, 2024
1 parent a7da443 commit d736f07
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
17 changes: 5 additions & 12 deletions gfx/display_servers/dispserv_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static void *kms_display_server_get_resolution_list(
unsigned curr_height = 0;
unsigned curr_bpp = 0;
bool curr_interlaced = false;
bool curr_doublestrike = false;
bool curr_dblscan = false;
float curr_refreshrate = 0;
unsigned curr_orientation = 0;
struct video_display_config *conf = NULL;
Expand All @@ -137,7 +137,7 @@ static void *kms_display_server_get_resolution_list(
curr_height = g_drm_mode->vdisplay;
curr_bpp = 32;
curr_interlaced = (g_drm_mode->flags & DRM_MODE_FLAG_INTERLACE) ? true : false;
curr_doublestrike = (g_drm_mode->flags & DRM_MODE_FLAG_DBLSCAN) ? true : false;
curr_dblscan = (g_drm_mode->flags & DRM_MODE_FLAG_DBLSCAN) ? true : false;
}

*len = g_drm_connector->count_modes;
Expand All @@ -153,23 +153,16 @@ static void *kms_display_server_get_resolution_list(
conf[j].refreshrate = floor(drm_calc_refresh_rate(&g_drm_connector->modes[i]));
conf[j].refreshrate_float = drm_calc_refresh_rate(&g_drm_connector->modes[i]);
conf[j].interlaced = (g_drm_connector->modes[i].flags & DRM_MODE_FLAG_INTERLACE) ? true : false;
conf[j].doublestrike = (g_drm_connector->modes[i].flags & DRM_MODE_FLAG_DBLSCAN) ? true : false;
conf[j].dblscan = (g_drm_connector->modes[i].flags & DRM_MODE_FLAG_DBLSCAN) ? true : false;
conf[j].idx = j;
conf[j].current = false;
RARCH_DBG("[DRM]: Display server resolution list %02d: %d x %d, %f Hz, interlace %s, doublestrike %s\n",
j,
conf[j].width,
conf[j].height,
conf[j].refreshrate_float,
conf[j].interlaced ? "true" : "false",
conf[j].doublestrike ? "true" : "false");

if ( (conf[j].width == curr_width)
&& (conf[j].height == curr_height)
&& (conf[j].bpp == curr_bpp)
&& (drm_calc_refresh_rate(&g_drm_connector->modes[i]) == curr_refreshrate)
&& (conf[j].refreshrate_float == curr_refreshrate)
&& (conf[j].interlaced == curr_interlaced)
&& (conf[j].doublestrike == curr_doublestrike)
&& (conf[j].dblscan == curr_dblscan)
)
conf[j].current = true;
j++;
Expand Down
5 changes: 4 additions & 1 deletion gfx/display_servers/dispserv_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ static void *win32_display_server_get_resolution_list(
#if _WIN32_WINNT >= 0x0500
unsigned curr_orientation = 0;
#endif
bool curr_interlaced = 0;
struct video_display_config *conf = NULL;

if (win32_get_video_output(&dm, -1, sizeof(dm)))
Expand All @@ -367,6 +368,7 @@ static void *win32_display_server_get_resolution_list(
#if _WIN32_WINNT >= 0x0500
curr_orientation = dm.dmDisplayOrientation;
#endif
curr_interlaced = (dm.dmDisplayFlags & DM_INTERLACED) ? true : false;
}

for (i = 0; win32_get_video_output(&dm, i, sizeof(dm)); i++)
Expand Down Expand Up @@ -407,12 +409,13 @@ static void *win32_display_server_get_resolution_list(
conf[j].idx = j;
conf[j].current = false;
conf[j].interlaced = (dm.dmDisplayFlags & DM_INTERLACED) ? true : false;
conf[j].doublestrike = false;
conf[j].dblscan = false;

if ( (conf[j].width == curr_width)
&& (conf[j].height == curr_height)
&& (conf[j].bpp == curr_bpp)
&& (conf[j].refreshrate == curr_refreshrate)
&& (conf[j].interlaced == curr_interlaced)
)
conf[j].current = true;

Expand Down
2 changes: 1 addition & 1 deletion gfx/video_display_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef struct video_display_config
unsigned idx;
bool current;
bool interlaced;
bool doublestrike;
bool dblscan;
float refreshrate_float;
} video_display_config_t;

Expand Down
3 changes: 2 additions & 1 deletion gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,8 @@ bool video_display_server_has_refresh_rate(float hz)
{
if ( (video_list[i].width == video_driver_width)
&& (video_list[i].height == video_driver_height)
&& (video_list[i].refreshrate == floor(hz)))
&& ((video_list[i].refreshrate == floor(hz)) ||
(video_list[i].refreshrate_float - hz < 0.06f)))
rate_exists = true;
}

Expand Down
8 changes: 7 additions & 1 deletion menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -8350,7 +8350,13 @@ unsigned menu_displaylist_build_list(
for (i = 0; i < size; i++)
{
char val_d[256], str[256];
snprintf(str, sizeof(str), "%dx%d (%d Hz)",
if (video_list[i].refreshrate_float > 0.0f)
snprintf(str, sizeof(str), "%dx%d (%.2f Hz)",
video_list[i].width,
video_list[i].height,
video_list[i].refreshrate_float);
else
snprintf(str, sizeof(str), "%dx%d (%d Hz)",
video_list[i].width,
video_list[i].height,
video_list[i].refreshrate);
Expand Down

0 comments on commit d736f07

Please sign in to comment.