From patchwork Sun Oct 1 15:33:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9979763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D3C1603FF for ; Sun, 1 Oct 2017 15:33:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FADB2897C for ; Sun, 1 Oct 2017 15:33:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 248952897E; Sun, 1 Oct 2017 15:33:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB3BA28A0A for ; Sun, 1 Oct 2017 15:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751125AbdJAPdd (ORCPT ); Sun, 1 Oct 2017 11:33:33 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:32990 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750965AbdJAPdc (ORCPT ); Sun, 1 Oct 2017 11:33:32 -0400 Received: by mail-wr0-f196.google.com with SMTP id z96so967893wrb.0 for ; Sun, 01 Oct 2017 08:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vMVDmQLr7YQvqOrcFQXYA7TxfmwXr0uC27cwoxn7P8s=; b=FXYHcRqH0PEgfwC9B6t/uxW3FObn+ZMy6GMZh1yKHY4Jwkod2eo/YqyuJIYzdVjR7g iC2OD0RLxUJOolqoizb4imBJm9LM3b8Wju7rcmkcQxjt4zsMesxnHTF8XaaFtsr/Ra8B HYMlCeyB6pYyJbGkNyZMM17VVE67fX8WbovdqNFlu0oUmZND/X80dR3C7vnfvDpRWaNd CvWNH6dz5n35zbxfIJADeXVsie3A7zFjioPKMgcGRHr3VGWUbHtBGX2wfaEJJGomtpHf UeqyYbPhvFnW1DpCl8x8juvTZcNCNh8N5q9bfv8U9lxo9ZCSxpy9KtlYTVlDUOOI0Qak Cesg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vMVDmQLr7YQvqOrcFQXYA7TxfmwXr0uC27cwoxn7P8s=; b=Vmf42qtliWGFDWyXXMXxoQXvJmMFuE5+MqkScWwJ36+H0D8lcWy/huQBhVnzk7kV+W Rl/YehEfppWfmCrtnTWmwULpf0NosHZFvNaZaxL6v1KklQAf67KU2PMpAAWmw1Mxx4we 2Ns4HSjL8LIurZJ6k9n4lBCsKMtpPv5fqJhOPkVueWxajF4ByvdHMnNyJaOkGWyKOvpj JsO8KiPlj4xnxjUZXuEnxXcn2fBOQo8CaiOQb3vXzJ7Mw4IqTLTOlcsQQ3ZdJKPiUUhP nqCGSIJhzi1crVj2wrlT2CC5mjrrEYcSdfSlUFMTHR8L9V4AjohPf19n2h0PRepKxd6a uYmw== X-Gm-Message-State: AHPjjUjxsoh9z+1OlDmCJjILjNPsZGKi/IlyMU76tHtSOuMGCO7CGZZ4 2k6/f9pqJipA0FxBnepUPFEmx9Tt X-Google-Smtp-Source: AOwi7QD3vx/LICdcmaLIoIbk34tSvK654MBObndYdAfSZ1DPjJKkrfUM3kSXhBrD9Xl/fzCjeR56Mw== X-Received: by 10.223.139.157 with SMTP id o29mr13440988wra.190.1506872011352; Sun, 01 Oct 2017 08:33:31 -0700 (PDT) Received: from shalem.localdomain.com (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id 30sm8700978wry.34.2017.10.01.08.33.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 01 Oct 2017 08:33:30 -0700 (PDT) From: Hans de Goede X-Google-Original-From: Hans de Goede To: Daniel Vetter , Jani Nikula , Sean Paul , David Airlie , Bartlomiej Zolnierkiewicz Cc: Hans de Goede , Bastien Nocera , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Subject: [PATCH v2 4/4] drm/fb-helper: Apply panel orientation connector prop to the primary plane Date: Sun, 1 Oct 2017 17:33:17 +0200 Message-Id: <20171001153317.2343-5-hdegoede@redhat.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171001153317.2343-1-hdegoede@redhat.com> References: <20171001153317.2343-1-hdegoede@redhat.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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=94894 Signed-off-by: Hans de Goede --- 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 #include +#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);