v4l2: v4l2_compat: Add eventfd signaling to support polling
To support polling, we need to be able to signal when data is available to be read (POLLIN), as well as events (POLLPRI). Add the necessary calls to eventfd to allow signaling POLLIN. We signal POLLIN by writing writing to the eventfd, and clear it by reading from the eventfd, upon VIDIOC_DQBUF. Note that eventfd does not support signaling POLLPRI, so we don't yet support V4L2 events. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
5c5481911a
commit
8df593841d
5 changed files with 32 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "v4l2_camera.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libcamera/internal/log.h"
|
||||
|
||||
|
@ -53,6 +54,11 @@ void V4L2Camera::close()
|
|||
camera_->release();
|
||||
}
|
||||
|
||||
void V4L2Camera::bind(int efd)
|
||||
{
|
||||
efd_ = efd;
|
||||
}
|
||||
|
||||
void V4L2Camera::getStreamConfig(StreamConfiguration *streamConfig)
|
||||
{
|
||||
*streamConfig = config_->at(0);
|
||||
|
@ -84,6 +90,9 @@ void V4L2Camera::requestComplete(Request *request)
|
|||
completedBuffers_.push_back(std::move(metadata));
|
||||
bufferLock_.unlock();
|
||||
|
||||
uint64_t data = 1;
|
||||
::write(efd_, &data, sizeof(data));
|
||||
|
||||
bufferSema_.release();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue