summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-11-29 20:38:10 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-12-04 23:05:07 +0200
commit560f5cf998646ddc54a20dc1c7326012834d3204 (patch)
treeb0b4da6084cdf2c10b359b986ad27e33baa6bdfb /src
parent5c85e7024027c90b1b054782e510691b8b9c7419 (diff)
libcamera: base: shared_fd: Rename fd() to get()
For consistency with UniqueFD, rename the fd() function to get(). Renaming UniqueFD::get() to fd() would have been another option, but was rejected to keep as close as possible to the std::shared_ptr<> and std::unique_ptr<> APIs. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/cam/drm.cpp4
-rw-r--r--src/cam/image.cpp4
-rw-r--r--src/gstreamer/gstlibcameraallocator.cpp2
-rw-r--r--src/ipa/raspberrypi/raspberrypi.cpp2
-rw-r--r--src/libcamera/base/shared_fd.cpp4
-rw-r--r--src/libcamera/framebuffer.cpp2
-rw-r--r--src/libcamera/ipc_pipe.cpp2
-rw-r--r--src/libcamera/mapped_framebuffer.cpp4
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp2
-rw-r--r--src/libcamera/v4l2_videodevice.cpp6
-rw-r--r--src/v4l2/v4l2_camera.cpp2
11 files changed, 17 insertions, 17 deletions
diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp
index f2530091..46e34eb5 100644
--- a/src/cam/drm.cpp
+++ b/src/cam/drm.cpp
@@ -608,12 +608,12 @@ std::unique_ptr<FrameBuffer> Device::createFrameBuffer(
unsigned int i = 0;
for (const libcamera::FrameBuffer::Plane &plane : planes) {
- int fd = plane.fd.fd();
+ int fd = plane.fd.get();
uint32_t handle;
auto iter = fb->planes_.find(fd);
if (iter == fb->planes_.end()) {
- ret = drmPrimeFDToHandle(fd_, plane.fd.fd(), &handle);
+ ret = drmPrimeFDToHandle(fd_, plane.fd.get(), &handle);
if (ret < 0) {
ret = -errno;
std::cerr
diff --git a/src/cam/image.cpp b/src/cam/image.cpp
index 0180be78..fe2cc6da 100644
--- a/src/cam/image.cpp
+++ b/src/cam/image.cpp
@@ -39,7 +39,7 @@ std::unique_ptr<Image> Image::fromFrameBuffer(const FrameBuffer *buffer, MapMode
std::map<int, MappedBufferInfo> mappedBuffers;
for (const FrameBuffer::Plane &plane : buffer->planes()) {
- const int fd = plane.fd.fd();
+ const int fd = plane.fd.get();
if (mappedBuffers.find(fd) == mappedBuffers.end()) {
const size_t length = lseek(fd, 0, SEEK_END);
mappedBuffers[fd] = MappedBufferInfo{ nullptr, 0, length };
@@ -61,7 +61,7 @@ std::unique_ptr<Image> Image::fromFrameBuffer(const FrameBuffer *buffer, MapMode
}
for (const FrameBuffer::Plane &plane : buffer->planes()) {
- const int fd = plane.fd.fd();
+ const int fd = plane.fd.get();
auto &info = mappedBuffers[fd];
if (!info.address) {
void *address = mmap(nullptr, info.mapLength, mmapFlags,
diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp
index cb07d6e9..c740b8fc 100644
--- a/src/gstreamer/gstlibcameraallocator.cpp
+++ b/src/gstreamer/gstlibcameraallocator.cpp
@@ -52,7 +52,7 @@ FrameWrap::FrameWrap(GstAllocator *allocator, FrameBuffer *buffer,
outstandingPlanes_(0)
{
for (const FrameBuffer::Plane &plane : buffer->planes()) {
- GstMemory *mem = gst_fd_allocator_alloc(allocator, plane.fd.fd(),
+ GstMemory *mem = gst_fd_allocator_alloc(allocator, plane.fd.get(),
plane.offset + plane.length,
GST_FD_MEMORY_FLAG_DONT_CLOSE);
gst_memory_resize(mem, plane.offset, plane.length);
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index aaf629ee..0ed41385 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -377,7 +377,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,
lsTableHandle_ = std::move(ipaConfig.lsTableHandle);
if (lsTableHandle_.isValid()) {
lsTable_ = mmap(nullptr, ipa::RPi::MaxLsGridSize, PROT_READ | PROT_WRITE,
- MAP_SHARED, lsTableHandle_.fd(), 0);
+ MAP_SHARED, lsTableHandle_.get(), 0);
if (lsTable_ == MAP_FAILED) {
LOG(IPARPI, Error) << "dmaHeap mmap failure for LS table.";
diff --git a/src/libcamera/base/shared_fd.cpp b/src/libcamera/base/shared_fd.cpp
index 346b4a85..bb35b448 100644
--- a/src/libcamera/base/shared_fd.cpp
+++ b/src/libcamera/base/shared_fd.cpp
@@ -208,7 +208,7 @@ SharedFD &SharedFD::operator=(SharedFD &&other)
*/
/**
- * \fn SharedFD::fd()
+ * \fn SharedFD::get()
* \brief Retrieve the numerical file descriptor
* \return The numerical file descriptor, which may be -1 if the SharedFD
* instance is invalid
@@ -227,7 +227,7 @@ SharedFD &SharedFD::operator=(SharedFD &&other)
*/
UniqueFD SharedFD::dup() const
{
- UniqueFD dupFd(::dup(fd()));
+ UniqueFD dupFd(::dup(get()));
if (!dupFd.isValid()) {
int ret = -errno;
LOG(SharedFD, Error)
diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp
index fbf8f1c2..ee93ba4d 100644
--- a/src/libcamera/framebuffer.cpp
+++ b/src/libcamera/framebuffer.cpp
@@ -218,7 +218,7 @@ ino_t fileDescriptorInode(const SharedFD &fd)
return 0;
struct stat st;
- int ret = fstat(fd.fd(), &st);
+ int ret = fstat(fd.get(), &st);
if (ret < 0) {
ret = -errno;
LOG(Buffer, Fatal)
diff --git a/src/libcamera/ipc_pipe.cpp b/src/libcamera/ipc_pipe.cpp
index 3b47032d..31a0ca09 100644
--- a/src/libcamera/ipc_pipe.cpp
+++ b/src/libcamera/ipc_pipe.cpp
@@ -113,7 +113,7 @@ IPCUnixSocket::Payload IPCMessage::payload() const
}
for (const SharedFD &fd : fds_)
- payload.fds.push_back(fd.fd());
+ payload.fds.push_back(fd.get());
return payload;
}
diff --git a/src/libcamera/mapped_framebuffer.cpp b/src/libcamera/mapped_framebuffer.cpp
index 464d35fe..6860069b 100644
--- a/src/libcamera/mapped_framebuffer.cpp
+++ b/src/libcamera/mapped_framebuffer.cpp
@@ -198,7 +198,7 @@ MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags)
std::map<int, MappedBufferInfo> mappedBuffers;
for (const FrameBuffer::Plane &plane : buffer->planes()) {
- const int fd = plane.fd.fd();
+ const int fd = plane.fd.get();
if (mappedBuffers.find(fd) == mappedBuffers.end()) {
const size_t length = lseek(fd, 0, SEEK_END);
mappedBuffers[fd] = MappedBufferInfo{ nullptr, 0, length };
@@ -220,7 +220,7 @@ MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags)
}
for (const FrameBuffer::Plane &plane : buffer->planes()) {
- const int fd = plane.fd.fd();
+ const int fd = plane.fd.get();
auto &info = mappedBuffers[fd];
if (!info.address) {
void *address = mmap(nullptr, info.mapLength, mmapFlags,
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 4885a939..321b72ad 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1479,7 +1479,7 @@ void RPiCameraData::setIspControls(const ControlList &controls)
Span<uint8_t> s = value.data();
bcm2835_isp_lens_shading *ls =
reinterpret_cast<bcm2835_isp_lens_shading *>(s.data());
- ls->dmabuf = lsTable_.fd();
+ ls->dmabuf = lsTable_.get();
}
isp_[Isp::Input].dev()->setControls(&ctrls);
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 0d214d9e..b4b89e27 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -282,7 +282,7 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const
return false;
for (unsigned int i = 0; i < planes.size(); i++)
- if (planes_[i].fd != planes[i].fd.fd() ||
+ if (planes_[i].fd != planes[i].fd.get() ||
planes_[i].length != planes[i].length)
return false;
return true;
@@ -1517,9 +1517,9 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
if (buf.memory == V4L2_MEMORY_DMABUF) {
if (multiPlanar) {
for (unsigned int p = 0; p < numV4l2Planes; ++p)
- v4l2Planes[p].m.fd = planes[p].fd.fd();
+ v4l2Planes[p].m.fd = planes[p].fd.get();
} else {
- buf.m.fd = planes[0].fd.fd();
+ buf.m.fd = planes[0].fd.get();
}
}
diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
index 46450750..e922b9e6 100644
--- a/src/v4l2/v4l2_camera.cpp
+++ b/src/v4l2/v4l2_camera.cpp
@@ -195,7 +195,7 @@ int V4L2Camera::getBufferFd(unsigned int index)
if (buffers.size() <= index)
return -1;
- return buffers[index]->planes()[0].fd.fd();
+ return buffers[index]->planes()[0].fd.get();
}
int V4L2Camera::streamOn()