Commit graph

14 commits

Author SHA1 Message Date
Niklas Söderlund
9217f274f6 libcamera: Switch to FrameBuffer interface
Switch to the FrameBuffer interface where all buffers are treated as
external buffers and are allocated outside the camera. Applications
allocating buffers using libcamera are switched to use the
FrameBufferAllocator helper.

Follow-up changes to this one will finalize the transition to the new
FrameBuffer interface by removing code that is left unused after this
change.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12 16:10:38 +01:00
Niklas Söderlund
5967363c0b libcamera: buffer: Move captured metadata to FrameMetadata
Move the metadata retrieved when dequeuing a V4L2 buffer into a
FrameMetadata object. This is done as a step to migrate to the
FrameBuffer interface as the functions added to Buffer around
FrameMetadata match the ones in FrameBuffer.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12 16:10:37 +01:00
Laurent Pinchart
6a735f014a v4l2: camera_proxy: Call V4L2Camera::getBufferFd() directly
The V4L2Camera::getBufferFd() method doesn't need to run in the camera
thread. Call it directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-12 16:10:37 +01:00
Niklas Söderlund
3c4b872443 v4l2: camera: Handle memory mapping of buffers directly
In the upcoming FrameBuffer API the memory mapping of buffers will be
left to the user of the FrameBuffer objects. Prepare the V4L2
compatibility layer to this upcoming change to ease conversion to the
new API.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12 16:10:37 +01:00
Niklas Söderlund
35ac23dca1 v4l2: Rename FrameMetadata to V4L2FrameMetadata
With the upcoming FrameBuffer API a new library wide FrameMetadata
object will be added which will replace the specific implementation in
the V4L2 compatibility layer.

Avoid name collisions while the new FrameBuffer API is added by renaming
the V4L2 compatibility layer specific implementation until it can be
replaced with the library wide implementation.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12 16:10:37 +01:00
Niklas Söderlund
96eaad1238 v4l2: camera_proxy: Fix compilation error use of undeclared identifier 'ret'
Refactoring of the camera_proxy have left the 'ret' variable undeclared,
declare it.

../../src/v4l2/v4l2_camera_proxy.cpp:273:2: error: use of undeclared identifier 'ret'
        ret = vcam_->invokeMethod(&V4L2Camera::configure,
        ^
../../src/v4l2/v4l2_camera_proxy.cpp:278:6: error: use of undeclared identifier 'ret'
        if (ret < 0)

Fixes: fce110c6d9 ("v4l2: camera_proxy: Break out try_fmt")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-09 00:40:32 +01:00
Jacopo Mondi
a5862a7a34 v4l2: camera_proxy: Align trace message style
Most of the ioctl handlers in the V4L2CameraProxy class have an empty
line between the tracing printouts and the immediately following buffer
type validation. Align the two occasions where such an empty line is missing
with the others.

Cosmetic change only.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-01-08 17:41:36 +01:00
Jacopo Mondi
fce110c6d9 v4l2: camera_proxy: Break out try_fmt
Calling vidioc_s_fmt() calls vidioc_try_fmt() duplicating prinouts.

Breakout try format procedure and call it from both functions.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-01-08 11:05:39 +01:00
Jacopo Mondi
769ca0a550 v4l2: camera_proxy: Fix try_fmt format conversion
The set pixelformat field of struct v4l2_pix_format structure was
wrongly converted to PixelFormat by calling v4l2ToDrm(), with an already
converted 'format' argument.

Fix this by calling the right drmToV4l2() conversion function.

Fixes: 0ce8f2390b ("v4l2: v4l2_compat: Add V4L2 compatibility layer")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-01-08 10:53:58 +01:00
Laurent Pinchart
eccbb17551 v4l2: camera_proxy: Include <array>
Commit 29c5508075 ("v4l2: camera_proxy: Create format info array")
introduced usage of the std::array template class, but didn't include
the corresponding header. This may cause a compilation breakage in the
future if the indirect include of <array> disappears due to unrelated
changes. Fix it.

Fixed: 29c5508075 ("v4l2: camera_proxy: Create format info array")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-08 06:20:58 +02:00
Laurent Pinchart
29c5508075 v4l2: camera_proxy: Create format info array
Create a PixelFormatInfo structure to store information about a format,
and add a global array of format info for all the formats currently
supported. Move the format helpers to use the information from the
array.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-01-07 22:37:54 +02:00
Laurent Pinchart
aff0b680aa v4l2: camera_proxy: Rationalize arguments to format helpers
To clarify code, adopt the following rules for format helpers:

- All variables representing V4L2 pixel formats shall use uint32_t
- All variables representing DRM pixel formats shall use PixelFormat
- Functions returning positive values only shall not have a signed
  return type

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-07 22:35:26 +02:00
Laurent Pinchart
b4415f1c98 v4l2: Use Object::invokeMethod() return value
Now that Object::invokeMethod() supports returning a value, use it and
drop the return value method argument.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-07 22:29:47 +02:00
Paul Elder
0ce8f2390b v4l2: v4l2_compat: Add V4L2 compatibility layer
Add libcamera V4L2 compatibility layer.

This initial implementation supports the minimal set of V4L2 operations,
which allows getting, setting, and enumerating formats, and streaming
frames from a video device. Some data about the wrapped V4L2 video
device are hardcoded.

Add a build option named 'v4l2' and adjust the build system to
selectively compile the V4L2 compatibility layer.

For now we match the V4L2 device node to a libcamera camera based on a
devnum that a pipeline handler may optionally map to a libcamera
camera.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-03 19:53:20 -05:00