From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Rob Clark <robin.clark@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jessica.zhang@oss.qualcomm.com>,
Sean Paul <sean@poorly.run>,
Marijn Suijten <marijn.suijten@somainline.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Jordan Crouse <jordan@cosmicpenguin.net>
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 12/12] drm/msm/dpu: use standard functions in _dpu_format_populate_plane_sizes_ubwc()
Date: Fri, 05 Sep 2025 03:38:41 +0300 [thread overview]
Message-ID: <20250905-dpu-formats-v2-12-7a674028c048@oss.qualcomm.com> (raw)
In-Reply-To: <20250905-dpu-formats-v2-0-7a674028c048@oss.qualcomm.com>
The _dpu_format_populate_plane_sizes_ubwc() used MSM_MEDIA_ALIGN() and
MSM_MEDIA_ROUNDUP(), macros inherited from the previous implementation,
msm_media_info.h. Replace them with the standard Linux macros,
round_up() and DIV_ROUND_UP() respectively.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c | 63 +++++++++++++----------------
1 file changed, 27 insertions(+), 36 deletions(-)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
index da1870ce7680899759d09caa01050eeb9844a484..6e8883dbfad439a3b3f07b6fe9337820048fc2eb 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
@@ -10,16 +10,6 @@
#include "dpu_kms.h"
#include "dpu_formats.h"
-#ifndef MSM_MEDIA_ALIGN
-#define MSM_MEDIA_ALIGN(__sz, __align) (((__align) & ((__align) - 1)) ?\
- ((((__sz) + (__align) - 1) / (__align)) * (__align)) :\
- (((__sz) + (__align) - 1) & (~((__align) - 1))))
-#endif
-
-#ifndef MSM_MEDIA_ROUNDUP
-#define MSM_MEDIA_ROUNDUP(__sz, __r) (((__sz) + ((__r) - 1)) / (__r))
-#endif
-
#define DPU_UBWC_PLANE_SIZE_ALIGNMENT 4096
/*
@@ -78,56 +68,57 @@ static int _dpu_format_populate_plane_sizes_ubwc(
if (MSM_FORMAT_IS_DX(fmt)) {
if (fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT) {
- stride = MSM_MEDIA_ALIGN(fb->width, 192);
- stride = MSM_MEDIA_ALIGN(stride * 4 / 3, 256);
+ /* can't use round_up() here because 192 is NPoT */
+ stride = roundup(fb->width, 192);
+ stride = round_up(stride * 4 / 3, 256);
y_tile_width = 48;
} else {
- stride = MSM_MEDIA_ALIGN(fb->width * 2, 256);
+ stride = round_up(fb->width * 2, 256);
y_tile_width = 32;
}
- sclines = MSM_MEDIA_ALIGN(fb->height, 16);
+ sclines = round_up(fb->height, 16);
y_tile_height = 4;
} else {
- stride = MSM_MEDIA_ALIGN(fb->width, 128);
+ stride = round_up(fb->width, 128);
y_tile_width = 32;
- sclines = MSM_MEDIA_ALIGN(fb->height, 32);
+ sclines = round_up(fb->height, 32);
y_tile_height = 8;
}
layout->plane_pitch[0] = stride;
- layout->plane_size[0] = MSM_MEDIA_ALIGN(layout->plane_pitch[0] *
+ layout->plane_size[0] = round_up(layout->plane_pitch[0] *
sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
layout->plane_pitch[1] = stride;
- layout->plane_size[1] = MSM_MEDIA_ALIGN(layout->plane_pitch[1] *
+ layout->plane_size[1] = round_up(layout->plane_pitch[1] *
sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
if (!meta)
return 0;
- y_meta_stride = MSM_MEDIA_ROUNDUP(fb->width, y_tile_width);
- layout->plane_pitch[2] = MSM_MEDIA_ALIGN(y_meta_stride, 64);
+ y_meta_stride = DIV_ROUND_UP(fb->width, y_tile_width);
+ layout->plane_pitch[2] = round_up(y_meta_stride, 64);
- y_meta_scanlines = MSM_MEDIA_ROUNDUP(fb->height, y_tile_height);
- y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
- layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] *
+ y_meta_scanlines = DIV_ROUND_UP(fb->height, y_tile_height);
+ y_meta_scanlines = round_up(y_meta_scanlines, 16);
+ layout->plane_size[2] = round_up(layout->plane_pitch[2] *
y_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
- uv_meta_stride = MSM_MEDIA_ROUNDUP((fb->width+1)>>1, y_tile_width / 2);
- layout->plane_pitch[3] = MSM_MEDIA_ALIGN(uv_meta_stride, 64);
+ uv_meta_stride = DIV_ROUND_UP((fb->width+1)>>1, y_tile_width / 2);
+ layout->plane_pitch[3] = round_up(uv_meta_stride, 64);
- uv_meta_scanlines = MSM_MEDIA_ROUNDUP((fb->height+1)>>1, y_tile_height);
- uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
- layout->plane_size[3] = MSM_MEDIA_ALIGN(layout->plane_pitch[3] *
+ uv_meta_scanlines = DIV_ROUND_UP((fb->height+1)>>1, y_tile_height);
+ uv_meta_scanlines = round_up(uv_meta_scanlines, 16);
+ layout->plane_size[3] = round_up(layout->plane_pitch[3] *
uv_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
} else {
unsigned int rgb_scanlines, rgb_meta_scanlines, rgb_meta_stride;
- layout->plane_pitch[0] = MSM_MEDIA_ALIGN(fb->width * fmt->bpp, 256);
- rgb_scanlines = MSM_MEDIA_ALIGN(fb->height, 16);
- layout->plane_size[0] = MSM_MEDIA_ALIGN(layout->plane_pitch[0] *
+ layout->plane_pitch[0] = round_up(fb->width * fmt->bpp, 256);
+ rgb_scanlines = round_up(fb->height, 16);
+ layout->plane_size[0] = round_up(layout->plane_pitch[0] *
rgb_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
if (!meta)
@@ -136,13 +127,13 @@ static int _dpu_format_populate_plane_sizes_ubwc(
/* uAPI leaves plane[1] empty and plane[2] as meta */
layout->num_planes += 1;
- rgb_meta_stride = MSM_MEDIA_ROUNDUP(fb->width, 16);
- layout->plane_pitch[2] = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
+ rgb_meta_stride = DIV_ROUND_UP(fb->width, 16);
+ layout->plane_pitch[2] = round_up(rgb_meta_stride, 64);
- rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(fb->height, 4);
- rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
+ rgb_meta_scanlines = DIV_ROUND_UP(fb->height, 4);
+ rgb_meta_scanlines = round_up(rgb_meta_scanlines, 16);
- layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] *
+ layout->plane_size[2] = round_up(layout->plane_pitch[2] *
rgb_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
}
--
2.47.2
prev parent reply other threads:[~2025-09-05 0:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 0:38 [PATCH v2 00/12] drm/msm/dpu: rework format handling code Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 01/12] drm/msm/disp: set num_planes to 1 for interleaved YUV formats Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 02/12] drm/msm/disp: set num_planes and fetch_mode in INTERLEAVED_RGB_FMT Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 03/12] drm/msm/disp: set num_planes, fetch_mode and tile_height in INTERLEAVED_RGB_FMT_TILED Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 04/12] drm/msm/disp: simplify RGB{,A,X} formats definitions Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 05/12] drm/msm/disp: simplify tiled " Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 06/12] drm/msm/disp: pull in common YUV format parameters Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 07/12] drm/msm/disp: pull in common tiled " Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 08/12] drm/msm/disp: drop PSEUDO_YUV_FMT_LOOSE_TILED Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 09/12] drm/msm/dpu: simplify _dpu_format_populate_plane_sizes_* Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 10/12] drm/msm/dpu: drop redundant num_planes assignment in _dpu_format_populate_plane_sizes*() Dmitry Baryshkov
2025-09-05 0:38 ` [PATCH v2 11/12] drm/msm/dpu: rewrite _dpu_format_populate_plane_sizes_ubwc() Dmitry Baryshkov
2025-09-05 0:38 ` Dmitry Baryshkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250905-dpu-formats-v2-12-7a674028c048@oss.qualcomm.com \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jessica.zhang@oss.qualcomm.com \
--cc=jordan@cosmicpenguin.net \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®