From patchwork Fri Aug 24 09:24:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10575459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EC821390 for ; Fri, 24 Aug 2018 15:07:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E20E28700 for ; Fri, 24 Aug 2018 15:07:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5259428757; Fri, 24 Aug 2018 15:07:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ECF1028700 for ; Fri, 24 Aug 2018 15:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dKlivSf4W+LPSJMwTnsM2i9TJ++fIBtv26rsXzp6PRE=; b=LDk+IsY+a6VUXJ J2hdQSk5krxrADFg500Wj6Z0x0QCZDADLg4qrJM9fVxIL0AmPUB2DLlr4dve6rU1x5kNPzK4yApcU NyoF8XnxoBsvNlMOfDGv/6oCJH6uJl33efDa76gvi+eOE6243nsuhnNe5I155Ufe/rfnhy5Rvpy7V 5ECwAbtqY0jjJ1cM/JavFyPOuTqwqmwvGlyTliwH+3fFA1RGSHJYmDJF7EzxSpzvBxXD5AJNWJcOn n+sKlgz7utivKJSQ1+583bFMBx0YF3zqYpofiByGz3KLKxW912uWA7ziOt3hpJL7Xl9RtBp4guBEZ +cnee5caTDzZH+V0S4gA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ftDg0-0004vZ-MA; Fri, 24 Aug 2018 15:07:04 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ftBfq-0005du-1B for linux-arm-kernel@bombadil.infradead.org; Fri, 24 Aug 2018 12:58:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=K8hS4ozfObn57mO4EE31ECCcilWxS2L3Olh+dJpLtBY=; b=wOu/UA6L0KciE07HZExhEMDyS Vu2NKNv76tsc/UNFHMmYrtABofShlJhUeAzDb6VzI5BSJeSGLgP3iVGZTi8qrikcK/l1Jz/0QndXA +ynqtsGbK/2NIz1rUm90voJ+BPUDXPpYju/c3ElkZNXiEBDwF9wC5i5j98mqkH75m62VGHzzG0y80 ji/cPxjIAPQup9v0jgum+jUwWkaD8rw/B/ngrAG7yktP+UUFl54zLJB2OUkbxTgZv3RUq5FW5ee68 E2RZ8L9TTY9pTV90Dc9HVrCSnSG0ktBSInv53eAOwPL9XwAD6wVNiEVde5fKpGV+AsHbyp/OfRZyR iMs2PDSDw==; Received: from mail-he1eur01on0714.outbound.protection.outlook.com ([2a01:111:f400:fe1e::714] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ft9pw-0000Qa-7Q for linux-arm-kernel@lists.infradead.org; Fri, 24 Aug 2018 11:01:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K8hS4ozfObn57mO4EE31ECCcilWxS2L3Olh+dJpLtBY=; b=sxSTw73tyNqCYu1CW3hBxLeoYYB8lkEmYtJGaYXSvRyzK48JTXiJKkHIsMs75b9670eWW/+cJNmENldDOy34kE8Rb1wh25f8IjQCR3zcOhrL64YcAbL64cv2DMbOtCG8N5EGK9rgDMY8QGJpZxnjcK/o4te40FWQxUDl6rhgcp0= Received: from orc.pedanet (85.226.244.23) by HE1PR0201MB2458.eurprd02.prod.outlook.com (2603:10a6:3:81::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.22; Fri, 24 Aug 2018 09:25:16 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] drm/atmel-hlcdc: prefer a higher rate clock as pixel-clock base Date: Fri, 24 Aug 2018 11:24:57 +0200 Message-Id: <20180824092458.13165-2-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180824092458.13165-1-peda@axentia.se> References: <20180824092458.13165-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: VI1PR0701CA0045.eurprd07.prod.outlook.com (2603:10a6:800:90::31) To HE1PR0201MB2458.eurprd02.prod.outlook.com (2603:10a6:3:81::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bfeafc91-ef5d-48fd-d88d-08d609a38186 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989137)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:HE1PR0201MB2458; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0201MB2458; 3:l7d/0elew4uc2INTLHL07jNsdbBDZWU36p8jNYt3Gex9CG+BarQeP5txq81aEnxHDBvaTRt/fMVzB5S8eSbs7oB6kwhoKXFRjKgjFi/zF6xeDkOQfHtGJXMx/0QIrO+XLZujJ0jwDmUkKUy1TvvGWLkTfk7P9jY63xAnGQc0PedhiTQAgpKYwaCPmp2ykmBLk+a6q/j5rQOlcqqj5drXxr+5+4N96eSk7ydIq4p88T1vRajqBNQNo1Yc0V0OsAnk; 25:dN3F8QCi4w2vq7EyJc2/BVFvJsS/vm/4WJUPcvcJZj/oUINJmLyKHI4IevELwE5BPLSdGAjrPPXDv4ZVsfbkaLzc+A2Un3jQ3ZgDa1rG3D3zHLD7ve44jzBGxUlUTenPRVgOhxX3MPr604VlGE9jSzHiqXFk6Lq0/JdWRL+7sQpfYSEGipQpdWQZBjJR84BVsE4lmOI4UfoUTaOBJ/BtmT5LeVZb6waylSt3NekmCsIZ6BGTgEwpCGPwAbthDUAia/dzfmKZGOg5jHvaXlmFWJU1UDPL11ipNMlqBT6ENm0FqU1Zol0PfTNK/gB1GUmDKBh3uiNLRfuF8uOBQjSYkA==; 31:6kfW7J/5HB5J/3ALX/d05kceRGiWPcZkQmCNtu2HwnEEAhR9Vx9ifjCszg1EoebHydsukEb82x+B3t/6oFSfnSCcFFacQrWodbU/csD65LMJXV722U0ycwhpoMFJVUfMWAUHmNIHmqFKS8DYBAno+DdMO2VuHLB/2yoWG1X6u4wB6ZbYicU1+1LYf+ybQKQsLyWhXBd+x2pEq9dr014kfSy1rs/hBYj3QuhA5s0HdNw= X-MS-TrafficTypeDiagnostic: HE1PR0201MB2458: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(823301075)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123560045)(2016111802025)(20161123564045)(20161123562045)(20161123558120)(6043046)(201708071742011)(7699016); SRVR:HE1PR0201MB2458; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0201MB2458; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0201MB2458; 4:759pihfiMtBZh43kDYaZi3qbrxcqA6CGj85pniEq2AQBTLlku0n0UtMRdOtS57yhcveByoS/FeNMLPvlcEo3OI5bUejKs/6crAFDmQmMMByoM57jz5xgn39BEF18tVqkB0/IpEXSmXtWa8QKbqe+OHtYMK3jB28kYpN2gMPMd7YjAzCtn248/XfjkZcRDmbImN7YN7cYgYtgTwA/189gWdwoeb6TobKNmKfvWMFwO51dMruxsTX7CG8lhpX/1TOUXyV2Shc2nJkzKB6e0veOgw== X-Forefront-PRVS: 07749F8C42 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(39830400003)(396003)(136003)(366004)(346002)(189003)(199004)(386003)(16526019)(186003)(1076002)(316002)(956004)(2616005)(25786009)(52116002)(476003)(51416003)(36756003)(26005)(6346003)(446003)(6506007)(6916009)(11346002)(6666003)(8936002)(4326008)(50226002)(76176011)(54906003)(16586007)(68736007)(3846002)(2361001)(6116002)(5660300001)(86362001)(6512007)(6486002)(105586002)(53936002)(106356001)(48376002)(74482002)(2351001)(50466002)(81166006)(7736002)(47776003)(66066001)(8676002)(2906002)(81156014)(478600001)(486006)(97736004)(305945005)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0201MB2458; H:orc.pedanet; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0201MB2458; 23:xRGWuQwO/4VefB3+SXe0U4JAW+Mu5LTUmE5Nc2U?= 0Biv2nXS6SD7YwrcLWtGZzWL45oztE6LljEWTIBXAeA98B2zhoa+NvQgWZHkXPGk578jHBnHZsSv9ozhtgmFljGLGOpMZDXZC52Ad0f5YOWxh3SAE4FWxjYrC0TR+f5ImY01LgtOzi4ZMV3bgbhv4OdV+ElQV5fjL+a6tmuUE+YNMWVcSZf6Iia36vt7zz0uDofF0DYoEUQtgJ/ICHUqfluPQ5n3uuDESUnsqo8rkt1c2Auyc9E9ng5eyMzYg0DCFx+kXUyMl7/UvTM7PBMV9FKubpOID/kNMisSw7QfnYDMdOmwYAhV8CcV9/QO/I/SKU0ulIAlOwuYMQSWs3tT2ZU3g6ZD8SwbYAA0wSFvMeO4zhj0KYXAGmrSSfgD9Oz3HrpihI0hsPey54HEKBWbIsxquq5MACO64SPH0J85ymj5lDP42F/PR9UqI7riyFswrsPNKn16I9ptIf2f17/A5PrbPPg7kEuRx4cqajN6ZdGGRonPxtlYlNfpRFq0/NEd1HOyatfW563TOCoybTYi/PGULI7gvJcjeVz/0jAB7fzVPKn7rhUjnDTxfQIJ3AoOxTNuoOyjiaEDafloC3tro0D/n5p561HA5fq7zbXBOPsRfFDEN7rilVw71VEmkx7CkyXQmUziv0y5YSFLDbkJxRvMt6MR5ja5r5obXJkaOcC5lGrp2yKbPDXUCj9DqAFHnANjmthtqWyi/GS7NkgprqX3ZNDhoX9EOneKvrWfdJu4vmpn6o1ZdczZD5lMjjQ1/leT/VFqgW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8Bl/AY7t3AWwZ20gPG8eFigAXBKOiiufEq6EvBpv0QdGztt4hpjvKutkZ++dZdGpGigTDnW3XrOjcN8J/SOQqUMtN0cy2lQ7tAaiWt8sC3x2bzHm/X15iTU5LI5bFFTYC2cZOl5gvQ154ZBds7G5IBqrOqvduWyBBu/AqnhJWAyw+784QgkP2FCItAB7OSh6ULnXgILMj1khCmKqcMg2cCMkXGM0EmKN9xpsWz2GGfoeec2d0ByFFwQHJmYmvcjksTUnp/nhsc4hu64tb68+YDBJ/uMIVoZTTnmmZtRIME2JiyExWL6wlxQnpTuMkxHPFG/A==; 5:mWEZUIci6EUI+gPU7LU8J8gPeWlx/AHzU48lKVvMptjoK7cdOK3ps9MTg9HTKq0VMYPI1pcxx0T8UrjLorcRTyAENtDzU6mwVYbhRrMJoddT2sY0DekkA0OKSX3a79dF84zGNEOEIh/n9BbuW0rzdXniay0Vyp9U+l3xbyO0C4E=; 7:bbBm5J5WOHDlNK4dSHwU331cbgZQTpTZc2CIxHpGsAEzJjqGI59pjmh1mHlxTCBhJtcYNoK0dSe5FjXHiUJE0Bcu7pNMwrACokMkgRxLLOA4ziDJVpYJq5SDxtFfebST2zwk4v2AAUeRdR5ve9HqVbUEVxPEUGKzeq7Bc4/m6Ffd2lHne7M1lN9SJgLWT00Qny6QQqZv5yhKz7856ddNzLG3wOMWer3XJ4xmmgnU2+qPIThpaWs5hXPCBvWbg8NO SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2018 09:25:16.8934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bfeafc91-ef5d-48fd-d88d-08d609a38186 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0201MB2458 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180824_070105_189756_FA02268E X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , David Airlie , dri-devel@lists.freedesktop.org, Boris Brezillon , Peter Rosin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the divider used to get the pixel-clock is small, the granularity of the frequencies possible for the pixel-clock is quite coarse. E.g. requesting a pixel-clock of 65MHz with a sys_clk of 132MHz results in the divider being set to 3 ending up with 44MHz. By preferring the doubled sys_clk as base, the divider instead ends up as 5 yielding a pixel-clock of 52.8Mhz, which is a definite improvement. While at it, clamp the divider so that it does not overflow in case it gets big. Signed-off-by: Peter Rosin --- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c index c38a479ada98..0d9d1042752a 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c @@ -101,18 +101,22 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) (adj->crtc_hdisplay - 1) | ((adj->crtc_vdisplay - 1) << 16)); - cfg = 0; + cfg = ATMEL_HLCDC_CLKSEL; - prate = clk_get_rate(crtc->dc->hlcdc->sys_clk); + prate = 2 * clk_get_rate(crtc->dc->hlcdc->sys_clk); mode_rate = adj->crtc_clock * 1000; - if ((prate / 2) < mode_rate) { - prate *= 2; - cfg |= ATMEL_HLCDC_CLKSEL; - } div = DIV_ROUND_UP(prate, mode_rate); - if (div < 2) + if (div < 2) { div = 2; + } else if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) { + /* The divider ended up too big, try a lower base rate. */ + cfg &= ~ATMEL_HLCDC_CLKSEL; + prate /= 2; + div = DIV_ROUND_UP(prate, mode_rate); + if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) + div = ATMEL_HLCDC_CLKDIV_MASK; + } cfg |= ATMEL_HLCDC_CLKDIV(div); From patchwork Fri Aug 24 09:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10575399 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C25551390 for ; Fri, 24 Aug 2018 14:49:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE5E02C6E3 for ; Fri, 24 Aug 2018 14:49:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EE992C767; Fri, 24 Aug 2018 14:49:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DD3B2C6E3 for ; Fri, 24 Aug 2018 14:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vgs6wDJsMYg36zr+zl1x6iT02Fvn50i8SWtjIClFMto=; b=emjvXHicukJ9c+ 3DCDsMXOIx2fNPgj4g+WKJ5YMdt0rq2Jc5wj9LnIMQ+gjduCqyZ10+DI5uXK6JNN6WrT9g6hv3x+q prsqqogxNOrPLCNseY0UdbhFapjFNQT82nOrPqdWfASo8s8yDRgQn9ALDImVSOM8d6/S5SQOFjgCg uy2baNaO2VnP/Atlgu5QXX/w2VTuD/TxMzeEiPtqBWDj78gFNnYK2RqlzWkjnBm7q8AmZg/UImsut 0/bLW+M3NpJJcNvumdtwUdZsR3ieNosan67djBFuiQoiwxZ4NvchyM0gpnwM6DCTalM3aGpvt8BqZ DzkDOQVqbAKShQJVGZeg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ftDPE-00060q-2F; Fri, 24 Aug 2018 14:49:44 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ft8Pc-0006eL-3L for linux-arm-kernel@bombadil.infradead.org; Fri, 24 Aug 2018 09:30:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IzB0uGcWewxXUwe+pV77qiFhTDKg8BRxuxM8UkcczeY=; b=ZChUkGs9GgDx5KlDnKYcqzWiI lOyoFqj+MyTr2wKI4LNCtmSDgIP4QfAbPLeXeBaFI2CejyAkN2r4osv61milI+C9hWzzMDdk1tc9h 9MetDhVVY4FNxG+xv93Y0g/embuDE+wqTkIZw/u7wKdSmRNpjc/k5KmmdVNZN4KhQ+P6orM0ltv5Y lWHF0ai6Zy8bcFl+qy0dO/BWW7Sld+oxvAfG8Xv6QIwczgZGfgbOsw+UU/VWQ5PG/xXLfGsk3fmYZ SlHrdQ4LaKyX2aDfCNGBiNEy5YIbpx34o5SgH6lm3BsIqKx1Nfw9w822el/V6200flBcTsPZEQaAo VjtW7ijlw==; Received: from mail-db5eur01on0092.outbound.protection.outlook.com ([104.47.2.92] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ft8MV-0005zH-Gk for linux-arm-kernel@lists.infradead.org; Fri, 24 Aug 2018 09:26:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IzB0uGcWewxXUwe+pV77qiFhTDKg8BRxuxM8UkcczeY=; b=UMUB4yQVFSU2f+fgfrovi9dn13+5YFdhAyU6sWhydbIzTGUpR6iyNS38Bifg7+y9R6JRpixafrwEVXeLBcmS57zkWGtA3Ui0OcyaD0X+f6LOR/mvMaNROxibKZxE0V9BUzM0q5XXhabu1+722bABnUPVFwX5zb45X92CmeuVPjQ= Received: from orc.pedanet (85.226.244.23) by HE1PR0201MB2458.eurprd02.prod.outlook.com (2603:10a6:3:81::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.22; Fri, 24 Aug 2018 09:25:23 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] drm/atmel-hlcdc: allow selecting a higher pixel-clock than requested Date: Fri, 24 Aug 2018 11:24:58 +0200 Message-Id: <20180824092458.13165-3-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180824092458.13165-1-peda@axentia.se> References: <20180824092458.13165-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: VI1PR0701CA0045.eurprd07.prod.outlook.com (2603:10a6:800:90::31) To HE1PR0201MB2458.eurprd02.prod.outlook.com (2603:10a6:3:81::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15dbae05-a1b2-4fb2-6121-08d609a3854d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989137)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:HE1PR0201MB2458; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0201MB2458; 3:fwEMpswvuf4sb8BbjZc9baCb6th49Z3NijxZzZai7X7Sv5CCSCVTX6AC3PMGQilQW237VH4SXlSqltzT2J0V4/V1G4noNJA4P28fECUHmX1jPyuPEe1lhZX7dJuyNSAEk8YHEpbTTW+2xziUC0XmQdDPEKxaTGjovoh67K2CyHmbhkIwUY9i7iWlc/O0XZ2ey+DJZjW3FWWfGlSaDE5gqUBiSLHTbHcQ5qVgzqrna9RZVY35SwqUxMkhkkoCILpv; 25:/MyKvfxQBFvzPmV1ISw/k3OVDH3QoUVKwyzus/dGUUEfD/A5Vg+KvN8BJYTO3WNyGkusWlGE0taRqK7tgvvZQaT0UqY7JWPKuppPpGi0+z7+n2TMRp+QqLqEqz1Eiuu4dHx2gFp+OdVoMWvFC58e8Jr3YP8tFsNyLFUGW0eMBCWwu5r/1KdsVFvfUFTc8/67R/2HyA2kaUYDB16RnvUnrG4HpF5jm7JhN7cQWx4KGs9pss4GsQ+xVQzYcVVQFsAzyB7RHBzQkmlhyzjIV/ixm8n4D/0rU8qWQ4cG2YPQmr9lXGw1jfLvM69X6EsmGEFH8CECNHvttukG1Da0GUwfww==; 31:K0oB5sx6ZTHsDv6vuINISp7Xf1rIzk6siQ3sZ8j1Z7uPAU1ayKbYIaF3YpZSfSccmVt8Nr4mt4dH4upjHtETeV1Xl44OTwSlRviA/kRsZbCVcaTeeSFvYxMo26n7A/L7ZuQPX/lQBQPdNZJFYCsz/n1riKu8npQHt0YRWJm6QnMmzaPca4G/9S33nV6TeMwej4QnXUQ+X6Og2aU4qULTSfAMK0M/GhqHqxbTk1oK7To= X-MS-TrafficTypeDiagnostic: HE1PR0201MB2458: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(823301075)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123560045)(2016111802025)(20161123564045)(20161123562045)(20161123558120)(6043046)(201708071742011)(7699016); SRVR:HE1PR0201MB2458; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0201MB2458; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0201MB2458; 4:n08GLvLaF2eNwc7s9oMcpTwsUR+h+SuNuaxo3txTtVtsYcA3Tga66nU50+1OTA1FJfF+pw2ZOFKTPq89F4efWrlWsI0bn6UMs+OLCoJk32eQUrbrVUJa6dJxCLVxqeQYZn4rxvoUXJDa4IkmetGIoWoNwqEy3PVzhYmF7XNvR+2HetshFwoXT1/9fuouKazVov6dZdKlP0r/7hHKMAONCzaN7MtKwzM4Slfn32NTBYJAho+5qmupvCpR13stg1S91Vrn4fdymZ0jWhOOhcHl+g== X-Forefront-PRVS: 07749F8C42 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(39830400003)(396003)(136003)(366004)(346002)(189003)(199004)(386003)(16526019)(186003)(1076002)(316002)(956004)(2616005)(25786009)(52116002)(476003)(51416003)(36756003)(26005)(6346003)(446003)(6506007)(6916009)(11346002)(6666003)(8936002)(4326008)(50226002)(76176011)(54906003)(16586007)(68736007)(3846002)(2361001)(6116002)(5660300001)(86362001)(6512007)(6486002)(105586002)(53936002)(106356001)(48376002)(74482002)(2351001)(50466002)(81166006)(7736002)(47776003)(66066001)(8676002)(2906002)(81156014)(478600001)(486006)(97736004)(305945005)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0201MB2458; H:orc.pedanet; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0201MB2458; 23:5cl+bJ708bUwTAIA5dXXSjLYaNNSNZW0aafmZYl?= xflfyY6TauRYmtOe6Ke/OyZKc1n8gay1pGHkAlNrC72X1jAsSZPGGBvCoY+tJIA9TZiha15N1SaGpbb8w6WQo/h7FKf8uhlo+8EHHh3k2KBrvYOWWazku0KTlQiWpKc5vKB5PHwjAPaQj+NWrbB4VuaO2w2AhZwcHOEogKrNRevEN16YWCUkngFRNvwq/oaSQtheUnF51wnzgQkX1t4RtXZuCqmWmibrVTXWK23HKsz3n+77npDORYSWZbteJUfiHqIW/tuXqXlcfS3un5LwvJBff73TtRXW6XtX2KFQOUxwAIET4tZBuKOtcI9NNAr8/ly7zJl9xSSGSEqWK+GqgKk6bvn+yEP08FY90RiRKw1cZHTo1M5GHUHKLhJVHxNWDITb1a2bvt7EpbtTM1Af3oNhswcll76g8TJWJN7taBAzmHqF6zk0DIRth96K97BrjVuD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pMY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2018 09:25:23.2327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15dbae05-a1b2-4fb2-6121-08d609a3854d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0201MB2458 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180824_102635_576341_04DFF5DE X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , David Airlie , dri-devel@lists.freedesktop.org, Boris Brezillon , Peter Rosin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP But only if the highest pixel-clock frequency lower than requested is significantly less accurate than the lowest frequency higher than requested. I pulled "10 times" as the discriminator out of the hat, and went with that. 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c index 0d9d1042752a..9e34bce089d0 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c @@ -116,6 +116,18 @@ 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);