summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2020-07-15 10:39:11 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-17 16:36:28 +0300
commit3e7aa49344ad5233f644703559898572b57f9613 (patch)
tree579857871a6bff875f06579b5faf3910c24c90ce /src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
parent3c02a808e8934a0c2d875d5585403ce0a09d7c93 (diff)
libcamera: pipeline: ipa: raspberrypi: Use dma heap allocs for LS tables
Remove use of vcsm allocations and replace with dma heap allocations. The pipeline handler now passes the fd of the allocation over to the IPA instead of the raw pointer. Also use libcamera::FileDescriptor for fd lifetime management. This commit must be built alongside the accompanying BCM2835 ISP kernel driver changes at https://github.com/raspberrypi/linux/pull/3715. Otherwise a mismatch will cause undefined behavior. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/raspberrypi/raspberrypi.cpp')
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp49
1 files changed, 13 insertions, 36 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 718749af..bf1c7714 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -13,6 +13,7 @@
#include <libcamera/camera.h>
#include <libcamera/control_ids.h>
+#include <libcamera/file_descriptor.h>
#include <libcamera/formats.h>
#include <libcamera/ipa/raspberrypi.h>
#include <libcamera/logging.h>
@@ -31,8 +32,8 @@
#include "libcamera/internal/v4l2_controls.h"
#include "libcamera/internal/v4l2_videodevice.h"
+#include "dma_heaps.h"
#include "staggered_ctrl.h"
-#include "vcsm.h"
namespace libcamera {
@@ -286,24 +287,11 @@ class RPiCameraData : public CameraData
{
public:
RPiCameraData(PipelineHandler *pipe)
- : CameraData(pipe), sensor_(nullptr), lsTable_(nullptr),
- state_(State::Stopped), dropFrame_(false), ispOutputCount_(0)
+ : CameraData(pipe), sensor_(nullptr), state_(State::Stopped),
+ dropFrame_(false), ispOutputCount_(0)
{
}
- ~RPiCameraData()
- {
- /*
- * Free the LS table if we have allocated one. Another
- * allocation will occur in applyLS() with the appropriate
- * size.
- */
- if (lsTable_) {
- vcsm_.free(lsTable_);
- lsTable_ = nullptr;
- }
- }
-
void frameStarted(uint32_t sequence);
int loadIPA();
@@ -329,9 +317,9 @@ public:
/* Buffers passed to the IPA. */
std::vector<IPABuffer> ipaBuffers_;
- /* VCSM allocation helper. */
- ::RPi::Vcsm vcsm_;
- void *lsTable_;
+ /* DMAHEAP allocation helper. */
+ RPi::DmaHeap dmaHeap_;
+ FileDescriptor lsTable_;
RPi::StaggeredCtrl staggeredCtrl_;
uint32_t expectedSequence_;
@@ -1142,26 +1130,15 @@ int RPiCameraData::configureIPA()
entityControls.emplace(0, unicam_[Unicam::Image].dev()->controls());
entityControls.emplace(1, isp_[Isp::Input].dev()->controls());
- /* Allocate the lens shading table via vcsm and pass to the IPA. */
- if (!lsTable_) {
- lsTable_ = vcsm_.alloc("ls_grid", MAX_LS_GRID_SIZE);
- uintptr_t ptr = reinterpret_cast<uintptr_t>(lsTable_);
-
- if (!lsTable_)
+ /* Allocate the lens shading table via dmaHeap and pass to the IPA. */
+ if (!lsTable_.isValid()) {
+ lsTable_ = dmaHeap_.alloc("ls_grid", MAX_LS_GRID_SIZE);
+ if (!lsTable_.isValid())
return -ENOMEM;
- /*
- * The vcsm allocation will always be in the memory region
- * < 32-bits to allow Videocore to access the memory.
- *
- * \todo Sending a pointer to the IPA is a workaround for
- * vc_sm_cma not yet supporting dmabuf. This will not work with
- * IPA module isolation and should be reworked when vc_sma_cma
- * will permit.
- */
+ /* Allow the IPA to mmap the LS table via the file descriptor. */
ipaConfig.operation = RPI_IPA_CONFIG_LS_TABLE;
- ipaConfig.data = { static_cast<uint32_t>(ptr & 0xffffffff),
- vcsm_.getVCHandle(lsTable_) };
+ ipaConfig.data = { static_cast<unsigned int>(lsTable_.fd()) };
}
CameraSensorInfo sensorInfo = {};