From patchwork Mon Mar 22 10:42:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11638 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5435AC32E1 for ; Mon, 22 Mar 2021 10:43:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 005F368D6F; Mon, 22 Mar 2021 11:43:11 +0100 (CET) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D57DC68D58 for ; Mon, 22 Mar 2021 11:43:08 +0100 (CET) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lOI1c-0008Ce-2T; Mon, 22 Mar 2021 11:43:08 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lOI1b-00087V-Q1; Mon, 22 Mar 2021 11:43:07 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Mon, 22 Mar 2021 11:42:40 +0100 Message-Id: <20210322104242.31107-2-m.cichy@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322104242.31107-1-m.cichy@pengutronix.de> References: <20210322104242.31107-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 1/3] libcamera: stream: Add controlList attribute X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: graphics@pengutronix.de, Marian Cichy Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" By adding a controlList to the stream attributes, we have access to several more configuration parameters for a stream. In this patch series, it is for now only used to access the frame duration of a sensor. Signed-off-by: Marian Cichy --- include/libcamera/stream.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index bb47c390..a6347e31 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -44,6 +45,7 @@ struct StreamConfiguration { Size size; unsigned int stride; unsigned int frameSize; + ControlList controls; unsigned int bufferCount; From patchwork Mon Mar 22 10:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11639 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BC905C32E1 for ; Mon, 22 Mar 2021 10:43:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3DF2A68D72; Mon, 22 Mar 2021 11:43:12 +0100 (CET) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE7B568D62 for ; Mon, 22 Mar 2021 11:43:08 +0100 (CET) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lOI1c-0008Cf-2q; Mon, 22 Mar 2021 11:43:08 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lOI1b-00087Y-QO; Mon, 22 Mar 2021 11:43:07 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Mon, 22 Mar 2021 11:42:41 +0100 Message-Id: <20210322104242.31107-3-m.cichy@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322104242.31107-1-m.cichy@pengutronix.de> References: <20210322104242.31107-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 2/3] pipeline: simple: Add FrameDurations to stream configuration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: graphics@pengutronix.de, Marian Cichy Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a instance of CameraSensorInfo to the simple pipeline and populate it with the sensorInfo from the sensor. With the informations from the sensor, compute the frame duration by using lineLength, minFrameLength and pixelRate and save it in the controlList of the stream. Signed-off-by: Marian Cichy --- src/libcamera/pipeline/simple/simple.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 24d940fc..2df83302 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include @@ -176,6 +178,7 @@ public: std::vector streams_; std::unique_ptr sensor_; + CameraSensorInfo sensorInfo_; std::list entities_; V4L2VideoDevice *video_; @@ -339,6 +342,8 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, ret = sensor_->init(); if (ret) sensor_.reset(); + + sensor_->sensorInfo(&sensorInfo_); } int SimpleCameraData::init() @@ -679,6 +684,10 @@ CameraConfiguration *SimplePipelineHandler::generateConfiguration(Camera *camera StreamConfiguration cfg{ StreamFormats{ formats } }; cfg.pixelFormat = formats.begin()->first; cfg.size = formats.begin()->second[0].max; + double frameDuration = (data->sensorInfo_.minFrameLength * data->sensorInfo_.lineLength) / + (data->sensorInfo_.pixelRate / 1'000'000); + cfg.controls.set(controls::FrameDurations, { static_cast(frameDuration), + static_cast(frameDuration) }); config->addConfiguration(cfg); } From patchwork Mon Mar 22 10:42:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11637 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AD231C32E1 for ; Mon, 22 Mar 2021 10:43:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C338E68D6C; Mon, 22 Mar 2021 11:43:11 +0100 (CET) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D975468D60 for ; Mon, 22 Mar 2021 11:43:08 +0100 (CET) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lOI1c-0008Cg-2d; Mon, 22 Mar 2021 11:43:08 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lOI1b-00087b-Qp; Mon, 22 Mar 2021 11:43:07 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Mon, 22 Mar 2021 11:42:42 +0100 Message-Id: <20210322104242.31107-4-m.cichy@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322104242.31107-1-m.cichy@pengutronix.de> References: <20210322104242.31107-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: graphics@pengutronix.de, Marian Cichy Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Access the frame duration from the controlList of the stream configuration and convert it to values fitting for GST_FRACTION. By setting the frame rate to the caps configuration, the Gstreamer pipeline has information about the camera frame rate, which can be potentially used for more efficient memory allocation or for debug purposes. Signed-off-by: Marian Cichy --- src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 5381dca5..fdd8b85c 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -8,6 +8,7 @@ #include "gstlibcamera-utils.h" +#include #include using namespace libcamera; @@ -128,10 +129,16 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg { GstCaps *caps = gst_caps_new_empty(); GstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat); + int numerator; + int denominator; + double framerate = 1'000'000 / static_cast(stream_cfg.controls.get( + controls::FrameDurations)[0]); + gst_util_double_to_fraction(framerate, &numerator, &denominator); gst_structure_set(s, "width", G_TYPE_INT, stream_cfg.size.width, "height", G_TYPE_INT, stream_cfg.size.height, + "framerate", GST_TYPE_FRACTION, numerator, denominator, nullptr); gst_caps_append_structure(caps, s);