From patchwork Mon Mar 13 09:19:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18387 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 BF03EC329D for ; Mon, 13 Mar 2023 09:20:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 467E36271C; Mon, 13 Mar 2023 10:20:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678699208; bh=74NT6tj49KoKhyeAa5hqxhOFn5GXnBdfSKSXaFI6R+U=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=R7KBWhilgLi9R2KH/WX2cfGi1HV931S6NhMJ+217AOWZL0G6XIUaEeQ60f7Ggiyi+ NW23yIUYqKQW8xdccSq9GP7tykvjcXzv1p/bLzSx1kSNGZZdev5VKhMY/FkQYViv8h fEGnIvzZYgn29wL/w7uPe7RzkB8XQtVwiDI00qxtjmrJXUT0RKJUcMRWvAEj2rR/kG oyxaGHjKNG4IsHAH+ImXAgkr46G1NjhycpJN7WeOQR1dBBpfYRZ6v1WG625rR0g1Z8 EZVhkdZKlQIaeclkPuTYqGIrWiS6kU5/aS4cRIE07F89nyYRyK37vwcnYVY+1cqDDu 4xJqa59aFNaxQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F98862712 for ; Mon, 13 Mar 2023 10:20:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TA9wSLFM"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-79-33-55-183.retail.telecomitalia.it [79.33.55.183]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F175C563; Mon, 13 Mar 2023 10:20:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1678699204; bh=74NT6tj49KoKhyeAa5hqxhOFn5GXnBdfSKSXaFI6R+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TA9wSLFMEAVmmgogrHolBIO6yJnoYOS/8DEscgGyjQ/SMgN0H/MFgXppVGX1twIqj KHqg6BeO/ZOv/svIJxfViKHcLCNHo3gtT1oT+6wohMnpC3mFuUEuD/p87/+mjqXlh4 LEvYpkJ+w9aCHw1AovpLXWdS5qXswvF48t9vJb2I= To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Mar 2023 10:19:42 +0100 Message-Id: <20230313091944.9530-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230313091944.9530-1-jacopo.mondi@ideasonboard.com> References: <20230313091944.9530-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/6] libcamera: camera_sensor: Add tryFormat() 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a function to the CameraSensor class that allows to test a format without applying it to the subdevice and without modifying any control value associated with the camera sensor. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 928c61af7f4e..02c77ab037da 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -56,6 +56,7 @@ public: const Size &size) const; int setFormat(V4L2SubdeviceFormat *format, Transform transform = Transform::Identity); + int tryFormat(V4L2SubdeviceFormat *format) const; const ControlInfoMap &controls() const; ControlList getControls(const std::vector &ids); diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index e442b89dacd0..06f315210240 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -795,6 +795,23 @@ int CameraSensor::setFormat(V4L2SubdeviceFormat *format, Transform transform) return 0; } +/** + * \brief Try the sensor output format + * \param[in] format The desired sensor output format + * + * The ranges of any controls associated with the sensor are not updated. + * + * \todo Add support for Transform by changing the format's Bayer ordering + * before calling subdev_->setFormat(). + * + * \return 0 on success or a negative error code otherwise + */ +int CameraSensor::tryFormat(V4L2SubdeviceFormat *format) const +{ + return subdev_->setFormat(pad_, format, + V4L2Subdevice::Whence::TryFormat); +} + /** * \brief Retrieve the supported V4L2 controls and their information *