From patchwork Wed Mar 1 02:57:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 9597347 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 452EB601D7 for ; Wed, 1 Mar 2017 03:04:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FEBA2022B for ; Wed, 1 Mar 2017 03:04:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34CB928492; Wed, 1 Mar 2017 03:04:52 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 BEAE32022B for ; Wed, 1 Mar 2017 03:04:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A830789221; Wed, 1 Mar 2017 03:04:49 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 02E686E877 for ; Wed, 1 Mar 2017 02:58:46 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2017 18:58:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,223,1484035200"; d="scan'208";a="939229706" Received: from nuc-skylake.jf.intel.com ([10.54.75.136]) by orsmga003.jf.intel.com with ESMTP; 28 Feb 2017 18:58:44 -0800 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Tue, 28 Feb 2017 18:57:17 -0800 Message-Id: <1488337038-2906-1-git-send-email-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.7.4 Cc: Ander Conselvan de Oliveira , Dhinakaran Pandiyan Subject: [Intel-gfx] [PATCH 1/2] drm/i915/glk: Apply cdclk workaround for DP audio 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 Implement GLK cdclk restriction for DP audio, similar to what's implemented for BDW and other GEN9 platforms. The cdclk restriction has been refactored out of max. pixel clock computation as the 1:1 relationship between pixel clock and cdclk frequency does not hold for GLK. Signed-off-by: Dhinakaran Pandiyan --- drivers/gpu/drm/i915/intel_cdclk.c | 83 ++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_cdclk.c b/drivers/gpu/drm/i915/intel_cdclk.c index d643c0c..8fc0f72 100644 --- a/drivers/gpu/drm/i915/intel_cdclk.c +++ b/drivers/gpu/drm/i915/intel_cdclk.c @@ -1069,11 +1069,11 @@ static int bxt_calc_cdclk(int max_pixclk) return 144000; } -static int glk_calc_cdclk(int max_pixclk) +static int glk_calc_cdclk(int max_pixclk, int min_cdclk) { - if (max_pixclk > 2 * 158400) + if (max_pixclk > 2 * 158400 || min_cdclk > 158400) return 316800; - else if (max_pixclk > 2 * 79200) + else if (max_pixclk > 2 * 79200 || min_cdclk > 79200) return 158400; else return 79200; @@ -1367,7 +1367,7 @@ void bxt_init_cdclk(struct drm_i915_private *dev_priv) * Need to make this change after VBT has changes for BXT. */ if (IS_GEMINILAKE(dev_priv)) { - cdclk_state.cdclk = glk_calc_cdclk(0); + cdclk_state.cdclk = glk_calc_cdclk(0, 0); cdclk_state.vco = glk_de_pll_vco(dev_priv, cdclk_state.cdclk); } else { cdclk_state.cdclk = bxt_calc_cdclk(0); @@ -1432,28 +1432,37 @@ void intel_set_cdclk(struct drm_i915_private *dev_priv, dev_priv->display.set_cdclk(dev_priv, cdclk_state); } -static int bdw_adjust_min_pipe_pixel_rate(struct intel_crtc_state *crtc_state, - int pixel_rate) +static int intel_min_cdclk(struct drm_atomic_state *state) { - struct drm_i915_private *dev_priv = - to_i915(crtc_state->base.crtc->dev); + struct drm_i915_private *dev_priv = to_i915(state->dev); + struct drm_crtc *crtc; + struct drm_crtc_state *cstate; + int i; + int min_cdclk = 0; - /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */ - if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled) - pixel_rate = DIV_ROUND_UP(pixel_rate * 100, 95); + for_each_crtc_in_state(state, crtc, cstate, i) { + struct intel_crtc_state *crtc_state; - /* BSpec says "Do not use DisplayPort with CDCLK less than - * 432 MHz, audio enabled, port width x4, and link rate - * HBR2 (5.4 GHz), or else there may be audio corruption or - * screen corruption." - */ - if (intel_crtc_has_dp_encoder(crtc_state) && - crtc_state->has_audio && - crtc_state->port_clock >= 540000 && - crtc_state->lane_count == 4) - pixel_rate = max(432000, pixel_rate); + crtc_state = to_intel_crtc_state(cstate); + + /* According to BSpec, "Do not use DisplayPort with CDCLK less + * than 432 MHz, audio enabled, port width x4, and link rate + * HBR2 (5.4 GHz), or else there may be audio corruption or + * screen corruption." for BDW and GEN9. The cdclk restriction + * for GLK is at 316.8 MHz + */ + if (intel_crtc_has_dp_encoder(crtc_state) && + crtc_state->has_audio && + crtc_state->port_clock >= 540000 && + crtc_state->lane_count == 4) { + if (IS_GEMINILAKE(dev_priv)) + min_cdclk = 316800; + else if (IS_BROADWELL(dev_priv) || IS_GEN9(dev_priv)) + min_cdclk = 432000; + } + } - return pixel_rate; + return min_cdclk; } /* compute the max rate for new configuration */ @@ -1481,10 +1490,9 @@ static int intel_max_pixel_rate(struct drm_atomic_state *state) pixel_rate = crtc_state->pixel_rate; - if (IS_BROADWELL(dev_priv) || IS_GEN9(dev_priv)) - pixel_rate = - bdw_adjust_min_pipe_pixel_rate(crtc_state, - pixel_rate); + /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */ + if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled) + pixel_rate = DIV_ROUND_UP(pixel_rate * 100, 95); intel_state->min_pixclk[i] = pixel_rate; } @@ -1531,13 +1539,17 @@ static int bdw_modeset_calc_cdclk(struct drm_atomic_state *state) struct drm_i915_private *dev_priv = to_i915(state->dev); struct intel_atomic_state *intel_state = to_intel_atomic_state(state); int max_pixclk = intel_max_pixel_rate(state); + int min_cdclk = intel_min_cdclk(state); int cdclk; /* * FIXME should also account for plane ratio * once 64bpp pixel formats are supported. */ - cdclk = bdw_calc_cdclk(max_pixclk); + if (min_cdclk > max_pixclk) + cdclk = bdw_calc_cdclk(min_cdclk); + else + cdclk = bdw_calc_cdclk(max_pixclk); if (cdclk > dev_priv->max_cdclk_freq) { DRM_DEBUG_KMS("requested cdclk (%d kHz) exceeds max (%d kHz)\n", @@ -1564,6 +1576,7 @@ static int skl_modeset_calc_cdclk(struct drm_atomic_state *state) struct intel_atomic_state *intel_state = to_intel_atomic_state(state); struct drm_i915_private *dev_priv = to_i915(state->dev); const int max_pixclk = intel_max_pixel_rate(state); + int min_cdclk = intel_min_cdclk(state); int cdclk, vco; vco = intel_state->cdclk.logical.vco; @@ -1574,7 +1587,10 @@ static int skl_modeset_calc_cdclk(struct drm_atomic_state *state) * FIXME should also account for plane ratio * once 64bpp pixel formats are supported. */ - cdclk = skl_calc_cdclk(max_pixclk, vco); + if (min_cdclk > max_pixclk) + cdclk = skl_calc_cdclk(min_cdclk, vco); + else + cdclk = skl_calc_cdclk(max_pixclk, vco); if (cdclk > dev_priv->max_cdclk_freq) { DRM_DEBUG_KMS("requested cdclk (%d kHz) exceeds max (%d kHz)\n", @@ -1604,13 +1620,18 @@ static int bxt_modeset_calc_cdclk(struct drm_atomic_state *state) int max_pixclk = intel_max_pixel_rate(state); struct intel_atomic_state *intel_state = to_intel_atomic_state(state); + int min_cdclk = intel_min_cdclk(state); int cdclk, vco; if (IS_GEMINILAKE(dev_priv)) { - cdclk = glk_calc_cdclk(max_pixclk); + cdclk = glk_calc_cdclk(max_pixclk, min_cdclk); vco = glk_de_pll_vco(dev_priv, cdclk); } else { - cdclk = bxt_calc_cdclk(max_pixclk); + if (min_cdclk > max_pixclk) + cdclk = bxt_calc_cdclk(min_cdclk); + else + cdclk = bxt_calc_cdclk(max_pixclk); + vco = bxt_de_pll_vco(dev_priv, cdclk); } @@ -1625,7 +1646,7 @@ static int bxt_modeset_calc_cdclk(struct drm_atomic_state *state) if (!intel_state->active_crtcs) { if (IS_GEMINILAKE(dev_priv)) { - cdclk = glk_calc_cdclk(0); + cdclk = glk_calc_cdclk(0, 0); vco = glk_de_pll_vco(dev_priv, cdclk); } else { cdclk = bxt_calc_cdclk(0);