From: Hans de Goede <hdegoede@redhat.com>
To: Daniel Vetter <daniel@ffwll.ch>, Hans de Goede <j.w.r.degoede@gmail.com>
Cc: linux-fbdev@vger.kernel.org,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
dri-devel@lists.freedesktop.org,
Bastien Nocera <hadess@hadess.net>,
Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH v2 4/4] drm/fb-helper: Apply panel orientation connector prop to the primary plane
Date: Mon, 23 Oct 2017 06:57:41 +0000 [thread overview]
Message-ID: <471a91f4-a4d0-f3a8-d10f-d0e995325dbb@redhat.com> (raw)
In-Reply-To: <20171002081557.hfhecrmpvc4gxx25@phenom.ffwll.local>
Hi,
On 02-10-17 10:15, Daniel Vetter wrote:
> On Sun, Oct 01, 2017 at 05:33:17PM +0200, Hans de Goede wrote:
>> 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);
>
> This is the loop to reset all the planes to default values, feels a bit
> awkward to change the rotation value in there. Also gives you that
> unpretty loop to check you're on the right plane.
>
> I think a cleaner way to do this would be:
> - add a rotation member to struct drm_fb_helper_crtc
> - set that when setting up the configuration drm_setup_crtcs
> - look up crtc->primary plane_state and set it int the loop below this one
> here (which is the one that actually sets the mode)
Ah yes much better, I've done this for v3. Thank you for the hints.
Regards,
Hans
>
> Cheers, Daniel
>> plane->old_fb = plane->fb;
>> plane_mask |= 1 << drm_plane_index(plane);
>>
>> --
>> 2.14.2
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
next prev parent reply other threads:[~2017-10-23 6:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 1/4] video: fb: Make fbcon dmi quirks usuable for drm drivers too Hans de Goede
2017-10-02 8:01 ` Daniel Vetter
2017-10-17 16:17 ` Hans de Goede
2017-10-18 8:03 ` Daniel Vetter
2017-10-18 9:12 ` Hans de Goede
2017-10-01 15:33 ` [PATCH v2 2/4] drm: Add support for a panel-orientation connector property Hans de Goede
2017-10-01 15:33 ` [PATCH v2 3/4] drm/i915: Add "panel orientation" property to the panel connector Hans de Goede
2017-10-02 8:06 ` Daniel Vetter
2017-10-23 6:57 ` 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 [this message]
-- strict thread matches above, loose matches on Subject: below --
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 4/4] drm/fb-helper: Apply panel orientation connector prop to the primary plane 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=471a91f4-a4d0-f3a8-d10f-d0e995325dbb@redhat.com \
--to=hdegoede@redhat.com \
--cc=b.zolnierkie@samsung.com \
--cc=daniel.vetter@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hadess@hadess.net \
--cc=j.w.r.degoede@gmail.com \
--cc=linux-fbdev@vger.kernel.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).