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: 9979791 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 15DE560327 for ; Sun, 1 Oct 2017 17:57:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08D8D289C4 for ; Sun, 1 Oct 2017 17:57:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1BA3289C9; Sun, 1 Oct 2017 17:57:43 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A7092289C4 for ; Sun, 1 Oct 2017 17:57:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 023426E1FE; Sun, 1 Oct 2017 17:57:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id DCE2E6E1B5 for ; Sun, 1 Oct 2017 15:33:32 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id 45so2268319wry.5 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=QWGduKSdOF/KgHYgtG22KWDqD56SWPx/NfAzrYprKaFzLUxtM6/2ODzIdYuUyhrGlB PI7esd6V6LJL940gZp7amW5CuU7kdoTfN7pYkY9NPTUf+QTyaeA0dwgeOZarSb5v5673 FbQfPPMrpD+W8NTKYDWpp1AU5bMAHjl0oMcqeydA9QCAzcvNF/Pb675piQgLhs5Xu+9m 2MLwJVGQuomdYkQDz/FwDqr5DxWoE+xEC3mBGPxcA9fGbUYMvptWysj6LEqTcC5/rIoR fpzDMHKVGgIoIEPW+6SX8s7J3bpue578oZdNy8W38s4KGczeoM3rvhJ/tqiYaFWFBmkj TqIA== X-Gm-Message-State: AHPjjUhk458868KqvIe/BkRSpE/p5I2KzN+z4PSO4bJHRxKTs+WT8ov+ yyekgSWr8/qVewDTdGYA7N8= 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 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> X-Mailman-Approved-At: Sun, 01 Oct 2017 17:57:25 +0000 Cc: Hans de Goede , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Bastien Nocera X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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);