v4l2: v4l2_camera: Return int in getBufferFd()
V4L2Camera::getBufferFd() returns FileDescriptor. However, the file descriptor is still owned by V4L2Camera. It should rather return an integer to represent V4L2Camera doesn't have the ownership of the file descriptor. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
1af788a8fb
commit
3dc3e2e61e
3 changed files with 7 additions and 7 deletions
|
@ -186,16 +186,16 @@ void V4L2Camera::freeBuffers()
|
||||||
bufferAllocator_->free(stream);
|
bufferAllocator_->free(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDescriptor V4L2Camera::getBufferFd(unsigned int index)
|
int V4L2Camera::getBufferFd(unsigned int index)
|
||||||
{
|
{
|
||||||
Stream *stream = config_->at(0).stream();
|
Stream *stream = config_->at(0).stream();
|
||||||
const std::vector<std::unique_ptr<FrameBuffer>> &buffers =
|
const std::vector<std::unique_ptr<FrameBuffer>> &buffers =
|
||||||
bufferAllocator_->buffers(stream);
|
bufferAllocator_->buffers(stream);
|
||||||
|
|
||||||
if (buffers.size() <= index)
|
if (buffers.size() <= index)
|
||||||
return FileDescriptor();
|
return -1;
|
||||||
|
|
||||||
return buffers[index]->planes()[0].fd;
|
return buffers[index]->planes()[0].fd.fd();
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Camera::streamOn()
|
int V4L2Camera::streamOn()
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
int allocBuffers(unsigned int count);
|
int allocBuffers(unsigned int count);
|
||||||
void freeBuffers();
|
void freeBuffers();
|
||||||
libcamera::FileDescriptor getBufferFd(unsigned int index);
|
int getBufferFd(unsigned int index);
|
||||||
|
|
||||||
int streamOn();
|
int streamOn();
|
||||||
int streamOff();
|
int streamOff();
|
||||||
|
|
|
@ -114,14 +114,14 @@ void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags,
|
||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDescriptor fd = vcam_->getBufferFd(index);
|
int fd = vcam_->getBufferFd(index);
|
||||||
if (!fd.isValid()) {
|
if (fd < 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *map = V4L2CompatManager::instance()->fops().mmap(addr, length, prot,
|
void *map = V4L2CompatManager::instance()->fops().mmap(addr, length, prot,
|
||||||
flags, fd.fd(), 0);
|
flags, fd, 0);
|
||||||
if (map == MAP_FAILED)
|
if (map == MAP_FAILED)
|
||||||
return map;
|
return map;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue