Re: [PATCH 2/2] media: cedrus: report only the picture as capture payload

From: Jernej Škrabec

Date: Thu Nov 26 2026 - 12:22:41 EST


Dne četrtek, 19. november 2026 ob 17:34:48 Srednjeevropski standardni čas je Arun Iyengar via B4 Relay napisal(a):
> From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
>
> For 10-bit H.265 the driver appends the low 2 bits of every sample to
> the capture buffer and counts them in sizeimage (extra_cap_size).
> buf_prepare reports the whole sizeimage as bytesused, so userspace that
> copies the payload gets the private plane as part of the picture.
>
> Report only the picture; sizeimage stays the allocation size.
>
> Fixes: 65429ba82572 ("media: cedrus: h265: Support decoding 10-bit frames")
> Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>

Reviewed-by: Jernej Skrabec <jernej.skrabec@xxxxxxxxx>

Best regards,
Jernej

> ---
> drivers/staging/media/sunxi/cedrus/cedrus_video.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> index 9b2d24e77fdb..b7e0cbe548e6 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> @@ -511,8 +511,15 @@ static int cedrus_buf_prepare(struct vb2_buffer *vb)
> * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets
> * it to buffer length).
> */
> - if (V4L2_TYPE_IS_CAPTURE(vq->type))
> - vb2_set_plane_payload(vb, 0, pix_fmt->sizeimage);
> + if (V4L2_TYPE_IS_CAPTURE(vq->type)) {
> + unsigned int payload = pix_fmt->sizeimage;
> +
> + if (ctx->current_codec->extra_cap_size)
> + payload -= ctx->current_codec->extra_cap_size(ctx,
> + pix_fmt);
> +
> + vb2_set_plane_payload(vb, 0, payload);
> + }
>
> return 0;
> }
>
>