[PATCHv4 10/36] drm/komeda: Retrieve drm_format_info once

Andrzej Pietrasiewicz
2019-12-13T21:24:58Z

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 --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
index bb1b43a64685..ce96389e3c40 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;
@@ -97,12 +98,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;
@@ -147,6 +149,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);
@@ -164,9 +167,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)) {
@@ -174,7 +178,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;