diff options
author | Harvey Yang <chenghaoyang@chromium.org> | 2024-11-21 05:51:32 +0000 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2024-11-28 16:44:08 +0000 |
commit | 1197fff4821e119c5aeca017fa095f2225aed292 (patch) | |
tree | a9132b9323ddf27699741b4ef538d2b072e69ce3 /src | |
parent | 39482d59fe7160740ea5dd61f3ed965a88d848ce (diff) |
debayer_cpu: Replace syncing DMABUFs with DmaSyncer
As there's an existing helper class DmaSyncer that makes synchronizing
DMABUFs more easily, this patch removes the self-defined function and
reuse DmaSyncer.
Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/software_isp/debayer_cpu.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index cf5ecdf7..31ab96ab 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -20,6 +20,7 @@ #include <libcamera/formats.h> #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/mapped_framebuffer.h" @@ -722,23 +723,6 @@ void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) namespace { -void syncBufferForCPU(FrameBuffer *buffer, uint64_t syncFlags) -{ - for (const FrameBuffer::Plane &plane : buffer->planes()) { - const int fd = plane.fd.get(); - struct dma_buf_sync sync = { syncFlags }; - int ret; - - ret = ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync); - if (ret < 0) { - ret = errno; - LOG(Debayer, Error) - << "Syncing buffer FD " << fd << " with flags " - << syncFlags << " failed: " << strerror(ret); - } - } -} - inline int64_t timeDiff(timespec &after, timespec &before) { return (after.tv_sec - before.tv_sec) * 1000000000LL + @@ -756,8 +740,12 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime); } - syncBufferForCPU(input, DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ); - syncBufferForCPU(output, DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE); + std::vector<DmaSyncer> dmaSyncers; + for (const FrameBuffer::Plane &plane : input->planes()) + dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read); + + for (const FrameBuffer::Plane &plane : output->planes()) + dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); green_ = params.green; red_ = swapRedBlueGains_ ? params.blue : params.red; @@ -786,8 +774,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output metadata.planes()[0].bytesused = out.planes()[0].size(); - syncBufferForCPU(output, DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE); - syncBufferForCPU(input, DMA_BUF_SYNC_END | DMA_BUF_SYNC_READ); + dmaSyncers.clear(); /* Measure before emitting signals */ if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure && |