From afcc8003d7e925d058398c3857df9aff652ef65e Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Sat, 13 Jun 2020 20:31:31 +0300 Subject: [PATCH] XXX: WIP: drm: Universal display rotation on Nexus 7 This removes a need to have bleeding edge userspace that knows how to work with the rotated planes. Only Opentegra driver supports planes rotation today, everything else is upside-down without the universal rotation support. The plan is to teach DRM core about the CRTC rotation capabilities and then this hack won't be needed, for now it's not obvious how to implement that. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_connector.c | 4 ++++ drivers/gpu/drm/grate/dc.c | 8 ++++++++ drivers/gpu/drm/tegra/dc.c | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index a50c82bc2b2fe..d07b79ed6f7ae 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2362,6 +2362,10 @@ int drm_connector_set_panel_orientation( struct drm_display_info *info = &connector->display_info; struct drm_property *prop; + /* Temporal hack for Nexus 7 */ + if (of_machine_is_compatible("asus,grouper")) + return 0; + /* Already set? */ if (info->panel_orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) return 0; diff --git a/drivers/gpu/drm/grate/dc.c b/drivers/gpu/drm/grate/dc.c index 9b8a5c080b2a0..ecedc6064f8f0 100644 --- a/drivers/gpu/drm/grate/dc.c +++ b/drivers/gpu/drm/grate/dc.c @@ -763,6 +763,14 @@ static void tegra_plane_atomic_update(struct drm_plane *plane, window.format = tegra_plane_state->format; window.swap = tegra_plane_state->swap; + if (of_machine_is_compatible("asus,grouper")) { + struct drm_display_mode *mode = &plane->state->crtc->state->adjusted_mode; + window.dst.x = mode->hdisplay - window.dst.w - window.dst.x; + window.dst.y = mode->vdisplay - window.dst.h - window.dst.y; + window.reflect_x = !window.reflect_x; + window.reflect_y = !window.reflect_y; + } + for (i = 0; i < fb->format->num_planes; i++) { window.base[i] = tegra_plane_state->iova[i] + fb->offsets[i]; diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index bb496646b7fec..7ea3c045a6f76 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -753,6 +753,14 @@ static void tegra_plane_atomic_update(struct drm_plane *plane, window.format = tegra_plane_state->format; window.swap = tegra_plane_state->swap; + if (of_machine_is_compatible("asus,grouper")) { + struct drm_display_mode *mode = &plane->state->crtc->state->adjusted_mode; + window.dst.x = mode->hdisplay - window.dst.w - window.dst.x; + window.dst.y = mode->vdisplay - window.dst.h - window.dst.y; + window.reflect_x = !window.reflect_x; + window.reflect_y = !window.reflect_y; + } + for (i = 0; i < fb->format->num_planes; i++) { window.base[i] = tegra_plane_state->iova[i] + fb->offsets[i];