diff options
author | Tian Tao <tiantao6@hisilicon.com> | 2020-01-08 10:41:41 +0100 |
---|---|---|
committer | Xinliang Liu <xinliang.liu@linaro.org> | 2020-02-27 05:34:32 +0100 |
commit | bc17e557495429ac8f8c1e68a8f0e7adefdb793b (patch) | |
tree | f98f0284b40d4b7c21ebd261c765f67664934ab4 | |
parent | drm/hisilicon: fixed the wrong resolution configurations (diff) | |
download | linux-bc17e557495429ac8f8c1e68a8f0e7adefdb793b.tar.xz linux-bc17e557495429ac8f8c1e68a8f0e7adefdb793b.zip |
drm/hisilicon: Add the mode_valid function
add mode_valid function, we can make sure the resolution is valid.
Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Gong junjie <gongjunjie2@huawei.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1578476501-45807-1-git-send-email-tiantao6@hisilicon.com
-rw-r--r-- | drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c index 66ed6b0441e6..55b46a7150a5 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c @@ -243,6 +243,25 @@ 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; @@ -511,6 +530,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) |