media: v4l2-mem2mem: add v4l2_m2m_buf_copy_data helper function

Memory-to-memory devices should copy various parts of
struct v4l2_buffer from the output buffer to the capture buffer.

Add a helper function that does that to simplify the driver code.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Hans Verkuil 2018-11-13 03:52:18 -05:00 коммит произвёл Mauro Carvalho Chehab
Родитель 5f5b4fa522
Коммит e2d8ffe2e7
2 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -975,6 +975,26 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx,
}
EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue);
void v4l2_m2m_buf_copy_data(const struct vb2_v4l2_buffer *out_vb,
struct vb2_v4l2_buffer *cap_vb,
bool copy_frame_flags)
{
u32 mask = V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
if (copy_frame_flags)
mask |= V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_PFRAME |
V4L2_BUF_FLAG_BFRAME;
cap_vb->vb2_buf.timestamp = out_vb->vb2_buf.timestamp;
if (out_vb->flags & V4L2_BUF_FLAG_TIMECODE)
cap_vb->timecode = out_vb->timecode;
cap_vb->field = out_vb->field;
cap_vb->flags &= ~mask;
cap_vb->flags |= out_vb->flags & mask;
}
EXPORT_SYMBOL_GPL(v4l2_m2m_buf_copy_data);
void v4l2_m2m_request_queue(struct media_request *req)
{
struct media_request_object *obj, *obj_safe;

Просмотреть файл

@ -622,6 +622,26 @@ v4l2_m2m_dst_buf_remove_by_idx(struct v4l2_m2m_ctx *m2m_ctx, unsigned int idx)
return v4l2_m2m_buf_remove_by_idx(&m2m_ctx->cap_q_ctx, idx);
}
/**
* v4l2_m2m_buf_copy_data() - copy buffer data from the output buffer to the
* capture buffer
*
* @out_vb: the output buffer that is the source of the data.
* @cap_vb: the capture buffer that will receive the data.
* @copy_frame_flags: copy the KEY/B/PFRAME flags as well.
*
* This helper function copies the timestamp, timecode (if the TIMECODE
* buffer flag was set), field and the TIMECODE, KEYFRAME, BFRAME, PFRAME
* and TSTAMP_SRC_MASK flags from @out_vb to @cap_vb.
*
* If @copy_frame_flags is false, then the KEYFRAME, BFRAME and PFRAME
* flags are not copied. This is typically needed for encoders that
* set this bits explicitly.
*/
void v4l2_m2m_buf_copy_data(const struct vb2_v4l2_buffer *out_vb,
struct vb2_v4l2_buffer *cap_vb,
bool copy_frame_flags);
/* v4l2 request helper */
void v4l2_m2m_request_queue(struct media_request *req);