Commit 3dd8c097 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab
Browse files

media: vb2: Introduce a vb2_get_buffer accessor



Some drivers need to access a vb2 buffer from its
queue index. Introduce an accessor to abstract this,
and avoid drivers from accessing private members.

Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent a84e355e
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -1163,6 +1163,24 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q)
	q->last_buffer_dequeued = false;
}

/**
 * vb2_get_buffer() - get a buffer from a queue
 * @q:		pointer to &struct vb2_queue with videobuf2 queue.
 * @index:	buffer index
 *
 * This function obtains a buffer from a queue, by its index.
 * Keep in mind that there is no refcounting involved in this
 * operation, so the buffer lifetime should be taken into
 * consideration.
 */
static inline struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q,
						unsigned int index)
{
	if (index < q->num_buffers)
		return q->bufs[index];
	return NULL;
}

/*
 * The following functions are not part of the vb2 core API, but are useful
 * functions for videobuf2-*.