From patchwork Tue Mar 16 15:52:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11594 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 F144ABD80C for ; Tue, 16 Mar 2021 15:52:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A947368D55; Tue, 16 Mar 2021 16:52:31 +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 BF1B068D4A for ; Tue, 16 Mar 2021 16:52:27 +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 1lMBze-0000V1-TI; Tue, 16 Mar 2021 16:52:26 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lMBze-0003DS-He; Tue, 16 Mar 2021 16:52:26 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Mar 2021 16:52:06 +0100 Message-Id: <20210316155211.6679-2-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [RFC PATCH 1/6] libcamera: Add fraction.h 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 new class that represents a fraction. A structure like this is also often used in linux camera drivers, e.g. v4l2_fract to represent a frame interval or in applications like Gstreamer to represent frame rates. Adding this class helps to interface frame intervals and frame rates in video streams. Signed-off-by: Marian Cichy --- include/libcamera/fraction.h | 34 ++++++++++++++++++++ src/libcamera/fraction.cpp | 60 ++++++++++++++++++++++++++++++++++++ src/libcamera/meson.build | 1 + 3 files changed, 95 insertions(+) create mode 100644 include/libcamera/fraction.h create mode 100644 src/libcamera/fraction.cpp diff --git a/include/libcamera/fraction.h b/include/libcamera/fraction.h new file mode 100644 index 00000000..aa6a1abb --- /dev/null +++ b/include/libcamera/fraction.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Pengutronix, Marian Cichy + * + * fraction.h - A fraction consisting of two integers + */ + +#ifndef __LIBCAMERA_FRACTION_H__ +#define __LIBCAMERA_FRACTION_H__ + +namespace libcamera { + +class Fraction { +public: + constexpr Fraction() : + numerator(0), denominator(0) + { + } + + constexpr Fraction(unsigned int num, unsigned int den) : + numerator(num), denominator(den) + { + } + + unsigned int numerator; + unsigned int denominator; + + const std::string toString() const; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_FRACTION_H__ */ diff --git a/src/libcamera/fraction.cpp b/src/libcamera/fraction.cpp new file mode 100644 index 00000000..76c373aa --- /dev/null +++ b/src/libcamera/fraction.cpp @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Pengutronix, Marian Cichy + * + * fraction.h - A fraction consisting of two integers + */ + +#include +#include + +#include + +/** + * \file fraction.h + * \brief A fraction consisting of two integers. + */ + +namespace libcamera { + +/** + * \class Fraction + * \brief Represents a fraction with a nominator and a denominator. + */ + +/** + * \fn Fraction::Fraction() + * \brief Construct a Fraction with value 0/0. This should be interpreted + * as invalid or not-used Fraction. + */ + +/** + * \fn Fraction::Fraction(unsigned int num, unsigned int den) + * \brief Construct a Fraction with value n/d. + */ + +/** + * \var Fraction::numerator + * \brief The numerator of the fraction. + */ + +/** + * \var Fraction::denominator + * \brief The denominator of the fraction. + */ + +/** + * \brief Assemble and return a string describing the fraction + * \return A string describing the fraction. + */ +const std::string Fraction::toString() const +{ + std::stringstream ss; + + ss << numerator << "/" << denominator; + + return ss.str(); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 815629db..7927481f 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -22,6 +22,7 @@ libcamera_sources = files([ 'file.cpp', 'file_descriptor.cpp', 'formats.cpp', + 'fraction.cpp', 'framebuffer_allocator.cpp', 'geometry.cpp', 'ipa_controls.cpp', From patchwork Tue Mar 16 15:52:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11596 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 553F8BD80C for ; Tue, 16 Mar 2021 15:52:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 18C8568D5D; Tue, 16 Mar 2021 16:52:33 +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 C729368D4D for ; Tue, 16 Mar 2021 16:52:27 +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 1lMBze-0000V2-Vg; Tue, 16 Mar 2021 16:52:26 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lMBze-0003Da-I7; Tue, 16 Mar 2021 16:52:26 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Mar 2021 16:52:07 +0100 Message-Id: <20210316155211.6679-3-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [RFC PATCH 2/6] libcamera: stream: Add frame interval 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" The frame interval can be get and set from and on v4l2-subdevices and is part of the stream configuration. 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..14bfbf44 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; + Fraction frameInterval; unsigned int bufferCount; From patchwork Tue Mar 16 15:52:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11593 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 050FCBD80C for ; Tue, 16 Mar 2021 15:52:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC72068D50; Tue, 16 Mar 2021 16:52:30 +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 9BED368D49 for ; Tue, 16 Mar 2021 16:52:27 +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 1lMBze-0000V3-SW; Tue, 16 Mar 2021 16:52:26 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lMBze-0003Dd-IZ; Tue, 16 Mar 2021 16:52:26 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Mar 2021 16:52:08 +0100 Message-Id: <20210316155211.6679-4-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [RFC PATCH 3/6] libcamera: v4l2_subdevice: Add methods to get/set frame interval 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 API-methods to get and set the frame interval on V4L2-subdevices. Signed-off-by: Marian Cichy --- include/libcamera/internal/v4l2_subdevice.h | 4 ++ src/libcamera/v4l2_subdevice.cpp | 43 +++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index d2b9ca55..310746d9 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -12,6 +12,7 @@ #include #include +#include #include #include "libcamera/internal/formats.h" @@ -60,6 +61,9 @@ public: int setFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); + int getFrameInterval(unsigned int pad, Fraction *frameInterval); + int setFrameInterval(unsigned int pad, Fraction *frameInterval); + static std::unique_ptr fromEntityName(const MediaDevice *media, const std::string &entity); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 721ff5a9..eac2d7d3 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include "libcamera/internal/log.h" @@ -440,6 +441,48 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format, return 0; } +int V4L2Subdevice::getFrameInterval(unsigned int pad, Fraction *frameInterval) +{ + struct v4l2_subdev_frame_interval subdevFrameInterval = {}; + subdevFrameInterval.pad = pad; + + int ret = ioctl(VIDIOC_SUBDEV_G_FRAME_INTERVAL, &subdevFrameInterval); + if (ret) { + LOG(V4L2, Debug) + << "Unable to get frame interval on pad " << pad + << ": " << strerror(-ret); + return ret; + } + + frameInterval->numerator = subdevFrameInterval.interval.numerator; + frameInterval->denominator = subdevFrameInterval.interval.denominator; + + return 0; +} + +int V4L2Subdevice::setFrameInterval(unsigned int pad, Fraction *frameInterval) +{ + struct v4l2_subdev_frame_interval subdevFrameInterval = {}; + struct v4l2_fract fract = { frameInterval->numerator, + frameInterval->denominator }; + + subdevFrameInterval.pad = pad; + subdevFrameInterval.interval = fract; + + int ret = ioctl(VIDIOC_SUBDEV_S_FRAME_INTERVAL, &subdevFrameInterval); + if (ret) { + LOG(V4L2, Debug) + << "Unable to set frame interval on pad " << pad + << ": " << strerror(-ret); + return ret; + } + + frameInterval->numerator = subdevFrameInterval.interval.numerator; + frameInterval->denominator = subdevFrameInterval.interval.denominator; + + return 0; +} + /** * \brief Create a new video subdevice instance from \a entity in media device * \a media From patchwork Tue Mar 16 15:52:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11595 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 BFCECBD80C for ; Tue, 16 Mar 2021 15:52:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D5EE68D4F; Tue, 16 Mar 2021 16:52:32 +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 C84BA68D4E for ; Tue, 16 Mar 2021 16:52:27 +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 1lMBzf-0000V4-1E; Tue, 16 Mar 2021 16:52:27 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lMBze-0003Dl-Iz; Tue, 16 Mar 2021 16:52:26 +0100 From: Marian Cichy 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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [RFC PATCH 4/6] pipeline: simple: Propagate frame interval through pipeline 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 propagating the frame interval from the sensor to the camera interface, userspace applications can query the frame interval there. This is useful for example with the gstreamer libcamerasrc, which can integrate this information into the Gstreamer pipeline, which is a valuable information for other elements. Signed-off-by: Marian Cichy --- src/libcamera/pipeline/simple/simple.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index d7128156..296412e2 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -182,6 +182,7 @@ public: std::vector> converterBuffers_; bool useConverter_; std::queue> converterQueue_; + Fraction frameInterval_; }; class SimpleCameraConfiguration : public CameraConfiguration @@ -458,6 +459,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, V4L2Subdevice::Whence whence) { SimplePipelineHandler *pipe = static_cast(pipe_); + Fraction frameInterval; int ret; /* @@ -478,6 +480,14 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, ret = subdev->getFormat(source->index(), format, whence); if (ret < 0) return ret; + } else { + V4L2Subdevice *subdev = pipe->subdev(source->entity()); + ret = subdev->getFrameInterval(source->index(), &frameInterval); + if (ret < 0) + LOG(SimplePipeline, Debug) << "Getting frame interval from sensor failed"; + else + LOG(SimplePipeline, Debug) << "Sensor frame interval: " + << frameInterval.toString(); } if (sink->entity()->function() != MEDIA_ENT_F_IO_V4L) { @@ -488,6 +498,18 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, if (ret < 0) return ret; + /* set frameinterval on all subdevs if we got one from the sensor */ + if (frameInterval.numerator != 0 && frameInterval.denominator != 0) { + ret = subdev->setFrameInterval(sink->index(), &frameInterval); + if (ret == 0) { + LOG(SimplePipeline, Debug) << "Set frame interval: " + << frameInterval.toString(); + /* Always remember the last frame interval we successfully + * set, as this determines the final frame interval at the end */ + frameInterval_ = frameInterval; + } + } + if (format->mbus_code != sourceFormat.mbus_code || format->size != sourceFormat.size) { LOG(SimplePipeline, Debug) @@ -668,6 +690,7 @@ CameraConfiguration *SimplePipelineHandler::generateConfiguration(Camera *camera StreamConfiguration cfg{ StreamFormats{ formats } }; cfg.pixelFormat = formats.begin()->first; cfg.size = formats.begin()->second[0].max; + cfg.frameInterval = data->frameInterval_; config->addConfiguration(cfg); } From patchwork Tue Mar 16 15:52:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11598 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 EC8CEBD80C for ; Tue, 16 Mar 2021 15:52:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1400768D5E; Tue, 16 Mar 2021 16:52:34 +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 C4B8568D4C for ; Tue, 16 Mar 2021 16:52:27 +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 1lMBzf-0000V5-3I; Tue, 16 Mar 2021 16:52:27 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lMBze-0003Du-Jb; Tue, 16 Mar 2021 16:52:26 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Mar 2021 16:52:10 +0100 Message-Id: <20210316155211.6679-6-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [RFC PATCH 5/6] pipeline: simple: rename setupFormats to setupStreamProperties 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" This function does not only setup the format anymore but also propagates the frame interval from the camera sensor to the camera interface, so lets choose a more generic name for it. Signed-off-by: Marian Cichy --- src/libcamera/pipeline/simple/simple.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 296412e2..bc969125 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -150,7 +150,7 @@ public: int init(); int setupLinks(); - int setupFormats(V4L2SubdeviceFormat *format, + int setupStreamProperties(V4L2SubdeviceFormat *format, V4L2Subdevice::Whence whence); unsigned int streamIndex(const Stream *stream) const @@ -354,7 +354,7 @@ int SimpleCameraData::init() for (unsigned int code : sensor_->mbusCodes()) { V4L2SubdeviceFormat format{ code, sensor_->resolution() }; - ret = setupFormats(&format, V4L2Subdevice::TryFormat); + ret = setupStreamProperties(&format, V4L2Subdevice::TryFormat); if (ret < 0) { LOG(SimplePipeline, Debug) << "Media bus code " << utils::hex(code, 4) @@ -455,7 +455,7 @@ int SimpleCameraData::setupLinks() return 0; } -int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, +int SimpleCameraData::setupStreamProperties(V4L2SubdeviceFormat *format, V4L2Subdevice::Whence whence) { SimplePipelineHandler *pipe = static_cast(pipe_); @@ -719,7 +719,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) const SimpleCameraData::Configuration *pipeConfig = config->pipeConfig(); V4L2SubdeviceFormat format{ pipeConfig->code, data->sensor_->resolution() }; - ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat); + ret = data->setupStreamProperties(&format, V4L2Subdevice::ActiveFormat); if (ret < 0) return ret; From patchwork Tue Mar 16 15:52:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian Cichy X-Patchwork-Id: 11597 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 B11D9C32E2 for ; Tue, 16 Mar 2021 15:52:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D24A368D57; Tue, 16 Mar 2021 16:52:33 +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 02C7668D4F for ; Tue, 16 Mar 2021 16:52:27 +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 1lMBzf-0000V6-2Y; Tue, 16 Mar 2021 16:52:27 +0100 Received: from mci by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lMBze-0003E2-K4; Tue, 16 Mar 2021 16:52:26 +0100 From: Marian Cichy To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Mar 2021 16:52:11 +0100 Message-Id: <20210316155211.6679-7-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); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [RFC PATCH 6/6] 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" The framerate of a stream is the inverse of the frame interval from the stream configuration. Signed-off-by: Marian Cichy --- src/gstreamer/gstlibcamera-utils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 61370d5f..7516f84a 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -125,6 +125,8 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg gst_structure_set(s, "width", G_TYPE_INT, stream_cfg.size.width, "height", G_TYPE_INT, stream_cfg.size.height, + "framerate", GST_TYPE_FRACTION, stream_cfg.frameInterval.denominator, + stream_cfg.frameInterval.numerator, nullptr); gst_caps_append_structure(caps, s);