Skip to content

Commit

Permalink
media: hantro: Empty encoder capture buffers by default
Browse files Browse the repository at this point in the history
[ Upstream commit 309373a ]

The payload size for encoder capture buffers is set by the driver upon
finishing encoding each frame, based on the encoded length returned from
hardware, and whatever header and padding length used. Setting a
non-zero default serves no real purpose, and also causes issues if the
capture buffer is returned to userspace unused, confusing the
application.

Instead, always set the payload size to 0 for encoder capture buffers
when preparing them.

Fixes: 775fec6 ("media: add Rockchip VPU JPEG encoder driver")
Fixes: 082aaec ("media: hantro: Fix .buf_prepare")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
wens authored and gregkh committed Jun 9, 2022
1 parent 461e4c1 commit b6b70cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/staging/media/hantro/hantro_v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,12 @@ static int hantro_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->plane_fmt[0].sizeimage);
if (V4L2_TYPE_IS_CAPTURE(vq->type)) {
if (ctx->is_encoder)
vb2_set_plane_payload(vb, 0, 0);
else
vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
}

return 0;
}
Expand Down

0 comments on commit b6b70cd

Please sign in to comment.