Re: [PATCH 3/9] drm/msm/dpu: split dpu_format_populate_layout

2024-04-19 Thread Abhinav Kumar




On 3/19/2024 6:22 AM, Dmitry Baryshkov wrote:

Split dpu_format_populate_layout() into addess-related and
pitch/format-related parts.

Signed-off-by: Dmitry Baryshkov 
---
  .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c|  8 +++-
  drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c| 44 +++---
  drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h|  8 +++-
  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c  | 12 --
  4 files changed, 45 insertions(+), 27 deletions(-)



Reviewed-by: Abhinav Kumar 


[PATCH 3/9] drm/msm/dpu: split dpu_format_populate_layout

2024-03-19 Thread Dmitry Baryshkov
Split dpu_format_populate_layout() into addess-related and
pitch/format-related parts.

Signed-off-by: Dmitry Baryshkov 
---
 .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c|  8 +++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c| 44 +++---
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h|  8 +++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c  | 12 --
 4 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
index 1924a2b28e53..0fd85c0479ec 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
@@ -584,7 +584,13 @@ static void dpu_encoder_phys_wb_prepare_wb_job(struct 
dpu_encoder_phys *phys_enc
return;
}
 
-   ret = dpu_format_populate_layout(aspace, job->fb, &wb_cfg->dest);
+   ret = dpu_format_populate_plane_sizes(job->fb, &wb_cfg->dest);
+   if (ret) {
+   DPU_DEBUG("failed to populate plane sizes%d\n", ret);
+   return;
+   }
+
+   ret = dpu_format_populate_addrs(aspace, job->fb, &wb_cfg->dest);
if (ret) {
DPU_DEBUG("failed to populate layout %d\n", ret);
return;
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
index ff0df478c958..1fc9817278df 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
@@ -629,7 +629,7 @@ static int _dpu_format_get_media_color_ubwc(const struct 
dpu_format *fmt)
return color_fmt;
 }
 
-static int _dpu_format_get_plane_sizes_ubwc(
+static int _dpu_format_populate_plane_sizes_ubwc(
const struct dpu_format *fmt,
const uint32_t width,
const uint32_t height,
@@ -708,7 +708,7 @@ static int _dpu_format_get_plane_sizes_ubwc(
return 0;
 }
 
-static int _dpu_format_get_plane_sizes_linear(
+static int _dpu_format_populate_plane_sizes_linear(
const struct dpu_format *fmt,
const uint32_t width,
const uint32_t height,
@@ -780,27 +780,37 @@ static int _dpu_format_get_plane_sizes_linear(
return 0;
 }
 
-static int dpu_format_get_plane_sizes(
-   const struct dpu_format *fmt,
-   const uint32_t w,
-   const uint32_t h,
-   struct dpu_hw_fmt_layout *layout,
-   const uint32_t *pitches)
+/*
+ * dpu_format_populate_addrs - populate non-address part of the layout based on
+ * fb, and format found in the fb
+ * @fb:framebuffer pointer
+ * @layout:  format layout structure to populate
+ *
+ * Return: error code on failure or 0 if new addresses were populated
+ */
+int dpu_format_populate_plane_sizes(
+   struct drm_framebuffer *fb,
+   struct dpu_hw_fmt_layout *layout)
 {
-   if (!layout || !fmt) {
+   struct dpu_format *fmt;
+
+   if (!layout || !fb) {
DRM_ERROR("invalid pointer\n");
return -EINVAL;
}
 
-   if ((w > DPU_MAX_IMG_WIDTH) || (h > DPU_MAX_IMG_HEIGHT)) {
+   if ((fb->width > DPU_MAX_IMG_WIDTH) || (fb->height > 
DPU_MAX_IMG_HEIGHT)) {
DRM_ERROR("image dimensions outside max range\n");
return -ERANGE;
}
 
+   fmt = to_dpu_format(msm_framebuffer_format(fb));
+
if (DPU_FORMAT_IS_UBWC(fmt) || DPU_FORMAT_IS_TILE(fmt))
-   return _dpu_format_get_plane_sizes_ubwc(fmt, w, h, layout);
+   return _dpu_format_populate_plane_sizes_ubwc(fmt, fb->width, 
fb->height, layout);
 
-   return _dpu_format_get_plane_sizes_linear(fmt, w, h, layout, pitches);
+   return _dpu_format_populate_plane_sizes_linear(fmt, fb->width, 
fb->height,
+  layout, fb->pitches);
 }
 
 static int _dpu_format_populate_addrs_ubwc(
@@ -924,7 +934,7 @@ static int _dpu_format_populate_addrs_linear(
return 0;
 }
 
-int dpu_format_populate_layout(
+int dpu_format_populate_addrs(
struct msm_gem_address_space *aspace,
struct drm_framebuffer *fb,
struct dpu_hw_fmt_layout *layout)
@@ -942,14 +952,6 @@ int dpu_format_populate_layout(
return -ERANGE;
}
 
-   layout->format = to_dpu_format(msm_framebuffer_format(fb));
-
-   /* Populate the plane sizes etc via get_format */
-   ret = dpu_format_get_plane_sizes(layout->format, fb->width, fb->height,
-   layout, fb->pitches);
-   if (ret)
-   return ret;
-
/* Populate the addresses given the fb */
if (DPU_FORMAT_IS_UBWC(layout->format) ||
DPU_FORMAT_IS_TILE(layout->format))
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h 
b/drivers/gpu/drm/msm/disp/d