summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-01-29 11:16:13 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-02-05 01:23:19 +0200
commitd7fd40ea2b17ea67a6ac495ba831abe1977ed283 (patch)
tree1593609e2d69f0865265b1069934e191cf221107 /src
parentf1b0c7f5e3f2d55c30934d1f2f9f417e0ff778ae (diff)
libcamera: camera_sensor: Add frame length limits to CameraSensorInfo
Sensor frame length is made up of active and inactive (blanking) lines. The minimum and maximum frame length values may be used by pipeline handlers to limit frame durations based on the sensor mode capabilities. Store the minimum and maximum allowable frame length values (in lines) in the CameraSensorInfo structure. These values are computed in CameraSensor::sensorInfo() by querying the sensor subdevice V4L2_CID_VBLANK control limits. This in turn means that V4L2_CID_VBLANK is now a mandatory subdevice control. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/camera_sensor.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index e008efd9..9d60b39f 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -114,6 +114,36 @@ LOG_DEFINE_CATEGORY(CameraSensor)
*/
/**
+ * \var CameraSensorInfo::minFrameLength
+ * \brief The minimum allowable frame length in units of lines
+ *
+ * The sensor frame length comprises of active output lines and blanking lines
+ * in a frame. The minimum frame length value dictates the minimum allowable
+ * frame duration of the sensor mode.
+ *
+ * To obtain the minimum frame duration:
+ *
+ * \verbatim
+ frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)
+ \endverbatim
+ */
+
+/**
+ * \var CameraSensorInfo::maxFrameLength
+ * \brief The maximum allowable frame length in units of lines
+ *
+ * The sensor frame length comprises of active output lines and blanking lines
+ * in a frame. The maximum frame length value dictates the maximum allowable
+ * frame duration of the sensor mode.
+ *
+ * To obtain the maximum frame duration:
+ *
+ * \verbatim
+ frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)
+ \endverbatim
+ */
+
+/**
* \class CameraSensor
* \brief A camera sensor based on V4L2 subdevices
*
@@ -706,12 +736,13 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
info->outputSize = format.size;
/*
- * Retrieve the pixel rate and the line length through V4L2 controls.
- * Support for the V4L2_CID_PIXEL_RATE and V4L2_CID_HBLANK controls is
- * mandatory.
+ * Retrieve the pixel rate, line length and minimum/maximum frame
+ * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE,
+ * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory.
*/
ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE,
- V4L2_CID_HBLANK });
+ V4L2_CID_HBLANK,
+ V4L2_CID_VBLANK });
if (ctrls.empty()) {
LOG(CameraSensor, Error)
<< "Failed to retrieve camera info controls";
@@ -722,6 +753,10 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
info->lineLength = info->outputSize.width + hblank;
info->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get<int64_t>();
+ const ControlInfo vblank = ctrls.infoMap()->at(V4L2_CID_VBLANK);
+ info->minFrameLength = info->outputSize.height + vblank.min().get<int32_t>();
+ info->maxFrameLength = info->outputSize.height + vblank.max().get<int32_t>();
+
return 0;
}