aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-03-09 20:42:52 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-25 10:37:49 -0400
commit34ea4d4417bb726245fdaeb2f8951eaa0c18fc4c (patch)
tree9953e2cfbfc8075dee2b7775fdb6c5d157d83a9b /drivers/media
parent08344492b350870db4499c7b90220030f07a5d4b (diff)
[media] v4l: vb2: Add a function to discard all DONE buffers
When suspending a device while a video stream is active all buffers marked as done but not dequeued yet will be kept across suspend and given back to userspace after resume. This will result in outdated buffers being dequeued. Introduce a new vb2 function to mark all done buffers as erroneous instead, to be used by drivers at resume time. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 349e659d75fb..7c4489c42365 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1200,6 +1200,30 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
1200EXPORT_SYMBOL_GPL(vb2_buffer_done); 1200EXPORT_SYMBOL_GPL(vb2_buffer_done);
1201 1201
1202/** 1202/**
1203 * vb2_discard_done() - discard all buffers marked as DONE
1204 * @q: videobuf2 queue
1205 *
1206 * This function is intended to be used with suspend/resume operations. It
1207 * discards all 'done' buffers as they would be too old to be requested after
1208 * resume.
1209 *
1210 * Drivers must stop the hardware and synchronize with interrupt handlers and/or
1211 * delayed works before calling this function to make sure no buffer will be
1212 * touched by the driver and/or hardware.
1213 */
1214void vb2_discard_done(struct vb2_queue *q)
1215{
1216 struct vb2_buffer *vb;
1217 unsigned long flags;
1218
1219 spin_lock_irqsave(&q->done_lock, flags);
1220 list_for_each_entry(vb, &q->done_list, done_entry)
1221 vb->state = VB2_BUF_STATE_ERROR;
1222 spin_unlock_irqrestore(&q->done_lock, flags);
1223}
1224EXPORT_SYMBOL_GPL(vb2_discard_done);
1225
1226/**
1203 * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a 1227 * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
1204 * v4l2_buffer by the userspace. The caller has already verified that struct 1228 * v4l2_buffer by the userspace. The caller has already verified that struct
1205 * v4l2_buffer has a valid number of planes. 1229 * v4l2_buffer has a valid number of planes.