Skip to content

Commit b05093f

Browse files
committed
drm/msm/dpu: split dpu_format_populate_layout
Split dpu_format_populate_layout() into addess-related and pitch/format-related parts. Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Tested-by: Abhinav Kumar <quic_abhinavk@quicinc.com> # sc7280 Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/612244/ Link: https://lore.kernel.org/r/20240903-dpu-mode-config-width-v6-10-617e1ecc4b7a@linaro.org
1 parent d8cb424 commit b05093f

4 files changed

Lines changed: 44 additions & 19 deletions

File tree

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,13 @@ static void dpu_encoder_phys_wb_prepare_wb_job(struct dpu_encoder_phys *phys_enc
582582

583583
format = msm_framebuffer_format(job->fb);
584584

585-
ret = dpu_format_populate_layout(aspace, job->fb, &wb_cfg->dest);
585+
ret = dpu_format_populate_plane_sizes(job->fb, &wb_cfg->dest);
586+
if (ret) {
587+
DPU_DEBUG("failed to populate plane sizes%d\n", ret);
588+
return;
589+
}
590+
591+
ret = dpu_format_populate_addrs(aspace, job->fb, &wb_cfg->dest);
586592
if (ret) {
587593
DPU_DEBUG("failed to populate layout %d\n", ret);
588594
return;

drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int _dpu_format_get_media_color_ubwc(const struct msm_format *fmt)
9393
return color_fmt;
9494
}
9595

96-
static int _dpu_format_get_plane_sizes_ubwc(
96+
static int _dpu_format_populate_plane_sizes_ubwc(
9797
const struct msm_format *fmt,
9898
struct drm_framebuffer *fb,
9999
struct dpu_hw_fmt_layout *layout)
@@ -170,7 +170,7 @@ static int _dpu_format_get_plane_sizes_ubwc(
170170
return 0;
171171
}
172172

173-
static int _dpu_format_get_plane_sizes_linear(
173+
static int _dpu_format_populate_plane_sizes_linear(
174174
const struct msm_format *fmt,
175175
struct drm_framebuffer *fb,
176176
struct dpu_hw_fmt_layout *layout)
@@ -244,12 +244,21 @@ static int _dpu_format_get_plane_sizes_linear(
244244
return 0;
245245
}
246246

247-
static int dpu_format_get_plane_sizes(
248-
const struct msm_format *fmt,
247+
/*
248+
* dpu_format_populate_addrs - populate non-address part of the layout based on
249+
* fb, and format found in the fb
250+
* @fb: framebuffer pointer
251+
* @layout: format layout structure to populate
252+
*
253+
* Return: error code on failure or 0 if new addresses were populated
254+
*/
255+
int dpu_format_populate_plane_sizes(
249256
struct drm_framebuffer *fb,
250257
struct dpu_hw_fmt_layout *layout)
251258
{
252-
if (!layout || !fmt) {
259+
const struct msm_format *fmt;
260+
261+
if (!layout || !fb) {
253262
DRM_ERROR("invalid pointer\n");
254263
return -EINVAL;
255264
}
@@ -260,10 +269,12 @@ static int dpu_format_get_plane_sizes(
260269
return -ERANGE;
261270
}
262271

272+
fmt = msm_framebuffer_format(fb);
273+
263274
if (MSM_FORMAT_IS_UBWC(fmt) || MSM_FORMAT_IS_TILE(fmt))
264-
return _dpu_format_get_plane_sizes_ubwc(fmt, fb, layout);
275+
return _dpu_format_populate_plane_sizes_ubwc(fmt, fb, layout);
265276

266-
return _dpu_format_get_plane_sizes_linear(fmt, fb, layout);
277+
return _dpu_format_populate_plane_sizes_linear(fmt, fb, layout);
267278
}
268279

269280
static int _dpu_format_populate_addrs_ubwc(
@@ -377,7 +388,7 @@ static int _dpu_format_populate_addrs_linear(
377388
return 0;
378389
}
379390

380-
int dpu_format_populate_layout(
391+
int dpu_format_populate_addrs(
381392
struct msm_gem_address_space *aspace,
382393
struct drm_framebuffer *fb,
383394
struct dpu_hw_fmt_layout *layout)
@@ -398,11 +409,6 @@ int dpu_format_populate_layout(
398409

399410
fmt = msm_framebuffer_format(fb);
400411

401-
/* Populate the plane sizes etc via get_format */
402-
ret = dpu_format_get_plane_sizes(fmt, fb, layout);
403-
if (ret)
404-
return ret;
405-
406412
/* Populate the addresses given the fb */
407413
if (MSM_FORMAT_IS_UBWC(fmt) ||
408414
MSM_FORMAT_IS_TILE(fmt))

drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static inline bool dpu_find_format(u32 format, const u32 *supported_formats,
3232
}
3333

3434
/**
35-
* dpu_format_populate_layout - populate the given format layout based on
35+
* dpu_format_populate_addrs - populate buffer addresses based on
3636
* mmu, fb, and format found in the fb
3737
* @aspace: address space pointer
3838
* @fb: framebuffer pointer
@@ -41,9 +41,13 @@ static inline bool dpu_find_format(u32 format, const u32 *supported_formats,
4141
* Return: error code on failure, -EAGAIN if success but the addresses
4242
* are the same as before or 0 if new addresses were populated
4343
*/
44-
int dpu_format_populate_layout(
44+
int dpu_format_populate_addrs(
4545
struct msm_gem_address_space *aspace,
4646
struct drm_framebuffer *fb,
4747
struct dpu_hw_fmt_layout *fmtl);
4848

49+
int dpu_format_populate_plane_sizes(
50+
struct drm_framebuffer *fb,
51+
struct dpu_hw_fmt_layout *layout);
52+
4953
#endif /*_DPU_FORMATS_H */

drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,19 @@ static int dpu_plane_prepare_fb(struct drm_plane *plane,
675675
}
676676
}
677677

678+
ret = dpu_format_populate_plane_sizes(new_state->fb, &pstate->layout);
679+
if (ret) {
680+
DPU_ERROR_PLANE(pdpu, "failed to get format plane sizes, %d\n", ret);
681+
if (pstate->aspace)
682+
msm_framebuffer_cleanup(new_state->fb, pstate->aspace,
683+
pstate->needs_dirtyfb);
684+
return ret;
685+
}
686+
678687
/* validate framebuffer layout before commit */
679-
ret = dpu_format_populate_layout(pstate->aspace,
680-
new_state->fb,
681-
&pstate->layout);
688+
ret = dpu_format_populate_addrs(pstate->aspace,
689+
new_state->fb,
690+
&pstate->layout);
682691
if (ret) {
683692
DPU_ERROR_PLANE(pdpu, "failed to get format layout, %d\n", ret);
684693
if (pstate->aspace)

0 commit comments

Comments
 (0)