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: simplify _dpu_format_populate_plane_sizes_*

Move common bits of _dpu_format_populate_plane_sizes_ubwc() and
_linear() to dpu_format_populate_plane_sizes(), reducing unnecessary
duplication and simplifying code flow fror the UBWC function.

Reviewed-by: Jessica Zhang <jessica.zhang@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/688178/
Link: https://lore.kernel.org/r/20251114-dpu-formats-v3-9-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>

+20 -23
+20 -23
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
··· 95 95 struct drm_framebuffer *fb, 96 96 struct dpu_hw_fmt_layout *layout) 97 97 { 98 - int i; 99 98 int color; 100 99 bool meta = MSM_FORMAT_IS_UBWC(fmt); 101 - 102 - memset(layout, 0, sizeof(struct dpu_hw_fmt_layout)); 103 - layout->width = fb->width; 104 - layout->height = fb->height; 105 - layout->num_planes = fmt->num_planes; 106 100 107 101 color = _dpu_format_get_media_color_ubwc(fmt); 108 102 if (color < 0) { ··· 122 128 uv_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 123 129 124 130 if (!meta) 125 - goto done; 131 + return 0; 126 132 127 133 layout->num_planes += 2; 128 134 layout->plane_pitch[2] = VENUS_Y_META_STRIDE(color, fb->width); ··· 146 152 rgb_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 147 153 148 154 if (!meta) 149 - goto done; 155 + return 0; 156 + 150 157 layout->num_planes += 2; 151 158 layout->plane_pitch[2] = VENUS_RGB_META_STRIDE(color, fb->width); 152 159 rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color, fb->height); 153 160 layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] * 154 161 rgb_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT); 155 162 } 156 - 157 - done: 158 - for (i = 0; i < DPU_MAX_PLANES; i++) 159 - layout->total_size += layout->plane_size[i]; 160 163 161 164 return 0; 162 165 } ··· 164 173 struct dpu_hw_fmt_layout *layout) 165 174 { 166 175 int i; 167 - 168 - memset(layout, 0, sizeof(struct dpu_hw_fmt_layout)); 169 - layout->width = fb->width; 170 - layout->height = fb->height; 171 - layout->num_planes = fmt->num_planes; 172 176 173 177 /* Due to memset above, only need to set planes of interest */ 174 178 if (fmt->fetch_type == MDP_PLANE_INTERLEAVED) { ··· 221 235 } 222 236 } 223 237 224 - for (i = 0; i < DPU_MAX_PLANES; i++) 225 - layout->total_size += layout->plane_size[i]; 226 - 227 238 return 0; 228 239 } 229 240 ··· 237 254 struct dpu_hw_fmt_layout *layout) 238 255 { 239 256 const struct msm_format *fmt; 257 + int ret, i; 240 258 241 259 if (!layout || !fb) { 242 260 DRM_ERROR("invalid pointer\n"); ··· 252 268 253 269 fmt = msm_framebuffer_format(fb); 254 270 255 - if (MSM_FORMAT_IS_UBWC(fmt) || MSM_FORMAT_IS_TILE(fmt)) 256 - return _dpu_format_populate_plane_sizes_ubwc(fmt, fb, layout); 271 + memset(layout, 0, sizeof(struct dpu_hw_fmt_layout)); 272 + layout->width = fb->width; 273 + layout->height = fb->height; 274 + layout->num_planes = fmt->num_planes; 257 275 258 - return _dpu_format_populate_plane_sizes_linear(fmt, fb, layout); 276 + if (MSM_FORMAT_IS_UBWC(fmt) || MSM_FORMAT_IS_TILE(fmt)) 277 + ret = _dpu_format_populate_plane_sizes_ubwc(fmt, fb, layout); 278 + else 279 + ret = _dpu_format_populate_plane_sizes_linear(fmt, fb, layout); 280 + 281 + if (ret) 282 + return ret; 283 + 284 + for (i = 0; i < DPU_MAX_PLANES; i++) 285 + layout->total_size += layout->plane_size[i]; 286 + 287 + return 0; 259 288 } 260 289 261 290 static void _dpu_format_populate_addrs_ubwc(struct drm_framebuffer *fb,