Commit graph

27 commits

Author SHA1 Message Date
Laurent Pinchart
84ad104499 Move test applications to src/apps/
The cam and qcam test application share code, currently through a crude
hack that references the cam source files directly from the qcam
meson.build file. To prepare for the introduction of hosting that code
in a static library, move all applications to src/apps/.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-20 13:36:25 +03:00
Paul Elder
6404b163bc cam: file_sink: Add support for DNG output
Add support for outputting buffers in DNG format. It reuses the DNG
writer that we had previously in qcam.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-19 21:05:49 +09:00
Eric Curtin
11554a259f cam: sdl_sink: Add SDL sink with initial YUYV support
This adds more portability to existing cam sinks. You can pass a
YUYV camera buffer and SDL will handle the pixel buffer conversion
to the display. This allows cam reference implementation to display
images on VMs, Mac M1, Raspberry Pi, etc. This also enables cam
reference implementation, to run as a desktop application in Wayland or
X11. SDL also has support for Android and ChromeOS which has not been
tested. Also tested on simpledrm Raspberry Pi 4 framebuffer
successfully where existing kms sink did not work. Can also be used as
kmsdrm sink. Only supports one camera stream at present.

Signed-off-by: Eric Curtin <ecurtin@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-23 12:49:44 +03:00
Jacopo Mondi
568865a6c1 cam: Use script parser to set controls
Add a "--script" option to the cam test application to allow specify a
capture script to be used to drive the capture session. Add to the
CameraSession class a script parser instance, created conditionally to
the OptCaptureScript option.

If the script parser has been created, use it at queueRequest time to
retrieve the list of controls that has to be associated with a Request,
and populate Request::controls() with it before queueing it to the
Camera.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-22 12:52:13 +03:00
Jacopo Mondi
3a91e37bb8 cam: Queue requests through CameraSession::queueRequest()
The CameraSession::processRequest() frame completion handler currently
re-queues completed requests by calling Camera::queueRequests()
explicitely.

In order to maintain the CameraSession::queuedRequest_ counter up to
date with the actual number of queued requests, call the
CameraSession::queueRequest() instead of operating the Camera directly.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-22 12:52:10 +03:00
Laurent Pinchart
8a845ab078 libcamera: Replace toString with operator<<() for format classes
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>
2022-05-04 14:11:33 +03:00
Laurent Pinchart
37958dfd71 libcamera: Replace toString with operator<<() for geometry classes
Now that geometry 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>
2022-05-04 14:11:25 +03:00
Nejc Galof
7a118dbdb8 cam: Use structured bindings in range-based for loops
Use structured bindings range-based for loops for better readability.

Signed-off-by: Nejc Galof <galof.nejc@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-02-21 16:23:52 +02:00
Laurent Pinchart
411987838e cam: Drop frames once the capture limit is reached
The camera session keeps requeuing requests until the capture limit is
reached. This causes more request than the limit to complete, as there's
a queue of requests in flight. When capturing from multiple cameras
concurrently, this results in the captureDone signal being emitted for
every request completion after the limit is reached, instead of once per
camera session when reaching the limit.

Fix this by simply dropping any request that completes after the limit
is reached. We could instead avoid requeuing more requests than needed
to reach the limit, but that may cause request starvation in pipelines,
which are currently not handled consistently (or correctly).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-10-15 05:05:32 +03:00
Laurent Pinchart
7e2948f5e1 cam: Pass stream names to FileSink
The FileSink class constructs stream names internally the same way that
the CameraSession does, except that it fails to add the camera name.
This results in files being written without the camera name.

This could be fixed in FileSink, but we would still duplicate code to
construct stream names. Pass the stream names map from CameraSession to
FileSink instead, and store it internally.

Fixes: 02001fecb0 ("cam: Turn BufferWriter into a FrameSink")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-10-15 05:05:31 +03:00
Laurent Pinchart
45662c4dd7 cam: Rename CameraSession::streamName_ to streamNames_
The streamName_ map contains names for all streams, rename it to
streamNames_ to make this more explicit.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-10-15 05:05:29 +03:00
Laurent Pinchart
32635054bc libcamera: framebuffer: Prevent modifying the number of metadata planes
The number of metadata planes should always match the number of frame
buffer planes. Enforce this by making the vector private and providing
accessor functions.

As this changes the public API, update all in-tree users accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-09-07 19:18:31 +03:00
Laurent Pinchart
2288550f7d cam: Add support for viewfinder through DRM/KMS
Use the KMSSink class to display the viewfinder stream, if any, through
DRM/KMS. The output connector is selected through the new -D/--display
argument.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-05 16:23:11 +03:00
Laurent Pinchart
ab623b4738 cam: Rename BufferWriter to FileSink
Rename the BufferWriter class to FileSink to establish a common naming
scheme for all sinks.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-08-05 16:23:11 +03:00
Laurent Pinchart
02001fecb0 cam: Turn BufferWriter into a FrameSink
Make the BufferWriter class inherit from FrameSink, and use the
FrameSink API to manage it. This makes the code more generic, and will
allow usage of other sinks.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-08-05 16:23:10 +03:00
Laurent Pinchart
e0704e97ea cam: Support using multiple cameras concurrently
To allow testing capture from multiple cameras concurrently, turn the
--camera option into an array option, and create one CameraSession per
specified camera. The code is adapted to iterate over the sessions
vector instead of handling a single session. Thanks to all the
refactoring previously performed, changes are minimal.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:14:05 +03:00
Laurent Pinchart
721f4b03d8 cam: Add camera index to file name of capture frames
To prepare for multi-camera support, extend the file naming scheme for
captured frames to include the camera index in addition to the stream
name and frame number.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:14:03 +03:00
Laurent Pinchart
7dab1fa58f cam: Make camera-related options sub-options of OptCamera
Use the new hierarchical options feature of the option parser to turn
camera-related option (--capture, --file, --stream, --strict-formats and
--metadata) into children of the --camera option. As an added bonus, we
don't need to check anymore if a camera has been specified when capture
is requested, as that's now enforced by the option parser.

This change prepares for support of multiple cameras.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:59 +03:00
Laurent Pinchart
66c955648f cam: Move printing of camera information to CameraSession class
The three CamApp functions listControls(), listProperties() and
infoConfiguration() operate on a camera. They would thus be better
placed in the CameraSession class. Move them there. As they now have no
error to return anymore, make them void functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:53 +03:00
Laurent Pinchart
8519df23a9 cam: Move camera acquire to the CameraSession class
Continue moving towards making the CameraSession class the central point
to handle a camera by moving the camera acquire operation. A new
CameraSession::camera() function is needed to allow access to the camera
from CamApp.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:47 +03:00
Laurent Pinchart
8e716be529 cam: Move CameraConfiguration creation to CameraSession class
Creating a configuration for a camera is an operation that logically
belongs to the CameraSession class. Move it there.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:46 +03:00
Laurent Pinchart
34d986d1ec cam: Store camera session pointer in CamApp class
Move the local CameraSession variable from the CamApp::run() function to
a member variable of the CamApp class, created in CamApp::init(). This
is a first step towards moving code to the CameraSession class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:45 +03:00
Laurent Pinchart
24ca846a27 cam: camera_session: Use std::unique_ptr<> to manage class members
Store the BufferWriter and FrameBufferAllocator pointers in
std::unique_ptr<> instances to simplify memory management and avoid
leaks.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:44 +03:00
Laurent Pinchart
4cd0f586fb cam: Move event loop execution from CameraSession to CamApp
To prepare for multiple concurrent camera sessions, move the event loop
exec() call from the CameraSession class to the CamApp class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:43 +03:00
Laurent Pinchart
011b3ff288 cam: Move event loop exit from CameraSession to CamApp
Make exiting the event loop the responsibility of the application, not
the camera session, to prepare for support of multiple camera sessions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:42 +03:00
Laurent Pinchart
453583e189 cam: camera_session: Access event loop through global instance
Don't pass the event loop to the CameraSession constructor, as passing
this global object explicitly isn't a design that can scale.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:40 +03:00
Laurent Pinchart
94d828d880 cam: Rename Capture to CameraSession
Rename the Capture class to CameraSession, to prepare for multi-camera
support that will gather more camera-related operations than capture in
that class.

While at it, remove an unneeded blank line.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-22 17:13:39 +03:00
Renamed from src/cam/capture.cpp (Browse further)