Age | Commit message (Collapse) | Author |
|
Now that format classes implement the stream formatting operator<<(),
use it instead of the toString() function.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The includes in the v4l2_camera_proxy do not match the code style
and trigger clang-format changes when running checkstyle.
Update and fix the include order accordingly
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The V4L2 Compatibility layer is returning timestamps for buffers which
are incorrectly calculated from the frame metadata.
The sec component of the timestamp is correct, but the usec component is
out, leaving frame captures reporting non-monotonically increasing
timestamps, and incorrect frame rate calculations.
Fix the usecs calculation reported by the V4L2 adaptation layer.
Bug: https://bugs.libcamera.org/show_bug.cgi?id=118
Fixes: 0ce8f2390b52 ("v4l2: v4l2_compat: Add V4L2 compatibility layer")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Support easier usage of the v4l2 compatibility layer with a script that
handles the LD_PRELOAD for applications.
The wrapper can be prefixed to launch any application with the preload
set:
$ libcamera-v4l2 v4l2-ctl --list-devices
\_SB_.PCI0.GP13.XHC0.RHUB.PRT4- (libcamera:0):
/dev/video0
platform/vimc.0 Sensor B (libcamera:1):
/dev/video2
/dev/video3
/dev/video4
Specifying '-d' once before the command to run will enable V4L2Compat
layer debug output from libcamera.
Specifying '-d' twice will enable all debug levels from all libcamera
components and provide a very detailed log for analysis.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
|
|
V4L2 is happy to map buffers read-only for capture devices (but rejects
write-only mappings). We can support this as the dmabuf mmap()
implementation supports it. This change fixes usage of the V4L2
compatibility layer with OpenCV.
While at it, attempt to validate the other flags. videobuf2 requires
MAP_SHARED and doesn't check other flags, so mimic the same behaviour.
While unlikly, other flags could get rejected by other kernel layers for
V4L2 buffers but not for dmabuf. This can be handled later if the need
arises.
Reported-by: Nejc Galof <galof.nejc@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Nejc Galof <galof.nejc@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
|
| /span> camera_->generateConfiguration({ StreamRole::VideoRecording });
if (!config_ || config_->size() != 1) {
cout << "Failed to generate default configuration" << endl;
return TestFail;
}
allocator_ = new FrameBufferAllocator(camera_);
StreamConfiguration &cfg = config_->at(0);
if (camera_->acquire()) {
cout << "Failed to acquire the camera" << endl;
return TestFail;
}
if (camera_->configure(config_.get())) {
cout << "Failed to set default configuration" << endl;
return TestFail;
}
stream_ = cfg.stream();
int ret = allocator_->allocate(stream_);
if (ret < 0)
return TestFail;
return TestPass;
}
void cleanup() override
{
delete allocator_;
}
int run() override
{
const std::unique_ptr<FrameBuffer> &buffer = allocator_->buffers(stream_).front();
std::vector<MappedBuffer> maps;
MappedFrameBuffer map(buffer.get(), MappedFrameBuffer::MapFlag::Read);
if (!map.isValid()) {
cout << "Failed to successfully map buffer" << endl;
return TestFail;
}
/* Make sure we can move it. */
maps.emplace_back(std::move(map));
/* But copying is prevented, it would cause double-unmap. */
// MappedFrameBuffer map_copy = map;
/* Local map should be invalid (after move). */
if (map.isValid()) {
cout << "Post-move map should not be valid" << endl;
return TestFail;
}
/* Test for multiple successful maps on the same buffer. */
MappedFrameBuffer write_map(buffer.get(), MappedFrameBuffer::MapFlag::Write);
if (!write_map.isValid()) {
cout << "Failed to map write buffer" << endl;
return TestFail;
}
MappedFrameBuffer rw_map(buffer.get(), MappedFrameBuffer::MapFlag::ReadWrite);
if (!rw_map.isValid()) {
cout << "Failed to map RW buffer" << endl;
return TestFail;
}
return TestPass;
}
private:
std::unique_ptr<CameraConfiguration> config_;
FrameBufferAllocator *allocator_;
Stream *stream_;
};
} /* namespace */
TEST_REGISTER(MappedBufferTest)