From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: clean up dsi pll calculation
Date: Tue, 12 May 2015 14:29:18 +0300 [thread overview]
Message-ID: <20150512112918.GV18908@intel.com> (raw)
In-Reply-To: <1431008057-9251-1-git-send-email-jani.nikula@intel.com>
On Thu, May 07, 2015 at 05:14:17PM +0300, Jani Nikula wrote:
> Improve readability. No functional changes.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> ---
>
> Cleaning up old branches... :)
> ---
> drivers/gpu/drm/i915/intel_dsi_pll.c | 52 ++++++++++++------------------------
> 1 file changed, 17 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dsi_pll.c b/drivers/gpu/drm/i915/intel_dsi_pll.c
> index 3622d0bafdf8..fc139946abee 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_pll.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_pll.c
> @@ -162,53 +162,35 @@ static u32 dsi_clk_from_pclk(u32 pclk, int pixel_format, int lane_count)
>
> #endif
>
> -static int dsi_calc_mnp(u32 dsi_clk, struct dsi_mnp *dsi_mnp)
> +static int dsi_calc_mnp(u32 target_dsi_clk, struct dsi_mnp *dsi_mnp)
> {
> u32 m, n, p;
> - u32 ref_clk;
> - u32 error;
> - u32 tmp_error;
> - int target_dsi_clk;
> - int calc_dsi_clk;
> - u32 calc_m;
> - u32 calc_p;
> + u32 ref_clk = 25000;
> + u32 delta = target_dsi_clk;
> + u32 calc_m = 0;
> + u32 calc_p = 0;
> u32 m_seed;
>
> - /* dsi_clk is expected in KHZ */
> - if (dsi_clk < 300000 || dsi_clk > 1150000) {
> + /* target_dsi_clk is expected in KHZ */
> + if (target_dsi_clk < 300000 || target_dsi_clk > 1150000) {
> DRM_ERROR("DSI CLK Out of Range\n");
> return -ECHRNG;
> }
>
> - ref_clk = 25000;
> - target_dsi_clk = dsi_clk;
> - error = 0xFFFFFFFF;
> - tmp_error = 0xFFFFFFFF;
> - calc_m = 0;
> - calc_p = 0;
> -
> - for (m = 62; m <= 92; m++) {
> - for (p = 2; p <= 6; p++) {
> - /* Find the optimal m and p divisors
> - with minimal error +/- the required clock */
> - calc_dsi_clk = (m * ref_clk) / p;
> - if (calc_dsi_clk == target_dsi_clk) {
> - calc_m = m;
> - calc_p = p;
> - error = 0;
> - break;
> - } else
> - tmp_error = abs(target_dsi_clk - calc_dsi_clk);
> -
> - if (tmp_error < error) {
> - error = tmp_error;
> + for (m = 62; m <= 92 && delta; m++) {
> + for (p = 2; p <= 6 && delta; p++) {
> + /*
> + * Find the optimal m and p divisors with minimal delta
> + * +/- the required clock
> + */
> + int calc_dsi_clk = (m * ref_clk) / p;
> + u32 d = abs(target_dsi_clk - calc_dsi_clk);
'target_dsi_clk - calc_dsi_clk' is going to be unsigned, so this is
still a bit confusing. abs() does stick that into a signed int before
comparing it, so it should just work, but still might be sensible to
make target_dsi_clk signed.
Also perhaps s/u32/unsigned int/ (or maybe just use int) all over?
> + if (d < delta) {
> + delta = d;
> calc_m = m;
> calc_p = p;
> }
> }
> -
> - if (error == 0)
> - break;
> }
>
> m_seed = lfsr_converts[calc_m - 62];
> --
> 2.1.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-05-12 11:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 14:14 [PATCH] drm/i915: clean up dsi pll calculation Jani Nikula
2015-05-08 10:09 ` shuang.he
2015-05-12 11:29 ` Ville Syrjälä [this message]
2015-05-12 12:23 ` Jani Nikula
2015-05-12 12:28 ` Ville Syrjälä
2015-05-12 13:09 ` 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=20150512112918.GV18908@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.