mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gjorgji Rosikopulos (Consultant)" <gjorgji.rosikopulos@oss.qualcomm.com>
To: Loic Poulain <loic.poulain@oss.qualcomm.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v4 10/14] media: qcom: camss: csid: Let a consumer hook into the frame start
Date: Fri, 4 Dec 2026 15:18:48 +0200	[thread overview]
Message-ID: <cdc3058e-4caf-4874-95de-d5873669212b@oss.qualcomm.com> (raw)
In-Reply-To: <20261203-camss-hw-ts-v4-10-c271022b4b0d@oss.qualcomm.com>

Hi Loic,

On 12/3/2026 6:53 PM, Loic Poulain wrote:
> The CSID publishes what it knows about a frame start and leaves a
> consumer to read it whenever it next needs it. That is too late. By the
> time the VFE handles a buffer done, the published state may already
> describe a later frame, so neither the timestamp nor the sequence number
> can be attributed to the buffer the VFE is completing. With two frames
> in flight,
> 
>   SOF_0 BUF_DONE_0 SOF_1 SOF_2 BUF_DONE_1 BUF_DONE_2
> 
> BUF_DONE_1 reads back what SOF_2 published, and the two buffers end up
> carrying the same timestamp and the same sequence number.
> 
> Add an optional callback, invoked from the CSID interrupt handler once
> the SOF state describes the frame that just started, so a consumer can
> act while that frame is still the one being captured. Nobody registers
> one yet.

Just to add i am not in favor to this kind of notifications. Apart from
that it is called from IRQ. So i think is better to have a flag and call
directly the function you need.

> 
> Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
> ---
>  drivers/media/platform/qcom/camss/camss-csid.c | 15 +++++++++++++++
>  drivers/media/platform/qcom/camss/camss-csid.h | 17 +++++++++++++++++
>  2 files changed, 32 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
> index fd53e854454a6fc9d7cbe0c946a852a6f009cab3..b237eb6a47c59626f33ed8342104b333dff98e44 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid.c
> @@ -1400,6 +1400,14 @@ struct csid_sof *csid_get_sof(struct media_pad *pad)
>  	return &csid->sof[csid_pad_to_port(pad->index)];
>  }
>  
> +void csid_set_sof_notify(struct csid_sof *sof, void (*notify)(void *priv), void *priv)
> +{
> +	if (notify)
> +		sof->priv = priv;
> +
> +	WRITE_ONCE(sof->notify, notify);
> +}
> +
>  static u64 csid_timestamp_to_ns(u64 ticks)
>  {
>  	return mul_u64_u32_div(ticks, CSID_TIMESTAMP_NS_MUL, CSID_TIMESTAMP_NS_DIV);
> @@ -1488,6 +1496,7 @@ void csid_sof_event(struct csid_device *csid, unsigned int id)
>  {
>  	/* Read before the sequence number below, which arms the first SOF */
>  	u64 ts = csid_hw_sof_ts(csid, id);
> +	void (*notify)(void *priv);
>  	struct v4l2_event event = {
>  		.type = V4L2_EVENT_FRAME_SYNC,
>  		.u.frame_sync.frame_sequence =
> @@ -1496,6 +1505,12 @@ void csid_sof_event(struct csid_device *csid, unsigned int id)
>  
>  	atomic64_set(&csid->sof[id].ts, ts);
>  
> +	/* Internal notification */
> +	notify = READ_ONCE(csid->sof[id].notify);
> +	if (notify)
> +		notify(csid->sof[id].priv);
> +
> +	/* User notification */
>  	if (atomic_read(&csid->frame_sync_users))
>  		v4l2_event_queue(csid->subdev.devnode, &event);
>  }
> diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
> index 4925ea714aa74081a2b602f08696734b1087babb..53c82b0546cde02b07ffc6f841ff02b8088e3d9a 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid.h
> +++ b/drivers/media/platform/qcom/camss/camss-csid.h
> @@ -168,10 +168,14 @@ struct csid_subdev_resources {
>   * struct csid_sof - What the CSID tracks at start of frame, per src stream
>   * @seq: Frame sequence number, -1 until the first SOF of the stream
>   * @ts: CLOCK_MONOTONIC time of the frame start, 0 until the first SOF
> + * @notify: Consumer to tell about a frame start, NULL if nobody asked
> + * @priv: Handed to @notify
>   */
>  struct csid_sof {
>  	atomic_t seq;
>  	atomic64_t ts;
> +	void (*notify)(void *priv);
> +	void *priv;
>  };

Just to add i am not in favor to this kind of notifications. Apart from
that it is called from IRQ. So i think is better to have a flag and call
directly the function you need.

~Gjorgji

>  
>  struct csid_device {
> @@ -298,4 +302,17 @@ void csid_sof_event(struct csid_device *csid, unsigned int id);
>   */
>  struct csid_sof *csid_get_sof(struct media_pad *pad);
>  
> +/*
> + * csid_set_sof_notify - Ask to be told about every start of frame
> + * @sof: SOF state of a CSID source stream, as returned by csid_get_sof()
> + * @notify: Called from the CSID interrupt handler with @sof already describing
> + *	    the frame that started, or NULL to stop being called
> + * @priv: Handed to @notify
> + *
> + * Unregistering does not wait for a call already in progress, so @notify has to
> + * cope with running once the consumer has started tearing its stream down.
> + */
> +void csid_set_sof_notify(struct csid_sof *sof, void (*notify)(void *priv),
> +			 void *priv);
> +
>  #endif /* QC_MSM_CAMSS_CSID_H */
> 


  reply	other threads:[~2026-12-04 13:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:53 [PATCH v4 00/14] media: qcom: camss: Report the hardware SOF timestamp Loic Poulain
2026-12-03 16:53 ` [PATCH v4 01/14] media: qcom: camss: Add csid pad to port helper Loic Poulain
2026-12-03 16:53 ` [PATCH v4 02/14] media: qcom: camss: csid: Add an operation to read the SOF timestamp Loic Poulain
2026-12-04  7:31   ` Gjorgji Rosikopulos (Consultant)
2026-12-03 16:53 ` [PATCH v4 03/14] media: qcom: camss: csid-340: Report the hardware " Loic Poulain
2026-12-03 16:53 ` [PATCH v4 04/14] media: camss: Define timestamp registers for csid-gen2 Loic Poulain
2026-12-03 16:53 ` [PATCH v4 05/14] media: camss: csid-gen2: Report the hardware SOF timestamp Loic Poulain
2026-12-03 16:53 ` [PATCH v4 06/14] media: qcom: camss: csid-gen3: Fix the RDI timestamp controls on Titan 690 Loic Poulain
2026-12-04  7:44   ` Gjorgji Rosikopulos (Consultant)
2026-12-03 16:53 ` [PATCH v4 07/14] media: qcom: camss: csid-gen3: Report the hardware SOF timestamp Loic Poulain
2026-12-03 16:53 ` [PATCH v4 08/14] media: qcom: camss: Timestamp buffers at start of frame Loic Poulain
2026-12-04  7:59   ` Gjorgji Rosikopulos (Consultant)
2026-12-03 16:53 ` [PATCH v4 09/14] media: qcom: camss: Tell userspace we're using start-of-frame timestamps Loic Poulain
2026-12-04  8:54   ` Gjorgji Rosikopulos (Consultant)
2026-12-03 16:53 ` [PATCH v4 10/14] media: qcom: camss: csid: Let a consumer hook into the frame start Loic Poulain
2026-12-04 13:18   ` Gjorgji Rosikopulos (Consultant) [this message]
2026-12-03 16:53 ` [PATCH v4 11/14] media: qcom: camss: Stamp the buffer the write master is filling Loic Poulain
2026-12-04 13:31   ` Gjorgji Rosikopulos (Consultant)
2026-12-03 16:53 ` [PATCH v4 12/14] media: qcom: camss: vfe-gen3: Report the address of the current frame Loic Poulain
2026-12-04 13:32   ` Gjorgji Rosikopulos (Consultant)
2026-12-03 16:53 ` [PATCH v4 13/14] media: qcom: camss: vfe-680: " Loic Poulain
2026-12-04 14:49   ` Gjorgji Rosikopulos (Consultant)
2026-12-03 16:53 ` [PATCH v4 14/14] media: qcom: camss: vfe-340: " Loic Poulain

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=cdc3058e-4caf-4874-95de-d5873669212b@oss.qualcomm.com \
    --to=gjorgji.rosikopulos@oss.qualcomm.com \
    --cc=bryan.odonoghue@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®