[PATCH] drm/rockchip: vop2: Add mode valid callback for crtc

Andy Yan posted 1 patch 1 month ago
There is a newer version of this series
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
[PATCH] drm/rockchip: vop2: Add mode valid callback for crtc
Posted by Andy Yan 1 month ago
From: Andy Yan <andy.yan@rock-chips.com>

Filter the mode that can't output by the crtc.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---

 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 498df0ce4680..74fba29bfff3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1439,6 +1439,17 @@ static void vop2_crtc_disable_vblank(struct drm_crtc *crtc)
 	vop2_crtc_disable_irq(vp, VP_INT_FS_FIELD);
 }
 
+static enum drm_mode_status vop2_crtc_mode_valid(struct drm_crtc *crtc,
+						 const struct drm_display_mode *mode)
+{
+	struct vop2_video_port *vp = to_vop2_video_port(crtc);
+
+	if (mode->hdisplay > vp->data->max_output.width)
+		return MODE_BAD_HVALUE;
+
+	return MODE_OK;
+}
+
 static bool vop2_crtc_mode_fixup(struct drm_crtc *crtc,
 				 const struct drm_display_mode *mode,
 				 struct drm_display_mode *adj_mode)
@@ -1884,6 +1895,7 @@ static void vop2_crtc_atomic_flush(struct drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs vop2_crtc_helper_funcs = {
 	.mode_fixup = vop2_crtc_mode_fixup,
+	.mode_valid = vop2_crtc_mode_valid,
 	.atomic_check = vop2_crtc_atomic_check,
 	.atomic_begin = vop2_crtc_atomic_begin,
 	.atomic_flush = vop2_crtc_atomic_flush,
-- 
2.43.0

base-commit: 84f1d42065381b7c3fbdeefe917e5e24ec0c6d87
branch: rk3576-dp-upstream
Re: [PATCH] drm/rockchip: vop2: Add mode valid callback for crtc
Posted by Daniel Stone 2 weeks, 4 days ago
Hi Andy,

On Fri, 9 Jan 2026 at 00:59, Andy Yan <andyshrk@163.com> wrote:
> Filter the mode that can't output by the crtc.
>
> [...]
>
> +static enum drm_mode_status vop2_crtc_mode_valid(struct drm_crtc *crtc,
> +                                                const struct drm_display_mode *mode)
> +{
> +       struct vop2_video_port *vp = to_vop2_video_port(crtc);
> +
> +       if (mode->hdisplay > vp->data->max_output.width)
> +               return MODE_BAD_HVALUE;

Why not test height as well?

Cheers,
Daniel
Re: [PATCH] drm/rockchip: vop2: Add mode valid callback for crtc
Posted by Daniel Stone 2 weeks, 4 days ago
Hi Andy,

On Tue, 20 Jan 2026 at 11:03, Daniel Stone <daniel@fooishbar.org> wrote:
> On Fri, 9 Jan 2026 at 00:59, Andy Yan <andyshrk@163.com> wrote:
> > Filter the mode that can't output by the crtc.
> >
> > [...]
> >
> > +static enum drm_mode_status vop2_crtc_mode_valid(struct drm_crtc *crtc,
> > +                                                const struct drm_display_mode *mode)
> > +{
> > +       struct vop2_video_port *vp = to_vop2_video_port(crtc);
> > +
> > +       if (mode->hdisplay > vp->data->max_output.width)
> > +               return MODE_BAD_HVALUE;
>
> Why not test height as well?

I see the question was answered about 45 minutes ago ... anyway, why
not as a follow-up, change struct vop_rect max_output to just a single
max_width value?

Cheers,
Daniel