From: Naushir Patuck <naush@raspberrypi.com>
To: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>
Cc: linux-media@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, jacopo.mondi@ideasonboard.com,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
Naushir Patuck <naush@raspberrypi.com>
Subject: [PATCH v1 1/5] drivers: media: bcm2835-unicam: Improve frame sequence count handling
Date: Fri, 22 Nov 2024 08:41:48 +0000 [thread overview]
Message-ID: <20241122084152.1841419-2-naush@raspberrypi.com> (raw)
In-Reply-To: <20241122084152.1841419-1-naush@raspberrypi.com>
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>
---
.../media/platform/broadcom/bcm2835-unicam.c | 22 +++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c
index 3aed0e493c81..36fb186a0421 100644
--- a/drivers/media/platform/broadcom/bcm2835-unicam.c
+++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
@@ -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);
}
--
2.34.1
next prev parent reply other threads:[~2024-11-22 8:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 8:41 [PATCH v1 0/5] media: bcm2835-unicam: Upstreaming various improvements Naushir Patuck
2024-11-22 8:41 ` Naushir Patuck [this message]
2024-11-22 14:45 ` [PATCH v1 1/5] drivers: media: bcm2835-unicam: Improve frame sequence count handling Jacopo Mondi
2024-11-22 8:41 ` [PATCH v1 2/5] drivers: media: bcm2835-unicam: Allow setting of unpacked formats Naushir Patuck
2024-11-22 11:16 ` Jacopo Mondi
2024-11-22 8:41 ` [PATCH v1 3/5] drivers: media: bcm2835-unicam: Disable trigger mode operation Naushir Patuck
2024-11-22 11:18 ` Jacopo Mondi
2024-11-22 8:41 ` [PATCH v1 4/5] drivers: media: bcm2835-unicam: Fix for possible dummy buffer overrun Naushir Patuck
2024-11-22 11:20 ` Jacopo Mondi
2024-11-22 11:35 ` Naushir Patuck
2024-11-22 14:42 ` Jacopo Mondi
2024-11-22 8:41 ` [PATCH v1 5/5] drivers: media: bcm2835-unicam: Correctly handle FS + FE ISR condition Naushir Patuck
2024-11-22 11:16 ` Jacopo Mondi
2024-11-22 11:40 ` Naushir Patuck
2024-11-22 14:41 ` Jacopo Mondi
2024-11-22 14:48 ` Jacopo Mondi
2024-11-24 7:04 ` Laurent Pinchart
2024-11-25 8:37 ` Naushir Patuck
2024-11-25 9:23 ` Laurent Pinchart
2024-11-25 9:46 ` Naushir Patuck
2024-11-25 10:27 ` Laurent Pinchart
2024-11-25 10:46 ` Naushir Patuck
2024-11-25 11:00 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241122084152.1841419-2-naush@raspberrypi.com \
--to=naush@raspberrypi.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=florian.fainelli@broadcom.com \
--cc=jacopo.mondi@ideasonboard.com \
--cc=kernel-list@raspberrypi.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox