drm: cleanup orientation code
This commit is contained in:
parent
12bff31008
commit
14f0b78f61
1 changed files with 17 additions and 17 deletions
30
src/drm.cpp
30
src/drm.cpp
|
@ -1282,7 +1282,7 @@ void drm_unlock_fbid( struct drm_t *drm, uint32_t fbid )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the orientation of the display */
|
/* Handle the orientation of the display */
|
||||||
void update_drm_effective_orientation(struct drm_t *drm, struct connector *conn)
|
static void update_drm_effective_orientation(struct drm_t *drm, struct connector *conn, const drmModeModeInfo *mode)
|
||||||
{
|
{
|
||||||
drm_screen_type screenType = drm_get_screen_type(drm);
|
drm_screen_type screenType = drm_get_screen_type(drm);
|
||||||
if ( screenType == DRM_SCREEN_TYPE_EXTERNAL )
|
if ( screenType == DRM_SCREEN_TYPE_EXTERNAL )
|
||||||
|
@ -1328,7 +1328,8 @@ void update_drm_effective_orientation(struct drm_t *drm, struct connector *conn)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_drmEffectiveOrientation = g_bRotated ? DRM_MODE_ROTATE_270 : DRM_MODE_ROTATE_0;
|
// Auto-detect portait mode
|
||||||
|
g_drmEffectiveOrientation = mode->hdisplay < mode->vdisplay ? DRM_MODE_ROTATE_270 : DRM_MODE_ROTATE_0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2262,25 +2263,24 @@ bool drm_set_mode( struct drm_t *drm, const drmModeModeInfo *mode )
|
||||||
drm->pending.mode_id = mode_id;
|
drm->pending.mode_id = mode_id;
|
||||||
drm->needs_modeset = true;
|
drm->needs_modeset = true;
|
||||||
|
|
||||||
g_nOutputWidth = mode->hdisplay;
|
|
||||||
g_nOutputHeight = mode->vdisplay;
|
|
||||||
g_nOutputRefresh = mode->vrefresh;
|
g_nOutputRefresh = mode->vrefresh;
|
||||||
|
|
||||||
// Auto-detect portrait mode
|
update_drm_effective_orientation(drm, drm->connector, mode);
|
||||||
g_bRotated = g_nOutputWidth < g_nOutputHeight;
|
|
||||||
|
|
||||||
if ( g_bRotated )
|
switch ( g_drmEffectiveOrientation )
|
||||||
{
|
|
||||||
g_nOutputWidth = mode->vdisplay;
|
|
||||||
g_nOutputHeight = mode->hdisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
update_drm_effective_orientation(drm, drm->connector);
|
|
||||||
|
|
||||||
if ( g_drmEffectiveOrientation == PANEL_ORIENTATION_0 || g_drmModeOrientation == PANEL_ORIENTATION_180 )
|
|
||||||
{
|
{
|
||||||
|
case DRM_MODE_ROTATE_0:
|
||||||
|
case DRM_MODE_ROTATE_180:
|
||||||
|
g_bRotated = false;
|
||||||
g_nOutputWidth = mode->hdisplay;
|
g_nOutputWidth = mode->hdisplay;
|
||||||
g_nOutputHeight = mode->vdisplay;
|
g_nOutputHeight = mode->vdisplay;
|
||||||
|
break;
|
||||||
|
case DRM_MODE_ROTATE_90:
|
||||||
|
case DRM_MODE_ROTATE_270:
|
||||||
|
g_bRotated = true;
|
||||||
|
g_nOutputWidth = mode->vdisplay;
|
||||||
|
g_nOutputHeight = mode->hdisplay;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue