public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Uma Shankar <uma.shankar@intel.com>, intel-gfx@lists.freedesktop.org
Cc: shobhit.kumar@intel.com
Subject: Re: [PATCH 10/12] drm/i915/bxt: get DSI pixelclock
Date: Mon, 25 May 2015 19:54:26 +0300	[thread overview]
Message-ID: <87382kion1.fsf@intel.com> (raw)
In-Reply-To: <1432310765-2218-11-git-send-email-uma.shankar@intel.com>

On Fri, 22 May 2015, Uma Shankar <uma.shankar@intel.com> wrote:
> From: Shashank Sharma <shashank.sharma@intel.com>
>
> BXT's DSI PLL is different from that of VLV. So this patch
> adds a new function to get the current DSI pixel clock based
> on the PLL divider ratio and lane count.
>
> This function is required for intel_dsi_get_config() function.
>
> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> Signed-off-by: Uma Shankar <uma.shankar@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_dsi.c     |   10 ++++++++--
>  drivers/gpu/drm/i915/intel_dsi.h     |    1 +
>  drivers/gpu/drm/i915/intel_dsi_pll.c |   35 ++++++++++++++++++++++++++++++++++
>  3 files changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
> index 2663cdd..5fbcebe 100644
> --- a/drivers/gpu/drm/i915/intel_dsi.c
> +++ b/drivers/gpu/drm/i915/intel_dsi.c
> @@ -714,7 +714,7 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
>  static void intel_dsi_get_config(struct intel_encoder *encoder,
>  				 struct intel_crtc_state *pipe_config)
>  {
> -	u32 pclk;
> +	u32 pclk = 0;

Unnecessary initialization.

>  	DRM_DEBUG_KMS("\n");
>  
>  	/*
> @@ -723,7 +723,13 @@ static void intel_dsi_get_config(struct intel_encoder *encoder,
>  	 */
>  	pipe_config->dpll_hw_state.dpll_md = 0;
>  
> -	pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
> +	if (IS_BROXTON(encoder->base.dev))
> +		pclk = bxt_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
> +	else if (IS_VALLEYVIEW(encoder->base.dev))
> +		pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
> +	else
> +		DRM_ERROR("Invalid DSI device to get config\n");

Please drop the else branch.

> +
>  	if (!pclk)
>  		return;
>  
> diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
> index 8bc8d94..01e08e7 100644
> --- a/drivers/gpu/drm/i915/intel_dsi.h
> +++ b/drivers/gpu/drm/i915/intel_dsi.h
> @@ -124,6 +124,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
>  extern void intel_enable_dsi_pll(struct intel_encoder *encoder);
>  extern void intel_disable_dsi_pll(struct intel_encoder *encoder);
>  extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
> +extern u32 bxt_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
>  extern void bxt_dsi_program_clocks(struct drm_device *dev, int pipe);
>  extern void intel_dsi_reset_clocks(struct intel_encoder *encoder,
>  						enum port port);
> diff --git a/drivers/gpu/drm/i915/intel_dsi_pll.c b/drivers/gpu/drm/i915/intel_dsi_pll.c
> index 49330b0..073bd1f 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_pll.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_pll.c
> @@ -369,6 +369,41 @@ u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
>  	return pclk;
>  }
>  
> +u32 bxt_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
> +{
> +	u32 pclk;
> +	u32 dsi_clk;
> +	u32 dsi_ratio;
> +	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
> +	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
> +
> +	/* Divide by zero */
> +	if (!pipe_bpp) {
> +		DRM_ERROR("Invalid BPP(0)\n");
> +		return 0;
> +	}
> +
> +	dsi_ratio = I915_READ(BXT_DSI_PLL_CTL) &
> +		BXT_DSI_MASK_PLL_RATIO;
> +
> +	/* Invalid DSI ratio ? */
> +	if (dsi_ratio < BXT_DSI_PLL_RATIO_MIN ||
> +			dsi_ratio > BXT_DSI_PLL_RATIO_MAX) {
> +		DRM_ERROR("Invalid DSI pll ratio(%u) programmed\n", dsi_ratio);
> +		return 0;
> +	}
> +
> +	dsi_clk = (dsi_ratio * BXT_REF_CLOCK_KHZ) / 2;
> +
> +	/* pixel_format and pipe_bpp should agree */
> +	assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
> +
> +	pclk = DIV_ROUND_CLOSEST(dsi_clk * intel_dsi->lane_count, pipe_bpp);
> +
> +	DRM_DEBUG_DRIVER("Calculated pclk=%u\n", pclk);
> +	return pclk;
> +}
> +
>  void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
>  {
>  	u32 temp;
> -- 
> 1.7.9.5
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-05-25 16:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 16:05 [PATCH 00/12] *** MIPI DSI Support for BXT *** Uma Shankar
2015-05-22 16:05 ` [PATCH 01/12] drm/i915/bxt: Initialize MIPI for BXT Uma Shankar
2015-05-22 16:05 ` [PATCH 02/12] drm/i915/bxt: Enable BXT DSI PLL Uma Shankar
2015-05-25 16:10   ` Jani Nikula
2015-05-22 16:05 ` [PATCH 03/12] drm/i915/bxt: Disable DSI PLL for BXT Uma Shankar
2015-05-25 16:12   ` Jani Nikula
2015-05-22 16:05 ` [PATCH 04/12] drm/i915/bxt: DSI prepare changes " Uma Shankar
2015-05-25 16:25   ` Jani Nikula
2015-05-22 16:05 ` [PATCH 05/12] drm/i915/bxt: DSI encoder support in CRTC modeset Uma Shankar
2015-05-25 10:13   ` Jani Nikula
2015-05-25 11:24     ` Jani Nikula
2015-05-25 10:25   ` Jani Nikula
2015-05-26  7:11     ` Daniel Vetter
2015-05-26  7:19       ` Jani Nikula
2015-05-26  8:26         ` Daniel Vetter
2015-05-22 16:05 ` [PATCH 06/12] drm/i915/bxt: DSI enable for BXT Uma Shankar
2015-05-25 16:39   ` Jani Nikula
2015-05-22 16:06 ` [PATCH 07/12] drm/i915/bxt: Program Tx Rx and Dphy clocks Uma Shankar
2015-05-25 16:52   ` Jani Nikula
2015-05-22 16:06 ` [PATCH 08/12] drm/i915/bxt: DSI disable and post-disable Uma Shankar
2015-05-25 16:44   ` Jani Nikula
2015-05-22 16:06 ` [PATCH 09/12] drm/i915/bxt: get_hw_state for BXT Uma Shankar
2015-05-22 16:06 ` [PATCH 10/12] drm/i915/bxt: get DSI pixelclock Uma Shankar
2015-05-25 16:54   ` Jani Nikula [this message]
2015-05-22 16:06 ` [PATCH 11/12] drm/i915/bxt: Modify BXT BLC according to VBT changes Uma Shankar
2015-05-25 10:03   ` Jani Nikula
2015-05-25 16:57     ` Jani Nikula
2015-05-22 16:06 ` [PATCH 12/12] drm/i915/bxt: Remove DSP CLK_GATE programming for BXT Uma Shankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87382kion1.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=shobhit.kumar@intel.com \
    --cc=uma.shankar@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox