Received: by 10.223.176.5 with SMTP id f5csp2711729wra; Mon, 29 Jan 2018 02:44:04 -0800 (PST) X-Google-Smtp-Source: AH8x226EdDlCuvjrUpx4e5ryPcMRgJUnVvA55cMQiP/oegDkH+/gbqiidfI4t2gkJ27i5Hm9EuPC X-Received: by 2002:a17:902:b487:: with SMTP id y7-v6mr964339plr.119.1517222644327; Mon, 29 Jan 2018 02:44:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517222644; cv=none; d=google.com; s=arc-20160816; b=eJdbdIJ5Esqu3hQ/ozQcr+R2GlcdEQa1tFwp0r5u+c6EtcRdshboGkQpbqx6TeOlAp iwR7qXJS8zT2x09BvJBMZfHs8Pq59/XN3PSwM75H+AskRXMSGUg081r/McdnX4vF/RNF nTgWBh8I5CCNbkfkVOXVG938YRy3Jpr3EdYh+UBP/+MrKF01jHx3w//pikF+j197Lwxc f9UJZq7oYmgh0en7e5/5ZYAFAn0y3LeuDGWtKkRm3ItEDznzM3krALZuzBLxoR0I47z3 45VIQfjX1eoNoCBLNpIEFHLr/Oz+8i/nyc2Nqbn0J5yTy7LRidjsUUWIUcyORP0J4Q03 86yw== 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:organization:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=BAmDI9ncLSIGqRCWw2HAZBLOHiKN0LHpoIB2tDbVgrM=; b=NmS/HOgqR3fHUlkcTG8FMY1dFYPOoUFlF5RqIOIiJv/pRpc3tpPiLYOhEXbG1Gsj/9 Yt7xIKvw/oRg4lAwW+ePwFb5OR6Lca1qnl404v2wnQl3REZiqDLpGFsnlNIHbujNlqYD bk+Vj4HMHK2IkUZyuAdQTNQW7jWtq/1iSGS9a5dcOZYgvaDDxOWGa4eJaJjDgs3V1tPH LvVoLg4xOIDAmmoQrqzPZVx1ZvouZjJiwWAZgVGs692Oc23MRBoANH8wddHpdCWJOlbg GW692F5BG3QdnGlvRPlEJEkcwgW9DwlRqlHj5uzWGzQp8fkHdvy8X8bUK8T8l5HO1B8Q zhXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=e7CqwDj+; 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 97-v6si9071252plb.789.2018.01.29.02.43.49; Mon, 29 Jan 2018 02:44:04 -0800 (PST) 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; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=e7CqwDj+; 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 S1751756AbeA2KnS (ORCPT + 99 others); Mon, 29 Jan 2018 05:43:18 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:53757 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbeA2KnR (ORCPT ); Mon, 29 Jan 2018 05:43:17 -0500 Received: from avalon.localnet (unknown [IPv6:2a02:a03f:52fb:2b00:ac86:2f77:64c9:83c0]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 9D000201BD; Mon, 29 Jan 2018 11:42:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1517222527; bh=QcW59jDvXw0gd1hCojAideS2X8T70Bw/JrvKyTStmLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7CqwDj+A75HcPWN0Yz/yjRQTjrlm+xOA1znFZWPI5BgtvGBRJqWYsI85KEx7xd5A 9Onp7lirG1S+7XLKydAgRCYSe9m3D6NVUqI2cnzh9CV2CR6lHpn2HQfKcndBqzt7XP okkLWpi6IMZSQa8bCsli3F01c/46ph/0j9x2Fk4Q= From: Laurent Pinchart To: Philippe Cornu Cc: Yannick Fertre , Benjamin Gaignard , Vincent Abriou , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Archit Taneja , Andrzej Hajda , Fabien Dessenne , Mickael Reulier , Ludovic Barre , Alexandre Torgue , Maxime Coquelin Subject: Re: [PATCH] drm/stm: ltdc: use crtc_mode_fixup to update adjusted_mode clock Date: Mon, 29 Jan 2018 12:43:31 +0200 Message-ID: <1617432.LU6HsMfOQM@avalon> Organization: Ideas on Board Oy In-Reply-To: <20180125160101.9102-1-philippe.cornu@st.com> References: <20180125160101.9102-1-philippe.cornu@st.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Philippe, On Thursday, 25 January 2018 18:01:01 EET Philippe Cornu wrote: > There is a difference between the panel/bridge requested pixel clock > value and the real one due to the hw platform clock preciseness (pll, > dividers...). This patch updates the adjusted_mode clock value with > the real hw clock value so then attached encoder & connector can use > it for precise timing computations. > > Signed-off-by: Philippe Cornu > --- > drivers/gpu/drm/stm/ltdc.c | 35 +++++++++++++++++++++++++---------- > 1 file changed, 25 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c > index b48589343ae1..90b3de516c91 100644 > --- a/drivers/gpu/drm/stm/ltdc.c > +++ b/drivers/gpu/drm/stm/ltdc.c > @@ -428,12 +428,35 @@ static void ltdc_crtc_atomic_disable(struct drm_crtc > *crtc, reg_set(ldev->regs, LTDC_SRCR, SRCR_IMR); > } > > +static bool ltdc_crtc_mode_fixup(struct drm_crtc *crtc, > + const struct drm_display_mode *mode, > + struct drm_display_mode *adjusted_mode) > +{ > + struct ltdc_device *ldev = crtc_to_ltdc(crtc); > + int rate = mode->clock * 1000; > + > + /* > + * TODO clk_round_rate() does not work yet. When ready, it can > + * be used instead of clk_set_rate() then clk_get_rate(). > + */ Why does it fail ? Is it due to the STM clock source implementation ? This looks like a big hack, I'd rather see clk_round_rate() being fixed. > + clk_disable(ldev->pixel_clk); > + if (clk_set_rate(ldev->pixel_clk, rate) < 0) { > + DRM_ERROR("Cannot set rate (%dHz) for pixel clk\n", rate); > + return false; > + } > + clk_enable(ldev->pixel_clk); > + > + adjusted_mode->clock = clk_get_rate(ldev->pixel_clk) / 1000; > + > + return true; > +} > + > static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc) > { > struct ltdc_device *ldev = crtc_to_ltdc(crtc); > struct drm_display_mode *mode = &crtc->state->adjusted_mode; > struct videomode vm; > - int rate = mode->clock * 1000; > u32 hsync, vsync, accum_hbp, accum_vbp, accum_act_w, accum_act_h; > u32 total_width, total_height; > u32 val; > @@ -456,15 +479,6 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc > *crtc) total_width = accum_act_w + vm.hfront_porch; > total_height = accum_act_h + vm.vfront_porch; > > - clk_disable(ldev->pixel_clk); > - > - if (clk_set_rate(ldev->pixel_clk, rate) < 0) { > - DRM_ERROR("Cannot set rate (%dHz) for pixel clk\n", rate); > - return; > - } > - > - clk_enable(ldev->pixel_clk); > - > /* Configures the HS, VS, DE and PC polarities. Default Active Low */ > val = 0; > > @@ -528,6 +542,7 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc > *crtc, } > > static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = { > + .mode_fixup = ltdc_crtc_mode_fixup, > .mode_set_nofb = ltdc_crtc_mode_set_nofb, > .atomic_flush = ltdc_crtc_atomic_flush, > .atomic_enable = ltdc_crtc_atomic_enable, -- Regards, Laurent Pinchart