summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_sensor.cpp
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2021-05-05 14:53:07 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-05-11 02:31:08 +0300
commit91122dea978c880b9bb03a78641ff5585e20be8c (patch)
treeb76ae8d350f1e1737ce2885afd203a2f26adca6d /src/libcamera/camera_sensor.cpp
parent45c6a7e6e8277fed743e4033d39deeb36a58a4b0 (diff)
libcamera: camera_sensor: Fix frame lengths calculated by sensorInfo()
The minimum and maximum vblanking can change when a new format is applied to the sensor subdevice, so be sure to retrieve up-to-date values. The V4L2Device acquires the new updateControlInfo() method to perform this function, and which the CameraSensor calls automatically if its setFormat method is used to update the sensor. However, not all pipeline handlers invoke the setFormat method directly, so the new method must be made publicly available for pipeline handlers to call if they need to. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera_sensor.cpp')
-rw-r--r--src/libcamera/camera_sensor.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 1db263cf..eb84d9eb 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -670,15 +670,30 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu
/**
* \brief Set the sensor output format
* \param[in] format The desired sensor output format
+ *
+ * The ranges of any controls associated with the sensor are also updated.
+ *
* \return 0 on success or a negative error code otherwise
*/
int CameraSensor::setFormat(V4L2SubdeviceFormat *format)
{
- return subdev_->setFormat(pad_, format);
+ int ret = subdev_->setFormat(pad_, format);
+ if (ret)
+ return ret;
+
+ updateControlInfo();
+ return 0;
}
/**
* \brief Retrieve the supported V4L2 controls and their information
+ *
+ * Control information is updated automatically to reflect the current sensor
+ * configuration when the setFormat() function is called, without invalidating
+ * any iterator on the ControlInfoMap. A manual update can also be forced by
+ * calling the updateControlInfo() function for pipeline handlers that change
+ * the sensor configuration wihtout using setFormat().
+ *
* \return A map of the V4L2 controls supported by the sensor
*/
const ControlInfoMap &CameraSensor::controls() const
@@ -764,6 +779,10 @@ int CameraSensor::setControls(ControlList *ctrls)
* Sensor information is only available for raw sensors. When called for a YUV
* sensor, this function returns -EINVAL.
*
+ * Pipeline handlers that do not change the sensor format using the setFormat()
+ * method may need to call updateControlInfo() beforehand, to ensure all the
+ * control ranges are up to date.
+ *
* \return 0 on success, a negative error code otherwise
*/
int CameraSensor::sensorInfo(CameraSensorInfo *info) const
@@ -835,6 +854,16 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
return 0;
}
+/**
+ * \fn void CameraSensor::updateControlInfo()
+ * \brief Update the sensor's ControlInfoMap in case they have changed
+ * \sa V4L2Device::updateControlInfo()
+ */
+void CameraSensor::updateControlInfo()
+{
+ subdev_->updateControlInfo();
+}
+
std::string CameraSensor::logPrefix() const
{
return "'" + entity_->name() + "'";