From: Tomi Valkeinen Date: Thu, 23 Apr 2026 14:21:18 +0000 (+0300) Subject: drm: xlnx: zynqmp: Use drm helpers when calculating buffer sizes X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=f5e096f0f494fbab20f0879395f0d3f2033b0ca1;p=thirdparty%2Fkernel%2Flinux.git drm: xlnx: zynqmp: Use drm helpers when calculating buffer sizes Use drm helpers, drm_format_info_plane_width(), drm_format_info_plane_height() and drm_format_info_min_pitch() to calculate sizes for the DMA. This cleans up the code, but also makes it possible to support more complex formats (like P030, P230). Reviewed-by: Laurent Pinchart Link: https://patch.msgid.link/20260423-xilinx-formats-v10-7-c690c2b8ea89@ideasonboard.com Signed-off-by: Tomi Valkeinen --- diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c index 9a8f38230cb4e..12a8d643915f9 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c @@ -1116,16 +1116,19 @@ int zynqmp_disp_layer_update(struct zynqmp_disp_layer *layer, return 0; for (i = 0; i < info->num_planes; i++) { - unsigned int width = state->crtc_w / (i ? info->hsub : 1); - unsigned int height = state->crtc_h / (i ? info->vsub : 1); struct zynqmp_disp_layer_dma *dma = &layer->dmas[i]; struct dma_async_tx_descriptor *desc; dma_addr_t dma_addr; + unsigned int width; + unsigned int height; + + width = drm_format_info_plane_width(info, state->crtc_w, i); + height = drm_format_info_plane_height(info, state->crtc_h, i); dma_addr = drm_fb_dma_get_gem_addr(state->fb, state, i); dma->xt.numf = height; - dma->sgl.size = width * info->cpp[i]; + dma->sgl.size = drm_format_info_min_pitch(info, i, width); dma->sgl.icg = state->fb->pitches[i] - dma->sgl.size; dma->xt.src_start = dma_addr; dma->xt.frame_size = 1;