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

media: mediatek: vcodec: Use vb2_find_buffer

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

Cc: Tiffany Lin <tiffany.lin@mediatek.com>
Cc: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
Cc: Yunfei Dong <yunfei.dong@mediatek.com>
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
25e3bc62 9d042e45

+10 -12
+3 -4
drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.c
··· 51 51 struct vb2_queue *vq; 52 52 struct vb2_buffer *vb; 53 53 struct vb2_v4l2_buffer *vb2_v4l2; 54 - int index, vb2_index; 54 + int index; 55 55 56 56 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 57 57 ··· 62 62 continue; 63 63 } 64 64 65 - vb2_index = vb2_find_timestamp(vq, dpb->reference_ts, 0); 66 - if (vb2_index < 0) { 65 + vb = vb2_find_buffer(vq, dpb->reference_ts); 66 + if (!vb) { 67 67 dev_err(&ctx->dev->plat_dev->dev, 68 68 "Reference invalid: dpb_index(%d) reference_ts(%lld)", 69 69 index, dpb->reference_ts); ··· 76 76 else 77 77 h264_dpb_info[index].reference_flag = 2; 78 78 79 - vb = vq->bufs[vb2_index]; 80 79 vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf); 81 80 h264_dpb_info[index].field = vb2_v4l2->field; 82 81
+3 -4
drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c
··· 237 237 struct vb2_queue *vq; 238 238 struct vb2_buffer *vb; 239 239 u64 referenct_ts; 240 - int index, vb2_index; 240 + int index; 241 241 242 242 frame_header = vdec_vp8_slice_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_VP8_FRAME); 243 243 if (IS_ERR(frame_header)) ··· 246 246 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 247 247 for (index = 0; index < 3; index++) { 248 248 referenct_ts = vdec_vp8_slice_get_ref_by_ts(frame_header, index); 249 - vb2_index = vb2_find_timestamp(vq, referenct_ts, 0); 250 - if (vb2_index < 0) { 249 + vb = vb2_find_buffer(vq, referenct_ts); 250 + if (!vb) { 251 251 if (!V4L2_VP8_FRAME_IS_KEY_FRAME(frame_header)) 252 252 mtk_vcodec_err(inst, "reference invalid: index(%d) ts(%lld)", 253 253 index, referenct_ts); ··· 256 256 } 257 257 inst->vsi->vp8_dpb_info[index].reference_flag = 1; 258 258 259 - vb = vq->bufs[vb2_index]; 260 259 inst->vsi->vp8_dpb_info[index].y_dma_addr = 261 260 vb2_dma_contig_plane_dma_addr(vb, 0); 262 261 if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2)
+4 -4
drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
··· 1672 1672 struct vdec_vp9_slice_reference *ref; 1673 1673 int plane; 1674 1674 int size; 1675 - int idx; 1676 1675 int w; 1677 1676 int h; 1678 1677 int i; ··· 1714 1715 */ 1715 1716 for (i = 0; i < 3; i++) { 1716 1717 ref = &vsi->frame.ref[i]; 1717 - idx = vb2_find_timestamp(vq, pfc->ref_idx[i], 0); 1718 - if (idx < 0) { 1718 + vb = vb2_find_buffer(vq, pfc->ref_idx[i]); 1719 + if (!vb) { 1719 1720 ref->frame_width = w; 1720 1721 ref->frame_height = h; 1721 1722 memset(&vsi->ref[i], 0, sizeof(vsi->ref[i])); 1722 1723 } else { 1724 + int idx = vb->index; 1725 + 1723 1726 ref->frame_width = instance->dpb[idx].width; 1724 1727 ref->frame_height = instance->dpb[idx].height; 1725 - vb = vq->bufs[idx]; 1726 1728 vsi->ref[i].y.dma_addr = 1727 1729 vb2_dma_contig_plane_dma_addr(vb, 0); 1728 1730 if (plane == 1)