drm, wlserver: Always use internal screen rotation for touchscreen orientation
Lets you use Deck screen as touchpad type thing when docked.
This commit is contained in:
parent
2f3029f5e0
commit
56f4263b3a
3 changed files with 24 additions and 17 deletions
36
src/drm.cpp
36
src/drm.cpp
|
@ -54,7 +54,7 @@ bool g_bSupportsAsyncFlips = false;
|
||||||
|
|
||||||
enum drm_mode_generation g_drmModeGeneration = DRM_MODE_GENERATE_CVT;
|
enum drm_mode_generation g_drmModeGeneration = DRM_MODE_GENERATE_CVT;
|
||||||
enum g_panel_orientation g_drmModeOrientation = PANEL_ORIENTATION_AUTO;
|
enum g_panel_orientation g_drmModeOrientation = PANEL_ORIENTATION_AUTO;
|
||||||
std::atomic<uint64_t> g_drmEffectiveOrientation(DRM_MODE_ROTATE_0);
|
std::atomic<uint64_t> g_drmEffectiveOrientation[DRM_SCREEN_TYPE_COUNT]{ {DRM_MODE_ROTATE_0}, {DRM_MODE_ROTATE_0} };
|
||||||
|
|
||||||
bool g_bForceDisableColorMgmt = false;
|
bool g_bForceDisableColorMgmt = false;
|
||||||
|
|
||||||
|
@ -1797,22 +1797,22 @@ static void update_drm_effective_orientation(struct drm_t *drm, struct connector
|
||||||
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 )
|
||||||
{
|
{
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_0;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch ( g_drmModeOrientation )
|
switch ( g_drmModeOrientation )
|
||||||
{
|
{
|
||||||
case PANEL_ORIENTATION_0:
|
case PANEL_ORIENTATION_0:
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_0;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_0;
|
||||||
break;
|
break;
|
||||||
case PANEL_ORIENTATION_90:
|
case PANEL_ORIENTATION_90:
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_90;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_90;
|
||||||
break;
|
break;
|
||||||
case PANEL_ORIENTATION_180:
|
case PANEL_ORIENTATION_180:
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_180;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_180;
|
||||||
break;
|
break;
|
||||||
case PANEL_ORIENTATION_270:
|
case PANEL_ORIENTATION_270:
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_270;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_270;
|
||||||
break;
|
break;
|
||||||
case PANEL_ORIENTATION_AUTO:
|
case PANEL_ORIENTATION_AUTO:
|
||||||
if (conn && conn->props.count("panel orientation") > 0)
|
if (conn && conn->props.count("panel orientation") > 0)
|
||||||
|
@ -1821,25 +1821,25 @@ static void update_drm_effective_orientation(struct drm_t *drm, struct connector
|
||||||
|
|
||||||
if (strcmp(orientation, "Normal") == 0)
|
if (strcmp(orientation, "Normal") == 0)
|
||||||
{
|
{
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_0;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_0;
|
||||||
}
|
}
|
||||||
else if (strcmp(orientation, "Left Side Up") == 0)
|
else if (strcmp(orientation, "Left Side Up") == 0)
|
||||||
{
|
{
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_90;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_90;
|
||||||
}
|
}
|
||||||
else if (strcmp(orientation, "Upside Down") == 0)
|
else if (strcmp(orientation, "Upside Down") == 0)
|
||||||
{
|
{
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_180;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_180;
|
||||||
}
|
}
|
||||||
else if (strcmp(orientation, "Right Side Up") == 0)
|
else if (strcmp(orientation, "Right Side Up") == 0)
|
||||||
{
|
{
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_270;
|
g_drmEffectiveOrientation[screenType] = DRM_MODE_ROTATE_270;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Auto-detect portait mode
|
// Auto-detect portait mode
|
||||||
g_drmEffectiveOrientation = mode->hdisplay < mode->vdisplay ? DRM_MODE_ROTATE_270 : DRM_MODE_ROTATE_0;
|
g_drmEffectiveOrientation[screenType] = mode->hdisplay < mode->vdisplay ? DRM_MODE_ROTATE_270 : DRM_MODE_ROTATE_0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1851,6 +1851,8 @@ drm_prepare_basic( struct drm_t *drm, const struct FrameInfo_t *frameInfo )
|
||||||
{
|
{
|
||||||
// Discard cases where our non-liftoff path is known to fail
|
// Discard cases where our non-liftoff path is known to fail
|
||||||
|
|
||||||
|
drm_screen_type screenType = drm_get_screen_type(drm);
|
||||||
|
|
||||||
// It only supports one layer
|
// It only supports one layer
|
||||||
if ( frameInfo->layerCount > 1 )
|
if ( frameInfo->layerCount > 1 )
|
||||||
{
|
{
|
||||||
|
@ -1869,7 +1871,7 @@ drm_prepare_basic( struct drm_t *drm, const struct FrameInfo_t *frameInfo )
|
||||||
|
|
||||||
drm->fbids_in_req.push_back( fb_id );
|
drm->fbids_in_req.push_back( fb_id );
|
||||||
|
|
||||||
add_plane_property(req, drm->primary, "rotation", g_drmEffectiveOrientation);
|
add_plane_property(req, drm->primary, "rotation", g_drmEffectiveOrientation[screenType] );
|
||||||
|
|
||||||
add_plane_property(req, drm->primary, "FB_ID", fb_id);
|
add_plane_property(req, drm->primary, "FB_ID", fb_id);
|
||||||
add_plane_property(req, drm->primary, "CRTC_ID", drm->crtc->id);
|
add_plane_property(req, drm->primary, "CRTC_ID", drm->crtc->id);
|
||||||
|
@ -2149,6 +2151,7 @@ bool g_bSinglePlaneOptimizations = true;
|
||||||
static int
|
static int
|
||||||
drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, bool needs_modeset )
|
drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, bool needs_modeset )
|
||||||
{
|
{
|
||||||
|
drm_screen_type screenType = drm_get_screen_type(drm);
|
||||||
auto entry = FrameInfoToLiftoffStateCacheEntry( drm, frameInfo );
|
auto entry = FrameInfoToLiftoffStateCacheEntry( drm, frameInfo );
|
||||||
|
|
||||||
// If we are modesetting, reset the state cache, we might
|
// If we are modesetting, reset the state cache, we might
|
||||||
|
@ -2186,7 +2189,7 @@ drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, boo
|
||||||
liftoff_layer_set_property( drm->lo_layers[ i ], "SRC_W", entry.layerState[i].srcW );
|
liftoff_layer_set_property( drm->lo_layers[ i ], "SRC_W", entry.layerState[i].srcW );
|
||||||
liftoff_layer_set_property( drm->lo_layers[ i ], "SRC_H", entry.layerState[i].srcH );
|
liftoff_layer_set_property( drm->lo_layers[ i ], "SRC_H", entry.layerState[i].srcH );
|
||||||
|
|
||||||
liftoff_layer_set_property( drm->lo_layers[ i ], "rotation", g_drmEffectiveOrientation );
|
liftoff_layer_set_property( drm->lo_layers[ i ], "rotation", g_drmEffectiveOrientation[screenType] );
|
||||||
|
|
||||||
liftoff_layer_set_property( drm->lo_layers[ i ], "CRTC_X", entry.layerState[i].crtcX);
|
liftoff_layer_set_property( drm->lo_layers[ i ], "CRTC_X", entry.layerState[i].crtcX);
|
||||||
liftoff_layer_set_property( drm->lo_layers[ i ], "CRTC_Y", entry.layerState[i].crtcY);
|
liftoff_layer_set_property( drm->lo_layers[ i ], "CRTC_Y", entry.layerState[i].crtcY);
|
||||||
|
@ -2793,7 +2796,8 @@ static void drm_unset_mode( struct drm_t *drm )
|
||||||
if (g_nOutputRefresh == 0)
|
if (g_nOutputRefresh == 0)
|
||||||
g_nOutputRefresh = 60;
|
g_nOutputRefresh = 60;
|
||||||
|
|
||||||
g_drmEffectiveOrientation = DRM_MODE_ROTATE_0;
|
g_drmEffectiveOrientation[DRM_SCREEN_TYPE_INTERNAL] = DRM_MODE_ROTATE_0;
|
||||||
|
g_drmEffectiveOrientation[DRM_SCREEN_TYPE_EXTERNAL] = DRM_MODE_ROTATE_0;
|
||||||
g_bRotated = false;
|
g_bRotated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2806,6 +2810,8 @@ bool drm_set_mode( struct drm_t *drm, const drmModeModeInfo *mode )
|
||||||
if (drmModeCreatePropertyBlob(drm->fd, mode, sizeof(*mode), &mode_id) != 0)
|
if (drmModeCreatePropertyBlob(drm->fd, mode, sizeof(*mode), &mode_id) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
drm_screen_type screenType = drm_get_screen_type(drm);
|
||||||
|
|
||||||
drm_log.infof("selecting mode %dx%d@%uHz", mode->hdisplay, mode->vdisplay, mode->vrefresh);
|
drm_log.infof("selecting mode %dx%d@%uHz", mode->hdisplay, mode->vdisplay, mode->vrefresh);
|
||||||
|
|
||||||
drm->pending.mode_id = mode_id;
|
drm->pending.mode_id = mode_id;
|
||||||
|
@ -2815,7 +2821,7 @@ bool drm_set_mode( struct drm_t *drm, const drmModeModeInfo *mode )
|
||||||
|
|
||||||
update_drm_effective_orientation(drm, drm->connector, mode);
|
update_drm_effective_orientation(drm, drm->connector, mode);
|
||||||
|
|
||||||
switch ( g_drmEffectiveOrientation )
|
switch ( g_drmEffectiveOrientation[screenType] )
|
||||||
{
|
{
|
||||||
case DRM_MODE_ROTATE_0:
|
case DRM_MODE_ROTATE_0:
|
||||||
case DRM_MODE_ROTATE_180:
|
case DRM_MODE_ROTATE_180:
|
||||||
|
|
|
@ -293,7 +293,7 @@ enum g_panel_orientation {
|
||||||
extern enum drm_mode_generation g_drmModeGeneration;
|
extern enum drm_mode_generation g_drmModeGeneration;
|
||||||
extern enum g_panel_orientation g_drmModeOrientation;
|
extern enum g_panel_orientation g_drmModeOrientation;
|
||||||
|
|
||||||
extern std::atomic<uint64_t> g_drmEffectiveOrientation; // DRM_MODE_ROTATE_*
|
extern std::atomic<uint64_t> g_drmEffectiveOrientation[DRM_SCREEN_TYPE_COUNT]; // DRM_MODE_ROTATE_*
|
||||||
|
|
||||||
extern bool g_bForceDisableColorMgmt;
|
extern bool g_bForceDisableColorMgmt;
|
||||||
|
|
||||||
|
|
|
@ -1518,7 +1518,8 @@ static void apply_touchscreen_orientation(double *x, double *y )
|
||||||
double tx = 0;
|
double tx = 0;
|
||||||
double ty = 0;
|
double ty = 0;
|
||||||
|
|
||||||
switch ( g_drmEffectiveOrientation )
|
// Use internal screen always for orientation purposes.
|
||||||
|
switch ( g_drmEffectiveOrientation[DRM_SCREEN_TYPE_INTERNAL] )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case DRM_MODE_ROTATE_0:
|
case DRM_MODE_ROTATE_0:
|
||||||
|
|
Loading…
Reference in a new issue