From patchwork Sat Nov 25 19:16:20 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: 10074953 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 334BD602BC for ; Sat, 25 Nov 2017 19:16:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26A4128ED2 for ; Sat, 25 Nov 2017 19:16:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B84828F0E; Sat, 25 Nov 2017 19:16:39 +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 B44D228ED2 for ; Sat, 25 Nov 2017 19:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751277AbdKYTQi (ORCPT ); Sat, 25 Nov 2017 14:16:38 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:41922 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775AbdKYTQh (ORCPT ); Sat, 25 Nov 2017 14:16:37 -0500 Received: by mail-wm0-f67.google.com with SMTP id b189so27418436wmd.0 for ; Sat, 25 Nov 2017 11:16:37 -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=EC63xorjVFNMqO2R7/0KN7Lvd+SOADrka1SQUaLz3xK8BgDz91cZPLWfEuem0LfEM0 lEunOcaS6OiXXQSxZu9aGbCciM5ye/vTrNQitXwQbdGYM6gcX7VxXB/eeuocxBv7f0+Y xtpC1ciH6jJVXy+YF2e94WwGWDXOyydCKWPIqxUrPdCsT45XUwgfp0AOaI1JQJlFdNAq Rc+aWVqkoPuKcdnx5aaLua5ieWqeyrRn8Kn6ea3LjSP3kxKnRmW016DWu66RggrDTBDT qBk2xBzeuFBQXH5e80Xbtqj4feLP/djyNBAAMb557YNdIMAAd9dN4ro5HByOgsdnM24A 0WyQ== 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=W6B5p01u78RLdV/RXs/qQv/+Z09Hmamh3mtDh3K+89CIbivyExmKrQCDlsfgylc3ZS glGXMXxCtfJxT4U++wvjJmvjc7w1IXQTs/w0/7wSeXcXJR4a8i/i08sO32P7GV/Zp6d6 kU39WxrA5JT8XsWCySnF6aRw/kBD0YvRRsojPnYw/nAHfac5QGozD9bQthk0o64okBjl qs0uaaHMp0DP5BFTWqKv6BGsATcVbDpCB7KTgHYOp2vQhf9TYMDI+kyPdb8SsyTPhLcz 41uiOqNEzZTlk8SFRsbHs/g4Qw3Q8miJZ167MlKZV7yE7CdWv/DhzFjYoeUvXLVd40qp 0laQ== X-Gm-Message-State: AJaThX6xWin2oALbTLf/Q3qBIGtLomPlPvk9osT+XopK/DqknPdahmlM riFoQrceEfirlkzooZrps2g= X-Google-Smtp-Source: AGs4zMZoHQTJOhOnyOm0KoGOj+XuyzntRVlSwm3LO4qwgUi27X1NlE6ANiHT1s6mU6FEkQvw5dlceg== X-Received: by 10.28.183.132 with SMTP id h126mr13004196wmf.76.1511637396588; Sat, 25 Nov 2017 11:16:36 -0800 (PST) Received: from localhost.localdomain.com ([2001:470:7a95:4242:2c1c:b9eb:f8cb:6ccb]) by smtp.gmail.com with ESMTPSA id 29sm22980796wrz.77.2017.11.25.11.16.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Nov 2017 11:16:35 -0800 (PST) From: Hans de Goede X-Google-Original-From: Hans de Goede To: Daniel Vetter , Jani Nikula , Sean Paul , Dave Airlie , Bartlomiej Zolnierkiewicz Cc: Hans de Goede , intel-gfx , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Subject: [PATCH v6 5/7] drm/i915: Add "panel orientation" property to the panel connector, v6. Date: Sat, 25 Nov 2017 20:16:20 +0100 Message-Id: <20171125191622.16289-6-hdegoede@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171125191622.16289-1-hdegoede@redhat.com> References: <20171125191622.16289-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 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 --- 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); } }