From: Hans de Goede <hdegoede@redhat.com>
To: Daniel Vetter <daniel.vetter@intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Sean Paul <seanpaul@chromium.org>,
David Airlie <airlied@linux.ie>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
Bastien Nocera <hadess@hadess.net>
Subject: [PATCH v2 4/4] drm/fb-helper: Apply panel orientation connector prop to the primary plane
Date: Mon, 18 Sep 2017 16:20:21 +0000 [thread overview]
Message-ID: <20170918162021.12021-4-hdegoede@redhat.com> (raw)
In-Reply-To: <20170918162021.12021-1-hdegoede@redhat.com>
Apply the "panel orientation" drm connector prop to the primary plane,
so that fbcon and fbdev using userspace programs display the right way
up.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id”894
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-New patch in v2 of this patch-set
---
drivers/gpu/drm/drm_fb_helper.c | 53 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 1b8f013ffa65..75c409430a26 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -41,6 +41,7 @@
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
+#include "drm_crtc_internal.h"
#include "drm_crtc_helper_internal.h"
static bool drm_fbdev_emulation = true;
@@ -347,6 +348,53 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
}
EXPORT_SYMBOL(drm_fb_helper_debug_leave);
+static int get_plane_rotation_from_panel_orientation(
+ struct drm_fb_helper *fb_helper, struct drm_plane *plane)
+{
+ int i, rotation = DRM_MODE_ROTATE_0;
+ struct drm_connector *conn;
+ uint64_t valid_mask = 0;
+
+ drm_fb_helper_for_each_connector(fb_helper, i) {
+ conn = fb_helper->connector_info[i]->connector;
+ if (conn->state->crtc && conn->state->crtc->primary = plane) {
+ switch (conn->display_info.panel_orientation) {
+ case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+ rotation = DRM_MODE_ROTATE_180;
+ break;
+ case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+ rotation = DRM_MODE_ROTATE_90;
+ break;
+ case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+ rotation = DRM_MODE_ROTATE_270;
+ break;
+ }
+ break;
+ }
+ }
+
+ /*
+ * Check the necessary rotation to compensate for the panel orientation
+ * is supported.
+ * Note currently we simply leave things as is when not supported, maybe
+ * we shouls set a hint in fb_info to tell fbcon to rotate in this case
+ * so that atleast the console ends up the right way. Maybe, but this:
+ * a) Is not necessary for any known models with a non upright panel
+ * b) Is tricky because fbcon rotation applies to all outputs rather
+ * then a single one
+ */
+ if (!plane->rotation_property)
+ return DRM_MODE_ROTATE_0;
+
+ for (i = 0; i < plane->rotation_property->num_values; i++)
+ valid_mask |= (1ULL << plane->rotation_property->values[i]);
+
+ if (rotation & ~valid_mask)
+ return DRM_MODE_ROTATE_0;
+
+ return rotation;
+}
+
static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool active)
{
struct drm_device *dev = fb_helper->dev;
@@ -376,8 +424,9 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ
goto out_state;
}
- plane_state->rotation = DRM_MODE_ROTATE_0;
-
+ plane_state->rotation + get_plane_rotation_from_panel_orientation(fb_helper,
+ plane);
plane->old_fb = plane->fb;
plane_mask |= 1 << drm_plane_index(plane);
--
2.14.1
next prev parent reply other threads:[~2017-09-18 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-18 16:20 [PATCH v2 1/4] video: fb: Make fbcon dmi quirks usuable for drm drivers too Hans de Goede
2017-09-18 16:20 ` [PATCH v2 2/4] drm: Add support for a panel-orientation connector property Hans de Goede
2017-09-18 16:20 ` [PATCH v2 3/4] drm/i915: Add "panel orientation" property to the panel connector Hans de Goede
2017-09-18 16:20 ` Hans de Goede [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-10-01 15:33 [PATCH v2 0/4] fb/drm: Add support for a panel-orientation connector prop Hans de Goede
2017-10-01 15:33 ` [PATCH v2 4/4] drm/fb-helper: Apply panel orientation connector prop to the primary plane Hans de Goede
2017-10-02 8:15 ` Daniel Vetter
2017-10-23 6:57 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170918162021.12021-4-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=airlied@linux.ie \
--cc=b.zolnierkie@samsung.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hadess@hadess.net \
--cc=jani.nikula@linux.intel.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=seanpaul@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).