From: Jani Nikula <jani.nikula@linux.intel.com>
To: ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 6/6] drm/i915: Use DIV_ROUND_CLOSEST for PWM calculations
Date: Thu, 03 Mar 2016 10:25:06 +0200 [thread overview]
Message-ID: <87mvqgrmsd.fsf@intel.com> (raw)
In-Reply-To: <1456932138-14004-7-git-send-email-ville.syrjala@linux.intel.com>
On Wed, 02 Mar 2016, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Supposedly we would want to get the PWM output as close as possible to
> the target, so let's round to closest.
>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
I have zero recollection of asking this change, but since it makes sense
I won't deny it was me.
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/intel_panel.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 5cf377507162..0fe059bc7d80 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -1240,7 +1240,7 @@ static void intel_backlight_device_unregister(struct intel_connector *connector)
> */
> static u32 bxt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> {
> - return KHz(19200) / pwm_freq_hz;
> + return DIV_ROUND_CLOSEST(KHz(19200), pwm_freq_hz);
> }
>
> /*
> @@ -1258,7 +1258,7 @@ static u32 spt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> else
> mul = 16;
>
> - return MHz(24) / (pwm_freq_hz * mul);
> + return DIV_ROUND_CLOSEST(MHz(24), pwm_freq_hz * mul);
> }
>
> /*
> @@ -1281,7 +1281,7 @@ static u32 lpt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> else
> clock = MHz(24); /* LPT:LP */
>
> - return clock / (pwm_freq_hz * mul);
> + return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
> }
>
> /*
> @@ -1292,7 +1292,7 @@ static u32 pch_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> {
> struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
>
> - return KHz(dev_priv->rawclk_freq) / (pwm_freq_hz * 128);
> + return DIV_ROUND_CLOSEST(KHz(dev_priv->rawclk_freq), pwm_freq_hz * 128);
> }
>
> /*
> @@ -1313,7 +1313,7 @@ static u32 i9xx_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> else
> clock = KHz(dev_priv->cdclk_freq);
>
> - return clock / (pwm_freq_hz * 32);
> + return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 32);
> }
>
> /*
> @@ -1332,7 +1332,7 @@ static u32 i965_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> else
> clock = KHz(dev_priv->cdclk_freq);
>
> - return clock / (pwm_freq_hz * 128);
> + return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 128);
> }
>
> /*
> @@ -1356,7 +1356,7 @@ static u32 vlv_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
> mul = 128;
> }
>
> - return clock / (pwm_freq_hz * mul);
> + return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
> }
>
> static u32 get_backlight_max_vbt(struct intel_connector *connector)
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-03-03 8:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 15:22 [PATCH v2 drm/i915: rawclk/cdclk stuff (v2) ville.syrjala
2016-03-02 15:22 ` [PATCH v2 1/6] drm/i915: Store rawclk_freq in dev_priv ville.syrjala
2016-03-03 8:47 ` Jani Nikula
2016-03-03 10:59 ` Ville Syrjälä
2016-03-02 15:22 ` [PATCH 2/6] drm/i915: Rename s/i9xx/g4x/ in DP code ville.syrjala
2016-03-02 15:22 ` [PATCH v2 3/6] drm/i915: Use g4x_get_aux_clock_divider() for VLV/CHV ville.syrjala
2016-03-02 15:22 ` [PATCH 4/6] drm/i915: Read out hrawclk from CCK on vlv/chv ville.syrjala
2016-03-03 8:51 ` Jani Nikula
2016-03-03 11:04 ` Ville Syrjälä
2016-03-03 18:13 ` Imre Deak
2016-03-02 15:22 ` [PATCH 5/6] drm/i915: Clean up .get_aux_clock_divider() functions ville.syrjala
2016-03-02 15:22 ` [PATCH 6/6] drm/i915: Use DIV_ROUND_CLOSEST for PWM calculations ville.syrjala
2016-03-03 8:25 ` Jani Nikula [this message]
2016-03-03 10:54 ` Ville Syrjälä
2016-03-02 16:55 ` ✗ Fi.CI.BAT: failure for series starting with [v2,1/6] drm/i915: Store rawclk_freq in dev_priv Patchwork
2016-03-02 17:27 ` Ville Syrjälä
2016-03-04 12:56 ` [PATCH v2 drm/i915: rawclk/cdclk stuff (v2) Ville Syrjälä
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=87mvqgrmsd.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@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