diff mbox series

[v3,07/11] drm: xlnx: zynqmp: Use drm helpers when calculating buffer sizes

Message ID 20250212-xilinx-formats-v3-7-90d0fe106995@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series drm: Add new pixel formats for Xilinx Zynqmp | expand

Commit Message

Tomi Valkeinen Feb. 12, 2025, 2:56 p.m. UTC
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 XV15, XV20).

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/xlnx/zynqmp_disp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Feb. 13, 2025, 8:45 p.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Wed, Feb 12, 2025 at 04:56:11PM +0200, Tomi Valkeinen wrote:
> 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 XV15, XV20).
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/gpu/drm/xlnx/zynqmp_disp.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> index 80d1e499a18d..3d4ade571f0f 100644
> --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> @@ -1116,16 +1116,18 @@ 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;
> +		unsigned int width, height;

I'd got with one variable per line.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  		dma_addr_t dma_addr;
>  
> +		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;
diff mbox series

Patch

diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c
index 80d1e499a18d..3d4ade571f0f 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
@@ -1116,16 +1116,18 @@  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;
+		unsigned int width, height;
 		dma_addr_t dma_addr;
 
+		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;