summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_sensor.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-01-31 19:35:44 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-02-05 01:24:35 +0200
commit5e1f0d8b54ab27fdbf3dbc202af1b63bf4eb10da (patch)
tree63e9e30ae0e8451c45a49192f14c680ea134663c /src/libcamera/camera_sensor.cpp
parentf19cbd517bd88a20a8b137ac465a3a4288cbc01a (diff)
libcamera: camera_sensor: Restrict sensor info to raw sensors
YUV sensors don't provide the necessary information to fill CameraSensorInfo, as they include an ISP and provide a higher-level API that doesn't always expose low-level information. The CameraSensor class makes low-level V4L2 controls mandatory for all sensors, which prevents usage of YUV sensors with the simple pipeline handler. Make CameraSensor::sensorInfo() available for raw sensors only. This won't introduce any regression in pipeline handlers that currently use the sensorInfo() function as they all operate with raw sensors, and won't be a limitation for the simple pipeline handler as well as it doesn't use sensor info. If part of the sensor info (such as the active pixel array size for instance) becomes useful to expose for YUV sensors in the future, the sensorInfo() function can be extended to report that information only and skip data that is only available for raw sensors. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/camera_sensor.cpp')
-rw-r--r--src/libcamera/camera_sensor.cpp61
1 files changed, 36 insertions, 25 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 563e531e..9d5d4f99 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -277,28 +277,6 @@ int CameraSensor::init()
int CameraSensor::validateSensorDriver()
{
/*
- * Make sure the sensor driver supports the mandatory controls
- * required by the CameraSensor class.
- */
- const std::vector<uint32_t> mandatoryControls{
- V4L2_CID_EXPOSURE,
- V4L2_CID_HBLANK,
- V4L2_CID_PIXEL_RATE,
- V4L2_CID_VBLANK,
- };
-
- ControlList ctrls = subdev_->getControls(mandatoryControls);
- if (ctrls.empty()) {
- LOG(CameraSensor, Error)
- << "Mandatory V4L2 controls not available";
- LOG(CameraSensor, Error)
- << "The sensor kernel driver needs to be fixed";
- LOG(CameraSensor, Error)
- << "See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information";
- return -EINVAL;
- }
-
- /*
* Optional controls are used to register optional sensor properties. If
* not present, some values will be defaulted.
*/
@@ -307,7 +285,7 @@ int CameraSensor::validateSensorDriver()
V4L2_CID_CAMERA_SENSOR_ROTATION,
};
- ctrls = subdev_->getControls(optionalControls);
+ ControlList ctrls = subdev_->getControls(optionalControls);
if (ctrls.empty())
LOG(CameraSensor, Debug) << "Optional V4L2 controls not supported";
@@ -357,6 +335,31 @@ int CameraSensor::validateSensorDriver()
<< "See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information";
}
+ if (!bayerFormat_)
+ return 0;
+
+ /*
+ * For raw sensors, make sure the sensor driver supports the controls
+ * required by the CameraSensor class.
+ */
+ const std::vector<uint32_t> mandatoryControls{
+ V4L2_CID_EXPOSURE,
+ V4L2_CID_HBLANK,
+ V4L2_CID_PIXEL_RATE,
+ V4L2_CID_VBLANK,
+ };
+
+ ctrls = subdev_->getControls(mandatoryControls);
+ if (ctrls.empty()) {
+ LOG(CameraSensor, Error)
+ << "Mandatory V4L2 controls not available";
+ LOG(CameraSensor, Error)
+ << "The sensor kernel driver needs to be fixed";
+ LOG(CameraSensor, Error)
+ << "See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information";
+ return -EINVAL;
+ }
+
return 0;
}
@@ -693,13 +696,21 @@ int CameraSensor::setControls(ControlList *ctrls)
* \brief Assemble and return the camera sensor info
* \param[out] info The camera sensor info
*
- * The CameraSensorInfo content is assembled by inspecting the currently
- * applied sensor configuration and the sensor static properties.
+ * This function fills \a info with information that describes the camera sensor
+ * and its current configuration. The information combines static data (such as
+ * the the sensor model or active pixel array size) and data specific to the
+ * current sensor configuration (such as the line length and pixel rate).
+ *
+ * Sensor information is only available for raw sensors. When called for a YUV
+ * sensor, this function returns -EINVAL.
*
* \return 0 on success, a negative error code otherwise
*/
int CameraSensor::sensorInfo(CameraSensorInfo *info) const
{
+ if (!bayerFormat_)
+ return -EINVAL;
+
info->model = model();
/*