The VOP2 has limitations on its input and output sizes. The clipped
display region must be at least 4px in each dimension for both
framebuffer source and plane destination, and the clipped source region
must be no greater than a per-version limit.

It is never valid for VOP2 to have a framebuffer which is less than four
pixels in either dimension, so declare that as our min width/height,
enforced by AddFB failing if the user tries. It can theoretically be
valid to have a single large framebuffer of which only certain clipped
regions are shown, but this is a very uncommon case. Declaring to
userspace that the framebuffer's maximum width and height is the maximum
source clip helps it make better decisions as to which mode to use,
instead of trying unsupported sizes and having to fall back.

Signed-off-by: Daniel Stone <[email protected]>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 4ba5444fde4f..f04fb5da1295 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -2647,6 +2647,12 @@ static int vop2_bind(struct device *dev, struct device 
*master, void *data)
        if (IS_ERR(vop2->map))
                return PTR_ERR(vop2->map);
 
+       /* Set the bounds for framebuffer creation */
+       drm->mode_config.min_width = 4;
+       drm->mode_config.min_height = 4;
+       drm->mode_config.max_width = vop2_data->max_input.width;
+       drm->mode_config.max_height = vop2_data->max_input.height;
+
        ret = vop2_win_init(vop2);
        if (ret)
                return ret;
-- 
2.51.0

Reply via email to