From patchwork Sun Oct 1 15:33:16 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: 9979793 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 3BCA960327 for ; Sun, 1 Oct 2017 17:58:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E004289C4 for ; Sun, 1 Oct 2017 17:58:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20F1F289C9; Sun, 1 Oct 2017 17:58:00 +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 E9535289C4 for ; Sun, 1 Oct 2017 17:57:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 791426E211; Sun, 1 Oct 2017 17:57:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 92F536E072 for ; Sun, 1 Oct 2017 15:33:31 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id z1so2275332wre.1 for ; Sun, 01 Oct 2017 08:33:31 -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=UMJvYKaODfuedbGGeYOvsd4moREVlwYmQltBP1biNpk=; b=nbdid8CMIvJEYp3WqYt95+0tFgDbuzeOk+jnHEMLq1bcFkuTgALrsP7cKm+6ofgnfu 4cShPV4KMmhvXHtiDbla8HACJV5g9KdgoHKI6g5T0+QfX4P5to3ler655RGZKcs0RJ0o wcNtnNqQIx5wQgCKOSf5EP7pM2f6WKKjkqyeBL3wONYqNekiNDfkFiUGBMsc9Appia79 Mtx3bZrgdn3fIxqNmmxbS1YdbypQghZ0m35//JUFSseMQkRQ9RgAb8ahJrH+SLkPAAAC Itpe5EAL3ZmRmmNxSjw10W6espVa7wWy3Ajx5Nci1z0w1yGtS+4UcSweFL8AmMDfxPIl jsxg== 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=UMJvYKaODfuedbGGeYOvsd4moREVlwYmQltBP1biNpk=; b=PuFCA8W1/hdgIUcgP/275+Rp4nE0IIvJdakKBcP9Vi2DqZOwkDWqPDF5aQvo7uT2KG gMQo5AkmqW18J0rj0o3+W0iG5Table5VO3aedl5iP/bWlbCBpcMRG/sbBIpVfsS4hMNw w0NW550GoDcYXmBUlGiH+IMs8lE9+y9stLWPltbm7eUHzWEvFUbOrXIdE29vLeiVely4 EVILs3WjMtHlgwz/yHqd7w252EeENTQf9gnp+qbCoXkEBvQGs/vrE8KdEYOVKb1RBcEN LuUhwVpk1ZRl51Dvzger04EJ7Je6ncjeNxkcVeXuijv21fNeepM6i71MlqKSPKs7XVak pSWg== X-Gm-Message-State: AMCzsaXt1/jRcfnoNIg58+W8zaqDv2422i9rj1fUDL24gi62vP51YTFG /L3U4C+3blxIoxkbXkEDSiA= X-Google-Smtp-Source: AOwi7QB/MbInWMZz6CRK4DPbY012q+p8VcSEC4HI0IjssL7dZuUT/6vaZrtgBAr//v6ZALcw9vgi/Q== X-Received: by 10.223.197.80 with SMTP id s16mr6097026wrf.106.1506872010192; Sun, 01 Oct 2017 08:33:30 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 01 Oct 2017 08:33:29 -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 3/4] drm/i915: Add "panel orientation" property to the panel connector Date: Sun, 1 Oct 2017 17:33:16 +0200 Message-Id: <20171001153317.2343-4-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 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, which is a bit more complicated. The code to read back the rotation from the hardware is based on an earlier attempt to fix fdo#94894 by Ville Syrjala. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=94894 Cc: Ville Syrjala Suggested-by: Ville Syrjala Signed-off-by: Hans de Goede --- Changes in v2: -Rebased on 4.14-rc1 -Readback primary plane rotation from the hardware and use that to set the panel orientation -This (readback) fixes fdo#94894, add Fixes: tag --- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/intel_display.c | 39 +++++++++++++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_drv.h | 5 +++++ drivers/gpu/drm/i915/intel_panel.c | 33 ++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 18d9da53282b..c4c8590972b4 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2151,6 +2151,8 @@ struct intel_cdclk_state { unsigned int cdclk, vco, ref; }; +struct intel_panel; + struct drm_i915_private { struct drm_device drm; @@ -2200,6 +2202,7 @@ struct drm_i915_private { struct i915_gem_context *kernel_context; struct intel_engine_cs *engine[I915_NUM_ENGINES]; struct i915_vma *semaphore; + struct intel_panel *panel; struct drm_dma_handle *status_page_dmah; struct resource mch_res; diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 00cd17c76fdc..fbd61f92b60d 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2891,6 +2891,9 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, return; } + intel_panel_set_orientation_from_crtc(dev_priv->panel, intel_crtc, + plane_config->panel_orientation); + plane_state->src_x = 0; plane_state->src_y = 0; plane_state->src_w = fb->width << 16; @@ -7523,6 +7526,10 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc, plane_config->tiling = I915_TILING_X; fb->modifier = I915_FORMAT_MOD_X_TILED; } + + if (val & DISPPLANE_ROTATE_180) + plane_config->panel_orientation = + DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; } pixel_format = val & DISPPLANE_PIXFORMAT_MASK; @@ -8576,6 +8583,24 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc, goto error; } + /* The rotation is used to *correct* for the panel orientation */ + switch (val & PLANE_CTL_ROTATE_MASK) { + case PLANE_CTL_ROTATE_0: + break; + case PLANE_CTL_ROTATE_90: + plane_config->panel_orientation = + DRM_MODE_PANEL_ORIENTATION_RIGHT_UP; + break; + case PLANE_CTL_ROTATE_180: + plane_config->panel_orientation = + DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; + break; + case PLANE_CTL_ROTATE_270: + plane_config->panel_orientation = + DRM_MODE_PANEL_ORIENTATION_LEFT_UP; + break; + } + base = I915_READ(PLANE_SURF(pipe, 0)) & 0xfffff000; plane_config->base = base; @@ -8661,6 +8686,10 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc, plane_config->tiling = I915_TILING_X; fb->modifier = I915_FORMAT_MOD_X_TILED; } + + if (val & DISPPLANE_ROTATE_180) + plane_config->panel_orientation = + DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; } pixel_format = val & DISPPLANE_PIXFORMAT_MASK; @@ -14578,7 +14607,9 @@ int intel_modeset_init(struct drm_device *dev) drm_modeset_unlock_all(dev); for_each_intel_crtc(dev, crtc) { - struct intel_initial_plane_config plane_config = {}; + struct intel_initial_plane_config plane_config = { + .panel_orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL, + }; if (!crtc->active) continue; @@ -14600,6 +14631,12 @@ int intel_modeset_init(struct drm_device *dev) intel_find_initial_plane_obj(crtc, &plane_config); } + /* + * Init panel orientation prop now that intel_find_initial_plane_obj() + * has had a chance to set panel orientation. + */ + intel_panel_init_orientation_prop(dev_priv->panel); + /* * Make sure hardware watermarks really match the state we read out. * Note that we need to do this after reconstructing the BIOS fb's diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index fa47285918f4..50fa0eeca655 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -447,6 +447,7 @@ struct intel_initial_plane_config { unsigned int tiling; int size; u32 base; + int panel_orientation; /* DRM_MODE_PANEL_ORIENTATION_* */ }; #define SKL_MIN_SRC_W 8 @@ -1703,6 +1704,10 @@ extern struct drm_display_mode *intel_find_panel_downclock( struct drm_i915_private *dev_priv, struct drm_display_mode *fixed_mode, struct drm_connector *connector); +void intel_panel_set_orientation_from_crtc(struct intel_panel *panel, + struct intel_crtc *intel_crtc, + int orientation); +void intel_panel_init_orientation_prop(struct intel_panel *panel); #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) int intel_backlight_device_register(struct intel_connector *connector); diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 0f7942a5dccf..fa7dfb9ac5f0 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -1925,11 +1925,44 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel) } } +void intel_panel_set_orientation_from_crtc(struct intel_panel *panel, + struct intel_crtc *intel_crtc, + int orientation) +{ + struct intel_connector *panel_conn; + + if (!panel) + return; + + panel_conn = container_of(panel, struct intel_connector, panel); + if (panel_conn->base.state->crtc == &intel_crtc->base) + panel_conn->base.display_info.panel_orientation = orientation; +} + +void intel_panel_init_orientation_prop(struct intel_panel *panel) +{ + struct intel_connector *panel_conn; + + if (!panel || !panel->fixed_mode) + return; + + panel_conn = container_of(panel, struct intel_connector, panel); + drm_connector_init_panel_orientation_property(&panel_conn->base, + panel->fixed_mode->hdisplay, panel->fixed_mode->vdisplay); +} + int intel_panel_init(struct intel_panel *panel, struct drm_display_mode *fixed_mode, struct drm_display_mode *alt_fixed_mode, struct drm_display_mode *downclock_mode) { + struct intel_connector *intel_connector = + container_of(panel, struct intel_connector, panel); + struct drm_i915_private *dev_priv = to_i915(intel_connector->base.dev); + + if (!dev_priv->panel) + dev_priv->panel = panel; + intel_panel_init_backlight_funcs(panel); panel->fixed_mode = fixed_mode;