diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-03 18:33:55 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-08-31 22:44:11 +0300 |
commit | f69b19667f017a94980657ebbd6a00f5448e69ff (patch) | |
tree | 04a7a2f7aab581f351eaf39fba5ada1f2e109186 /src | |
parent | 2b314587638f0a14b95cf579ba963c2237560537 (diff) |
libcamera: pipeline: simple: Open all video devices at match() time
Move opening of video devices at match() time, the same way as subdevs
are opened, to make the handling of V4L2 video devices and subdevices
more consistent.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/pipeline/simple/simple.cpp | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index c3fd7e1f..1c53de5c 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -83,14 +83,12 @@ LOG_DEFINE_CATEGORY(SimplePipeline) * handled by this heuristic. * * Once the camera data instances have been created, the match() function - * creates a V4L2Subdevice instance for each entity used by any of the cameras - * and stores the instances in SimplePipelineHandler::subdevs_, accessible by - * the SimpleCameraData class through the SimplePipelineHandler::subdev() - * function. This avoids duplication of subdev instances between different - * cameras when the same entity is used in multiple paths. A similar mechanism - * is used for V4L2VideoDevice instances, but instances are in this case created - * on demand when accessed through SimplePipelineHandler::video() instead of all - * in one go at initialization time. + * creates a V4L2VideoDevice or V4L2Subdevice instance for each entity used by + * any of the cameras and stores them in SimplePipelineHandler::entities_, + * accessible by the SimpleCameraData class through the + * SimplePipelineHandler::subdev() and SimplePipelineHandler::video() functions. + * This avoids duplication of subdev instances between different cameras when + * the same entity is used in multiple paths. * * Finally, all camera data instances are initialized to gather information * about the possible pipeline configurations for the corresponding camera. If @@ -403,10 +401,7 @@ int SimpleCameraData::init() int ret; video_ = pipe->video(entities_.back().entity); - if (!video_) { - LOG(SimplePipeline, Error) << "Failed to open video device"; - return -ENODEV; - } + ASSERT(video_); /* * Setup links first as some subdev drivers take active links into @@ -1074,24 +1069,44 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) /* * Insert all entities in the global entities list. Create and open - * V4L2Subdevice instances for each entity corresponding to a V4L2 - * subdevice. + * V4L2VideoDevice and V4L2Subdevice instances for the corresponding + * entities. */ for (Me/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Collabora Ltd.
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
*
* gstlibcamerapool.cpp - GStreamer Buffer Pool
*/
#include "gstlibcamerapool.h"
#include <libcamera/stream.h>
#include "gstlibcamera-utils.h"
using namespace libcamera;
enum {
SIGNAL_BUFFER_NOTIFY,
N_SIGNALS
};
static guint signals[N_SIGNALS];
struct _GstLibcameraPool {
GstBufferPool parent;
GstAtomicQueue *queue;
GstLibcameraAllocator *allocator;
Stream *stream;
};
G_DEFINE_TYPE(GstLibcameraPool, gst_libcamera_pool, GST_TYPE_BUFFER_POOL)
static GstFlowReturn
gst_libcamera_pool_acquire_buffer(GstBufferPool *pool, GstBuffer **buffer,
[[maybe_unused]] GstBufferPoolAcquireParams *params)
{
GstLibcameraPool *self = GST_LIBCAMERA_POOL(pool);
GstBuffer *buf = GST_BUFFER(gst_atomic_queue_pop(self->queue));
if (!buf)
return GST_FLOW_ERROR;
if (!gst_libcamera_allocator_prepare_buffer(self->allocator, self->stream, buf)) {
gst_atomic_queue_push(self->queue, buf);
return GST_FLOW_ERROR;
}
*buffer = buf;
return GST_FLOW_OK;
}
static void
gst_libcamera_pool_reset_buffer(GstBufferPool *pool, |