From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933823AbcIRTRB (ORCPT ); Sun, 18 Sep 2016 15:17:01 -0400 Received: from down.free-electrons.com ([37.187.137.238]:42288 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932595AbcIRTQv (ORCPT ); Sun, 18 Sep 2016 15:16:51 -0400 Date: Sun, 18 Sep 2016 21:16:48 +0200 From: Maxime Ripard To: Chen-Yu Tsai Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] drm/sun4i: dotclock: Round to closest clock rate Message-ID: <20160918191648.GJ17518@lukather> References: <20160915151402.15992-1-wens@csie.org> <20160915151402.15992-5-wens@csie.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JsihDCElWRmQcbOr" Content-Disposition: inline In-Reply-To: <20160915151402.15992-5-wens@csie.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --JsihDCElWRmQcbOr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Thu, Sep 15, 2016 at 11:14:02PM +0800, Chen-Yu Tsai wrote: > With display pixel clocks we want to have the closest possible clock > rate, to minimize timing and refresh rate skews. Whether the actual > clock rate is higher or lower than the requested rate is less important. >=20 > Also check candidates against the requested rate, rather than the > ideal parent rate, the varying dividers also influence the difference > between the requested rate and the rounded rate. >=20 > Signed-off-by: Chen-Yu Tsai > --- > drivers/gpu/drm/sun4i/sun4i_dotclock.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_dotclock.c b/drivers/gpu/drm/sun= 4i/sun4i_dotclock.c > index 3eb99784f371..d401156490f3 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c > +++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c > @@ -90,7 +90,8 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, un= signed long rate, > goto out; > } > =20 > - if ((rounded < ideal) && (rounded > best_parent)) { > + if (abs(rate - rounded / i) < > + abs(rate - best_parent / best_div)) { I'm not sure what you're trying to do here. Why is the divider involved? Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --JsihDCElWRmQcbOr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJX3uggAAoJEBx+YmzsjxAg/p8P/3UnHCf+ebarBWKuSN9TR/s9 YJcn98l2KKOjYrbOEg+nwBkYcnjBtg1mJ2+zSHtW4j3akoaqx+/brInGnAbSTW72 xVTS+5J3lPcb2L4bZ2zwwuBv6yCYxdkHoXZMWFl37ys4lMDCgIexIjGt/KQEs+zi TdCAJSCA3e0hQbl0TxN/Qt23YiwXB5Hn1ht8fBmJ/birtnSYg7G9tlufkZD365ey PNZiHovMVtpnXFaHNVwlqiE9G6DxQIf0lzVa/wRXV9StS6oa/Vo5lwf8o2JmIOi4 JhBk4/vY1xyyCXtQwjCpXS3oKSMAXyf6iaMXtfEpBTrNkHsojyZGdvBExIsUqz7k SLJzbEzknY+/enJjmU0yLrIUJO0Umhqb/82r9J+nGj/O7Y7K6zni5caR4UOBnUv/ RhkQua82UrATyt0uhkJfNXN59fFY2uN5moNfAYH9CvhydV+5Kawgmgxut+6HY3Vl NfoskwfrmMoip2dYpwRTKe2eU0DsC58+CmdFN7AAuWe1wRf9DfRxonDTmWkAyNca xNTQJtzrBPV+ztRSPBUIDz0aQcjQZuJS/NZ0eI7LFmPdrJZ39IlwCzXkImRkIUiv WKa2zVUsfvk578IfhObevJDX4hIRYtgjw/uQdUaJbm32vQwDmV0Coatd95c20CPP 7caPDgXYwktufUXIH3Jx =s1Ys -----END PGP SIGNATURE----- --JsihDCElWRmQcbOr--