Message ID | 20240907143110.2210711-8-chenghaoyang@google.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Quoting Harvey Yang (2024-09-07 15:28:32) > As the helper function DmaBufAllocator::exportBuffers is added, we can > avoid some code duplication in SoftwareIsp as well. > > Signed-off-by: Harvey Yang <chenghaoyang@chromium.org> > Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/libcamera/software_isp/software_isp.cpp | 20 +------------------- > 1 file changed, 1 insertion(+), 19 deletions(-) > > diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp > index 1140372c..3455f13a 100644 > --- a/src/libcamera/software_isp/software_isp.cpp > +++ b/src/libcamera/software_isp/software_isp.cpp > @@ -255,25 +255,7 @@ int SoftwareIsp::exportBuffers(const Stream *stream, unsigned int count, > if (stream == nullptr) > return -EINVAL; > > - for (unsigned int i = 0; i < count; i++) { > - const std::string name = "frame-" + std::to_string(i); > - const size_t frameSize = debayer_->frameSize(); > - > - FrameBuffer::Plane outPlane; > - outPlane.fd = SharedFD(dmaHeap_.alloc(name.c_str(), frameSize)); > - if (!outPlane.fd.isValid()) { > - LOG(SoftwareIsp, Error) > - << "failed to allocate a dma_buf"; > - return -ENOMEM; > - } > - outPlane.offset = 0; > - outPlane.length = frameSize; > - > - std::vector<FrameBuffer::Plane> planes{ outPlane }; > - buffers->emplace_back(std::make_unique<FrameBuffer>(std::move(planes))); > - } > - > - return count; > + return dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers); > } > > /** > -- > 2.46.0.469.g59c65b2a67-goog >
diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 1140372c..3455f13a 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -255,25 +255,7 @@ int SoftwareIsp::exportBuffers(const Stream *stream, unsigned int count, if (stream == nullptr) return -EINVAL; - for (unsigned int i = 0; i < count; i++) { - const std::string name = "frame-" + std::to_string(i); - const size_t frameSize = debayer_->frameSize(); - - FrameBuffer::Plane outPlane; - outPlane.fd = SharedFD(dmaHeap_.alloc(name.c_str(), frameSize)); - if (!outPlane.fd.isValid()) { - LOG(SoftwareIsp, Error) - << "failed to allocate a dma_buf"; - return -ENOMEM; - } - outPlane.offset = 0; - outPlane.length = frameSize; - - std::vector<FrameBuffer::Plane> planes{ outPlane }; - buffers->emplace_back(std::make_unique<FrameBuffer>(std::move(planes))); - } - - return count; + return dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers); } /**