mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 16:12:59 +02:00
drm/msm/dpu: use standard functions in _dpu_format_populate_plane_sizes_ubwc()
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. Patchwork: https://patchwork.freedesktop.org/patch/688182/ Link: https://lore.kernel.org/r/20251114-dpu-formats-v3-12-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>
This commit is contained in:
parent
ada4a19ed2
commit
2f3ff6ab8f
|
|
@ -10,16 +10,6 @@
|
||||||
#include "dpu_kms.h"
|
#include "dpu_kms.h"
|
||||||
#include "dpu_formats.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
|
#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 (MSM_FORMAT_IS_DX(fmt)) {
|
||||||
if (fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT) {
|
if (fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT) {
|
||||||
stride = MSM_MEDIA_ALIGN(fb->width, 192);
|
/* can't use round_up() here because 192 is NPoT */
|
||||||
stride = MSM_MEDIA_ALIGN(stride * 4 / 3, 256);
|
stride = roundup(fb->width, 192);
|
||||||
|
stride = round_up(stride * 4 / 3, 256);
|
||||||
y_tile_width = 48;
|
y_tile_width = 48;
|
||||||
} else {
|
} else {
|
||||||
stride = MSM_MEDIA_ALIGN(fb->width * 2, 256);
|
stride = round_up(fb->width * 2, 256);
|
||||||
y_tile_width = 32;
|
y_tile_width = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
sclines = MSM_MEDIA_ALIGN(fb->height, 16);
|
sclines = round_up(fb->height, 16);
|
||||||
y_tile_height = 4;
|
y_tile_height = 4;
|
||||||
} else {
|
} else {
|
||||||
stride = MSM_MEDIA_ALIGN(fb->width, 128);
|
stride = round_up(fb->width, 128);
|
||||||
y_tile_width = 32;
|
y_tile_width = 32;
|
||||||
|
|
||||||
sclines = MSM_MEDIA_ALIGN(fb->height, 32);
|
sclines = round_up(fb->height, 32);
|
||||||
y_tile_height = 8;
|
y_tile_height = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->plane_pitch[0] = stride;
|
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);
|
sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
||||||
|
|
||||||
layout->plane_pitch[1] = stride;
|
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);
|
sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
||||||
|
|
||||||
if (!meta)
|
if (!meta)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
y_meta_stride = MSM_MEDIA_ROUNDUP(fb->width, y_tile_width);
|
y_meta_stride = DIV_ROUND_UP(fb->width, y_tile_width);
|
||||||
layout->plane_pitch[2] = MSM_MEDIA_ALIGN(y_meta_stride, 64);
|
layout->plane_pitch[2] = round_up(y_meta_stride, 64);
|
||||||
|
|
||||||
y_meta_scanlines = MSM_MEDIA_ROUNDUP(fb->height, y_tile_height);
|
y_meta_scanlines = DIV_ROUND_UP(fb->height, y_tile_height);
|
||||||
y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
|
y_meta_scanlines = round_up(y_meta_scanlines, 16);
|
||||||
layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] *
|
layout->plane_size[2] = round_up(layout->plane_pitch[2] *
|
||||||
y_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
y_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
||||||
|
|
||||||
uv_meta_stride = MSM_MEDIA_ROUNDUP((fb->width+1)>>1, y_tile_width / 2);
|
uv_meta_stride = DIV_ROUND_UP((fb->width+1)>>1, y_tile_width / 2);
|
||||||
layout->plane_pitch[3] = MSM_MEDIA_ALIGN(uv_meta_stride, 64);
|
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 = DIV_ROUND_UP((fb->height+1)>>1, y_tile_height);
|
||||||
uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
|
uv_meta_scanlines = round_up(uv_meta_scanlines, 16);
|
||||||
layout->plane_size[3] = MSM_MEDIA_ALIGN(layout->plane_pitch[3] *
|
layout->plane_size[3] = round_up(layout->plane_pitch[3] *
|
||||||
uv_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
uv_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
||||||
} else {
|
} else {
|
||||||
unsigned int rgb_scanlines, rgb_meta_scanlines, rgb_meta_stride;
|
unsigned int rgb_scanlines, rgb_meta_scanlines, rgb_meta_stride;
|
||||||
|
|
||||||
layout->plane_pitch[0] = MSM_MEDIA_ALIGN(fb->width * fmt->bpp, 256);
|
layout->plane_pitch[0] = round_up(fb->width * fmt->bpp, 256);
|
||||||
rgb_scanlines = MSM_MEDIA_ALIGN(fb->height, 16);
|
rgb_scanlines = round_up(fb->height, 16);
|
||||||
layout->plane_size[0] = MSM_MEDIA_ALIGN(layout->plane_pitch[0] *
|
layout->plane_size[0] = round_up(layout->plane_pitch[0] *
|
||||||
rgb_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
rgb_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
||||||
|
|
||||||
if (!meta)
|
if (!meta)
|
||||||
|
|
@ -136,13 +127,13 @@ static int _dpu_format_populate_plane_sizes_ubwc(
|
||||||
/* uAPI leaves plane[1] empty and plane[2] as meta */
|
/* uAPI leaves plane[1] empty and plane[2] as meta */
|
||||||
layout->num_planes += 1;
|
layout->num_planes += 1;
|
||||||
|
|
||||||
rgb_meta_stride = MSM_MEDIA_ROUNDUP(fb->width, 16);
|
rgb_meta_stride = DIV_ROUND_UP(fb->width, 16);
|
||||||
layout->plane_pitch[2] = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
|
layout->plane_pitch[2] = round_up(rgb_meta_stride, 64);
|
||||||
|
|
||||||
rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(fb->height, 4);
|
rgb_meta_scanlines = DIV_ROUND_UP(fb->height, 4);
|
||||||
rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
|
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);
|
rgb_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user