media: hantro: Use vb2_find_buffer

Use the newly introduced vb2_find_buffer API to get a vb2_buffer
given a buffer timestamp.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
Ezequiel Garcia 2022-07-11 22:11:38 +01:00 committed by Mauro Carvalho Chehab
parent 5b25e5432b
commit d642f7c842
2 changed files with 7 additions and 9 deletions

View File

@ -47,12 +47,10 @@ dma_addr_t hantro_get_ref(struct hantro_ctx *ctx, u64 ts)
{ {
struct vb2_queue *q = v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx); struct vb2_queue *q = v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx);
struct vb2_buffer *buf; struct vb2_buffer *buf;
int index;
index = vb2_find_timestamp(q, ts, 0); buf = vb2_find_buffer(q, ts);
if (index < 0) if (!buf)
return 0; return 0;
buf = vb2_get_buffer(q, index);
return hantro_get_dec_buf_addr(ctx, buf); return hantro_get_dec_buf_addr(ctx, buf);
} }

View File

@ -111,17 +111,17 @@ get_ref_buf(struct hantro_ctx *ctx, struct vb2_v4l2_buffer *dst, u64 timestamp)
{ {
struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q;
int buf_idx; struct vb2_buffer *buf;
/* /*
* If a ref is unused or invalid, address of current destination * If a ref is unused or invalid, address of current destination
* buffer is returned. * buffer is returned.
*/ */
buf_idx = vb2_find_timestamp(cap_q, timestamp, 0); buf = vb2_find_buffer(cap_q, timestamp);
if (buf_idx < 0) if (!buf)
return vb2_to_hantro_decoded_buf(&dst->vb2_buf); buf = &dst->vb2_buf;
return vb2_to_hantro_decoded_buf(vb2_get_buffer(cap_q, buf_idx)); return vb2_to_hantro_decoded_buf(buf);
} }
static void update_dec_buf_info(struct hantro_decoded_buffer *buf, static void update_dec_buf_info(struct hantro_decoded_buffer *buf,