@@ -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>
@@ -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; }
@@ -618,7 +618,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,14 +77,18 @@ 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)
+ SoftwareIspFlags flags, ControlInfoMap *ipaControls)
: ispWorkerThread_("SWIspWorker"),
- dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |
+ /* clang-format off */
+ dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf |
DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |
- DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)
+ ((flags & SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers) ?
+ DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap :
+ DmaBufAllocator::DmaBufAllocatorFlag{})) /* clang-format on */
{
if (!dmaHeap_.isValid()) {
LOG(SoftwareIsp, Error) << "Failed to create DmaBufAllocator object";
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. clang-format wants to make the lines with the "flags ? cma : none" code one single long line, so disable it for the dmaHeap_() initialization. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com> --- Changes in v2: - Keep SoftwareIsp->dmaHeap_ as an embedded object rather then changing it into a (raw) pointer and use the c++ "member initializer list" construction suggested by Barnabás to conditionally set the types parameter when initializing it --- .../libcamera/internal/software_isp/software_isp.h | 9 ++++++++- src/libcamera/pipeline/simple/simple.cpp | 4 +++- src/libcamera/software_isp/software_isp.cpp | 11 ++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-)