summaryrefslogtreecommitdiff
path: root/src/libcamera/software_isp/software_isp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcamera/software_isp/software_isp.cpp')
-rw-r--r--src/libcamera/software_isp/software_isp.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp
index e4e56086..20fb6f48 100644
--- a/src/libcamera/software_isp/software_isp.cpp
+++ b/src/libcamera/software_isp/software_isp.cpp
@@ -2,11 +2,13 @@
/*
* Copyright (C) 2023, Linaro Ltd
*
- * software_isp.cpp - Simple software ISP implementation
+ * Simple software ISP implementation
*/
#include "libcamera/internal/software_isp/software_isp.h"
+#include <cmath>
+#include <stdint.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
@@ -18,6 +20,7 @@
#include "libcamera/internal/framebuffer.h"
#include "libcamera/internal/ipa_manager.h"
#include "libcamera/internal/mapped_framebuffer.h"
+#include "libcamera/internal/software_isp/debayer_params.h"
#include "debayer_cpu.h"
@@ -63,12 +66,29 @@ LOG_DEFINE_CATEGORY(SoftwareIsp)
* handler
*/
SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor)
- : debayerParams_{ DebayerParams::kGain10, DebayerParams::kGain10,
- DebayerParams::kGain10, 0.5f, 0 },
- dmaHeap_(DmaHeap::DmaHeapFlag::Cma | DmaHeap::DmaHeapFlag::System)
+ : dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |
+ DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |
+ DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)
{
+ /*
+ * debayerParams_ must be initialized because the initial value is used for
+ * the first two frames, i.e. until stats processing starts providing its
+ * own parameters.
+ *
+ * \todo This should be handled in the same place as the related
+ * operations, in the IPA module.
+ */
+ std::array<uint8_t, 256> gammaTable;
+ for (unsigned int i = 0; i < 256; i++)
+ gammaTable[i] = UINT8_MAX * std::pow(i / 256.0, 0.5);
+ for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) {
+ debayerParams_.red[i] = gammaTable[i];
+ debayerParams_.green[i] = gammaTable[i];
+ debayerParams_.blue[i] = gammaTable[i];
+ }
+
if (!dmaHeap_.isValid()) {
- LOG(SoftwareIsp, Error) << "Failed to create DmaHeap object";
+ LOG(SoftwareIsp, Error) << "Failed to create DmaBufAllocator object";
return;
}