Skip to content

Commit

Permalink
media: staging: rkisp1: cap: don't set next buffer from rkisp1_vb2_bu…
Browse files Browse the repository at this point in the history
…f_queue

The function 'rkisp1_vb2_buf_queue' sets the next buffer directly
in case the capture is already streaming but no frame yet arrived
from the sensor. This is an optimization that tries to avoid
dropping a frame.
The call atomic_read(&cap->rkisp1->isp.frame_sequence) is used
to check if a frame arrived. Reading the 'frame_sequence' should
be avoided outside irq handlers to avoid race conditions.

This patch removes this optimization. Dropping of the first
frames can be avoided if userspace queues the buffers before
start streaming. If userspace starts queueing buffers
only after calling 'streamon' he risks frame drops anyway.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
  • Loading branch information
Dafna Hirschfeld authored and Mauro Carvalho Chehab committed Jul 19, 2020
1 parent 2cc6a9f commit aa86e0b
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions drivers/staging/media/rkisp1/rkisp1-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,18 +743,7 @@ static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb)
ispbuf->buff_addr[RKISP1_PLANE_CB]);

spin_lock_irqsave(&cap->buf.lock, flags);

/*
* If there's no next buffer assigned, queue this buffer directly
* as the next buffer, and update the memory interface.
*/
if (cap->is_streaming && !cap->buf.next &&
atomic_read(&cap->rkisp1->isp.frame_sequence) == -1) {
cap->buf.next = ispbuf;
rkisp1_set_next_buf(cap);
} else {
list_add_tail(&ispbuf->queue, &cap->buf.queue);
}
list_add_tail(&ispbuf->queue, &cap->buf.queue);
spin_unlock_irqrestore(&cap->buf.lock, flags);
}

Expand Down

0 comments on commit aa86e0b

Please sign in to comment.