diff options
author | Florian Klink <flokli@flokli.de> | 2024-01-30T09·43+0200 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2024-01-30T09·54+0000 |
commit | af9a8d372b24710bf7fc27c8e81244e1ca6d1658 (patch) | |
tree | df8bee03b202ec5081b9bd7e7b5d7b6ecdd28e1b /users/flokli/ipu6-softisp/libcamera/0003-libcamera-dma_heaps-extend-DmaHeap-class-to-support-.patch | |
parent | b38be028d96ce107439f3323026270228a871a13 (diff) |
feat(users/flokli/ipu6-softisp): init r/7454
This code adds support for the ipu6 webcams via libcamera, based on the work in https://copr.fedorainfracloud.org/coprs/jwrdegoede/ipu6-softisp/. It's supposed to be included in your NixOS configuration imports. Change-Id: Ifb71999ad61161fa23506b97cb449f73fb1270e3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10709 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'users/flokli/ipu6-softisp/libcamera/0003-libcamera-dma_heaps-extend-DmaHeap-class-to-support-.patch')
-rw-r--r-- | users/flokli/ipu6-softisp/libcamera/0003-libcamera-dma_heaps-extend-DmaHeap-class-to-support-.patch | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/users/flokli/ipu6-softisp/libcamera/0003-libcamera-dma_heaps-extend-DmaHeap-class-to-support-.patch b/users/flokli/ipu6-softisp/libcamera/0003-libcamera-dma_heaps-extend-DmaHeap-class-to-support-.patch new file mode 100644 index 000000000000..de819244871a --- /dev/null +++ b/users/flokli/ipu6-softisp/libcamera/0003-libcamera-dma_heaps-extend-DmaHeap-class-to-support-.patch @@ -0,0 +1,121 @@ +From 6d5f3b0b54df4ff66079675a4c1f0f0b76778e22 Mon Sep 17 00:00:00 2001 +From: Andrey Konovalov <andrey.konovalov@linaro.org> +Date: Wed, 10 Jan 2024 23:51:25 +0300 +Subject: [PATCH 03/25] libcamera: dma_heaps: extend DmaHeap class to support + system heap + +Add an argument to the constructor to specify dma heaps type(s) +to use. Can be DmaHeapFlag::Cma and/or DmaHeapFlag::System. +By default DmaHeapFlag::Cma is used. If both DmaHeapFlag::Cma and +DmaHeapFlag::System are set, CMA heap is tried first. + +Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s +Tested-by: Pavel Machek <pavel@ucw.cz> +--- + include/libcamera/internal/dma_heaps.h | 12 +++++++- + src/libcamera/dma_heaps.cpp | 39 +++++++++++++++----------- + 2 files changed, 34 insertions(+), 17 deletions(-) + +diff --git a/include/libcamera/internal/dma_heaps.h b/include/libcamera/internal/dma_heaps.h +index cff8f140..22aa1007 100644 +--- a/include/libcamera/internal/dma_heaps.h ++++ b/include/libcamera/internal/dma_heaps.h +@@ -9,6 +9,7 @@ + + #include <stddef.h> + ++#include <libcamera/base/flags.h> + #include <libcamera/base/unique_fd.h> + + namespace libcamera { +@@ -16,7 +17,14 @@ namespace libcamera { + class DmaHeap + { + public: +- DmaHeap(); ++ enum class DmaHeapFlag { ++ Cma = (1 << 0), ++ System = (1 << 1), ++ }; ++ ++ using DmaHeapFlags = Flags<DmaHeapFlag>; ++ ++ DmaHeap(DmaHeapFlags flags = DmaHeapFlag::Cma); + ~DmaHeap(); + bool isValid() const { return dmaHeapHandle_.isValid(); } + UniqueFD alloc(const char *name, std::size_t size); +@@ -25,4 +33,6 @@ private: + UniqueFD dmaHeapHandle_; + }; + ++LIBCAMERA_FLAGS_ENABLE_OPERATORS(DmaHeap::DmaHeapFlag) ++ + } /* namespace libcamera */ +diff --git a/src/libcamera/dma_heaps.cpp b/src/libcamera/dma_heaps.cpp +index 7444d9c2..177de31b 100644 +--- a/src/libcamera/dma_heaps.cpp ++++ b/src/libcamera/dma_heaps.cpp +@@ -16,6 +16,8 @@ + + #include "libcamera/internal/dma_heaps.h" + ++namespace libcamera { ++ + /* + * /dev/dma-heap/linux,cma is the dma-heap allocator, which allows dmaheap-cma + * to only have to worry about importing. +@@ -23,28 +25,33 @@ + * Annoyingly, should the cma heap size be specified on the kernel command line + * instead of DT, the heap gets named "reserved" instead. + */ +-static constexpr std::array<const char *, 2> heapNames = { +- "/dev/dma_heap/linux,cma", +- "/dev/dma_heap/reserved" ++static constexpr std::array<std::pair<DmaHeap::DmaHeapFlag, const char *>, 3> heapNames = { ++ /* CMA heap names first */ ++ std::make_pair(DmaHeap::DmaHeapFlag::Cma, "/dev/dma_heap/linux,cma"), ++ std::make_pair(DmaHeap::DmaHeapFlag::Cma, "/dev/dma_heap/reserved"), ++ std::make_pair(DmaHeap::DmaHeapFlag::System, "/dev/dma_heap/system") + }; + +-namespace libcamera { +- + LOG_DEFINE_CATEGORY(DmaHeap) + +-DmaHeap::DmaHeap() ++DmaHeap::DmaHeap(DmaHeapFlags flags) + { +- for (const char *name : heapNames) { +- int ret = ::open(name, O_RDWR | O_CLOEXEC, 0); +- if (ret < 0) { +- ret = errno; +- LOG(DmaHeap, Debug) << "Failed to open " << name << ": " +- << strerror(ret); +- continue; +- } ++ int ret; + +- dmaHeapHandle_ = UniqueFD(ret); +- break; ++ for (const auto &name : heapNames) { ++ if (flags & name.first) { ++ ret = ::open(name.second, O_RDWR | O_CLOEXEC, 0); ++ if (ret < 0) { ++ ret = errno; ++ LOG(DmaHeap, Debug) << "Failed to open " << name.second << ": " ++ << strerror(ret); ++ continue; ++ } ++ ++ LOG(DmaHeap, Debug) << "Using " << name.second; ++ dmaHeapHandle_ = UniqueFD(ret); ++ break; ++ } + } + + if (!dmaHeapHandle_.isValid()) +-- +2.43.0 + |