libcamera: camera_sensor: Add tryFormat()

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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi 2023-03-13 10:02:33 +01:00
parent 14995410fe
commit 608af3127c
2 changed files with 18 additions and 0 deletions

View file

@ -56,6 +56,7 @@ public:
const Size &size) const; const Size &size) const;
int setFormat(V4L2SubdeviceFormat *format, int setFormat(V4L2SubdeviceFormat *format,
Transform transform = Transform::Identity); Transform transform = Transform::Identity);
int tryFormat(V4L2SubdeviceFormat *format) const;
const ControlInfoMap &controls() const; const ControlInfoMap &controls() const;
ControlList getControls(const std::vector<uint32_t> &ids); ControlList getControls(const std::vector<uint32_t> &ids);

View file

@ -795,6 +795,23 @@ int CameraSensor::setFormat(V4L2SubdeviceFormat *format, Transform transform)
return 0; 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 * \brief Retrieve the supported V4L2 controls and their information
* *