From patchwork Thu Apr 27 14:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18570 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 46018C327D for ; Thu, 27 Apr 2023 14:48:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 808EC627EF; Thu, 27 Apr 2023 16:48:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1682606885; bh=e7YYOFwqw/JxN1vpxtRp7jZYRBWw7rMkfkQiS6aJu/o=; 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=VKDl+GiCdSfe5sfXNCICL8euUUbqk7gDZY2QC3fCJtA9bfj+W4RROH5NtoHhm3/UO Ua/XrtKMagaSdj0rWXTBQe7T0VSdjc+5Qpxry36E0j7k+SYdcF41ZoC2eB5hb4gk/p Q8qMrtDTEtI6MR+XNoKyJfOL8jW+/9p9OsE5Jy4YcqSx7F68eTHVRr0gto2CckYO8a PHGW3zeyKLqvCKsLTh7kKfzgC1OS/WC2/+qDqKSb3vhh3iRVkPJhfW+2eSugLWCrqm Gx8kevFo/KXDyY31M/u5lbyGBNyFZ/OGIdnh6x/AjdJNJnnFqj5sXnogzDv7WDmSp1 elAg4mILAabIQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B4A3A627DE for ; Thu, 27 Apr 2023 16:48:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="r2LTdOQC"; dkim-atps=neutral Received: from uno.lan (unknown [IPv6:2001:b07:5d2e:52c9:1cf0:b3bc:c785:4625]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 798AE802; Thu, 27 Apr 2023 16:47:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1682606868; bh=e7YYOFwqw/JxN1vpxtRp7jZYRBWw7rMkfkQiS6aJu/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2LTdOQCYWzFPdFm31ebkMHKlMidtxQavz0TtS5jPP1xcU7OuXsl2FuOpDQx0KCsQ N1ua0Ubs1LTvUn9Ux8vYpai+zGnqsiUInnpKZV/rgPWMWgqJTEOL3iXC0rHhjdqsGP hwPDlgz6+r4tP7TZsFFOUYYETW59FFtv3ojz+O+I= To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Apr 2023 16:47:38 +0200 Message-Id: <20230427144740.64075-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230427144740.64075-1-jacopo.mondi@ideasonboard.com> References: <20230427144740.64075-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 Reviewed-by: Laurent Pinchart --- 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 *