From patchwork Sun Feb 5 07:36:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yao mark X-Patchwork-Id: 9555931 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 C5480602B1 for ; Sun, 5 Feb 2017 07:37:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B38EB26D08 for ; Sun, 5 Feb 2017 07:37:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A60F5272F9; Sun, 5 Feb 2017 07:37:03 +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 43C7426E81 for ; Sun, 5 Feb 2017 07:36:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD9A16E1F9; Sun, 5 Feb 2017 07:36:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.134]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D4966E1F9 for ; Sun, 5 Feb 2017 07:36:55 +0000 (UTC) Received: from mark.yao?rock-chips.com (unknown [192.168.167.175]) by regular1.263xmail.com (Postfix) with ESMTP id 72C339127; Sun, 5 Feb 2017 15:36:48 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from yaozq-pc.lan (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id D7A6B38A; Sun, 5 Feb 2017 15:36:48 +0800 (CST) X-RL-SENDER: mark.yao@rock-chips.com X-FST-TO: airlied@linux.ie X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: mark.yao@rock-chips.com X-UNIQUE-TAG: <3583b2ab4d4aa23d50a5ad339fcad463> X-ATTACHMENT-NUM: 0 X-SENDER: yzq@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 212577RH37F; Sun, 05 Feb 2017 15:36:49 +0800 (CST) From: Mark Yao To: David Airlie , Heiko Stuebner , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drm/rockchip: dw_hdmi: check display mode with crtc mode valid Date: Sun, 5 Feb 2017 15:36:37 +0800 Message-Id: <1486280197-1585-2-git-send-email-mark.yao@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486280197-1585-1-git-send-email-mark.yao@rock-chips.com> References: <1486280197-1585-1-git-send-email-mark.yao@rock-chips.com> 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 Signed-off-by: Mark Yao --- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 47 +++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index a6d4a02..64408bc 100644 --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c @@ -158,18 +158,59 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi) struct drm_display_mode *mode) { const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg; + struct drm_device *dev = connector->dev; + struct drm_encoder *encoder = connector->encoder; + struct rockchip_drm_private *priv = dev->dev_private; int pclk = mode->clock * 1000; - bool valid = false; + enum drm_mode_status status = MODE_BAD; + struct drm_crtc *crtc; int i; for (i = 0; mpll_cfg[i].mpixelclock != (~0UL); i++) { if (pclk == mpll_cfg[i].mpixelclock) { - valid = true; + status = MODE_OK; break; } } - return (valid) ? MODE_OK : MODE_BAD; + + if (status != MODE_OK) + return status; + + if (!encoder) { + const struct drm_connector_helper_funcs *funcs; + + funcs = connector->helper_private; + if (funcs->atomic_best_encoder) + encoder = funcs->atomic_best_encoder(connector, + connector->state); + else + encoder = funcs->best_encoder(connector); + } + + if (!encoder || !encoder->possible_crtcs) + return MODE_BAD; + /* + * ensure all drm display mode can work, if someone want support more + * resolutions, please limit the possible_crtc, only connect to + * needed crtc. + */ + drm_for_each_crtc(crtc, connector->dev) { + int pipe = drm_crtc_index(crtc); + const struct rockchip_crtc_funcs *funcs = + priv->crtc_funcs[pipe]; + + if (!(encoder->possible_crtcs & drm_crtc_mask(crtc))) + continue; + if (!funcs || !funcs->mode_valid) + continue; + + status = funcs->mode_valid(crtc, mode); + if (status != MODE_OK) + return status; + } + + return status; } static const struct drm_encoder_funcs dw_hdmi_rockchip_encoder_funcs = {