From 5bcd5bb6ca6a0101d767192d53d1bfb62b82df49 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 26 Jul 2024 11:48:53 +0200 Subject: libcamera: v4l2: Add bind context Signed-off-by: Jacopo Mondi --- include/libcamera/internal/v4l2_videodevice.h | 2 ++ src/libcamera/v4l2_videodevice.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index d077f958..2583001f 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -204,6 +204,8 @@ public: const V4L2Capability &caps() const { return caps_; } + int bindContext(unsigned int context); + int getFormat(V4L2DeviceFormat *format); int tryFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 03ce5df0..a1d9f0ce 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -796,6 +796,18 @@ std::string V4L2VideoDevice::logPrefix() const (V4L2_TYPE_IS_OUTPUT(bufferType_) ? ":out]" : ":cap]"); } +int V4L2VideoDevice::bindContext(unsigned int context) +{ + struct v4l2_context c = {}; + + c.context_fd = context; + int ret = ioctl(VIDIOC_BIND_CONTEXT, &c); + if (ret) + LOG(V4L2, Error) << "Unable to bind context: " << strerror(-ret); + + return ret; +} + /** * \brief Retrieve the image format set on the V4L2 video device * \param[out] format The image format applied on the video device -- cgit v1.2.1