From patchwork Sat Nov 4 14:08:26 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: 10042755 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 CA60F601EB for ; Mon, 6 Nov 2017 08:32:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B864F29925 for ; Mon, 6 Nov 2017 08:32:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABEC32992D; Mon, 6 Nov 2017 08:32:36 +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=unavailable 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 1B67129925 for ; Mon, 6 Nov 2017 08:32:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C1EF6E25F; Mon, 6 Nov 2017 08:32:08 +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 30B1B6E327; Sat, 4 Nov 2017 14:08:43 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id l18so1312238wrc.3; Sat, 04 Nov 2017 07:08:43 -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=J6ssMy88BFSOiEXJy310aZJU9zurLhEVm3jYlzKRaFk=; b=RUuiaCdK16VNCNxJREy1Vy4bNZJ45gKguXClu5owPcEEAYmk7H08qRgMVKbF3uW0SY MO8GweWwCtDiSvzZHm1/Ype3NwsG/xTBeFD5jjX2FF0/c2MadSXyvXOjJJyrrN99cEBy s0TWbrmxIiE7gBd9TebyOMmRx9rT58nHYBnQsQkUkCbReRogILGV4ZpcqOil2Dn3mhyU eyCi4cE67iNGReJ/jGtTLPYpoGOsdkBLypdYMA+YTj6W6UMA5/x87QvnFumRsPHNlwiE 3VLds5V7px5eTne/C2/I+Sd3J9/6kPSoxCHfWVcnrE9paLqoxxsVO/H6lmqtUPyNhW4E jb4Q== 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=J6ssMy88BFSOiEXJy310aZJU9zurLhEVm3jYlzKRaFk=; b=grcz9W5jMAc34KFcw1P/OwCvmMElBJNJ6rJqqA4W0VB0Ld3B/DGdmCt/8sjx7Jcu7l X/R8wmK6/u5nhOWosQ9vLzbKbxMbcY35n7/ix3F92G5JleashuwtHQM77KWSrgFNUNcU zwd5bWhQ3eYe/g/asw0GdmEbmlds8bMMesTu+95O6UHztODCVtv0xQpBobNINyQEBvmc Yxid2VUccK39jXtwz/ZXbgPwwNbfayIyjEPpbrc3SAEP5mtOJNPCvhKvegdz3r3QLvQ3 kvI3xyHVPllOWs5HvSnrtTMSQIQaqVn1EuKqlWtl5gbh1Dof1LuVy6+Uhbd2OmF9WQF/ IXHw== X-Gm-Message-State: AMCzsaVPiDIXsbM2faj0wJjf8PbonJDhAn9HvMIB8heQC0wjqREFSG2V TMmy6QJSWlMdiyNvgqUV+Mw= X-Google-Smtp-Source: ABhQp+QVZbM7uxaISs4/G6RoyHLzPUs/C7sKj4dm3/IXOZru1IopSeZxFXD96vd7hc1BPa9T2fYJuw== X-Received: by 10.223.197.19 with SMTP id q19mr9241885wrf.272.1509804522597; Sat, 04 Nov 2017 07:08:42 -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 p128sm4672674wmb.1.2017.11.04.07.08.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Nov 2017 07:08:41 -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 v5 5/7] drm/i915: Add "panel orientation" property to the panel connector Date: Sat, 4 Nov 2017 15:08:26 +0100 Message-Id: <20171104140828.32469-6-hdegoede@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171104140828.32469-1-hdegoede@redhat.com> References: <20171104140828.32469-1-hdegoede@redhat.com> X-Mailman-Approved-At: Mon, 06 Nov 2017 08:32:05 +0000 Cc: linux-fbdev@vger.kernel.org, intel-gfx , dri-devel@lists.freedesktop.org, Daniel Drake , Hans de Goede , Carlo Caione , Bastien Nocera , Robert McQueen 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 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. To read the info from the primary plane, we need to know which crtc the panel is hooked up to, so we do this the first time the panel encoder's get_config function get called, as by then the encoder crtc routing has been set up. This commit only implements the panel orientation property for DSI panels on BYT / CHT / BXT hardware, as all known non normal oriented panels are only found on this hardware. Signed-off-by: Hans de Goede --- 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 --- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_dsi.c | 48 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_dsi.h | 2 ++ drivers/gpu/drm/i915/intel_panel.c | 16 +++++++++++++ 4 files changed, 67 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 47d022d48718..11efc6cb74c8 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1727,6 +1727,7 @@ void intel_panel_enable_backlight(const struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state); void intel_panel_disable_backlight(const struct drm_connector_state *old_conn_state); void intel_panel_destroy_backlight(struct drm_connector *connector); +void intel_panel_set_orientation(struct intel_panel *panel, int orientation); enum drm_connector_status intel_panel_detect(struct drm_i915_private *dev_priv); extern struct drm_display_mode *intel_find_panel_downclock( struct drm_i915_private *dev_priv, diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index 83f15848098a..3e2f12db8d15 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c @@ -1084,13 +1084,16 @@ static void bxt_dsi_get_pipe_config(struct intel_encoder *encoder, struct drm_display_mode *adjusted_mode_sw; struct intel_crtc *intel_crtc; struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); + struct intel_panel *panel = &intel_dsi->attached_connector->panel; unsigned int lane_count = intel_dsi->lane_count; unsigned int bpp, fmt; + int orientation; enum port port; u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp; u16 hfp_sw, hsync_sw, hbp_sw; u16 crtc_htotal_sw, crtc_hsync_start_sw, crtc_hsync_end_sw, crtc_hblank_start_sw, crtc_hblank_end_sw; + u32 val; /* FIXME: hw readout should not depend on SW state */ intel_crtc = to_intel_crtc(encoder->base.crtc); @@ -1234,6 +1237,49 @@ static void bxt_dsi_get_pipe_config(struct intel_encoder *encoder, if (adjusted_mode->crtc_hblank_end == crtc_hblank_end_sw) adjusted_mode->crtc_hblank_end = adjusted_mode_sw->crtc_hblank_end; + + if (!intel_dsi->got_panel_orientation) { + val = I915_READ(PLANE_CTL(intel_crtc->pipe, 0)); + /* The rotation is used to correct for the panel orientation */ + switch (val & PLANE_CTL_ROTATE_MASK) { + case PLANE_CTL_ROTATE_0: + orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; + break; + case PLANE_CTL_ROTATE_90: + orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP; + break; + case PLANE_CTL_ROTATE_180: + orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; + break; + case PLANE_CTL_ROTATE_270: + orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP; + break; + } + intel_panel_set_orientation(panel, orientation); + intel_dsi->got_panel_orientation = true; + } +} + +static void vlv_dsi_get_pipe_config(struct intel_encoder *encoder) +{ + struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); + struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); + struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); + struct intel_panel *panel = &intel_dsi->attached_connector->panel; + int orientation; + u32 val; + + if (!intel_dsi->got_panel_orientation) { + val = I915_READ(DSPCNTR(intel_crtc->plane)); + + if (val & DISPPLANE_ROTATE_180) + orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; + else + orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; + + intel_panel_set_orientation(panel, orientation); + intel_dsi->got_panel_orientation = true; + } } static void intel_dsi_get_config(struct intel_encoder *encoder, @@ -1245,6 +1291,8 @@ static void intel_dsi_get_config(struct intel_encoder *encoder, if (IS_GEN9_LP(dev_priv)) bxt_dsi_get_pipe_config(encoder, pipe_config); + else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) + vlv_dsi_get_pipe_config(encoder); pclk = intel_dsi_get_pclk(encoder, pipe_config->pipe_bpp, pipe_config); diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h index 7afeb9580f41..92c2fe31f3fd 100644 --- a/drivers/gpu/drm/i915/intel_dsi.h +++ b/drivers/gpu/drm/i915/intel_dsi.h @@ -52,6 +52,8 @@ struct intel_dsi { /* if true, use HS mode, otherwise LP */ bool hs; + bool got_panel_orientation; + /* virtual channel */ int channel; diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index adc51e452e3e..7d571bef847e 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -1842,6 +1842,22 @@ void intel_panel_destroy_backlight(struct drm_connector *connector) panel->backlight.present = false; } +void intel_panel_set_orientation(struct intel_panel *panel, int orientation) +{ + struct intel_connector *panel_conn; + int width = 0, height = 0; + + if (panel->fixed_mode) { + width = panel->fixed_mode->hdisplay; + height = panel->fixed_mode->vdisplay; + } + + panel_conn = container_of(panel, struct intel_connector, panel); + panel_conn->base.display_info.panel_orientation = orientation; + drm_connector_init_panel_orientation_property(&panel_conn->base, + width, height); +} + /* Set up chip specific backlight functions */ static void intel_panel_init_backlight_funcs(struct intel_panel *panel)