Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: rkvdec: 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>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Ezequiel Garcia and committed by
Mauro Carvalho Chehab
c4d987de d642f7c8

+18 -31
+13 -26
drivers/staging/media/rkvdec/rkvdec-h264.c
··· 109 109 const struct v4l2_ctrl_h264_sps *sps; 110 110 const struct v4l2_ctrl_h264_pps *pps; 111 111 const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; 112 - int ref_buf_idx[V4L2_H264_NUM_DPB_ENTRIES]; 112 + struct vb2_buffer *ref_buf[V4L2_H264_NUM_DPB_ENTRIES]; 113 113 }; 114 114 115 115 struct rkvdec_h264_ctx { ··· 742 742 struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; 743 743 const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; 744 744 struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; 745 - int buf_idx = -1; 745 + struct vb2_buffer *buf = NULL; 746 746 747 747 if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) { 748 - buf_idx = vb2_find_timestamp(cap_q, 749 - dpb[i].reference_ts, 0); 750 - if (buf_idx < 0) 748 + buf = vb2_find_buffer(cap_q, dpb[i].reference_ts); 749 + if (!buf) 751 750 pr_debug("No buffer for reference_ts %llu", 752 751 dpb[i].reference_ts); 753 752 } 754 753 755 - run->ref_buf_idx[i] = buf_idx; 754 + run->ref_buf[i] = buf; 756 755 } 757 756 } 758 757 ··· 804 805 if (WARN_ON(ref->index >= ARRAY_SIZE(dec_params->dpb))) 805 806 continue; 806 807 807 - dpb_valid = run->ref_buf_idx[ref->index] >= 0; 808 + dpb_valid = run->ref_buf[ref->index] != NULL; 808 809 bottom = ref->fields == V4L2_H264_BOTTOM_FIELD_REF; 809 810 810 811 set_ps_field(hw_rps, DPB_INFO(i, j), ··· 880 881 RKVDEC_REG_H264_POC_REFER2(1) 881 882 }; 882 883 883 - static struct vb2_buffer * 884 - get_ref_buf(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run, 885 - unsigned int dpb_idx) 886 - { 887 - struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; 888 - struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; 889 - int buf_idx = run->ref_buf_idx[dpb_idx]; 890 - 891 - /* 892 - * If a DPB entry is unused or invalid, address of current destination 893 - * buffer is returned. 894 - */ 895 - if (buf_idx < 0) 896 - return &run->base.bufs.dst->vb2_buf; 897 - 898 - return vb2_get_buffer(cap_q, buf_idx); 899 - } 900 - 901 884 static void config_registers(struct rkvdec_ctx *ctx, 902 885 struct rkvdec_h264_run *run) 903 886 { ··· 952 971 953 972 /* config ref pic address & poc */ 954 973 for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { 955 - struct vb2_buffer *vb_buf = get_ref_buf(ctx, run, i); 974 + struct vb2_buffer *vb_buf = run->ref_buf[i]; 956 975 976 + /* 977 + * If a DPB entry is unused or invalid, address of current destination 978 + * buffer is returned. 979 + */ 980 + if (!vb_buf) 981 + vb_buf = &dst_buf->vb2_buf; 957 982 refer_addr = vb2_dma_contig_plane_dma_addr(vb_buf, 0); 958 983 959 984 if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)
+5 -5
drivers/staging/media/rkvdec/rkvdec-vp9.c
··· 383 383 { 384 384 struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; 385 385 struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; 386 - int buf_idx; 386 + struct vb2_buffer *buf; 387 387 388 388 /* 389 389 * If a ref is unused or invalid, address of current destination 390 390 * buffer is returned. 391 391 */ 392 - buf_idx = vb2_find_timestamp(cap_q, timestamp, 0); 393 - if (buf_idx < 0) 394 - return vb2_to_rkvdec_decoded_buf(&dst->vb2_buf); 392 + buf = vb2_find_buffer(cap_q, timestamp); 393 + if (!buf) 394 + buf = &dst->vb2_buf; 395 395 396 - return vb2_to_rkvdec_decoded_buf(vb2_get_buffer(cap_q, buf_idx)); 396 + return vb2_to_rkvdec_decoded_buf(buf); 397 397 } 398 398 399 399 static dma_addr_t get_mv_base_addr(struct rkvdec_decoded_buffer *buf)