From patchwork Thu Mar 2 17:27:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 9601913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C210260453 for ; Fri, 3 Mar 2017 01:52:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B364D285A1 for ; Fri, 3 Mar 2017 01:52:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A811D285CC; Fri, 3 Mar 2017 01:52:52 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3A055285A1 for ; Fri, 3 Mar 2017 01:52:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F7D16EC9F; Fri, 3 Mar 2017 01:51:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 528 seconds by postgrey-1.35 at gabe; Thu, 02 Mar 2017 17:36:54 UTC Received: from smtprelay.synopsys.com (smtprelay4.synopsys.com [198.182.47.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id CDDB76E212 for ; Thu, 2 Mar 2017 17:36:54 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 3A3EB24E1ED2; Thu, 2 Mar 2017 09:28:04 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id C6944649; Thu, 2 Mar 2017 09:28:04 -0800 (PST) Received: from abrodkin-7440l.internal.synopsys.com (unknown [10.121.8.102]) by mailhost.synopsys.com (Postfix) with ESMTP id AB2725D9; Thu, 2 Mar 2017 09:28:01 -0800 (PST) From: Alexey Brodkin To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/arcpgu: use .mode_fixup instead of .atomic_check Date: Thu, 2 Mar 2017 20:27:54 +0300 Message-Id: <1488475674-6694-1-git-send-email-abrodkin@synopsys.com> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Fri, 03 Mar 2017 01:51:38 +0000 Cc: Jose Abreu , Daniel Vetter , Alexey Brodkin , linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since we cannot always generate exactly requested pixel clock there's not much sense in checking requested_clock == clk_round_rate(). In that case for quite some modes we'll be getting -EINVAL and no video output at all. But given there's some tolerance to real pixel clock in TVs/monitors we may still give it a try with the clock as close to requested one as PLL on the board may generate. So we just do a fixup to what current board may provide. Signed-off-by: Alexey Brodkin Cc: Daniel Vetter Cc: David Airlie Cc: Jose Abreu --- drivers/gpu/drm/arc/arcpgu_crtc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c index ad9a95916f1f..3f2823c1efc3 100644 --- a/drivers/gpu/drm/arc/arcpgu_crtc.c +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c @@ -129,18 +129,16 @@ static void arc_pgu_crtc_disable(struct drm_crtc *crtc) ~ARCPGU_CTRL_ENABLE_MASK); } -static int arc_pgu_crtc_atomic_check(struct drm_crtc *crtc, - struct drm_crtc_state *state) +static bool arc_pgu_crtc_mode_fixup(struct drm_crtc *crtc, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) { struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc); - struct drm_display_mode *mode = &state->adjusted_mode; - long rate, clk_rate = mode->clock * 1000; - rate = clk_round_rate(arcpgu->clk, clk_rate); - if (rate != clk_rate) - return -EINVAL; + adjusted_mode->clock = + clk_round_rate(arcpgu->clk, mode->clock * 1000) / 1000; - return 0; + return true; } static void arc_pgu_crtc_atomic_begin(struct drm_crtc *crtc, @@ -165,8 +163,8 @@ static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = { .disable = arc_pgu_crtc_disable, .prepare = arc_pgu_crtc_disable, .commit = arc_pgu_crtc_enable, - .atomic_check = arc_pgu_crtc_atomic_check, .atomic_begin = arc_pgu_crtc_atomic_begin, + .mode_fixup = arc_pgu_crtc_mode_fixup, }; static void arc_pgu_plane_atomic_update(struct drm_plane *plane,