libcamera: v4l2_videodevice: Add a dequeue timer

Add a timer that gets reset on every buffer dequeue event. If the timeout
expires, optionally call a slot in the pipeline handler to handle this
condition. This may be useful in detecting and handling stalls in either the
hardware or device driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
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>
This commit is contained in:
Naushir Patuck 2022-04-06 13:35:52 +01:00 committed by Laurent Pinchart
parent 226792a141
commit 16f3d2de50
2 changed files with 63 additions and 0 deletions

View file

@ -20,7 +20,9 @@
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
#include <libcamera/base/timer.h>
#include <libcamera/base/unique_fd.h>
#include <libcamera/base/utils.h>
#include <libcamera/color_space.h>
#include <libcamera/framebuffer.h>
@ -217,6 +219,9 @@ public:
int streamOn();
int streamOff();
void setDequeueTimeout(utils::Duration timeout);
Signal<> dequeueTimeout;
static std::unique_ptr<V4L2VideoDevice>
fromEntityName(const MediaDevice *media, const std::string &entity);
@ -253,6 +258,8 @@ private:
void bufferAvailable();
FrameBuffer *dequeueBuffer();
void watchdogExpired();
V4L2Capability caps_;
V4L2DeviceFormat format_;
const PixelFormatInfo *formatInfo_;
@ -266,6 +273,9 @@ private:
EventNotifier *fdBufferNotifier_;
State state_;
Timer watchdog_;
utils::Duration watchdogDuration_;
};
class V4L2M2MDevice