From patchwork Thu Feb 11 02:32:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 8276201 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9D4C39F1C1 for ; Thu, 11 Feb 2016 02:33:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 622CE20380 for ; Thu, 11 Feb 2016 02:33:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 39A18202FE for ; Thu, 11 Feb 2016 02:33:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 86C4A7206B; Wed, 10 Feb 2016 18:33:47 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BD6E720BF; Wed, 10 Feb 2016 18:33:46 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 10 Feb 2016 18:33:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,428,1449561600"; d="scan'208";a="45968775" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.207]) by fmsmga004.fm.intel.com with ESMTP; 10 Feb 2016 18:33:46 -0800 Received: from mattrope by mdroper-hswdev with local (Exim 4.84) (envelope-from ) id 1aTh4k-0001vu-66; Wed, 10 Feb 2016 18:33:46 -0800 From: Matt Roper To: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 2/2] drm/i915/gen9: Add support for pipe background color (v2) Date: Wed, 10 Feb 2016 18:32:59 -0800 Message-Id: <1455157979-7341-3-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455157979-7341-1-git-send-email-matthew.d.roper@intel.com> References: <1455157979-7341-1-git-send-email-matthew.d.roper@intel.com> MIME-Version: 1.0 Cc: dri-devel@lists.freedesktop.org, Chandra Konduru 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Gen9 platforms allow CRTC's to be programmed with a background/canvas color below the programmable planes. Let's expose this as a property to allow userspace to program a desired value. This patch is based on earlier work by Chandra Konduru; unfortunately the driver has evolved so much since his patches were written (in the pre-atomic era) that the functionality had to be pretty much completely rewritten for the new i915 atomic internals. v2: - Set initial background color (black) via proper helper function (Bob) - Fix debugfs output - General rebasing Cc: Chandra Konduru Cc: Bob Paauwe Cc: dri-devel@lists.freedesktop.org Signed-off-by: Matt Roper --- Documentation/DocBook/gpu.tmpl | 10 +++++++- drivers/gpu/drm/i915/i915_debugfs.c | 8 +++++++ drivers/gpu/drm/i915/i915_reg.h | 9 +++++++ drivers/gpu/drm/i915/intel_display.c | 46 ++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index fe6b36a..9e003cd 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -2092,7 +2092,7 @@ void intel_crt_init(struct drm_device *dev) TBD - i915 + i915 Generic "Broadcast RGB" ENUM @@ -2108,6 +2108,14 @@ void intel_crt_init(struct drm_device *dev) TBD + CRTC + “background_color” + RGBA +   + CRTC + Background color of regions not covered by a plane + + SDVO-TV “mode” ENUM diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index ec0c2a05e..e7352fc 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -3104,6 +3104,14 @@ static int i915_display_info(struct seq_file *m, void *unused) intel_scaler_info(m, crtc); intel_plane_info(m, crtc); } + if (INTEL_INFO(dev)->gen >= 9 && pipe_config->base.active) { + struct drm_rgba background = pipe_config->base.background_color; + + seq_printf(m, "\tbackground color (10bpc): r=%x g=%x b=%x\n", + DRM_RGBA_REDBITS(background, 10), + DRM_RGBA_GREENBITS(background, 10), + DRM_RGBA_BLUEBITS(background, 10)); + } seq_printf(m, "\tunderrun reporting: cpu=%s pch=%s \n", yesno(!crtc->cpu_fifo_underrun_disabled), diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 144586e..b0b014d 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -7649,6 +7649,15 @@ enum skl_disp_power_wells { #define PIPE_CSC_POSTOFF_ME(pipe) _MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_ME, _PIPE_B_CSC_POSTOFF_ME) #define PIPE_CSC_POSTOFF_LO(pipe) _MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_LO, _PIPE_B_CSC_POSTOFF_LO) +/* Skylake pipe bottom color */ +#define _PIPE_BOTTOM_COLOR_A 0x70034 +#define _PIPE_BOTTOM_COLOR_B 0x71034 +#define _PIPE_BOTTOM_COLOR_C 0x72034 +#define PIPE_BOTTOM_GAMMA_ENABLE (1 << 31) +#define PIPE_BOTTOM_CSC_ENABLE (1 << 30) +#define PIPE_BOTTOM_COLOR_MASK 0x3FFFFFFF +#define PIPE_BOTTOM_COLOR(pipe) _MMIO_PIPE(pipe, _PIPE_BOTTOM_COLOR_A, _PIPE_BOTTOM_COLOR_B) + /* MIPI DSI registers */ #define _MIPI_PORT(port, a, c) _PORT3(port, a, 0, c) /* ports A and C only */ diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 836bbdc..a616ac42 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -3299,6 +3299,8 @@ static void intel_update_pipe_config(struct intel_crtc *crtc, struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc_state *pipe_config = to_intel_crtc_state(crtc->base.state); + struct drm_rgba background = pipe_config->base.background_color; + uint32_t val; /* drm_atomic_helper_update_legacy_modeset_state might not be called. */ crtc->base.mode = crtc->base.state->mode; @@ -3335,6 +3337,26 @@ static void intel_update_pipe_config(struct intel_crtc *crtc, else if (old_crtc_state->pch_pfit.enabled) ironlake_pfit_disable(crtc, true); } + + if (INTEL_INFO(dev)->gen >= 9) { + /* BGR 16bpc ==> RGB 10bpc */ + val = DRM_RGBA_REDBITS(background, 10) << 20 + | DRM_RGBA_GREENBITS(background, 10) << 10 + | DRM_RGBA_BLUEBITS(background, 10); + + /* + * Set CSC and gamma for bottom color. + * + * FIXME: We turn these on unconditionally for now to match + * how we've setup the various planes. Once the color + * management framework lands, it may or may not choose to + * set these bits. + */ + val |= PIPE_BOTTOM_CSC_ENABLE; + val |= PIPE_BOTTOM_GAMMA_ENABLE; + + I915_WRITE(PIPE_BOTTOM_COLOR(crtc->pipe), val); + } } static void intel_fdi_normal_train(struct drm_crtc *crtc) @@ -12032,6 +12054,9 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc, pipe_config); } + if (crtc->state->background_color.v != crtc_state->background_color.v) + pipe_config->update_pipe = true; + return ret; } @@ -13660,6 +13685,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = intel_crtc_destroy, .page_flip = intel_crtc_page_flip, + .set_property = drm_atomic_helper_crtc_set_property, .atomic_duplicate_state = intel_crtc_duplicate_state, .atomic_destroy_state = intel_crtc_destroy_state, }; @@ -14254,6 +14280,20 @@ static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_cr scaler_state->scaler_id = -1; } +static void intel_create_background_color_property(struct drm_device *dev, + struct intel_crtc *crtc) +{ + if (!dev->mode_config.prop_background_color) + dev->mode_config.prop_background_color = + drm_mode_create_background_color_property(dev); + if (!dev->mode_config.prop_background_color) + return; + + drm_object_attach_property(&crtc->base.base, + dev->mode_config.prop_background_color, + crtc->base.state->background_color.v); +} + static void intel_crtc_init(struct drm_device *dev, int pipe) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -14329,6 +14369,12 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); WARN_ON(drm_crtc_index(&intel_crtc->base) != intel_crtc->pipe); + + if (INTEL_INFO(dev)->gen >= 9) { + crtc_state->base.background_color = drm_rgba(16, 0, 0, 0, 0); + intel_create_background_color_property(dev, intel_crtc); + } + return; fail: