[PATCHv5,25/34] drm/komeda: Use special helper for afbc case size check
diff mbox series

Message ID 20191217145020.14645-26-andrzej.p@collabora.com
State New
Headers show
Series
  • Add AFBC support for Rockchip
Related show

Commit Message

Andrzej Pietrasiewicz Dec. 17, 2019, 2:50 p.m. UTC
Use generic helper code.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
---
 .../arm/display/komeda/komeda_framebuffer.c   | 22 +++++++------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Patch
diff mbox series

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
index 766b6944c53c..2c9691b86cff 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
@@ -37,17 +37,15 @@  static const struct drm_framebuffer_funcs komeda_fb_funcs = {
 };
 
 static int
-komeda_fb_afbc_size_check(struct komeda_fb *kfb,
+komeda_fb_afbc_size_check(struct drm_device *dev,
+			  struct komeda_fb *kfb,
 			  const struct drm_format_info *info,
 			  struct drm_gem_object **objs,
 			  struct drm_file *file,
 			  const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-	struct drm_gem_object *obj;
+	struct drm_size_check check = { 0 };
 	u32 alignment_w = 0, alignment_h = 0, alignment_header, n_blocks, bpp;
-	u64 min_size;
-
-	obj = objs[0];
 
 	if (!drm_afbc_get_superblock_wh(mode_cmd->modifier[0], &alignment_w, &alignment_h))
 		return -EINVAL;
@@ -77,14 +75,10 @@  komeda_fb_afbc_size_check(struct komeda_fb *kfb,
 	kfb->afbc_size = kfb->offset_payload + n_blocks *
 			 ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8,
 			       AFBC_SUPERBLK_ALIGNMENT);
-	min_size = kfb->afbc_size + mode_cmd->offsets[0];
-	if (min_size > obj->size) {
-		DRM_DEBUG_KMS("afbc size check failed, obj_size: 0x%zx. min_size 0x%llx.\n",
-			      obj->size, min_size);
-		return -EINVAL;
-	}
+	check.min_size[0] = kfb->afbc_size + mode_cmd->offsets[0];
+	check.use_min_size = true;
 
-	return 0;
+	return drm_gem_fb_size_check2(dev, mode_cmd, &check, objs);
 }
 
 struct drm_framebuffer *
@@ -125,8 +119,8 @@  komeda_fb_create(struct drm_device *dev, struct drm_file *file,
 			goto err_cleanup;
 		}
 
-		ret = komeda_fb_afbc_size_check(kfb, info, objs, file,
-						mode_cmd);
+		ret = komeda_fb_afbc_size_check(dev, kfb, info, objs,
+						file, mode_cmd);
 	} else {
 		struct drm_size_check check = { 0 };