Skip to content

Commit bc17e55

Browse files
Tian Taoxin3liang
authored andcommitted
drm/hisilicon: Add the mode_valid function
add mode_valid function, we can make sure the resolution is valid. Signed-off-by: Tian Tao <[email protected]> Signed-off-by: Gong junjie <[email protected]> Reviewed-by: Thomas Zimmermann <[email protected]> Signed-off-by: Xinliang Liu <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent de3c3ed commit bc17e55

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,25 @@ static void hibmc_crtc_atomic_disable(struct drm_crtc *crtc,
243243
hibmc_set_current_gate(priv, reg);
244244
}
245245

246+
static enum drm_mode_status
247+
hibmc_crtc_mode_valid(struct drm_crtc *crtc,
248+
const struct drm_display_mode *mode)
249+
{
250+
int i = 0;
251+
int vrefresh = drm_mode_vrefresh(mode);
252+
253+
if (vrefresh < 59 || vrefresh > 61)
254+
return MODE_NOCLOCK;
255+
256+
for (i = 0; i < ARRAY_SIZE(hibmc_pll_table); i++) {
257+
if (hibmc_pll_table[i].hdisplay == mode->hdisplay &&
258+
hibmc_pll_table[i].vdisplay == mode->vdisplay)
259+
return MODE_OK;
260+
}
261+
262+
return MODE_BAD;
263+
}
264+
246265
static unsigned int format_pll_reg(void)
247266
{
248267
unsigned int pllreg = 0;
@@ -511,6 +530,7 @@ static const struct drm_crtc_helper_funcs hibmc_crtc_helper_funcs = {
511530
.atomic_flush = hibmc_crtc_atomic_flush,
512531
.atomic_enable = hibmc_crtc_atomic_enable,
513532
.atomic_disable = hibmc_crtc_atomic_disable,
533+
.mode_valid = hibmc_crtc_mode_valid,
514534
};
515535

516536
int hibmc_de_init(struct hibmc_drm_private *priv)

0 commit comments

Comments
 (0)