From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796390334; b=nvzEptsDS7Fc4nspxkXJIbk6PjDyOgQKXHjwalSFePaFfiz4t3ghN7GUTEWBi5AxOLBw GNEKZkAt7HnH7Wlqo0VU730tF2WloFfUr2S7tXneP0dxqzV2eAJWHuTV/+FlUouC6eib8 ilGUEWd9vvGnC2hQrvR1HgBM0iDXNvr7z9hu20qBCXyvfH7paTTIARvKjZP+xFr7mG3Id eYkA8bHyMDcYohHne7OlmHSRrIdJz/TtXNzX0QLmrmo4WGbwqbIFP0DyAGL/7mJqA8hx4 +1m7WlBjdnW0IODfcEzSKAQLkpy6wlX8+/ZV7bXTaZckMkniH/AaszIM0XVTh7bxQzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390334; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Info:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=19J66HgTXe9SsVz4pCSj14wOwC/x24ZEhXU/okRuhOc=; b=o6sBpRTb7VtgzElHXl9cMZU7cI9bsvCdFEGg1R9f+uxsU41oYmAaqYcAdRDb7yC3ifOg oKllxnXOok/qQnRzf8uUncRvD8giO4Uo735jOR20Py6jOhrbCdNlMXn4oN7rDs6OkSE5Q l2tjRRLk5OGdFH1uQXIOYAZs7nvtQdk0VAFRw8++jJunpnqSIMFVfLZqf7yV9v0TjGPBD sZVjpZOKpxzXNWo0jYJX5BcxMcKtgV3Z2OTNCVrhZrMhPBoZSSzEOjNMNUxSWLBwi9V11 HUDr5iXbg53u0q+9P2Hd1pPGl+JRXLCQgwpbtWTn5b8Jem+63NbpZD5mmovk6kEVBTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=blbIsknY; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=FNqj5ou9; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67FB2606A32D for ; Fri, 4 Dec 2026 13:18:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 67FB2606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=blbIsknY; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=FNqj5ou9 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B4BJ7xl2325823 for ; Fri, 4 Dec 2026 13:18:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 19J66HgTXe9SsVz4pCSj14wOwC/x24ZEhXU/okRuhOc=; b=blbIsknY0rPTCJzI jwhS7HH9JFp0bJ2Oa0kvsaG4alUFvtJRXr0NicHsj9MUtoTwZgoRSPO7hASEw/pZ YMxlXBW6HTE29+kOIabTOZ7wB2XspNUr8z2u/IJjAShLqGc6F8YACh3LqP+YLZTT RW9NUOXt7le46tBfJVqoJU1LRo5Uth/aPwcOxNkfAz4LhB+c9KebpxRClDHbL3iZ X9J261HZBzr1sN8xOAX4p/nQqAv+KquUzz20PLtGSSqNylSiBMf7vG/35rb/yzMt AvXo9wNeTBp2zOcosZYa0NlV8DF6yNOUMGh+gn1a1unIDNXzkOb9BKKuyngOjOGJ lV/q6g== Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4jbq8nhec3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Dec 2026 13:18:52 +0000 (GMT) Received: by mail-vs1-f70.google.com with SMTP id ada2fe7eead31-7cc450e6dc2so803347137.2 for ; Fri, 04 Dec 2026 05:18:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796390331; x=1796995131; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=19J66HgTXe9SsVz4pCSj14wOwC/x24ZEhXU/okRuhOc=; b=FNqj5ou9aNkgneGk3ESZUii0Mm/CTXe/vYQ5LnwYjncGW46ipdRZXYDUC+v2AU6i9R 8azMTSrjfNBFIo2sE4gvWBl0AJuBQ+2LKS2McUIaTGZKwzeDhzNUwcNe+Kztye7VW6Tp ccNak2+c4JlKlSXg5UeKis72o8Envu3pgIPTsmIlvVQvNPvcmZf3LEwwCmVe0Oe5GQqG nNMSxmxlMXaKqjrzF4ZBMFSxhC8/eIohRFkLEDRJeEIs/OHgGUdCPSCJvzAJ2yM0gnhe p831C1xNienA7LQa/qCawGTxcZQalhE23DG7RVvfLH3D5M3za2yf2oFJYEPsL/GSEJp1 vd6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796390331; x=1796995131; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=19J66HgTXe9SsVz4pCSj14wOwC/x24ZEhXU/okRuhOc=; b=esswGYAb0T+p+vn80fM32XayfvQGduUiu33JFKQrHrW8V++ZmRB7oel38lGK/HucEA GcEwTksEGSedhgWh2PtC/v4GhO32FDGfUya0o/0xWDMzUmUVPm+EVZZKWA20S91U50pF dmuior0xD2s5GvVEOGeQpIPXhjmb1ak/KTwzadjLywP2K/9XGSgOFK1+M3IIXpB9Q4nI 1mS5fXeTpSUQssN8ISbYJNk9VszXG6ICZCk7wjJH4feBJvN1ZKwRV5+vzlxUj7gsi1Bw un95qVd6MmdEm4gWGCJOt/nLgahn9wQdlH4hf97I9Wu0ZtBxQtKIguOg/8tLngYET34H lIwA== X-Forwarded-Encrypted: i=1; AL+hErER/x/k9iZGP12Vi/3bLljYJL85X8cHFIV26on/onQ3NQCH9T4xDY9KtgPPQ6BZeniyoDA7x+4556yGfms=@vger.kernel.org X-Gm-Message-State: APuU4Z9qhc51uDrI8uU0bHHR51jcSYx0J2h9GvsbcOCzENn4nIx4zxe7 uTcErPF5u3x8I1bGgUmMPcHuDrNRMmb3rzf1AvVxf7UHhW7K7otm9qBzLEyvVAmZTxbBb6FaS/H WppW0t3hRmhv+OmWLOReZFzX+3kYSFk2CQiIQN1E9dHaU9FdBYz6QMGWQPlI4gkQ9nNs= X-Gm-Gg: AZFdTZeaNb3sVhyqTWeVGUtPELchuyTqVgpg6xVvKZAjiwov8pnYguCRTD9aA9w+u6K J/1ITOf1XwoTXaMgLPm5rlF3W+a3H84m/1rvN9jMfvRfg2Xy0BLayeLfo/qDCp4VmOTROx9/kpR InxZvLghWbzz+5FV1WPE84MSdJFRqYbPRy4P9zvmlASX1lfSxX2Nm2zZpEPaayYvjLgXmTHQwwr F4bhMeOnHC7d74ee7Mu3BSZO9Xypr5hJlQCwalVCBb4kOzz8YCrwbpcfDjnEBCxCp60Yt2VLN3S tbVQOWA4jccyy+mabf6sPN3NVyPb+RA4KIIlqHbpBbGCPVTz8VSWJ+d088XNqgMt8IqeGlRzFes DCQ6y7l9EyJm6Yk9iLzktymw08p0goE2bkf5Gg7QBuvKoUnfNOkIMWUiQjgUkKtw4V62JrpYA8Q CKPhagh85BK5M= X-Received: by 2002:a05:6102:8092:b0:7da:c57c:d4f2 with SMTP id ada2fe7eead31-7daec8085e6mr1626941137.25.1796390331413; Fri, 04 Dec 2026 05:18:51 -0800 (PST) X-Received: by 2002:a05:6102:8092:b0:7da:c57c:d4f2 with SMTP id ada2fe7eead31-7daec8085e6mr1626909137.25.1796390330861; Fri, 04 Dec 2026 05:18:50 -0800 (PST) Received: from [192.168.1.35] ([85.196.172.179]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d16e0b0c9bsm5468905f8f.3.2026.12.04.05.18.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 05:18:50 -0800 (PST) Message-ID: Date: Fri, 4 Dec 2026 15:18:48 +0200 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 10/14] media: qcom: camss: csid: Let a consumer hook into the frame start To: Loic Poulain , Mauro Carvalho Chehab , Bryan O'Donoghue , Vladimir Zapolskiy Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20261203-camss-hw-ts-v4-0-c271022b4b0d@oss.qualcomm.com> <20261203-camss-hw-ts-v4-10-c271022b4b0d@oss.qualcomm.com> Content-Language: en-US From: "Gjorgji Rosikopulos (Consultant)" In-Reply-To: <20261203-camss-hw-ts-v4-10-c271022b4b0d@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: BhB5uKkkhnlBkHlXL3J-BpYseovUZylC X-Proofpoint-Spam-Info: AW1haW4tMjYxMjA0MDA1MiBTYWx0ZWRfXzHmvYSpnEZDF WPWanLHkXqGIDOP3DoOKtgQRieZxuqWoH+z7Y2mnweB0b0fIFoKP4tSa/iznLNIkHrqQgaJHKH9 7ivP1wetiu1qIHvxZESwRSz2TccGjUI= X-Authority-Analysis: v=2.4 cv=dqdOmFg4 c=1 sm=1 tr=0 ts=6b12bdbc cx=c_pps a=N1BjEkVkxJi3uNfLdpvX3g==:117 a=Q/e3f29T3Hw2hnAEzBPF7w==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=roehnrkoG0YElRrradsA:9 a=QEXdDO2ut3YA:10 a=crWF4MFLhNY0qMRaF8an:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjA0MDA1MiBTYWx0ZWRfX7YKOZmwgFaSg jCsTno2KPLU7TBhnmRFXO3U162+y0eevPEud2YRgo6LiwHWmmL7KXIctuPVRbxpZGKVx7JOb+A/ q8oBtwJcYBY5gD91wxE13CAHg1dK1QlIJJXie+biLKUVh4Hh1uC8pWBt7989QwMH6GVlNc+VSCT CAhlPbP3p8rCsuw3GOxA6bs9Ii8pTP0px5RDUFspSHvjr+PISKF7LzA1MyT1MuiZYgls3FPFzbI aLinW/oj3F90UhEJpSajePcAjXoVHSuCBNGyRg+/P3NvG/XH44SP1ucSZdcHPQQcTCN5RzQLMI+ l1nrGcGOaV8MHq76rxYfP+VeAqsxZAqi69qUoNU94VdSk9ZOJ+38YZLF/EkcnJMWn2fvKEvzy/u gDiZ1SGRXRDmHelY8rUmdITTGgj1XXArU4ZeVirNhM8qKugP5v9dnzlcbhyyuXdEKoBGyO/47qg 5S0eGbXk1gdRuYEuf2w== X-Proofpoint-GUID: BhB5uKkkhnlBkHlXL3J-BpYseovUZylC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-04_02,2026-12-03_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612040052 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 > --- > 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 */ >