From: bryan.odonoghue@linaro.org
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
Loic Poulain <loic.poulain@oss.qualcomm.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, Bryan O'Donoghue <bod@kernel.org>
Subject: [PATCH v3 02/11] media: qcom: camss: Introduce SOF sequence tracking
Date: Sat, 07 Nov 2026 01:01:45 +0000 [thread overview]
Message-ID: <20261107-v4l2-frame-sync-v3-2-e5bf7073a35d@kernel.org> (raw)
In-Reply-To: <20261107-v4l2-frame-sync-v3-0-e5bf7073a35d@kernel.org>
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
In order to communicate to user-space CSI2 SOF events we will need to hook
into and control v4l2_ctrl_subdev_subscribe_event. In-line with other
implementations of FRAME_SYNC have CSI decoders which support the event
always generate it in our case if and only if an atomic user count
indicates it should be so.
A flag in the CSID descriptor indicates if frame_sync_en is supported so
for each SoC that supports it this flag should be true. Since bool is false
by default no negative enumeration of existing or in-flight CSID is
required.
Subsequent patches will enable on a per-CSID basis.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
---
drivers/media/platform/qcom/camss/camss-csid.c | 54 +++++++++++++++++++++++++-
drivers/media/platform/qcom/camss/camss-csid.h | 12 ++++++
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index a00791b00feb7..7f33fb81ca8cc 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -760,6 +760,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
static int csid_set_stream(struct v4l2_subdev *sd, int enable)
{
struct csid_device *csid = v4l2_get_subdevdata(sd);
+ unsigned int i;
int ret;
if (enable) {
@@ -778,6 +779,10 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)
}
if (csid->phy.need_vc_update) {
+ /* Set to -1 as we want to do atomic_inc_return to read */
+ for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS; i++)
+ atomic_set(&csid->sof_seq[i], -1);
+
csid->res->hw_ops->configure_stream(csid, enable);
csid->phy.need_vc_update = false;
}
@@ -1316,9 +1321,56 @@ static int csid_link_setup(struct media_entity *entity,
return 0;
}
+static int csid_frame_sync_add(struct v4l2_subscribed_event *sev, unsigned int elems)
+{
+ struct csid_device *csid = v4l2_get_subdevdata(vdev_to_v4l2_subdev(sev->fh->vdev));
+
+ atomic_inc(&csid->frame_sync_users);
+
+ return 0;
+}
+
+static void csid_frame_sync_del(struct v4l2_subscribed_event *sev)
+{
+ struct csid_device *csid = v4l2_get_subdevdata(vdev_to_v4l2_subdev(sev->fh->vdev));
+
+ atomic_dec(&csid->frame_sync_users);
+}
+
+static const struct v4l2_subscribed_event_ops csid_frame_sync_ops = {
+ .add = csid_frame_sync_add,
+ .del = csid_frame_sync_del,
+};
+
+static int csid_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
+ struct v4l2_event_subscription *sub)
+{
+ struct csid_device *csid = v4l2_get_subdevdata(sd);
+
+ if (sub->type != V4L2_EVENT_FRAME_SYNC)
+ return v4l2_ctrl_subdev_subscribe_event(sd, fh, sub);
+
+ if (!csid->res->frame_sync_en)
+ return -EINVAL;
+
+ return v4l2_event_subscribe(fh, sub, 0, &csid_frame_sync_ops);
+}
+
+void csid_sof_event(struct csid_device *csid, unsigned int id)
+{
+ struct v4l2_event event = {
+ .type = V4L2_EVENT_FRAME_SYNC,
+ .u.frame_sync.frame_sequence =
+ atomic_inc_return(&csid->sof_seq[id]),
+ };
+
+ if (atomic_read(&csid->frame_sync_users))
+ v4l2_event_queue(csid->subdev.devnode, &event);
+}
+
static const struct v4l2_subdev_core_ops csid_core_ops = {
.s_power = csid_set_power,
- .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+ .subscribe_event = csid_subscribe_event,
.unsubscribe_event = v4l2_event_subdev_unsubscribe,
};
diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
index 5296b10f6bac8..a9d88909d37fc 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.h
+++ b/drivers/media/platform/qcom/camss/camss-csid.h
@@ -141,6 +141,7 @@ struct csid_hw_ops {
struct csid_subdev_resources {
bool is_lite;
+ bool frame_sync_en;
const struct csid_hw_ops *hw_ops;
const struct parent_dev_ops *parent_dev_ops;
const struct csid_formats *formats;
@@ -167,6 +168,8 @@ struct csid_device {
struct v4l2_ctrl_handler ctrls;
struct v4l2_ctrl *testgen_mode;
const struct csid_subdev_resources *res;
+ atomic_t frame_sync_users;
+ atomic_t sof_seq[MSM_CSID_MAX_SRC_STREAMS];
};
struct camss_subdev_resources;
@@ -248,4 +251,13 @@ u32 csid_hw_version(struct csid_device *csid);
u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
unsigned int match_format_idx, u32 match_code);
+/*
+ * csid_sof_event - Track SOF generate V4L2_EVENT_FRAME_SYNC
+ * @csid: CSID device
+ * @id: CSID src-stream ID
+ *
+ * Called from the CSID interrupt handler on SOF of the path driving the event.
+ */
+void csid_sof_event(struct csid_device *csid, unsigned int id);
+
#endif /* QC_MSM_CAMSS_CSID_H */
--
2.56.0
next prev parent reply other threads:[~2026-11-07 1:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 1:01 [PATCH v3 00/11] Add SOF sequence logic bryan.odonoghue
2026-11-07 1:01 ` [PATCH v3 01/11] media: qcom: camss: Introduce CPU latency QoS during streaming bryan.odonoghue
2026-11-07 1:01 ` bryan.odonoghue [this message]
2026-11-09 9:35 ` [PATCH v3 02/11] media: qcom: camss: Introduce SOF sequence tracking Loic Poulain
2026-11-07 1:01 ` [PATCH v3 03/11] media: qcom: camss: Use SOF sequence tracking for vb.sequence bryan.odonoghue
2026-11-09 9:49 ` Loic Poulain
2026-11-09 15:50 ` Bryan O'Donoghue
2026-11-07 1:01 ` [PATCH v3 04/11] media: qcom: camss: csid-gen3: Enable RDI SOF driving bryan.odonoghue
2026-11-07 1:01 ` [PATCH v3 05/11] media: qcom: camss: csid-680: Enable RDI SOF tracking bryan.odonoghue
2026-11-07 1:01 ` [PATCH v3 06/11] media: qcom: camss: csid-gen2: " bryan.odonoghue
2026-11-07 1:01 ` [PATCH v3 07/11] media: qcom: camss: csid-340: " bryan.odonoghue
2026-11-09 15:49 ` Bryan O'Donoghue
2026-11-07 1:01 ` [PATCH v3 08/11] media: qcom: camss: Switch on frame_sync_en logic for csid-gen3 bryan.odonoghue
2026-11-09 9:56 ` Loic Poulain
2026-11-10 6:38 ` Gjorgji Rosikopulos (Consultant)
2026-11-07 1:01 ` [PATCH v3 09/11] media: qcom: camss: Switch on frame_sync_en for x1e/x2e bryan.odonoghue
2026-11-07 1:01 ` [PATCH v3 10/11] media: qcom: camss: Switch on frame_sync_en for csid-gen2 bryan.odonoghue
2026-11-07 1:01 ` [PATCH v3 11/11] media: qcom: camss: Switch on frame_sync_en for csid-340 bryan.odonoghue
2026-11-09 15:49 ` Bryan O'Donoghue
2026-11-09 17:31 ` [PATCH v3 00/11] Add SOF sequence logic Gjorgji Rosikopulos (Consultant)
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=20261107-v4l2-frame-sync-v3-2-e5bf7073a35d@kernel.org \
--to=bryan.odonoghue@linaro.org \
--cc=bod@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mchehab@kernel.org \
--cc=vladimir.zapolskiy@linaro.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.