Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2607996imm; Fri, 24 Aug 2018 02:08:46 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZeEJYGjGnTlYa8yRLZSannT+Pn0qhJd1cdJsdX4Eyz1OF3iOaVrP4xreuU8GrwK9YZo98x X-Received: by 2002:a63:3dc6:: with SMTP id k189-v6mr830189pga.191.1535101726152; Fri, 24 Aug 2018 02:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535101726; cv=none; d=google.com; s=arc-20160816; b=D5RSbprsblheY4tm4rp6xXIoDWOO1viMXE0Wuv/Q5zbdCq7L3FyU+icxu4WFUVftW2 G/AYdwKGppQg9VFcKmcGqoklIPmS2z86dXNZdQcTf5LTPoKqQJAoWYtYSc55jiwIRA4w uYWxq5SU8rj24p5kLMUH63joid3bI4I06pkKVShzbPWSlImRnPR3Zq2RunYXgbN91tye IGDowh3aXv+miGOhvkeykpe/MrxHUDA+gjnXxb0alXIUpAzDpaa5DzJZlu4Pqdc0oGen MwUScr2UEM1MONqfwQ+4Z4W8sZHZ1Q4YIyvODlwLwygM5Z/NzhCO06s8CSHpPENJDSId 7vew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=c/VOUgIBZCGu9xYJ6m9pDyZKWMooeGx21EO7FewTnhw=; b=V8a7fl1ZKcY+6Vu7ZRz0hJEaWR/UG3EjmRCQg3MX/jfMUwNRNq7gl4YJrJIrhmBbML Q39i2R3iGJcBcqxRZ4y2tQwmA84FUeQnvL6eekouWza0tCJG/raUy4uLnF1E4zo03Svg X0mZJM0xuM4JbuBjjbLX0HAZHOKoDr5vcxhovdYKmyuRH8lSAkcw47wbIhHnkA5UhApN j8GypFxwhE/YX6JHoOEEKfnDlj0CdY1EQR02m8kWN2hVMmQ0X6W1nAByp0k+vCuElN5J VwxuqI35mN6wUqIJzM4ygZ7/BbUIiOzQOwZz+WhlAlYF8jdtGGPpc6Owmo87hsMJPzbi PrAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 29-v6si6405902pgv.292.2018.08.24.02.08.30; Fri, 24 Aug 2018 02:08:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727019AbeHXMlJ (ORCPT + 99 others); Fri, 24 Aug 2018 08:41:09 -0400 Received: from mail.bootlin.com ([62.4.15.54]:45098 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726686AbeHXMlI (ORCPT ); Fri, 24 Aug 2018 08:41:08 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 7A53620732; Fri, 24 Aug 2018 11:07:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-53-19.w90-88.abo.wanadoo.fr [90.88.170.19]) by mail.bootlin.com (Postfix) with ESMTPSA id 3F9C920711; Fri, 24 Aug 2018 11:07:15 +0200 (CEST) Date: Fri, 24 Aug 2018 11:07:13 +0200 From: Boris Brezillon To: Peter Rosin Cc: linux-kernel@vger.kernel.org, David Airlie , Nicolas Ferre , Alexandre Belloni , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/2] drm/atmel-hlcdc: allow selecting a higher pixel-clock that requested Message-ID: <20180824110713.3c801034@bbrezillon> In-Reply-To: <20180824085501.9740-3-peda@axentia.se> References: <20180824085501.9740-1-peda@axentia.se> <20180824085501.9740-3-peda@axentia.se> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Aug 2018 10:55:01 +0200 Peter Rosin wrote: > But only if the highest pixel-clock frequency lower than requested > is significantly much less accurate that the lowest frequency higher > than requested. > > I pulled "10 times" as the discriminator out of the hat, and went with > that. Okay, let's go with that until we have a way to properly expose display tolerance. > > This is useful, if e.g. the target pixel-clock is 65MHz and the sys_clk > is 132MHz. In this case the highest possible pixel-clock lower than the > requested 65MHz is 52.8MHz, which is almost 20% off (and outside the > spec for the panel). The lowest possible pixel-clock higher than 65MHz > is 66MHz, which is a *much* better match, and only 1.5% off. > > Signed-off-by: Peter Rosin > --- > drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c > index 71c9cd90d2ae..0c2717ed4ac6 100644 > --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c > +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c > @@ -116,6 +116,19 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) > div = DIV_ROUND_UP(prate, mode_rate); > if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) > div = ATMEL_HLCDC_CLKDIV_MASK; > + } else { > + int div_low = prate / mode_rate; > + > + if (div_low >= 2 && > + ((prate / div_low - mode_rate) < > + 10 * (mode_rate - prate / div))) > + /* > + * At least 10 times better when > + * using a higher frequency than > + * requested, instead of a lower. > + * So, go with that. > + */ > + div = div_low; > } > > cfg |= ATMEL_HLCDC_CLKDIV(div);