diff mbox series

[PATCHv5,08/34] drm/komeda: Retrieve drm_format_info once

Message ID 20191217145020.14645-9-andrzej.p@collabora.com (mailing list archive)
State New, archived
Headers show
Series Add AFBC support for Rockchip | expand

Commit Message

Andrzej Pietrasiewicz Dec. 17, 2019, 2:49 p.m. UTC
Next step towards unifying afbc and non-afbc cases as much as possible.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
---
 .../drm/arm/display/komeda/komeda_framebuffer.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
index 33181bdab16b..7004c3c8f8de 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
@@ -37,11 +37,12 @@  static const struct drm_framebuffer_funcs komeda_fb_funcs = {
 };
 
 static int
-komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file,
+komeda_fb_afbc_size_check(struct komeda_fb *kfb,
+			  const struct drm_format_info *info,
+			  struct drm_file *file,
 			  const struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct drm_framebuffer *fb = &kfb->base;
-	const struct drm_format_info *info = fb->format;
 	struct drm_gem_object *obj;
 	u32 alignment_w = 0, alignment_h = 0, alignment_header, n_blocks, bpp;
 	u64 min_size;
@@ -96,12 +97,13 @@  komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file,
 }
 
 static int
-komeda_fb_none_afbc_size_check(struct komeda_dev *mdev, struct komeda_fb *kfb,
+komeda_fb_none_afbc_size_check(struct komeda_dev *mdev,
+			       struct komeda_fb *kfb,
+			       const struct drm_format_info *info,
 			       struct drm_file *file,
 			       const struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct drm_framebuffer *fb = &kfb->base;
-	const struct drm_format_info *info = fb->format;
 	struct drm_gem_object *obj;
 	u32 i, block_h;
 	u64 min_size;
@@ -146,6 +148,7 @@  komeda_fb_create(struct drm_device *dev, struct drm_file *file,
 {
 	struct komeda_dev *mdev = dev->dev_private;
 	struct komeda_fb *kfb;
+	const struct drm_format_info *info;
 	int ret = 0, i;
 
 	kfb = kzalloc(sizeof(*kfb), GFP_KERNEL);
@@ -163,9 +166,10 @@  komeda_fb_create(struct drm_device *dev, struct drm_file *file,
 	}
 
 	drm_helper_mode_fill_fb_struct(dev, &kfb->base, mode_cmd);
+	info = kfb->base.format;
 
 	if (kfb->base.modifier) {
-		ret = komeda_fb_afbc_size_check(kfb, file, mode_cmd);
+		ret = komeda_fb_afbc_size_check(kfb, info, file, mode_cmd);
 	} else {
 		if (komeda_fb_check_src_coords(kfb, 0, 0, kfb->base.width,
 					       kfb->base.height)) {
@@ -173,7 +177,8 @@  komeda_fb_create(struct drm_device *dev, struct drm_file *file,
 			return ERR_PTR(-EINVAL);
 		}
 
-		ret = komeda_fb_none_afbc_size_check(mdev, kfb, file, mode_cmd);
+		ret = komeda_fb_none_afbc_size_check(mdev, kfb, info, file,
+						     mode_cmd);
 	}
 	if (ret < 0)
 		goto err_cleanup;