]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/msm/dpu: simplify _dpu_format_populate_plane_sizes_*
authorDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Fri, 14 Nov 2025 03:43:36 +0000 (05:43 +0200)
committerDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Tue, 13 Jan 2026 06:20:00 +0000 (08:20 +0200)
Move common bits of _dpu_format_populate_plane_sizes_ubwc() and
_linear() to dpu_format_populate_plane_sizes(), reducing unnecessary
duplication and simplifying code flow fror the UBWC function.

Reviewed-by: Jessica Zhang <jessica.zhang@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/688178/
Link: https://lore.kernel.org/r/20251114-dpu-formats-v3-9-cae312379d49@oss.qualcomm.com
Tested-by: Luca Weiss <luca.weiss@fairphone.com> # qcm6490-fairphone-fp5
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c

index b0d585c5315ca0d459c7ab7f936f1ae350a4a520..b950bc827a36c231bcd4a9374e58cde6b41230bf 100644 (file)
@@ -95,15 +95,9 @@ static int _dpu_format_populate_plane_sizes_ubwc(
                struct drm_framebuffer *fb,
                struct dpu_hw_fmt_layout *layout)
 {
-       int i;
        int color;
        bool meta = MSM_FORMAT_IS_UBWC(fmt);
 
-       memset(layout, 0, sizeof(struct dpu_hw_fmt_layout));
-       layout->width = fb->width;
-       layout->height = fb->height;
-       layout->num_planes = fmt->num_planes;
-
        color = _dpu_format_get_media_color_ubwc(fmt);
        if (color < 0) {
                DRM_ERROR("UBWC format not supported for fmt: %p4cc\n",
@@ -128,7 +122,7 @@ static int _dpu_format_populate_plane_sizes_ubwc(
                        uv_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
 
                if (!meta)
-                       goto done;
+                       return 0;
 
                layout->num_planes += 2;
                layout->plane_pitch[2] = VENUS_Y_META_STRIDE(color, fb->width);
@@ -152,7 +146,8 @@ static int _dpu_format_populate_plane_sizes_ubwc(
                        rgb_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
 
                if (!meta)
-                       goto done;
+                       return 0;
+
                layout->num_planes += 2;
                layout->plane_pitch[2] = VENUS_RGB_META_STRIDE(color, fb->width);
                rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color, fb->height);
@@ -160,10 +155,6 @@ static int _dpu_format_populate_plane_sizes_ubwc(
                        rgb_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
        }
 
-done:
-       for (i = 0; i < DPU_MAX_PLANES; i++)
-               layout->total_size += layout->plane_size[i];
-
        return 0;
 }
 
@@ -174,11 +165,6 @@ static int _dpu_format_populate_plane_sizes_linear(
 {
        int i;
 
-       memset(layout, 0, sizeof(struct dpu_hw_fmt_layout));
-       layout->width = fb->width;
-       layout->height = fb->height;
-       layout->num_planes = fmt->num_planes;
-
        /* Due to memset above, only need to set planes of interest */
        if (fmt->fetch_type == MDP_PLANE_INTERLEAVED) {
                layout->num_planes = 1;
@@ -235,9 +221,6 @@ static int _dpu_format_populate_plane_sizes_linear(
                }
        }
 
-       for (i = 0; i < DPU_MAX_PLANES; i++)
-               layout->total_size += layout->plane_size[i];
-
        return 0;
 }
 
@@ -254,6 +237,7 @@ int dpu_format_populate_plane_sizes(
                struct dpu_hw_fmt_layout *layout)
 {
        const struct msm_format *fmt;
+       int ret, i;
 
        if (!layout || !fb) {
                DRM_ERROR("invalid pointer\n");
@@ -268,10 +252,23 @@ int dpu_format_populate_plane_sizes(
 
        fmt = msm_framebuffer_format(fb);
 
+       memset(layout, 0, sizeof(struct dpu_hw_fmt_layout));
+       layout->width = fb->width;
+       layout->height = fb->height;
+       layout->num_planes = fmt->num_planes;
+
        if (MSM_FORMAT_IS_UBWC(fmt) || MSM_FORMAT_IS_TILE(fmt))
-               return _dpu_format_populate_plane_sizes_ubwc(fmt, fb, layout);
+               ret = _dpu_format_populate_plane_sizes_ubwc(fmt, fb, layout);
+       else
+               ret = _dpu_format_populate_plane_sizes_linear(fmt, fb, layout);
 
-       return _dpu_format_populate_plane_sizes_linear(fmt, fb, layout);
+       if (ret)
+               return ret;
+
+       for (i = 0; i < DPU_MAX_PLANES; i++)
+               layout->total_size += layout->plane_size[i];
+
+       return 0;
 }
 
 static void _dpu_format_populate_addrs_ubwc(struct drm_framebuffer *fb,