ipa: rkisp1: Use offset in mapping IPABuffer
IPABuffer is represented by FrameBuffer. FrameBuffer::Plane has now an offset. This uses the offset variable to map the IPABuffer. The mapped IPABuffer is represented and managed as MappedFrameBuffer. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
470513b6a7
commit
73994ec6bc
1 changed files with 13 additions and 20 deletions
|
@ -10,7 +10,6 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
|
||||||
|
|
||||||
#include <linux/rkisp1-config.h>
|
#include <linux/rkisp1-config.h>
|
||||||
#include <linux/v4l2-controls.h>
|
#include <linux/v4l2-controls.h>
|
||||||
|
@ -24,6 +23,8 @@
|
||||||
#include <libcamera/ipa/rkisp1_ipa_interface.h>
|
#include <libcamera/ipa/rkisp1_ipa_interface.h>
|
||||||
#include <libcamera/request.h>
|
#include <libcamera/request.h>
|
||||||
|
|
||||||
|
#include <libcamera/internal/mapped_framebuffer.h>
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
LOG_DEFINE_CATEGORY(IPARkISP1)
|
LOG_DEFINE_CATEGORY(IPARkISP1)
|
||||||
|
@ -54,7 +55,7 @@ private:
|
||||||
void metadataReady(unsigned int frame, unsigned int aeState);
|
void metadataReady(unsigned int frame, unsigned int aeState);
|
||||||
|
|
||||||
std::map<unsigned int, FrameBuffer> buffers_;
|
std::map<unsigned int, FrameBuffer> buffers_;
|
||||||
std::map<unsigned int, void *> buffersMemory_;
|
std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;
|
||||||
|
|
||||||
ControlInfoMap ctrls_;
|
ControlInfoMap ctrls_;
|
||||||
|
|
||||||
|
@ -160,22 +161,13 @@ void IPARkISP1::mapBuffers(const std::vector<IPABuffer> &buffers)
|
||||||
std::forward_as_tuple(buffer.planes));
|
std::forward_as_tuple(buffer.planes));
|
||||||
const FrameBuffer &fb = elem.first->second;
|
const FrameBuffer &fb = elem.first->second;
|
||||||
|
|
||||||
/*
|
MappedFrameBuffer mappedBuffer(&fb, MappedFrameBuffer::MapFlag::ReadWrite);
|
||||||
* \todo Provide a helper to mmap() buffers (possibly exposed
|
if (!mappedBuffer.isValid()) {
|
||||||
* to applications).
|
|
||||||
*/
|
|
||||||
buffersMemory_[buffer.id] = mmap(NULL,
|
|
||||||
fb.planes()[0].length,
|
|
||||||
PROT_READ | PROT_WRITE,
|
|
||||||
MAP_SHARED,
|
|
||||||
fb.planes()[0].fd.fd(),
|
|
||||||
0);
|
|
||||||
|
|
||||||
if (buffersMemory_[buffer.id] == MAP_FAILED) {
|
|
||||||
int ret = -errno;
|
|
||||||
LOG(IPARkISP1, Fatal) << "Failed to mmap buffer: "
|
LOG(IPARkISP1, Fatal) << "Failed to mmap buffer: "
|
||||||
<< strerror(-ret);
|
<< strerror(mappedBuffer.error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mappedBuffers_.emplace(buffer.id, std::move(mappedBuffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,8 +178,7 @@ void IPARkISP1::unmapBuffers(const std::vector<unsigned int> &ids)
|
||||||
if (fb == buffers_.end())
|
if (fb == buffers_.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
munmap(buffersMemory_[id], fb->second.planes()[0].length);
|
mappedBuffers_.erase(id);
|
||||||
buffersMemory_.erase(id);
|
|
||||||
buffers_.erase(id);
|
buffers_.erase(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +191,8 @@ void IPARkISP1::processEvent(const RkISP1Event &event)
|
||||||
unsigned int bufferId = event.bufferId;
|
unsigned int bufferId = event.bufferId;
|
||||||
|
|
||||||
const rkisp1_stat_buffer *stats =
|
const rkisp1_stat_buffer *stats =
|
||||||
static_cast<rkisp1_stat_buffer *>(buffersMemory_[bufferId]);
|
reinterpret_cast<rkisp1_stat_buffer *>(
|
||||||
|
mappedBuffers_.at(bufferId).maps()[0].data());
|
||||||
|
|
||||||
updateStatistics(frame, stats);
|
updateStatistics(frame, stats);
|
||||||
break;
|
break;
|
||||||
|
@ -210,7 +202,8 @@ void IPARkISP1::processEvent(const RkISP1Event &event)
|
||||||
unsigned int bufferId = event.bufferId;
|
unsigned int bufferId = event.bufferId;
|
||||||
|
|
||||||
rkisp1_params_cfg *params =
|
rkisp1_params_cfg *params =
|
||||||
static_cast<rkisp1_params_cfg *>(buffersMemory_[bufferId]);
|
reinterpret_cast<rkisp1_params_cfg *>(
|
||||||
|
mappedBuffers_.at(bufferId).maps()[0].data());
|
||||||
|
|
||||||
queueRequest(frame, params, event.controls);
|
queueRequest(frame, params, event.controls);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue