From patchwork Fri Nov 6 15:49:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10390 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 9D65BBE084 for ; Fri, 6 Nov 2020 15:49:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C4CA462D81; Fri, 6 Nov 2020 16:49:54 +0100 (CET) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DD9F5629A6 for ; Fri, 6 Nov 2020 16:49:53 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id A2B7640002 for ; Fri, 6 Nov 2020 15:49:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Nov 2020 16:49:46 +0100 Message-Id: <20201106154947.261132-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201106154947.261132-1-jacopo@jmondi.org> References: <20201106154947.261132-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] libcamera: camera_sensor: Initialize PixelArray properties 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 pixel array properties 'PixelArraySize' and 'PixelArrayActiveArea' inspecting the V4L2 CROP_BOUNDS and CROP_DEFAULT selection targets. The properties are registered only if the sensor subdevice support the above mentioned selection targets. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/camera_sensor.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 49b0a026125c..266ed7e9238e 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -288,6 +288,28 @@ int CameraSensor::initProperties() propertyValue = 0; properties_.set(properties::Rotation, propertyValue); + Rectangle bounds{}; + ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &bounds); + if (!ret) { + properties_.set(properties::PixelArraySize, + Size(bounds.width, bounds.height)); + } + + Rectangle crop{}; + ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &crop); + if (!ret) { + /* + * V4L2_SEL_TGT_CROP_DEFAULT and V4L2_SEL_TGT_CROP_BOUNDS are + * defined relatively to the sensor native pixel array size, + * while properties::PixelArrayActiveAreas is defined relatively + * to properties::PixelArraySize. Adjust them + */ + crop.x -= bounds.x; + crop.y -= bounds.y; + properties_.set(properties::PixelArrayActiveAreas, + { crop }); + } + return 0; }