mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 18:13:41 +02:00
media: bcm2835-unicam: Improve frame sequence count handling
Ensure that the frame sequence counter is incremented only if a previous frame start interrupt has occurred, or a frame start + frame end has occurred simultaneously. This corresponds the sequence number with the actual number of frames produced by the sensor, not the number of frame buffers dequeued back to userland. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
fb6ba073ff
commit
f21ebe2c7d
|
|
@ -199,6 +199,7 @@ struct unicam_device {
|
|||
/* subdevice async notifier */
|
||||
struct v4l2_async_notifier notifier;
|
||||
unsigned int sequence;
|
||||
bool frame_started;
|
||||
|
||||
/* Sensor node */
|
||||
struct {
|
||||
|
|
@ -742,6 +743,8 @@ static irqreturn_t unicam_isr(int irq, void *dev)
|
|||
* buffer forever.
|
||||
*/
|
||||
if (fe) {
|
||||
bool inc_seq = unicam->frame_started;
|
||||
|
||||
/*
|
||||
* Ensure we have swapped buffers already as we can't
|
||||
* stop the peripheral. If no buffer is available, use a
|
||||
|
|
@ -761,11 +764,24 @@ static irqreturn_t unicam_isr(int irq, void *dev)
|
|||
* + FS + LS). In this case, we cannot signal the buffer
|
||||
* as complete, as the HW will reuse that buffer.
|
||||
*/
|
||||
if (node->cur_frm && node->cur_frm != node->next_frm)
|
||||
if (node->cur_frm && node->cur_frm != node->next_frm) {
|
||||
unicam_process_buffer_complete(node, sequence);
|
||||
inc_seq = true;
|
||||
}
|
||||
node->cur_frm = node->next_frm;
|
||||
}
|
||||
unicam->sequence++;
|
||||
|
||||
/*
|
||||
* Increment the sequence number conditionally on either a FS
|
||||
* having already occurred, or in the FE + FS condition as
|
||||
* caught in the FE handler above. This ensures the sequence
|
||||
* number corresponds to the frames generated by the sensor, not
|
||||
* the frames dequeued to userland.
|
||||
*/
|
||||
if (inc_seq) {
|
||||
unicam->sequence++;
|
||||
unicam->frame_started = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ista & UNICAM_FSI) {
|
||||
|
|
@ -795,6 +811,7 @@ static irqreturn_t unicam_isr(int irq, void *dev)
|
|||
}
|
||||
|
||||
unicam_queue_event_sof(unicam);
|
||||
unicam->frame_started = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1413,6 +1430,7 @@ static int unicam_sd_enable_streams(struct v4l2_subdev *sd,
|
|||
if (unicam->pipe.nodes & BIT(UNICAM_METADATA_NODE))
|
||||
unicam_start_metadata(unicam);
|
||||
|
||||
unicam->frame_started = false;
|
||||
unicam_start_rx(unicam, state);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user