Skip to content

Commit

Permalink
drm: fix drm_set_refresh when rotated
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Oct 19, 2021
1 parent dd45be8 commit d3496fd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,17 +1286,25 @@ bool drm_set_mode( struct drm_t *drm, const drmModeModeInfo *mode )

bool drm_set_refresh( struct drm_t *drm, int refresh )
{
int width = g_nOutputWidth;
int height = g_nOutputHeight;
if ( g_bRotated ) {
int tmp = width;
width = height;
height = tmp;
}

drmModeConnector *connector = drm->connector->connector;
const drmModeModeInfo *existing_mode = find_mode(connector, g_nOutputWidth, g_nOutputHeight, refresh);
drmModeModeInfo mode;
const drmModeModeInfo *existing_mode = find_mode(connector, width, height, refresh);
drmModeModeInfo mode = {0};
if ( existing_mode )
{
mode = *existing_mode;
}
else
{
/* TODO: check refresh is within the EDID limits */
generate_cvt_mode( &mode, g_nOutputWidth, g_nOutputHeight, refresh, true, false );
generate_cvt_mode( &mode, width, height, refresh, true, false );
}

return drm_set_mode(drm, &mode);
Expand Down

0 comments on commit d3496fd

Please sign in to comment.