Skip to content

Commit

Permalink
Small cleanup to drm_ctx.c
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jun 20, 2023
1 parent 1cff8e2 commit 700b58a
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions gfx/drivers_context/drm_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static bool switch_mode = false;

static float mode_vrefresh(drmModeModeInfo *mode)
{
return mode->clock * 1000.00 / (mode->htotal * mode->vtotal);
return mode->clock * 1000.00f / (mode->htotal * mode->vtotal);
}

static void dump_mode(drmModeModeInfo *mode, int index)
Expand Down Expand Up @@ -345,40 +345,38 @@ bool gfx_ctx_drm_get_mode_from_video_state(drmModeModeInfoPtr modeInfo)
{
#ifdef HAVE_CRTSWITCHRES
video_driver_state_t *video_st = video_state_get_ptr();
if (video_st->crt_switch_st.vdisplay < 1)
if (video_st->crt_switch_st.vdisplay >= 1)
{
return false;
}
modeInfo->clock = video_st->crt_switch_st.clock;
modeInfo->hdisplay = video_st->crt_switch_st.hdisplay;
modeInfo->hsync_start = video_st->crt_switch_st.hsync_start;
modeInfo->hsync_end = video_st->crt_switch_st.hsync_end;
modeInfo->htotal = video_st->crt_switch_st.htotal;
modeInfo->vdisplay = video_st->crt_switch_st.vdisplay;
modeInfo->vsync_start = video_st->crt_switch_st.vsync_start;
modeInfo->vsync_end = video_st->crt_switch_st.vsync_end;
modeInfo->vtotal = video_st->crt_switch_st.vtotal;
modeInfo->flags = (video_st->crt_switch_st.interlace ? DRM_MODE_FLAG_INTERLACE : 0)
| (video_st->crt_switch_st.doublescan ? DRM_MODE_FLAG_DBLSCAN : 0)
| (video_st->crt_switch_st.hsync ? DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC)
| (video_st->crt_switch_st.vsync ? DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC);
modeInfo->hskew = 0;
modeInfo->vscan = 0;
modeInfo->vrefresh = video_st->crt_switch_st.vrefresh;
modeInfo->type = DRM_MODE_TYPE_USERDEF;

snprintf(modeInfo->name, 45, "RetroArch_CRT-%dx%d@%.02f%s"
modeInfo->clock = video_st->crt_switch_st.clock;
modeInfo->hdisplay = video_st->crt_switch_st.hdisplay;
modeInfo->hsync_start = video_st->crt_switch_st.hsync_start;
modeInfo->hsync_end = video_st->crt_switch_st.hsync_end;
modeInfo->htotal = video_st->crt_switch_st.htotal;
modeInfo->vdisplay = video_st->crt_switch_st.vdisplay;
modeInfo->vsync_start = video_st->crt_switch_st.vsync_start;
modeInfo->vsync_end = video_st->crt_switch_st.vsync_end;
modeInfo->vtotal = video_st->crt_switch_st.vtotal;
modeInfo->flags = (video_st->crt_switch_st.interlace ? DRM_MODE_FLAG_INTERLACE : 0)
| (video_st->crt_switch_st.doublescan ? DRM_MODE_FLAG_DBLSCAN : 0)
| (video_st->crt_switch_st.hsync ? DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC)
| (video_st->crt_switch_st.vsync ? DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC);
modeInfo->hskew = 0;
modeInfo->vscan = 0;
modeInfo->vrefresh = video_st->crt_switch_st.vrefresh;
modeInfo->type = DRM_MODE_TYPE_USERDEF;

snprintf(modeInfo->name, 45, "RetroArch_CRT-%dx%d@%.02f%s"
, video_st->crt_switch_st.hdisplay
, video_st->crt_switch_st.vdisplay
, mode_vrefresh(modeInfo)
, video_st->crt_switch_st.interlace ? "i" : "");
dump_mode(modeInfo, 0);
/* consider the mode read and removed */
video_st->crt_switch_st.vdisplay = 0;
return true;
#else
return false;
dump_mode(modeInfo, 0);
/* consider the mode read and removed */
video_st->crt_switch_st.vdisplay = 0;
return true;
}
#endif
return false;
}

/* Load custom hdmi timings from config */
Expand Down

0 comments on commit 700b58a

Please sign in to comment.