Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbdHPGtp (ORCPT ); Wed, 16 Aug 2017 02:49:45 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:19668 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750904AbdHPGtn (ORCPT ); Wed, 16 Aug 2017 02:49:43 -0400 X-AuditID: cbfec7f5-f79d06d0000031c7-70-5993eb034035 Subject: Re: [PATCH v6 2/5] drm/vc4: Avoid using vrefresh==0 mode in DSI htotal math. To: Eric Anholt , dri-devel@lists.freedesktop.org, Archit Taneja , Laurent Pinchart , Thierry Reding Cc: linux-kernel@vger.kernel.org From: Andrzej Hajda Message-id: Date: Wed, 16 Aug 2017 08:49:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-version: 1.0 In-reply-to: <20170815234722.20700-2-eric@anholt.net> Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit Content-language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJKsWRmVeSWpSXmKPExsWy7djPc7rMrydHGrxeZmbR1PGW1eLK1/ds FgcaLzNadE5cwm5xedccNoufu+axOLB5NL0/xuZxua+XyWPnrLvsHrM7ZrJ63O8+zuTxeZNc AFsUl01Kak5mWWqRvl0CV8b6V9NYCubxVDTdecbSwNjH1cXIwSEhYCKxsSW0i5ETyBSTuHBv PVsXIxeHkMBSRokTV1YxQTifGSVmrpzABtPw8kYWRHwZo8SaT6uYIZxnjBI3H99nBBklLBAu cf9aA9goEYGLjBITb05kB0kwCyhI/Lq3iRXEZhPQlPi7+SYbiM0rYCfx++VfsDiLgKrEzvkr mUBsUYEIiW3fZ0DVCEr8mHyPBcTmFDCVaHwznwlipqbEiy+TWCBseYnNa94yQ9jiEs2tN1lA jpAQ2MYucf10IwvEC7ISmw4wQ/zsInHgYQOULSzx6vgWdghbRqKz4yAT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+Ye YpTgYFYS4V0dCxTiTUmsrEotyo8vKs1JLT7EaAr02kRmKdHkfGCSyCuJNzQxNLc0NDK2sDA3 MlIS51W/3BQpJJCeWJKanZpakFoE08fEwSnVwJgr7/bAVOnPgeks7IEsi3dt+f/6nMVu2Qrf KJUpPefKco8Kr3/KkMz59a7LdxHpowW1R7JUPTqaPW22L5U5ob6yZQ5LmMqe4yE859h2XDvg WpnwwVFahyfL8XX1X6V5i9cozzQ+WOjufuStaWFY5zam9N3dq2utvl9X9dKzdK406/VaeD4w SImlOCPRUIu5qDgRAKt7eLraAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170816064939eucas1p16f339a43985324470236d2300548e486 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRvsgrw=?= =?UTF-8?B?7ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRtTYW1z?= =?UTF-8?B?dW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170815235303epcas1p46481292cb50938c4236978a67127e923 X-RootMTR: 20170815235303epcas1p46481292cb50938c4236978a67127e923 References: <20170815234722.20700-1-eric@anholt.net> <20170815234722.20700-2-eric@anholt.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1522 Lines: 42 On 16.08.2017 01:47, Eric Anholt wrote: > The incoming mode might have a missing vrefresh field if it came from > drmModeSetCrtc(), which the kernel is supposed to calculate using > drm_mode_vrefresh(). We could either use that or the adjusted_mode's > original vrefresh value. > > However, we can maintain a more exact vrefresh value (not just the > integer approximation), by scaling by the ratio of our clocks. > > v2: Use math suggested by Andrzej Hajda instead. > v3: Simplify math now that adjusted_mode->clock isn't padded. > > Signed-off-by: Eric Anholt > --- > drivers/gpu/drm/vc4/vc4_dsi.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c > index eb787eed8abe..2516cd3a1d87 100644 > --- a/drivers/gpu/drm/vc4/vc4_dsi.c > +++ b/drivers/gpu/drm/vc4/vc4_dsi.c > @@ -862,7 +862,8 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, > adjusted_mode->clock = pixel_clock_hz / 1000; > > /* Given the new pixel clock, adjust HFP to keep vrefresh the same. */ > - adjusted_mode->htotal = pixel_clock_hz / (mode->vrefresh * mode->vtotal); > + adjusted_mode->htotal = (adjusted_mode->clock * mode->htotal / > + mode->clock); Parentheses can be removed. Beside this: Reviewed-by: Andrzej Hajda -- Regards Andrzej > adjusted_mode->hsync_end += adjusted_mode->htotal - mode->htotal; > adjusted_mode->hsync_start += adjusted_mode->htotal - mode->htotal; >