From patchwork Tue Jan 5 19:05:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10820 X-Patchwork-Delegate: jacopo@jmondi.org 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 92A1AC0F1A for ; Tue, 5 Jan 2021 19:05:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A00163400; Tue, 5 Jan 2021 20:05:19 +0100 (CET) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 203BF62D2C for ; Tue, 5 Jan 2021 20:05:16 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id D9CF4100003 for ; Tue, 5 Jan 2021 19:05:15 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Jan 2021 20:05:16 +0100 Message-Id: <20210105190522.682324-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210105190522.682324-1-jacopo@jmondi.org> References: <20210105190522.682324-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/12] libcamera: ipu3: Initialize ScalerCropMaximum property 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Initialize the camera properties by registering the sensor provided ones and the ScalerCropMaximum property computed by the pipeline handler by using the analogue crop rectangle of the sensor resolution. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 43 +++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 879057dab328..418301b33a5e 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -121,6 +122,7 @@ private: PipelineHandler::cameraData(camera)); } + int initProperties(IPU3CameraData *data); int initControls(IPU3CameraData *data); int registerCameras(); @@ -734,6 +736,43 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) return ret == 0; } +/* + * \brief Initialize the camera properties + * \param[in] data The camera data + * + * Initialize the camera properties by registering the pipeline handler + * ones along with the properties assembled by inspecting the sensor + * capabilities. + * + * \return 0 on success or a negative error code for error + */ +int PipelineHandlerIPU3::initProperties(IPU3CameraData *data) +{ + CameraSensor *sensor = data->cio2_.sensor(); + data->properties_ = sensor->properties(); + + /* + * \todo The ScalerCropMaximum property depends on the sensor + * configuration. Initialize the property using the analogue crop + * rectangle of the largest sensor resolution. To be updated later when + * a new one is applied. + */ + V4L2SubdeviceFormat format; + format.size = sensor->resolution(); + int ret = sensor->setFormat(&format); + if (ret) + return ret; + + CameraSensorInfo sensorInfo{}; + ret = sensor->sensorInfo(&sensorInfo); + if (ret) + return ret; + + data->properties_.set(properties::ScalerCropMaximum, sensorInfo.analogCrop); + + return 0; +} + /* * \brief Initialize the camera controls * \param[in] data The camera data @@ -831,7 +870,9 @@ int PipelineHandlerIPU3::registerCameras() continue; /* Initialize the camera properties. */ - data->properties_ = cio2->sensor()->properties(); + ret = initProperties(data.get()); + if (ret) + continue; ret = initControls(data.get()); if (ret)