Commit e2d8ffe2 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

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: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: default avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 5f5b4fa5
...@@ -975,6 +975,26 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, ...@@ -975,6 +975,26 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx,
} }
EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue); 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) void v4l2_m2m_request_queue(struct media_request *req)
{ {
struct media_request_object *obj, *obj_safe; 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) ...@@ -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); 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 */ /* v4l2 request helper */
void v4l2_m2m_request_queue(struct media_request *req); void v4l2_m2m_request_queue(struct media_request *req);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment