@@ -17,6 +17,7 @@
#include <vector>
#include <libcamera/base/class.h>
+#include <libcamera/base/flags.h>
#include <libcamera/base/log.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
@@ -29,7 +30,6 @@
#include <libcamera/ipa/softisp_ipa_proxy.h>
#include "libcamera/internal/camera_sensor.h"
-#include "libcamera/internal/dma_buf_allocator.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/shared_mem_object.h"
#include "libcamera/internal/software_isp/debayer_params.h"
@@ -37,6 +37,7 @@
namespace libcamera {
class Debayer;
+class DmaBufAllocator;
class FrameBuffer;
class PixelFormat;
class Stream;
@@ -47,8 +48,14 @@ LOG_DECLARE_CATEGORY(SoftwareIsp)
class SoftwareIsp : public Object
{
public:
+ enum class SoftwareIspFlag {
+ AllocCmaDmaBuffers = 1 << 0,
+ };
+
+ using SoftwareIspFlags = Flags<SoftwareIspFlag>;
+
SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
- ControlInfoMap *ipaControls);
+ SoftwareIspFlags flags, ControlInfoMap *ipaControls);
~SoftwareIsp();
int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }
@@ -99,7 +106,7 @@ private:
Thread ispWorkerThread_;
SharedMemObject<DebayerParams> sharedParams_;
DebayerParams debayerParams_;
- DmaBufAllocator dmaHeap_;
+ DmaBufAllocator *dmaHeap_;
bool ccmEnabled_;
bool lscEnabled_;
@@ -615,7 +615,9 @@ int SimpleCameraData::init()
* Instantiate Soft ISP if this is enabled for the given driver and no converter is used.
*/
if (!converter_ && pipe->swIspEnabled()) {
- swIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_.get(), &controlInfo_);
+ swIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_.get(),
+ SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers,
+ &controlInfo_);
if (!swIsp_->isValid()) {
LOG(SimplePipeline, Warning)
<< "Failed to create software ISP, disabling software debayering";
@@ -24,6 +24,7 @@
#include <libcamera/stream.h>
#include "libcamera/internal/bayer_format.h"
+#include "libcamera/internal/dma_buf_allocator.h"
#include "libcamera/internal/framebuffer.h"
#include "libcamera/internal/software_isp/debayer_params.h"
@@ -76,16 +77,22 @@ LOG_DEFINE_CATEGORY(SoftwareIsp)
* \brief Constructs SoftwareIsp object
* \param[in] pipe The pipeline handler in use
* \param[in] sensor Pointer to the CameraSensor instance owned by the pipeline handler
+ * \param[in] flags SoftwareIspFlags
* \param[out] ipaControls The IPA controls to update
*/
SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
- ControlInfoMap *ipaControls)
- : ispWorkerThread_("SWIspWorker"),
- dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |
- DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |
- DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)
+ SoftwareIspFlags flags, ControlInfoMap *ipaControls)
+ : ispWorkerThread_("SWIspWorker")
{
- if (!dmaHeap_.isValid()) {
+ DmaBufAllocator::DmaBufAllocatorFlags types =
+ DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |
+ DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf;
+
+ if (flags & SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers)
+ types |= DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap;
+
+ dmaHeap_ = new DmaBufAllocator(types);
+ if (!dmaHeap_->isValid()) {
LOG(SoftwareIsp, Error) << "Failed to create DmaBufAllocator object";
return;
}
@@ -323,7 +330,7 @@ int SoftwareIsp::exportBuffers(const Stream *stream, unsigned int count,
if (stream == nullptr)
return -EINVAL;
- return dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers);
+ return dmaHeap_->exportBuffers(count, { debayer_->frameSize() }, buffers);
}
/**
Allocating DMA buffers from the CMA pool is not necessary on platforms where the expected consumers (GPU, video-encoder) support non contiguous memory and allocating the buffers from the limited CMA pool may cause starvation of that pool for other processes which do actually require CMA. Add a new "SoftwareIspFlags flags" parameter to the SoftwareIsp() constructor, implement a single AllocCmaDmaBuffers flag for now and only request CmaHeap backed DmaBuffers when this flag is set. The only SoftwareIsp() constructor caller is modified to pass the new flag so this patch does not cause any behavior change. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com> --- .../internal/software_isp/software_isp.h | 13 +++++++++--- src/libcamera/pipeline/simple/simple.cpp | 4 +++- src/libcamera/software_isp/software_isp.cpp | 21 ++++++++++++------- 3 files changed, 27 insertions(+), 11 deletions(-)