From patchwork Tue Jan 5 19:05:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10823 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 80686C0F1A for ; Tue, 5 Jan 2021 19:05:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 54DDA6345C; Tue, 5 Jan 2021 20:05:21 +0100 (CET) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D2FC633EF for ; Tue, 5 Jan 2021 20:05:17 +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 20692100002 for ; Tue, 5 Jan 2021 19:05:16 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Jan 2021 20:05:19 +0100 Message-Id: <20210105190522.682324-10-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 09/12] libcamera: ipu3: Handle ScalerCrop 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" Add support for caching the value of control::ScalerCrop to return it in the request metadata. No cropping is currently applied on the input video device, the control value is returned in the metadata pack as it is received. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index f1329ffb0463..381524bb3499 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -66,6 +66,7 @@ public: Stream rawStream_; int32_t exposureTime_; + Rectangle scalerCrop_; }; class IPU3CameraConfiguration : public CameraConfiguration @@ -75,6 +76,7 @@ public: Status validate() override; + const Size &cio2Size() const { return cio2Configuration_.size; } const StreamConfiguration &cio2Format() const { return cio2Configuration_; } const ImgUDevice::PipeConfig imguConfig() const { return pipeConfig_; } @@ -468,12 +470,19 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) * Pass the requested stream size to the CIO2 unit and get back the * adjusted format to be propagated to the ImgU output devices. */ - const Size &sensorSize = config->cio2Format().size; V4L2DeviceFormat cio2Format; - ret = cio2->configure(sensorSize, &cio2Format); + ret = cio2->configure(config->cio2Size(), &cio2Format); if (ret) return ret; + /* Initialize the scaler crop using the sensor's analogue crop. */ + CameraSensorInfo sensorInfo; + ret = cio2->sensor()->sensorInfo(&sensorInfo); + if (ret) + /* Use the requested CIO2 output size as fallback. */ + sensorInfo.analogCrop = Rectangle(config->cio2Size()); + data->scalerCrop_ = sensorInfo.analogCrop; + /* * If the ImgU gets configured, its driver seems to expect that * buffers will be queued to its outputs, as otherwise the next @@ -656,6 +665,14 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) IPU3CameraData *data = cameraData(camera); int error = 0; + ControlList &controls = request->controls(); + if (controls.contains(controls::ScalerCrop)) + /* + * \todo No scaling is applied. Just return the value in the + * request metadata as it is. + */ + data->scalerCrop_ = controls.get(controls::ScalerCrop); + /* * Queue a buffer on the CIO2, using the raw stream buffer provided in * the request, if any, or a CIO2 internal buffer otherwise. @@ -991,6 +1008,7 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer) /* Mark the request as complete. */ request->metadata().set(controls::draft::PipelineDepth, 3); request->metadata().set(controls::ExposureTime, exposureTime_); + request->metadata().set(controls::ScalerCrop, scalerCrop_); pipe_->completeRequest(request); }