Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp586990ybl; Wed, 8 Jan 2020 02:30:07 -0800 (PST) X-Google-Smtp-Source: APXvYqyRaJkAN1iavZMdm3XK98WNwoP6Dr1zSWMOcGefzIOk9dniiVGmb13XmjWO+7zD8ttpt0kr X-Received: by 2002:a9d:674f:: with SMTP id w15mr3633984otm.243.1578479407002; Wed, 08 Jan 2020 02:30:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578479406; cv=none; d=google.com; s=arc-20160816; b=Ka8LjNEYYkpNizKJmhV4M9Vsa2NZ/aMKr+WMIyYEnkxZSn9iBEBAl3MIdiTxauzqN2 xe6+E9V00olLqznqPUfZfmswWhS8nKy7Qr954qPsuiTWeM7DbTkqcJauYhBTYPWPYtpT apO4jo1LaaZOWX6zYBuaSO4BWEYZichbiLzIe2NCw4rnyyVLzN2bhL11ATcCgaFcphqm TUNaw6pcOC48tzOKLE99dBYw2uVKpw0XGg/yJqKb4t8MQpf9ziZ4kqBSaWGz1RggUZv4 aYk+6MnbZ4h/xtkvjqtgUGB1p1WVY7LOA9JiLXAirmo9KEep+HwJyotSLvDCfbhSbVL2 qLeA== 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=3bH4IOfN8GtuBAieIEFiAR+M5hlWjAro21iEQ0dkJfg=; b=FROjtUSpxA+5RWDQM4aeIWoEE6x4Cf+eZiLthY452ea+8cA0bvbAdUTBUg5bRhAMLc JzwOCraV9cWf3j70j/sgZm0ZvmNHda/5B5RJZ/JjrHvf//WU7/fjbAirDJDfxP1/Y4Hb FI3nDiFEMXnH+c/W3yKsu9tcQaW460j5ZuGjsbpnboXxLXMb6PB+Yy3o9QR9N59y/Hb4 1xbpHM5V6XDCwFZMiKZiYe8dqpzlvuNFm7IaCXX95MRnf/USsuVB36w4MeISAlawCN44 +BNAtoVlRwIg8KJR0M14RhEGn9iLfzqy87OdlL19fiQcF/AJpah8LwQ582VvEQWqumE/ 9gIA== 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 x20si1614069otq.222.2020.01.08.02.29.54; Wed, 08 Jan 2020 02:30:06 -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 S1727035AbgAHITG (ORCPT + 99 others); Wed, 8 Jan 2020 03:19:06 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:51934 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726492AbgAHITG (ORCPT ); Wed, 8 Jan 2020 03:19:06 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 28DD080D2392C2F66047; Wed, 8 Jan 2020 16:19:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 8 Jan 2020 16:18:55 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH] drm/hisilicon: add the mode_valid function Date: Wed, 8 Jan 2020 16:19:00 +0800 Message-ID: <1578471540-43322-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, and we can also use it to make suse the resolution is valid. Signed-off-by: Tian Tao Signed-off-by: Gong junjie --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 20 ++++++++++++++++++++ 1 file changed, 20 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..6cb7a79 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c @@ -242,6 +242,25 @@ static void hibmc_crtc_atomic_disable(struct drm_crtc *crtc, hibmc_set_current_gate(priv, reg); } +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_NOMODE; + + 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_NOMODE; +} + + static unsigned int format_pll_reg(void) { unsigned int pllreg = 0; @@ -510,6 +529,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