From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796124165; b=WuvX/AtnQoMaChDOmjN1XnVlZSlkEZrI6qlNZIuBTZFZPs5kuuwHw6sS3NBdvXIuPNsg xTcbvwBGXm2eHEIqyr6Vo2muuj0j3eXz2kkAYZXo0glUMyPzH7gF32L6NuWwWifOLUcfV d/mYU9lQSL2hZLZmVef0nCY1TkiKFddgONivYkUeaORuz+iVIFX04o7hkHeSPJC61yBl/ I/AhVRgS83FUnBvE3hOQ4DPaauV/ARBmak9lHO8NFXC7avvpqDVNs5cOJhTFFnzv8bman C8Uxjhhfcv9BRHU/V/1m0SNmmilVoA9YJuvMqHxwlEbV0sjUdg9TL0mSUZCaVJZCcQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796124165; 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-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-Spam-Details-Enc: X-Authority-Analysis:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=OTnU76kjW8HIzhQPBMR4xhIYFLzLoGr9HhIuw5zScUo=; b=p6LLNHJ0PrhibTF68x0kSxakZ/GRUAEJWvM27Nwd4DEm+2GqHRdF07nSZSGxeQ8NinJV sERGxsaUtAPEqG/i845Z9bDbqRD26h9IM8hTCod7cqSC2li6G00jCgX1q0YZLcqwiX2/N 6g5Ra8KY6hsAn/FFIqF9h7Q2McyvBkPMzrVY3o+1xHqXHKHb6vuc6bn2EYmyvUUHtG88E C/HJgY9N3D489hOUepS1LuRj19rmmzdUm0Ltxb9OtjSewz6hCW91bBVNrmAJOMxA1DLs0 AL+Th1LD4f99wck1yu6TvZdbv/LLDxZeoXquQJPMUsElkczStIbpH7xS2ZWUbUVL69Q== 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=mQkCFPn6; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=HEoycsCs; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 27DD5606A334 for ; Tue, 1 Dec 2026 11:22:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 27DD5606A334 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=mQkCFPn6; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=HEoycsCs Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1AQAnt455630 for ; Tue, 1 Dec 2026 11:22:44 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= OTnU76kjW8HIzhQPBMR4xhIYFLzLoGr9HhIuw5zScUo=; b=mQkCFPn6qtMPiDAa ec+g0Tyq+P8TzF3fnByyvSojToGGBrew9DN3/yrOD4P7taekyLpGa9YTRMejGAhW QcnpJX1xc/GQHCBWwY6qklkym4oAOz7zTl+0DX1+exi7/9Ah+lzNLqhllJOoF+zu lVin0PMaqw8fxCelDJ27B5RoaWNSlgm9PbtJ9PVoi+fRcbE1PitvXFmfxEsdtfMA aMftiJNZDecciyAml55oT9PzHZd5VavXxXXxzZCtRh/RuN0HvDYenv47cVQygS7M pWx9GZL8CaTymx080hIOiYyQJBvgo0bn47mg5YCAt3Mzy32CbO8J19QPqSqYlgVk PpXrUw== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9qth1hnd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 11:22:44 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-94970ad532bso1087192085a.0 for ; Tue, 01 Dec 2026 03:22:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796124163; x=1796728963; 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=OTnU76kjW8HIzhQPBMR4xhIYFLzLoGr9HhIuw5zScUo=; b=HEoycsCss+xd8O2o5JQw78rt53NUJAJAwK47WFBst5YmQB9rqR6wIrzhHXE2rn/eun 9Os2f1j+5R6Slt9x7a6Zdf0xOoKa+5H7VYaw6MC5KimJA0S7osHNMH72kurSgiBSP6hy cNjsnkeraWy956L70AquZEAPt85hhPnMR/AHJdD6kfec8oU27W+54c2qm72EOqzE+Fwq 0IkVV5rvDYacCLifzszOkOcU3nZ2duuYx7j3wzm/RPfWRqmILZu0vNP5CRieSYwWVY8Z 9opJcHxb6YXoY7CV+MjTf2zVoN3PpZ+Mjrn2Uwj6a7e3Bmy6uetO/k3WBC8/c6BrVkM/ oWHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796124163; x=1796728963; 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=OTnU76kjW8HIzhQPBMR4xhIYFLzLoGr9HhIuw5zScUo=; b=voGBaX2DWlIOHLM21rnx9CINRdjh017rdgnFFq1jbrqtqJrCnIgLv86pvR85eKAy7Z 6Z1qnexB+f3Li+0Z/onKa/qXZXpDKsXvU6PZe/iro/Tr1qhdaWPzqDol4vwOJ5QomJKV CYbr4asClluqbXSZupk/LEVW7oYsZyBXQ5+m4ZxgANHT7RPGbmTVjU1LETYzZ5bXH5Lo H5vF+M23dYLRdKbMjqwpvq3dyZ8QknY0uoTBFULArX8vuRe7ava7MCrSq2aUk23GVHRT 9LM/nHml2c2aM9DFRzcJYu4E6egOmWxVbB8Ecw65XmgaSZhCVU5Ev4/sHB0MeMKoxoEd M+uw== X-Forwarded-Encrypted: i=1; AL+hErGbHw1OniuoER8319aanVZVncOW+U1Gaym444CvCWIfLkYdZ2v1cNStNhNrMqImwu8tAxvmApMSCdYvYu0=@vger.kernel.org X-Gm-Message-State: APuU4Z8h0c0bL+7ZBcSImByAddHSoqZJ7cqPXyA9nTL0mRGKBLZ1gCC2 d9MM3MEzr1mWiVLE5PG5ziMvn+Le5lnlwPc02lyww9qZ4nbzbMNZoov0znQ0G+McOdGEH2ijr/N ufymJ7XAFHW0RsOe8hOE3jmfO2LwGHdx0s0rsWVP5X/KWAp2J4EEF6YR5IcjNfBuyxRI= X-Gm-Gg: AZFdTZf2tbh98hMnhkZE3ZTCyzWAi/36lLnYGEuBEoPQk3MoeRqdauXLwVAHGzQBJCP fSBJRPxViHi3RYTXtDXK5vc89S2WDU29cjgKORDYGuXyd+8jT3Ztkm7EPJLyn5ADhInbSsgPERP d2+WvT70XasfqNR8Ol7t6SCDL3yjpy6CQfCglpVygkHTo8fONi3aVUAddFDPlSyvbzRo9MjA6SI DHde3JY3J9Enz7dZjYq4t/D2nAry7A4grANjeO5rV/TnkvjYLc3fI1eY8ZdKkY17FxVKrrq9GJq zu0kcAnRyLopUKG/L/8i0cZk1r9HzRTaa7Funlb72a4ntuudJXfdsUYG72AT6CcM+G+gBCT1Pea 2SlwKFgj++H61XyoBnes1tbgEBfOsEyOEFjYJSMnGRJnLCvOGZ6kFFde5oWPCIe1Rk/Uw6FzkDz QAJp0o7WompoLv X-Received: by 2002:a05:620a:2b98:b0:949:6655:1dc6 with SMTP id af79cd13be357-949ba81a551mr6618636885a.1.1796124163280; Tue, 01 Dec 2026 03:22:43 -0800 (PST) X-Received: by 2002:a05:620a:2b98:b0:949:6655:1dc6 with SMTP id af79cd13be357-949ba81a551mr6618632885a.1.1796124162774; Tue, 01 Dec 2026 03:22:42 -0800 (PST) Received: from [192.168.25.64] ([94.155.124.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ad644140b5sm66847952f8f.17.2026.12.01.03.22.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 03:22:42 -0800 (PST) Message-ID: <66cf5508-190e-4cd1-bdae-a83bd3b69e20@oss.qualcomm.com> Date: Tue, 1 Dec 2026 13:22:41 +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 v3 2/8] media: qcom: camss: csid-340: Report the hardware SOF timestamp 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: <20261127-camss-hw-ts-v3-0-e4b6ad98ce9c@oss.qualcomm.com> <20261127-camss-hw-ts-v3-2-e4b6ad98ce9c@oss.qualcomm.com> Content-Language: en-US From: "Gjorgji Rosikopulos (Consultant)" In-Reply-To: <20261127-camss-hw-ts-v3-2-e4b6ad98ce9c@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: J03Az_XnNH_Ikh_DK0f3WbDilYG1-FMK X-Proofpoint-GUID: J03Az_XnNH_Ikh_DK0f3WbDilYG1-FMK X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA0NSBTYWx0ZWRfX1w/i2FNvZrDX f6vN4S2SgfGpIY5m1eSGoS1D+79CLJbCl7Vju45uIjDJSkD6fV+K+rwyVnMfyy9d/13pujQ7xLY yjePzm64NRsz1rPprLZdrBE46UXjLt0= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA0NSBTYWx0ZWRfX4QQcjHwsM9nu NhO5+0JFa6OAhQkBDSyFrv52+802b2wzjqzQrYbbgo6SFCQ1U2QsjoCU9JzRi/OX4DoIvxJ9XHJ NnrkmF1s+h0gAmcFR43mWnYoX/XH9vC/Y/THM5eH01+yMPoF4STFlYshPx2/qz3Sa0Gw9yohgSN CwuNh6ioemS4wsKdfVRL68QWsQ8fwbJRpQHDxPiIwtEt1B5S1kVLYPEIGfEptF2EG2Xuv4HzJKl kEyl7NHn5AOdPSX7c6QAf99sbft922+LuWd2d16ddyFY5AuxeTdF1Q9kriFm8fj8b0xWBwAcGpI g7NV9p1Uok56OM5T02UUsAjQGEhqjgzpcZrBS6xlncmmgwH14mlnhTNoLkU9WE6UEvnTIQUFRhW hJM6/zYgbucWHiRPAq3p80s2Mq+PRUhHf+mbGwOUWkQqagY7ZlOd8JC0emI6Th4lEKVvHczuR3J tjTj1fkPvt8e7gIyOiQ== X-Authority-Analysis: v=2.4 cv=MLn1C8Zl c=1 sm=1 tr=0 ts=6b0eae04 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=eGCDHFSXubCXFTSSGhjuOA==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=cux_b7lepKbGRq5HHLUA:9 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 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-01_02,2026-11-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 suspectscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010045 Hi Loic, On 11/27/2026 6:11 PM, Loic Poulain wrote: > The CSID latches the global timestamp counter at start-of-frame into a > per-interface register pair. Implement the sof_ts operation to > read it, so that the frame sync event carries the time the frame > actually started rather than the time the interrupt handler ran. > > Measured on QCM2290 that removes around 36 us of delay, with ~8 us of > jitter, from the timestamp userspace sees on a 60 fps stream. > > TIMESTAMP_EN is not at the same bit in the PIX and the RDI layouts of > CSID_CFG0, so replace the single define with one for each. > > Signed-off-by: Loic Poulain > --- > drivers/media/platform/qcom/camss/camss-csid-340.c | 37 +++++++++++++++++++--- > 1 file changed, 33 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/platform/qcom/camss/camss-csid-340.c b/drivers/media/platform/qcom/camss/camss-csid-340.c > index 42ff629ce410d33f21930ee56d714f41911cc077..ec4b1d9a86fcf08c2ceb12b4c4c2b85b5c7b8e51 100644 > --- a/drivers/media/platform/qcom/camss/camss-csid-340.c > +++ b/drivers/media/platform/qcom/camss/camss-csid-340.c > @@ -49,7 +49,8 @@ > > #define CSID_CFG0(iface) (0x200 + 0x100 * (iface)) > #define CSID_CFG0_BYTE_CNTR_EN BIT(0) > -#define CSID_CFG0_TIMESTAMP_EN BIT(1) > +#define CSID_CFG0_PIX_TIMESTAMP_EN BIT(1) > +#define CSID_CFG0_RDI_TIMESTAMP_EN BIT(2) > #define CSID_CFG0_DECODE_FORMAT_MASK GENMASK(15, 12) > #define CSID_CFG0_DECODE_FORMAT_NOP CSID_CFG0_DECODE_FORMAT_MASK > #define CSID_CFG0_DT_MASK GENMASK(21, 16) > @@ -61,6 +62,13 @@ > #define CSID_CTRL_HALT_AT_FRAME_BOUNDARY 0 > #define CSID_CTRL_RESUME_AT_FRAME_BOUNDARY 1 > > +/* > + * SOF timestamp of the most recent frame, a pair of registers holding a 56-bit > + * counter value, the low 32 bits in the first and the high 24 in the second. > + */ > +#define CSID_TIMESTAMP_CURR0_SOF(iface) (0x290 + 0x100 * (iface)) > +#define CSID_TIMESTAMP_CURR1_SOF(iface) (0x294 + 0x100 * (iface)) > + > enum csid_iface { > CSID_IFACE_PIX, > CSID_IFACE_RDI0, > @@ -108,6 +116,7 @@ static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 port > input_format->code); > enum csid_iface iface = csid_port_iface_map[port]; > > + u32 timestamp_en; > u8 dt_id; > u32 val; > > @@ -125,17 +134,21 @@ static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 port > */ > dt_id = port & 0x03; > > - if (iface == CSID_IFACE_PIX) > + if (iface == CSID_IFACE_PIX) { > val = FIELD_PREP(CSID_CFG0_DECODE_FORMAT_MASK, format->decode_format); > - else /* RDI is raw, no decoding */ > + timestamp_en = CSID_CFG0_PIX_TIMESTAMP_EN; > + } else { > + /* RDI is raw, no decoding */ > val = CSID_CFG0_DECODE_FORMAT_NOP; > + timestamp_en = CSID_CFG0_RDI_TIMESTAMP_EN; > + } > > val |= FIELD_PREP(CSID_CFG0_DT_MASK, format->data_type); > val |= FIELD_PREP(CSID_CFG0_VC_MASK, vc); > val |= FIELD_PREP(CSID_CFG0_DTID_MASK, dt_id); > > if (enable) > - val |= CSID_CFG0_ENABLE; > + val |= CSID_CFG0_ENABLE | timestamp_en; > > dev_dbg(csid->camss->dev, "CSID%u: Stream %s (dt:0x%x df=0x%x port=%u vc=%u)\n", > csid->id, enable ? "enable" : "disable", format->data_type, > @@ -184,6 +197,21 @@ static int csid_reset(struct csid_device *csid) > return 0; > } > > +static u64 csid_sof_ts(struct csid_device *csid, unsigned int id) > +{ > + enum csid_iface iface = csid_port_iface_map[id]; > + u32 lo, hi; > + > + /* > + * The pair is latched on SOF rather than counting, so it can be read > + * one word at a time without tearing. > + */ > + lo = readl_relaxed(csid->base + CSID_TIMESTAMP_CURR0_SOF(iface)); > + hi = readl_relaxed(csid->base + CSID_TIMESTAMP_CURR1_SOF(iface)); > + > + return ((u64)hi << 32) | lo; > +} > + > static irqreturn_t csid_isr(int irq, void *dev) > { > struct csid_device *csid = dev; > @@ -233,6 +261,7 @@ const struct csid_hw_ops csid_ops_340 = { > .hw_version = csid_hw_version, > .isr = csid_isr, > .reset = csid_reset, > + .sof_ts = csid_sof_ts, > .src_pad_code = csid_src_pad_code, > .subdev_init = csid_subdev_init, > }; Looks good to me. Reviewed-by: Gjorgji Rosikopulos ~Gjorgji >