Received: by 10.223.176.46 with SMTP id f43csp2313560wra; Thu, 25 Jan 2018 08:03:10 -0800 (PST) X-Google-Smtp-Source: AH8x225ZNSBb5pRI4sbv6PjANCujdrp856hgYkDC4eQyfsoCEBYBXXZeUSJh/bOnpnJ1QJVQKLSM X-Received: by 2002:a17:902:4222:: with SMTP id g31-v6mr11610827pld.203.1516896190228; Thu, 25 Jan 2018 08:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516896190; cv=none; d=google.com; s=arc-20160816; b=A1sIISCKoJeCQ+5ewbPzIkD2twc0G+doZhKawg2C+4aXWj8+SoPe/8nmABiIpgQxBa 5z1XnlWdTh2uPT6rPi3Z+pg1ssgA234/NVUmzPEB1mHHQ9+qNPyBHKK5x+8xry7dByNi HSjRUw/tTnmcFStDFxkrHomAr5rAvZsln4vqCWZpqRSuvYCUStnYeKHgvJRqWnPG8HtJ rsvconbXy+6x2i+GTxoEN7lni7eA5DaewD6CiiRgWz3XjP5OZwI5hcyQ8huOnTO57s2S hnw8j7Z3LLmQJJRYmpTjK2Xig/hxs5SCV5VakzwBHQWD92mz6sd/ItHCbc5LIE851qO4 ODig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=YF9qaqqfdqh5xEU/9Nkgen537jdgKYop2cgQ5d19qmo=; b=cOoa1e8yfH0YnhxYggKaTVFIMdmFNnQJUw0F0orEr7qcGg5QnpO1bE4scbuNYQqiZ1 bEm4/EUUELV7tU5qN3vD/pf8l551C1sh4CeFcDKLUNZyGxndyKgqh7h65wLUNQaR4INx MQ0DxmtzbbLeqoCb2CBs7Wln5UPIimqZ8BxQYPLu3jN0bj7SPIxdzUieDdTqan8rFLHr DFDX9jV7PgAjKLFUlzCt9AKV2XFdBQEDdV9wmxK9OSGQu1Rb26rfsU1WQ/fKc1TTsm/+ 5Pqy32FXua6crVpkX+CqtUXznytQEXH+PbqxjlqdvfexEXDBHvbQ+8PW1lr9b1WQunLK 7mmQ== 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 a138si4777617pfd.161.2018.01.25.08.02.55; Thu, 25 Jan 2018 08:03:10 -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; 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 S1751232AbeAYQBg (ORCPT + 99 others); Thu, 25 Jan 2018 11:01:36 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:44286 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750980AbeAYQBf (ORCPT ); Thu, 25 Jan 2018 11:01:35 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w0PFwgJk014068; Thu, 25 Jan 2018 17:01:14 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2fphsq0wxt-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 25 Jan 2018 17:01:14 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0A40A34; Thu, 25 Jan 2018 16:01:13 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DE5A94F2C; Thu, 25 Jan 2018 16:01:12 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 25 Jan 2018 17:01:12 +0100 Received: from localhost (10.129.7.153) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 25 Jan 2018 17:01:12 +0100 From: Philippe Cornu To: Yannick Fertre , Philippe Cornu , Benjamin Gaignard , Vincent Abriou , David Airlie , , , "Archit Taneja" , Andrzej Hajda , "Laurent Pinchart" CC: Fabien Dessenne , Mickael Reulier , Ludovic Barre , "Alexandre Torgue" , Maxime Coquelin Subject: [PATCH] drm/stm: ltdc: use crtc_mode_fixup to update adjusted_mode clock Date: Thu, 25 Jan 2018 17:01:01 +0100 Message-ID: <20180125160101.9102-1-philippe.cornu@st.com> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.129.7.153] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-25_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). + */ + + 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, -- 2.15.1