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

media: videobuf2: Add helper to get queue number of buffers

In the future a side effect of introducing DELETE_BUFS ioctl is
the create of 'holes' (i.e. unused buffers) in bufs arrays.
To know which entries of the bufs arrays are used a bitmap will
be added in struct vb2_queue. That will also mean that the number
of buffers will be computed given the number of bit set in this bitmap.
To smoothly allow this evolution all drives must stop using
directly num_buffers field from struct vb2_queue.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Benjamin Gaignard and committed by
Mauro Carvalho Chehab
741d0f6b 5287f489

+10 -1
+10 -1
include/media/videobuf2-core.h
··· 1140 1140 } 1141 1141 1142 1142 /** 1143 + * vb2_get_num_buffers() - get the number of buffer in a queue 1144 + * @q: pointer to &struct vb2_queue with videobuf2 queue. 1145 + */ 1146 + static inline unsigned int vb2_get_num_buffers(struct vb2_queue *q) 1147 + { 1148 + return q->num_buffers; 1149 + } 1150 + 1151 + /** 1143 1152 * vb2_is_busy() - return busy status of the queue. 1144 1153 * @q: pointer to &struct vb2_queue with videobuf2 queue. 1145 1154 * ··· 1156 1147 */ 1157 1148 static inline bool vb2_is_busy(struct vb2_queue *q) 1158 1149 { 1159 - return (q->num_buffers > 0); 1150 + return vb2_get_num_buffers(q) > 0; 1160 1151 } 1161 1152 1162 1153 /**