[libcamera-devel,v2,4/6] libcamera: camera_sensor: Add tryFormat()
diff mbox series

Message ID 20230313091944.9530-5-jacopo.mondi@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: imx8-isi: Remove pixelformat-2-media-bus map
Related show

Commit Message

Jacopo Mondi March 13, 2023, 9:19 a.m. UTC
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 <jacopo.mondi@ideasonboard.com>
---
 include/libcamera/internal/camera_sensor.h |  1 +
 src/libcamera/camera_sensor.cpp            | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

Comments

Paul Elder April 24, 2023, 3:19 a.m. UTC | #1
On Mon, Mar 13, 2023 at 10:19:42AM +0100, Jacopo Mondi via libcamera-devel wrote:
> 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 <jacopo.mondi@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  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<uint32_t> &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
>   *
> -- 
> 2.39.0
>

Patch
diff mbox series

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<uint32_t> &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
  *