Skip to content

Commit 9436def

Browse files
naushirherrnst
authored andcommitted
media: bcm2835-unicam: Correctly handle FS + FE ISR condtion
If we get a simultaneous FS + FE interrupt for the same frame, it cannot be marked as completed and returned to userland as the framebuffer will be refilled by Unicam on the next sensor frame. Additionally, the timestamp will be set to 0 as the FS interrupt handling code will not have run yet. To avoid these problems, the frame is considered dropped in the FE handler, and will be returned to userland on the subsequent sensor frame. Signed-off-by: Naushir Patuck <[email protected]>
1 parent 9184557 commit 9436def

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

drivers/media/platform/bcm2835/bcm2835-unicam.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,9 @@ static irqreturn_t unicam_isr(int irq, void *dev)
919919
* to use.
920920
*/
921921
for (i = 0; i < ARRAY_SIZE(unicam->node); i++) {
922-
if (!unicam->node[i].streaming)
922+
struct unicam_node *node = &unicam->node[i];
923+
924+
if (!node->streaming)
923925
continue;
924926

925927
/*
@@ -929,14 +931,24 @@ static irqreturn_t unicam_isr(int irq, void *dev)
929931
* + FS + LS). In this case, we cannot signal the buffer
930932
* as complete, as the HW will reuse that buffer.
931933
*/
932-
if (unicam->node[i].cur_frm &&
933-
unicam->node[i].cur_frm != unicam->node[i].next_frm) {
934-
unicam_process_buffer_complete(&unicam->node[i],
935-
sequence);
936-
unicam->node[i].cur_frm = unicam->node[i].next_frm;
937-
unicam->node[i].next_frm = NULL;
934+
if (node->cur_frm && node->cur_frm != node->next_frm) {
935+
/*
936+
* This condition checks if FE + FS for the same
937+
* frame has occurred. In such cases, we cannot
938+
* return out the frame, as no buffer handling
939+
* or timestamping has yet been done as part of
940+
* the FS handler.
941+
*/
942+
if (!node->cur_frm->vb.vb2_buf.timestamp) {
943+
unicam_dbg(2, unicam, "ISR: FE without FS, dropping frame\n");
944+
continue;
945+
}
946+
947+
unicam_process_buffer_complete(node, sequence);
948+
node->cur_frm = node->next_frm;
949+
node->next_frm = NULL;
938950
} else {
939-
unicam->node[i].cur_frm = unicam->node[i].next_frm;
951+
node->cur_frm = node->next_frm;
940952
}
941953
}
942954
unicam->sequence++;

0 commit comments

Comments
 (0)