From patchwork Sat Nov 25 17:33:39 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: 10074915 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 98D94602BC for ; Sat, 25 Nov 2017 17:34:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85A0C29011 for ; Sat, 25 Nov 2017 17:34:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AAED29013; Sat, 25 Nov 2017 17:34:16 +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 3379329011 for ; Sat, 25 Nov 2017 17:34:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C09A56E159; Sat, 25 Nov 2017 17:34:15 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4F196E137; Sat, 25 Nov 2017 17:33:59 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id s41so17346274wrc.7; Sat, 25 Nov 2017 09:33:59 -0800 (PST) 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=j0y0ymsuEQ+LUL4/PhFYVg9DsQIewB8dHcxOobTdBJ0=; b=MR/hBuOGH1zyLe+8a6fKDDI+VcvXx95uNoXgt74r1x8mbRXoU7dWfdXiEhdcQFR9eG ZFOfGvnmXeEzdiO/LcW7LwcYGMUbbMTZBxG3Gz1KNVUQg7tsUEisAWGtTOkjzo6GMG3a AIKo9ipzqa7JudLAIjCHtgYx0alh1DwHBkQuWpQWQipW+nvZO2zfmztJqGED3meQ6NYo 59tQJFgJQG5DL3sDFRw5bwlqxL9iTL0uzZfmX/lg3/uoTk8w2mwgJeMaa9Jhkrb9gKzZ uZ/52BC3kCqf/e5Dl1c2pqLNDO6BBPOdZY2G088XXiHjDSOmerI2akBgec1lNJSNj1Sc y2IQ== 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=j0y0ymsuEQ+LUL4/PhFYVg9DsQIewB8dHcxOobTdBJ0=; b=VBCoIDsRPUoHnnfWwV8xElQvidE3+LjVbaQr3uI/gRXa+PBLLJo/DN0dvP2qtwsFku OxDqoKGRU40oY56SlytJsQwOpM1guxiQJBxbzkcfZnOMKgNi+64FLTO2Ex4ksv7rFyBH JtUOBpa2y8yg2XVFAKF56vvUwRtQLvrsGLuXBeKjAlsJAv3JP1bTT9ktduGcQlY4Pj12 PSKpt2H1AYmDSjqh/D9zSEW6JDfNfxHMB22W8Uf5PUCbOF6fQtqS0aykcd9Il0mNXpMf CYQLIjUIv6d08Q3GG08PJvdW4k+/iBKC1Vwgjtjmxc3YmJ63Pe5MF5LaT6Mvp4BN7Z/g 5O7Q== X-Gm-Message-State: AJaThX6zSUFwTQo4zD3jQZeaTKNzP1e0l4Od70mUmRtI2N5CsDhbnC8V 5zawSuEb0fgJlVO3bnt0w+Cmuhos X-Google-Smtp-Source: AGs4zMbMq3D8oTCiJ6QSAC4p2ENNhCSi96ir+xu6Ap0wSE3qKLiv/VFmwm9ZK5g/qS0/FQaDKID64A== X-Received: by 10.223.188.141 with SMTP id g13mr7636175wrh.169.1511631238350; Sat, 25 Nov 2017 09:33:58 -0800 (PST) Received: from localhost.localdomain.com ([2001:470:7a95:4242:2c1c:b9eb:f8cb:6ccb]) by smtp.gmail.com with ESMTPSA id o135sm8439658wmg.1.2017.11.25.09.33.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Nov 2017 09:33:57 -0800 (PST) From: Hans de Goede X-Google-Original-From: Hans de Goede To: Daniel Vetter , Jani Nikula , Sean Paul , Dave Airlie , Bartlomiej Zolnierkiewicz Date: Sat, 25 Nov 2017 18:33:39 +0100 Message-Id: <20171125173341.14162-6-hdegoede@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171125173341.14162-1-hdegoede@redhat.com> References: <20171125173341.14162-1-hdegoede@redhat.com> Cc: Hans de Goede , intel-gfx , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v6 5/7] drm/i915: Add "panel orientation" property to the panel connector, v6. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Ideally we could use the VBT for this, that would be simple, in intel_dsi_init() check dev_priv->vbt.dsi.config->rotation, set connector->display_info.panel_orientation accordingly and call drm_connector_init_panel_orientation_property(), done. Unfortunately vbt.dsi.config->rotation is always 0 even on tablets with an upside down LCD and where the GOP is properly rotating the EFI fb in hardware. So instead we end up reading the rotation from the primary plane. This commit only implements the panel orientation property for DSI panels on BYT / CHT hardware, as all known non normal oriented panels sofar are only found on this hardware. Changes in v2: -Read back the rotation applied by the GOP from the primary plane instead of relying on dev_priv->vbt.dsi.config->rotation, because it seems that the VBT rotation filed is always 0 even on devices where the GOP does apply a rotation Changes in v3: -Rewrite the code to read back the orientation from the primary plane to contain all of this in intel_dsi.c instead of poking a bunch of holes between all the different layers Changes in v6: -Move hardware readout to intel_dsi_init() Signed-off-by: Hans de Goede Reviewed-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_dsi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index f09474b0c4d3..f67d321376e4 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c @@ -1666,6 +1666,27 @@ static const struct drm_connector_funcs intel_dsi_connector_funcs = { .atomic_duplicate_state = intel_digital_connector_duplicate_state, }; +static int intel_dsi_get_panel_orientation(struct intel_connector *connector) +{ + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); + int orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; + enum i9xx_plane_id plane; + u32 val; + + if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { + if (connector->encoder->crtc_mask == BIT(PIPE_B)) + plane = PLANE_B; + else + plane = PLANE_A; + + val = I915_READ(DSPCNTR(plane)); + if (val & DISPPLANE_ROTATE_180) + orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; + } + + return orientation; +} + static void intel_dsi_add_properties(struct intel_connector *connector) { struct drm_i915_private *dev_priv = to_i915(connector->base.dev); @@ -1681,6 +1702,13 @@ static void intel_dsi_add_properties(struct intel_connector *connector) allowed_scalers); connector->base.state->scaling_mode = DRM_MODE_SCALE_ASPECT; + + connector->base.display_info.panel_orientation = + intel_dsi_get_panel_orientation(connector); + drm_connector_init_panel_orientation_property( + &connector->base, + connector->panel.fixed_mode->hdisplay, + connector->panel.fixed_mode->vdisplay); } }