{"id":11595,"url":"https://patchwork.libcamera.org/api/1.1/patches/11595/?format=json","web_url":"https://patchwork.libcamera.org/patch/11595/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210316155211.6679-5-m.cichy@pengutronix.de>","date":"2021-03-16T15:52:09","name":"[libcamera-devel,RFC,4/6] pipeline: simple: Propagate frame interval through pipeline","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"23724d9946626978fb522c3171a70e47a5ad07e8","submitter":{"id":80,"url":"https://patchwork.libcamera.org/api/1.1/people/80/?format=json","name":"Marian Cichy","email":"m.cichy@pengutronix.de"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11595/mbox/","series":[{"id":1798,"url":"https://patchwork.libcamera.org/api/1.1/series/1798/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1798","date":"2021-03-16T15:52:05","name":"Add propagation of sensor frame interval","version":1,"mbox":"https://patchwork.libcamera.org/series/1798/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11595/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11595/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BFCECBD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Mar 2021 15:52:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D5EE68D4F;\n\tTue, 16 Mar 2021 16:52:32 +0100 (CET)","from metis.ext.pengutronix.de (metis.ext.pengutronix.de\n\t[IPv6:2001:67c:670:201:290:27ff:fe1d:cc33])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C84BA68D4E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Mar 2021 16:52:27 +0100 (CET)","from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28])\n\tby metis.ext.pengutronix.de with esmtps\n\t(TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)\n\t(envelope-from <mci@pengutronix.de>)\n\tid 1lMBzf-0000V4-1E; Tue, 16 Mar 2021 16:52:27 +0100","from mci by dude02.hi.pengutronix.de with local (Exim 4.92)\n\t(envelope-from <mci@pengutronix.de>)\n\tid 1lMBze-0003Dl-Iz; Tue, 16 Mar 2021 16:52:26 +0100"],"From":"Marian Cichy <m.cichy@pengutronix.de>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 16 Mar 2021 16:52:09 +0100","Message-Id":"<20210316155211.6679-5-m.cichy@pengutronix.de>","X-Mailer":"git-send-email 2.29.2","In-Reply-To":"<20210316155211.6679-1-m.cichy@pengutronix.de>","References":"<20210316155211.6679-1-m.cichy@pengutronix.de>","MIME-Version":"1.0","X-SA-Exim-Connect-IP":"2001:67c:670:100:1d::28","X-SA-Exim-Mail-From":"mci@pengutronix.de","X-SA-Exim-Scanned":"No (on metis.ext.pengutronix.de);\n\tSAEximRunCond expanded to false","X-PTX-Original-Recipient":"libcamera-devel@lists.libcamera.org","Subject":"[libcamera-devel] [RFC PATCH 4/6] pipeline: simple: Propagate frame\n\tinterval through pipeline","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"graphics@pengutronix.de, Marian Cichy <m.cichy@pengutronix.de>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"By propagating the frame interval from the sensor to the camera\ninterface, userspace applications can query the frame interval there.\nThis is useful for example with the gstreamer libcamerasrc, which can\nintegrate this information into the Gstreamer pipeline, which is a\nvaluable information for other elements.\n\nSigned-off-by: Marian Cichy <m.cichy@pengutronix.de>\n---\n src/libcamera/pipeline/simple/simple.cpp | 23 +++++++++++++++++++++++\n 1 file changed, 23 insertions(+)","diff":"diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex d7128156..296412e2 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -182,6 +182,7 @@ public:\n \tstd::vector<std::unique_ptr<FrameBuffer>> converterBuffers_;\n \tbool useConverter_;\n \tstd::queue<std::map<unsigned int, FrameBuffer *>> converterQueue_;\n+\tFraction frameInterval_;\n };\n \n class SimpleCameraConfiguration : public CameraConfiguration\n@@ -458,6 +459,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format,\n \t\t\t\t   V4L2Subdevice::Whence whence)\n {\n \tSimplePipelineHandler *pipe = static_cast<SimplePipelineHandler *>(pipe_);\n+\tFraction frameInterval;\n \tint ret;\n \n \t/*\n@@ -478,6 +480,14 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format,\n \t\t\tret = subdev->getFormat(source->index(), format, whence);\n \t\t\tif (ret < 0)\n \t\t\t\treturn ret;\n+\t\t} else {\n+\t\t\tV4L2Subdevice *subdev = pipe->subdev(source->entity());\n+\t\t\tret = subdev->getFrameInterval(source->index(), &frameInterval);\n+\t\t\tif (ret < 0)\n+\t\t\t\tLOG(SimplePipeline, Debug) << \"Getting frame interval from sensor failed\";\n+\t\t\telse\n+\t\t\t\tLOG(SimplePipeline, Debug) << \"Sensor frame interval: \"\n+\t\t\t\t\t\t\t  << frameInterval.toString();\n \t\t}\n \n \t\tif (sink->entity()->function() != MEDIA_ENT_F_IO_V4L) {\n@@ -488,6 +498,18 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format,\n \t\t\tif (ret < 0)\n \t\t\t\treturn ret;\n \n+\t\t\t/* set frameinterval on all subdevs if we got one from the sensor */\n+\t\t\tif (frameInterval.numerator != 0 && frameInterval.denominator != 0) {\n+\t\t\t\tret = subdev->setFrameInterval(sink->index(), &frameInterval);\n+\t\t\t\tif (ret == 0) {\n+\t\t\t\t\tLOG(SimplePipeline, Debug) << \"Set frame interval: \"\n+\t\t\t\t\t\t\t\t  << frameInterval.toString();\n+\t\t\t\t\t/* Always remember the last frame interval we successfully\n+\t\t\t\t\t * set, as this determines the final frame interval at the end */\n+\t\t\t\t\tframeInterval_ = frameInterval;\n+\t\t\t\t}\n+\t\t\t}\n+\n \t\t\tif (format->mbus_code != sourceFormat.mbus_code ||\n \t\t\t    format->size != sourceFormat.size) {\n \t\t\t\tLOG(SimplePipeline, Debug)\n@@ -668,6 +690,7 @@ CameraConfiguration *SimplePipelineHandler::generateConfiguration(Camera *camera\n \t\tStreamConfiguration cfg{ StreamFormats{ formats } };\n \t\tcfg.pixelFormat = formats.begin()->first;\n \t\tcfg.size = formats.begin()->second[0].max;\n+\t\tcfg.frameInterval = data->frameInterval_;\n \n \t\tconfig->addConfiguration(cfg);\n \t}\n","prefixes":["libcamera-devel","RFC","4/6"]}