summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/vimc.cpp
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2018-12-20 01:38:09 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2018-12-31 00:58:31 +0100
commit167f751701d838538c656b9ae2b566e005489f6c (patch)
tree7b92b1cbd80d1101b720682412fd4e3ddbd2121e /src/libcamera/pipeline/vimc.cpp
parent1c4f1563326ed1d9596a330ac750ee0decbd702f (diff)
libcamera: pipeline: vimc: add pipeline handler for vimc
Provide a pipeline handler for the virtual vimc driver. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/vimc.cpp')
-rw-r--r--src/libcamera/pipeline/vimc.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
new file mode 100644
index 00000000..b1e2d32c
--- /dev/null
+++ b/src/libcamera/pipeline/vimc.cpp
@@ -0,0 +1,92 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2018, Google Inc.
+ *
+ * vimc.cpp - Pipeline handler for the vimc device
+ */
+
+#include <libcamera/camera.h>
+
+#include "device_enumerator.h"
+#include "pipeline_handler.h"
+
+namespace libcamera {
+
+class PipeHandlerVimc : public PipelineHandler
+{
+public:
+ PipeHandlerVimc();
+ ~PipeHandlerVimc();
+
+ bool match(DeviceEnumerator *enumerator);
+
+ unsigned int count();
+ Camera *camera(unsigned int id) final;
+
+private:
+ DeviceInfo *info_;
+ Camera *camera_;
+};
+
+PipeHandlerVimc::PipeHandlerVimc()
+ : info_(nullptr), camera_(nullptr)
+{
+}
+
+PipeHandlerVimc::~PipeHandlerVimc()
+{
+ if (camera_)
+ camera_->put();
+
+ if (info_)
+ info_->release();
+}
+
+unsigned int PipeHandlerVimc::count()
+{
+ return 1;
+}
+
+Camera *PipeHandlerVimc::camera(unsigned int id)
+{
+ if (id != 0)
+ return nullptr;
+
+ return camera_;
+}
+
+bool PipeHandlerVimc::match(DeviceEnumerator *enumerator)
+{
+ DeviceMatch dm("vimc");
+
+ dm.add("Raw Capture 0");
+ dm.add("Raw Capture 1");
+ dm.add("RGB/YUV Capture");
+ dm.add("Sensor A");
+ dm.add("Sensor B");
+ dm.add("Debayer A");
+ dm.add("Debayer B");
+ dm.add("RGB/YUV Input");
+ dm.add("Scaler");
+
+ info_ = enumerator->search(dm);
+ if (!info_)
+ return false;
+
+ info_->acquire();
+
+ /*
+ * NOTE: A more complete Camera implementation could
+ * be passed the DeviceInfo(s) it controls here or
+ * a reference to the PipelineHandler. Which method
+ * will be chosen depends on how the Camera
+ * object is modeled.
+ */
+ camera_ = new Camera("Dummy VIMC Camera");
+
+ return true;
+}
+
+REGISTER_PIPELINE_HANDLER(PipeHandlerVimc);
+
+} /* namespace libcamera */