summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/rpi/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcamera/pipeline/rpi/common')
-rw-r--r--src/libcamera/pipeline/rpi/common/delayed_controls.cpp2
-rw-r--r--src/libcamera/pipeline/rpi/common/delayed_controls.h2
-rw-r--r--src/libcamera/pipeline/rpi/common/pipeline_base.cpp8
-rw-r--r--src/libcamera/pipeline/rpi/common/pipeline_base.h2
-rw-r--r--src/libcamera/pipeline/rpi/common/rpi_stream.cpp2
-rw-r--r--src/libcamera/pipeline/rpi/common/rpi_stream.h2
-rw-r--r--src/libcamera/pipeline/rpi/common/shared_mem_object.h128
7 files changed, 11 insertions, 135 deletions
diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.cpp b/src/libcamera/pipeline/rpi/common/delayed_controls.cpp
index 3db92e7d..ad50a7c8 100644
--- a/src/libcamera/pipeline/rpi/common/delayed_controls.cpp
+++ b/src/libcamera/pipeline/rpi/common/delayed_controls.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Raspberry Pi Ltd
*
- * delayed_controls.cpp - Helper to deal with controls that take effect with a delay
+ * Helper to deal with controls that take effect with a delay
*
* Note: This has been forked from the libcamera core implementation.
*/
diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.h b/src/libcamera/pipeline/rpi/common/delayed_controls.h
index 61f755f0..487b0057 100644
--- a/src/libcamera/pipeline/rpi/common/delayed_controls.h
+++ b/src/libcamera/pipeline/rpi/common/delayed_controls.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Raspberry Pi Ltd
*
- * delayed_controls.h - Helper to deal with controls that take effect with a delay
+ * Helper to deal with controls that take effect with a delay
*
* Note: This has been forked from the libcamera core implementation.
*/
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index 7e420b3f..289af516 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019-2023, Raspberry Pi Ltd
*
- * pipeline_base.cpp - Pipeline handler base class for Raspberry Pi devices
+ * Pipeline handler base class for Raspberry Pi devices
*/
#include "pipeline_base.h"
@@ -474,7 +474,11 @@ PipelineHandlerBase::generateConfiguration(Camera *camera, Span<const StreamRole
*/
for (const auto &format : fmts) {
PixelFormat pf = format.first.toPixelFormat();
- if (pf.isValid()) {
+ /*
+ * Some V4L2 formats translate to the same pixel format (e.g. YU12, YM12
+ * both give YUV420). We must avoid duplicating the range in this case.
+ */
+ if (pf.isValid() && deviceFormats.find(pf) == deviceFormats.end()) {
const SizeRange &ispSizes = format.second[0];
deviceFormats[pf].emplace_back(ispSizes.min, sensorSize,
ispSizes.hStep, ispSizes.vStep);
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h
index 0608bbe5..f9cecf70 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.h
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019-2023, Raspberry Pi Ltd
*
- * pipeline_base.h - Pipeline handler base class for Raspberry Pi devices
+ * Pipeline handler base class for Raspberry Pi devices
*/
#include <map>
diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
index 70f115f1..accf59eb 100644
--- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Raspberry Pi Ltd
*
- * rpi_stream.cpp - Raspberry Pi device stream abstraction class.
+ * Raspberry Pi device stream abstraction class.
*/
#include "rpi_stream.h"
diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h
index 48ed41ab..a13d5dc0 100644
--- a/src/libcamera/pipeline/rpi/common/rpi_stream.h
+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Raspberry Pi Ltd
*
- * rpi_stream.h - Raspberry Pi device stream abstraction class.
+ * Raspberry Pi device stream abstraction class.
*/
#pragma once
diff --git a/src/libcamera/pipeline/rpi/common/shared_mem_object.h b/src/libcamera/pipeline/rpi/common/shared_mem_object.h
deleted file mode 100644
index aa56c220..00000000
--- a/src/libcamera/pipeline/rpi/common/shared_mem_object.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2023, Raspberry Pi Ltd
- *
- * shared_mem_object.h - Helper class for shared memory allocations
- */
-#pragma once
-
-#include <cstddef>
-#include <fcntl.h>
-#include <string>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <utility>
-
-#include <libcamera/base/class.h>
-#include <libcamera/base/shared_fd.h>
-
-namespace libcamera {
-
-namespace RPi {
-
-template<class T>
-class SharedMemObject
-{
-public:
- static constexpr std::size_t SIZE = sizeof(T);
-
- SharedMemObject()
- : obj_(nullptr)
- {
- }
-
- template<class... Args>
- SharedMemObject(const std::string &name, Args &&...args)
- : name_(name), obj_(nullptr)
- {
- void *mem;
- int ret;
-
- ret = memfd_create(name_.c_str(), MFD_CLOEXEC);
- if (ret < 0)
- return;
-
- fd_ = SharedFD(std::move(ret));
- if (!fd_.isValid())
- return;
-
- ret = ftruncate(fd_.get(), SIZE);
- if (ret < 0)
- return;
-
- mem = mmap(nullptr, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
- fd_.get(), 0);
- if (mem == MAP_FAILED)
- return;
-
- obj_ = new (mem) T(std::forward<Args>(args)...);
- }
-
- SharedMemObject(SharedMemObject<T> &&rhs)
- {
- this->name_ = std::move(rhs.name_);
- this->fd_ = std::move(rhs.fd_);
- this->obj_ = rhs.obj_;
- rhs.obj_ = nullptr;
- }
-
- ~SharedMemObject()
- {
- if (obj_) {
- obj_->~T();
- munmap(obj_, SIZE);
- }
- }
-
- /* Make SharedMemObject non-copyable for now. */
- LIBCAMERA_DISABLE_COPY(SharedMemObject)
-
- SharedMemObject<T> &operator=(SharedMemObject<T> &&rhs)
- {
- this->name_ = std::move(rhs.name_);
- this->fd_ = std::move(rhs.fd_);
- this->obj_ = rhs.obj_;
- rhs.obj_ = nullptr;
- return *this;
- }
-
- T *operator->()
- {
- return obj_;
- }
-
- const T *operator->() const
- {
- return obj_;
- }
-
- T &operator*()
- {
- return *obj_;
- }
-
- const T &operator*() const
- {
- return *obj_;
- }
-
- const SharedFD &fd() const
- {
- return fd_;
- }
-
- explicit operator bool() const
- {
- return !!obj_;
- }
-
-private:
- std::string name_;
- SharedFD fd_;
- T *obj_;
-};
-
-} /* namespace RPi */
-
-} /* namespace libcamera */