Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp611238ybl; Wed, 8 Jan 2020 02:58:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxO7IxP5g1Fny3Izh8yXNLgEknIHvssAwE+BXUVSmb/EpuH2So6UDdJMEXqoFuBJqyGkxIp X-Received: by 2002:aca:1103:: with SMTP id 3mr2444498oir.70.1578481135299; Wed, 08 Jan 2020 02:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578481135; cv=none; d=google.com; s=arc-20160816; b=bViVZ8euycqAxAOu8K40KK1hawfLdpQDqGUG6QO4P8JP+sntLnSLQTW4GZNMtHtBAq 1ViksXhspEZF8m/1WgesJqdx3FFTYaznmzP7fupbqprtrSc3EzLMRvZKMRP8YN2WOPrb iC8FGZq6/VopKDvdjE+3M175cTg57r0UgG+O196l/p9AIjtVq7akcx/C80w2reZn/CNq lyW6KjIo1l7E4s9mxxPs6WbmycLaoyEiLljwAU19Fg9Dq/u7s8PRtG3QKc48fYougLkY vVsYpi79w9zHJcU3GxhUwLjZkSdwMCaOl/IbcDEgwW85ARL4+Dpg+1SWIXsVVgUoZK9V YR6A== 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; bh=zBf9aBXSMR0v42J4u2/Htf/rmyiM5osMjmY+vzbA3po=; b=M/+vQpZ53xl6Iaud3eBYKGHJI3Kzd013X+RV3F2m9TxGT4CETcUZe4NNJih4eGvvTU v52HFDWc/s9v8upEliuoJo7VTnShGZZPPC6VqqPHIhytNHuRrX4skKVKDcFhTJ1hxns+ dq9dCr+eoaHEgm3z1E9UMF0N5YJaX6L2b/1dzjZbwl31C3oVLlU9jZbxCdLV8S25r4F1 WLFxZmgSI49TJ46rN12GKI3DdWYs4vtWh8XhADo4rGdv6y8N3k3cSVkysduliZGV5IFT crRYaWrz8mjTQzpAjJEX2wNjNXl/C3tSawARRuSkHaUoNyz3z2UX+mF1uSK0SA5nMnjs 87Lw== 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 n139si1619243oig.121.2020.01.08.02.58.42; Wed, 08 Jan 2020 02:58:55 -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 S1727097AbgAHJls (ORCPT + 99 others); Wed, 8 Jan 2020 04:41:48 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8242 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726098AbgAHJls (ORCPT ); Wed, 8 Jan 2020 04:41:48 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4020ED9CD9FD658F6AFA; Wed, 8 Jan 2020 17:41:46 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Wed, 8 Jan 2020 17:41:37 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH v2] drm/hisilicon: Add the mode_valid function Date: Wed, 8 Jan 2020 17:41:41 +0800 Message-ID: <1578476501-45807-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org add mode_valid function, we can make sure the resolution is valid. Signed-off-by: Tian Tao Signed-off-by: Gong junjie Reviewed-by: Thomas Zimmermann --- v2: declare hibmc_crtc_mode_valid as static. Modify the return value of hibmc_crtc_mode_valid . --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c index 843d784..675d629 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c @@ -242,6 +242,24 @@ static void hibmc_crtc_atomic_disable(struct drm_crtc *crtc, hibmc_set_current_gate(priv, reg); } +static enum drm_mode_status hibmc_crtc_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) +{ + int i = 0; + int vrefresh = drm_mode_vrefresh(mode); + + if (vrefresh < 59 || vrefresh > 61) + return MODE_NOCLOCK; + + for (i = 0; i < ARRAY_SIZE(hibmc_pll_table); i++) { + if (hibmc_pll_table[i].hdisplay == mode->hdisplay && + hibmc_pll_table[i].vdisplay == mode->vdisplay) + return MODE_OK; + } + + return MODE_BAD; +} + static unsigned int format_pll_reg(void) { unsigned int pllreg = 0; @@ -510,6 +528,7 @@ static const struct drm_crtc_helper_funcs hibmc_crtc_helper_funcs = { .atomic_flush = hibmc_crtc_atomic_flush, .atomic_enable = hibmc_crtc_atomic_enable, .atomic_disable = hibmc_crtc_atomic_disable, + .mode_valid = hibmc_crtc_mode_valid, }; int hibmc_de_init(struct hibmc_drm_private *priv) -- 2.7.4