public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915: Add intel_dotclock_calculate()
Date: Mon, 16 Sep 2013 22:41:38 +0200	[thread overview]
Message-ID: <20130916204138.GE32145@phenom.ffwll.local> (raw)
In-Reply-To: <87txhldnmg.fsf@intel.com>

On Mon, Sep 16, 2013 at 02:14:47PM +0300, Jani Nikula wrote:
> On Fri, 13 Sep 2013, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Extract the code to calculate the dotclock from the link clock and M/N
> > values into a new function from ironlake_crtc_clock_get().
> >
> > The new function can be used to calculate the dotclock for both FDI and
> > DP cases.
> >
> > Also simplify the code a bit along the way.
> >
> > v2: Don't forget about non-pch encoders in ironlake_crtc_clock_get()
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> 
> > ---
> >  drivers/gpu/drm/i915/intel_display.c | 43 ++++++++++++++++++------------------
> >  drivers/gpu/drm/i915/intel_drv.h     |  2 ++
> >  2 files changed, 24 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index c0ee41c..13dea9b 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -7405,16 +7405,9 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
> >  	pipe_config->adjusted_mode.clock = clock.dot;
> >  }
> >  
> > -static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
> > -				    struct intel_crtc_config *pipe_config)
> > +int intel_dotclock_calculate(int link_freq,
> > +			     const struct intel_link_m_n *m_n)

intel_dotclock_calculate is an awfully generic name for something which
computes the dotclock for an fdi/dp link ... Maybe intel_dotclock_from_m_n
instead?

Patch merged since I don't want to block this any longer (and maybe it
makes more sense in the end, haven't checked).

Cheers, Daniel

> >  {
> > -	struct drm_device *dev = crtc->base.dev;
> > -	struct drm_i915_private *dev_priv = dev->dev_private;
> > -	enum transcoder cpu_transcoder = pipe_config->cpu_transcoder;
> > -	int link_freq;
> > -	u64 clock;
> > -	u32 link_m, link_n;
> > -
> >  	/*
> >  	 * The calculation for the data clock is:
> >  	 * pixel_clock = ((m/n)*(link_clock * nr_lanes))/bpp
> > @@ -7425,6 +7418,18 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
> >  	 * link_clock = (m * link_clock) / n
> >  	 */
> >  
> > +	if (!m_n->link_n)
> > +		return 0;
> > +
> > +	return div_u64((u64)m_n->link_m * link_freq, m_n->link_n);
> > +}
> > +
> > +static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
> > +				    struct intel_crtc_config *pipe_config)
> > +{
> > +	struct drm_device *dev = crtc->base.dev;
> > +	int link_freq;
> > +
> >  	/*
> >  	 * We need to get the FDI or DP link clock here to derive
> >  	 * the M/N dividers.
> > @@ -7433,21 +7438,17 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
> >  	 * For DP, it's either 1.62GHz or 2.7GHz.
> >  	 * We do our calculations in 10*MHz since we don't need much precison.
> >  	 */
> > -	if (pipe_config->has_pch_encoder)
> > +	if (pipe_config->has_pch_encoder) {
> >  		link_freq = intel_fdi_link_freq(dev) * 10000;
> > -	else
> > -		link_freq = pipe_config->port_clock;
> >  
> > -	link_m = I915_READ(PIPE_LINK_M1(cpu_transcoder));
> > -	link_n = I915_READ(PIPE_LINK_N1(cpu_transcoder));
> > -
> > -	if (!link_m || !link_n)
> > -		return;
> > -
> > -	clock = ((u64)link_m * (u64)link_freq);
> > -	do_div(clock, link_n);
> > +		pipe_config->adjusted_mode.clock =
> > +			intel_dotclock_calculate(link_freq, &pipe_config->fdi_m_n);
> > +	} else {
> > +		link_freq = pipe_config->port_clock;
> >  
> > -	pipe_config->adjusted_mode.clock = clock;
> > +		pipe_config->adjusted_mode.clock =
> > +			intel_dotclock_calculate(link_freq, &pipe_config->dp_m_n);
> > +	}
> >  }
> >  
> >  /** Returns the currently programmed mode of the given pipe. */
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index c058f1b..6b97ac1 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -805,5 +805,7 @@ extern void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
> >  extern void i915_disable_vga_mem(struct drm_device *dev);
> >  extern void intel_dp_get_m_n(struct intel_crtc *crtc,
> >  			     struct intel_crtc_config *pipe_config);
> > +extern int intel_dotclock_calculate(int link_freq,
> > +				    const struct intel_link_m_n *m_n);
> >  
> >  #endif /* __INTEL_DRV_H__ */
> > -- 
> > 1.8.1.5
> >
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

  reply	other threads:[~2013-09-16 20:41 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-06 20:28 [PATCH 00/11] drm/i915: adjusted_mode.clock vs. port_clock v3 ville.syrjala
2013-09-06 20:28 ` [PATCH 01/11] drm/i915: Don't factor in pixel multplier when deriving dotclock from link clock and M/N values ville.syrjala
2013-09-06 20:28 ` [PATCH v2 02/11] drm/i915: Make adjusted_mode.clock non-pixel multiplied ville.syrjala
2013-09-13 11:40   ` Jani Nikula
2013-09-06 20:29 ` [PATCH v2 03/11] drm/i915: Add support for pipe_bpp readout ville.syrjala
2013-09-13 11:59   ` Jani Nikula
2013-09-06 20:29 ` [PATCH 04/11] drm/i915: Add state readout and checking for has_dp_encoder and dp_m_n ville.syrjala
2013-09-10 14:02   ` [PATCH v2] " ville.syrjala
2013-09-13 12:11     ` Jani Nikula
2013-09-06 20:29 ` [PATCH 05/11] drm/i915: Make intel_fuzzy_clock_check() take in arbitrary clocks ville.syrjala
2013-09-13 12:55   ` Daniel Vetter
2013-09-06 20:29 ` [PATCH 06/11] drm/i915: Add intel_dotclock_calculate() ville.syrjala
2013-09-13 12:30   ` Jani Nikula
2013-09-13 12:43     ` Ville Syrjälä
2013-09-13 12:59       ` [PATCH v2] " ville.syrjala
2013-09-16 11:14         ` Jani Nikula
2013-09-16 20:41           ` Daniel Vetter [this message]
2013-09-17  8:16             ` Ville Syrjälä
2013-09-06 20:29 ` [PATCH 07/11] drm/i915: Make i9xx_crtc_clock_get() use dpll_hw_state ville.syrjala
2013-09-13 12:40   ` Jani Nikula
2013-09-13 13:12     ` Ville Syrjälä
2013-09-13 13:18     ` [PATCH v2] " ville.syrjala
2013-09-13 13:44       ` Jani Nikula
2013-09-06 20:29 ` [PATCH 08/11] drm/i915: Make i9xx_crtc_clock_get() work for PCH DPLLs ville.syrjala
2013-09-08 12:35   ` Daniel Vetter
2013-09-09 11:06     ` [PATCH v2] " ville.syrjala
2013-09-13 13:04       ` Jani Nikula
2013-09-13 13:06         ` Ville Syrjälä
2013-09-13 13:47           ` Jani Nikula
2013-09-13 13:54             ` Ville Syrjälä
2013-09-16 20:43             ` Daniel Vetter
2013-09-06 20:29 ` [PATCH 09/11] drm/i915: Fix port_clock and adjusted_mode.clock readout all over ville.syrjala
2013-09-08 12:37   ` Daniel Vetter
2013-09-09 10:35     ` [PATCH v2] " ville.syrjala
2013-09-09 11:34       ` [PATCH v3] " ville.syrjala
2013-09-13 13:00         ` [PATCH v4] " ville.syrjala
2013-09-16 11:16           ` Jani Nikula
2013-09-06 20:29 ` [PATCH v2 10/11] drm/i915: Add PIPE_CONF_CHECK_CLOCK_FUZZY() ville.syrjala
2013-09-06 20:29 ` [PATCH v2 11/11] drm/i915: Add fuzzy clock check for port_clock ville.syrjala
2013-09-16 21:16   ` Daniel Vetter
2013-09-08 12:38 ` [PATCH 00/11] drm/i915: adjusted_mode.clock vs. port_clock v3 Daniel Vetter

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=20130916204138.GE32145@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.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