Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+27 -36
+27 -36
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
··· 10 10 #include "dpu_kms.h" 11 11 #include "dpu_formats.h" 12 12 13 - #ifndef MSM_MEDIA_ALIGN 14 - #define MSM_MEDIA_ALIGN(__sz, __align) (((__align) & ((__align) - 1)) ?\ 15 - ((((__sz) + (__align) - 1) / (__align)) * (__align)) :\ 16 - (((__sz) + (__align) - 1) & (~((__align) - 1)))) 17 - #endif 18 - 19 - #ifndef MSM_MEDIA_ROUNDUP 20 - #define MSM_MEDIA_ROUNDUP(__sz, __r) (((__sz) + ((__r) - 1)) / (__r)) 21 - #endif 22 - 23 13 #define DPU_UBWC_PLANE_SIZE_ALIGNMENT 4096 24 14 25 15 /* ··· 68 78 69 79 if (MSM_FORMAT_IS_DX(fmt)) { 70 80 if (fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT) { 71 - stride = MSM_MEDIA_ALIGN(fb->width, 192); 72 - stride = MSM_MEDIA_ALIGN(stride * 4 / 3, 256); 81 + /* can't use round_up() here because 192 is NPoT */ 82 + stride = roundup(fb->width, 192); 83 + stride = round_up(stride * 4 / 3, 256); 73 84 y_tile_width = 48; 74 85 } else { 75 - stride = MSM_MEDIA_ALIGN(fb->width * 2, 256); 86 + stride = round_up(fb->width * 2, 256); 76 87 y_tile_width = 32; 77 88 } 78 89 79 - sclines = MSM_MEDIA_ALIGN(fb->height, 16); 90 + sclines = round_up(fb->height, 16); 80 91 y_tile_height = 4; 81 92 } else { 82 - stride = MSM_MEDIA_ALIGN(fb->width, 128); 93 + stride = round_up(fb->width, 128); 83 94 y_tile_width = 32; 84 95 85 - sclines = MSM_MEDIA_ALIGN(fb->height, 32); 96 + sclines = round_up(fb->height, 32); 86 97 y_tile_height = 8; 87 98 } 88 99 89 100 layout->plane_pitch[0] = stride; 90 - layout->plane_size[0] = MSM_MEDIA_ALIGN(layout->plane_pitch[0] * 101 + layout->plane_size[0] = round_up(layout->plane_pitch[0] * 91 102 sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 92 103 93 104 layout->plane_pitch[1] = stride; 94 - layout->plane_size[1] = MSM_MEDIA_ALIGN(layout->plane_pitch[1] * 105 + layout->plane_size[1] = round_up(layout->plane_pitch[1] * 95 106 sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 96 107 97 108 if (!meta) 98 109 return 0; 99 110 100 - y_meta_stride = MSM_MEDIA_ROUNDUP(fb->width, y_tile_width); 101 - layout->plane_pitch[2] = MSM_MEDIA_ALIGN(y_meta_stride, 64); 111 + y_meta_stride = DIV_ROUND_UP(fb->width, y_tile_width); 112 + layout->plane_pitch[2] = round_up(y_meta_stride, 64); 102 113 103 - y_meta_scanlines = MSM_MEDIA_ROUNDUP(fb->height, y_tile_height); 104 - y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16); 105 - layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] * 114 + y_meta_scanlines = DIV_ROUND_UP(fb->height, y_tile_height); 115 + y_meta_scanlines = round_up(y_meta_scanlines, 16); 116 + layout->plane_size[2] = round_up(layout->plane_pitch[2] * 106 117 y_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 107 118 108 - uv_meta_stride = MSM_MEDIA_ROUNDUP((fb->width+1)>>1, y_tile_width / 2); 109 - layout->plane_pitch[3] = MSM_MEDIA_ALIGN(uv_meta_stride, 64); 119 + uv_meta_stride = DIV_ROUND_UP((fb->width+1)>>1, y_tile_width / 2); 120 + layout->plane_pitch[3] = round_up(uv_meta_stride, 64); 110 121 111 - uv_meta_scanlines = MSM_MEDIA_ROUNDUP((fb->height+1)>>1, y_tile_height); 112 - uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16); 113 - layout->plane_size[3] = MSM_MEDIA_ALIGN(layout->plane_pitch[3] * 122 + uv_meta_scanlines = DIV_ROUND_UP((fb->height+1)>>1, y_tile_height); 123 + uv_meta_scanlines = round_up(uv_meta_scanlines, 16); 124 + layout->plane_size[3] = round_up(layout->plane_pitch[3] * 114 125 uv_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 115 126 } else { 116 127 unsigned int rgb_scanlines, rgb_meta_scanlines, rgb_meta_stride; 117 128 118 - layout->plane_pitch[0] = MSM_MEDIA_ALIGN(fb->width * fmt->bpp, 256); 119 - rgb_scanlines = MSM_MEDIA_ALIGN(fb->height, 16); 120 - layout->plane_size[0] = MSM_MEDIA_ALIGN(layout->plane_pitch[0] * 129 + layout->plane_pitch[0] = round_up(fb->width * fmt->bpp, 256); 130 + rgb_scanlines = round_up(fb->height, 16); 131 + layout->plane_size[0] = round_up(layout->plane_pitch[0] * 121 132 rgb_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 122 133 123 134 if (!meta) ··· 127 136 /* uAPI leaves plane[1] empty and plane[2] as meta */ 128 137 layout->num_planes += 1; 129 138 130 - rgb_meta_stride = MSM_MEDIA_ROUNDUP(fb->width, 16); 131 - layout->plane_pitch[2] = MSM_MEDIA_ALIGN(rgb_meta_stride, 64); 139 + rgb_meta_stride = DIV_ROUND_UP(fb->width, 16); 140 + layout->plane_pitch[2] = round_up(rgb_meta_stride, 64); 132 141 133 - rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(fb->height, 4); 134 - rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16); 142 + rgb_meta_scanlines = DIV_ROUND_UP(fb->height, 4); 143 + rgb_meta_scanlines = round_up(rgb_meta_scanlines, 16); 135 144 136 - layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] * 145 + layout->plane_size[2] = round_up(layout->plane_pitch[2] * 137 146 rgb_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 138 147 } 139 148