Commit graph

1019 commits

Author SHA1 Message Date
Laurent Pinchart
a40023e6cc libcamera: Use stream roles directly instead of StreamUsage
In order to prepare for an API overhall of the camera configuration
generation, remove the StreamUsage class and replace its uses by stream
roles. The size hints can't be specified anymore, and will be replaced
with an API on the StreamConfiguration to negotiate configuration
parameters with cameras.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-05-23 00:27:13 +03:00
Laurent Pinchart
2ca2d65870 libcamera: camera: Rename configureStreams() and streamConfiguration()
Rename the configureStreams() and streamConfiguration() methods to
configure() and generateConfiguration() respectively in order to clarify
the API. Both methods deal with CameraConfiguration objects, and are
thus not limited to streams, even if a CameraConfiguration currently
contains streams only.

While at it, remove the qcam MainWindow::configureStreams() method that
is declared but never defined or used.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-05-23 00:27:10 +03:00
Paul Elder
c1bbbd3b5b libcamera: ipa_module: add IPA shared library module
Implement a class to wrap around an IPA module shared object.

For now, just load a struct IPAModuleInfo with symbol name
ipaModuleInfo from an IPA module .so shared object.

Also provide a public header file including the struct IPAModuleInfo,
structured such that both C and C++ IPA modules are supported.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-05-21 18:31:37 -04:00
Laurent Pinchart
a2dddf7c26 libcamera: Use the Size class through libcamera
Several of our structures include width and height fields that model a
size while we have a Size class for that purpose. Use the Size class
through libcamera, and give it a toString() method like other geometry
and format classes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-04-30 22:18:42 +03:00
Laurent Pinchart
152147c539 libcamera: Correct struct forward declarations
Several structures are forward-declarated as classes. Fix this by using
the struct keyword where appropriate, or removing the forward
declaration when not needed.

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>
2019-04-26 19:07:45 +03:00
Laurent Pinchart
0af0fb9ca9 libcamera: stream: Add and use toString() method to StreamConfiguration
Add a toString() method to the StreamConfiguration class, and replace
all manually coded implementations through the source code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-19 13:38:14 +03:00
Laurent Pinchart
66337b96b1 libcamera: geometry: Add comparison operators to geometry classes
Add equality and inequality comparison operators for the Rectangle, Size
and SizeRange classes.

For the Size class, also add ordering operators. Sizes are first
compared on combined width and height, then on area, and finally on
width only to achieve a stable ordering.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 18:13:07 +03:00
Laurent Pinchart
72afcbb087 libcamera: geometry: Use Size to store min and max in SizeRange
Instead of storing four integers for the minimum and maximum width and
height in the SizeRange class, use two instance of the Size class for
the minimum and maximum sizes.

While it at replace the mention of image size with size in the SizeRange
documentation, as the Size class isn't limited to image sizes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 18:13:06 +03:00
Laurent Pinchart
e7f446e1ed libcamera: geometry: Sort classes alphabetically
Move the Size class before the SizeRange class. No functional change.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 18:13:05 +03:00
Jacopo Mondi
ee027781b4 libcamera: buffer: Store Request reference in Buffer
Add to the Buffer class methods to set and retrieve a reference to the
Request instance the buffer is part of.

As buffers outlive the Request they are associated with, the reference
is only temporary valid during the buffer completion interval (from when
the buffer gets queued to Camera for processing, until it gets marked as
completed).

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 15:37:59 +02:00
Jacopo Mondi
0527ba92ad libcamera: request: Expose the Stream to Buffers map
Add to the Request class a method to access the map of Stream to Buffer.

With the introduction of multiple stream support, pipeline handler
should be able to access the map of streams at request queueing time.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 15:36:48 +02:00
Jacopo Mondi
571d16b539 libcamera: request: Add hasPendingBuffers() method
Add method to verify if a request has pending buffers yet to be
completed.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 15:35:34 +02:00
Jacopo Mondi
4e1dc9004f libcamera: stream: Make Stream inheritable
In preparation for multiple streams support prepare to allow sub-classing
the Stream class by removing the 'final' specifier from the class
definition and make its private members protected.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-16 14:55:58 +02:00
Niklas Söderlund
b0c730e330 libcamera: Switch to CameraConfiguration
Implement the camera configuration thru out the library, tests, cam and
qcam tools.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-09 16:59:19 +02:00
Niklas Söderlund
9a7dc3ce7f libcamera: camera: Add CameraConfiguration
To properly support both multiple streams and stream usages the library
must provide a method to map the stream usages to the returned streams
configurations. Add a camera configuration object to handle this
mapping.

Applications can iterate over the returned camera configuration to
retrieve the streams selected by the library in the same order as the
usages it provided to the library.

Applications can use the operator[] to retrieve the stream pointer and
the stream configuration. Using a numerical index retrieves the stream
pointer, the numerical indexes corresponds to the insertion order of
usages in the CameraConfiguration, using the stream pointer retrieves
the stream's configuration.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-09 16:57:53 +02:00
Niklas Söderlund
20a6455e0b libcamera: camera: Add support for stream usages
Instead of requesting the default configuration for a set of streams
where the application has to figure out which streams provided by the
camera is best suited for its intended usage, have the library figure
this out by using stream usages.

The application asks the library for a list of streams and a suggested
default configuration for them by supplying a list of stream usages.
Once the list is retrieved the application can fine-tune the returned
configuration and then try to apply it to the camera.

Currently no pipeline handler is prepared to handle stream usages but
nor did it make use of the list of Stream IDs which was the previous
interface. The main reason for this is that all cameras currently only
provide one stream each. This will still be the case but the API will be
prepared to expand both pipeline handlers and applications to support
streams usages.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-05 22:07:47 +02:00
Niklas Söderlund
70e53be538 libcamera: stream: Add basic stream usages
In preparation of reworking how a default configuration is retrieved
from a camera add stream usages. The usages will be used by applications
to describe how they intend to use a camera and replace the Stream IDs
when retrieving default configuration from the camera using
streamConfiguration().

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-05 22:07:24 +02:00
Niklas Söderlund
58f1ad3c79 libcamera: Make geometry.h a public header
Make the geometry header public so it can be used by the API facing
applications.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-05 21:47:34 +02:00
Jacopo Mondi
29f323eea8 libcamera: stream: Qualify 'Camera' friend directive
Align the Stream class to all other classes in the code base to use the
'class' qualifier in 'friend' declarations.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-02 12:59:20 +02:00
Jacopo Mondi
cf4bb3fb2d libcamera: stream: Remove 2 empty lines
Remove two empty lines. Cosmetic change only.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-02 12:58:53 +02:00
Laurent Pinchart
b2c06cf409 libcamera: Handle request completion explicitly in pipeline handlers
Request complete by themselves when all the buffers they contain have
completed, connecting the buffer's completed signal to be notified of
buffer completion. While this works for now, it prevents pipelines from
delaying request completion until all metadata is available, and makes
it impossible to ensure that requests complete in the order they are
queued.

To fix this, make request completion handling explicit in pipeline
handlers. The base PipelineHandler class is extended with
implementations of the queueRequest() and stop() methods and gets new
completeBuffer() and completeRequest() methods to help pipeline handlers
tracking requests and buffers.

The three existing pipeline handlers connect the bufferReady signal of
their capture video node to a slot of their respective camera data
instance, where they use the PipelineHandler helpers to notify buffer
and request completion. Request completion is handled synchronously with
buffer completion as the pipeline handlers don't need to support more
advanced use cases, but this paves the road for future work.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-03-01 20:46:40 +02:00
Laurent Pinchart
1accc258cc libcamera: request: Add request completion status
Add a new field to the Request class to report its completion status,
and a new complete() method to update the status.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-03-01 15:45:09 +02:00
Laurent Pinchart
fca7602c3c libcamera: buffer: Add buffer completion status
Add a new field to the Buffer class to report its completion status,
with a new cancel() method to mark the buffer as cancelled.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-03-01 15:45:09 +02:00
Niklas Söderlund
77100a7578 libcamera: camera: add state machine to control access from applications
There is a need to better control the order of operations an application
performs on a camera for it to function correctly. Add a basic state
machine to ensure applications perform operations on the camera in good
order.

Internal to the Camera states are added; Available, Acquired,
Configured, Prepared and Running. Each state represents a higher state
of configuration of the camera ultimately leading to the highest state
where the camera is capturing frames. Each state supports a subset of
operations the application may perform.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-03-01 00:28:17 +01:00
Niklas Söderlund
132ce9c1cf libcamera: store stream pointers in sets instead of a vectors
The arrays that store Stream pointers shall always contain unique
values. Storing them in vectors opens up for the same stream pointer
appearing twice. Remove this possibility by storing them in a set which
guarantees each element is unique.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-28 18:41:52 +01:00
Laurent Pinchart
98bd9cb8c9 libcamera: signal: Disconnect signal automatically on slot deletion
When a signal is connected to a member function slot, the slot is not
disconnected when the slot object is deleted. This can lead to calling a
member function of a deleted object if the signal isn't disconnected
manually by the slot object's destructor.

Make signal handling easier by implementing a base Object class that
tracks all connected signals and disconnects from them automatically
when the object is deleted, using template specialization resolution in
the Signal class.

As inheriting from the Object class may to a too harsh requirement for
Signal usage in applications, keep the existing behaviour working if the
slot doesn't inherit from the Object class. We may reconsider this later
and require all slot objects to inherit from the Object class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-13 13:23:43 +02:00
Laurent Pinchart
73a1bea709 libcamera: signal: Fix coding style issues
Fix issues reported by checkstyle.py in preparation for further changes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-13 13:23:38 +02:00
Niklas Söderlund
bd38112b77 libcamera: camera: Extend the interface to support capture
In order to support capture, the camera needs methods to allocate and
free buffers, to start and stop the capture and to queue requests.
Define those interfaces in the Camera class and implement them to call
the corresponding pipeline handler methods.

Once a camera is started the pipeline handler of the camera will begin
processing requests queued to the camera by the application until it
gets stopped.

Once a request is created it can be queued to the camera and the
application will be notified asynchronously once the request is
completed and be able to process all the buffers involved in the
request.

At this point the request objects don't support controls. This will be
extended in the future.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06 07:41:51 +02:00
Niklas Söderlund
98edf29e01 libcamera: camera: Cache the stream configuration in the stream object
The API towards the application and pipeline handler can be simplified
if the camera caches which streams have been selected and their
respective configuration.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06 07:41:51 +02:00
Niklas Söderlund
31bb25ae8d libcamera: camera: Add helper to check for exclusive access
Some operations on the camera requires the application to have exclusive
access to the camera. To help check for this in these operations add a
helper.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06 07:41:51 +02:00
Jacopo Mondi
5aef825764 libcamera: Provide a Request object
Implement a Request object used by applications to queue image capture
requests to a camera.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06 07:41:51 +02:00
Niklas Söderlund
1d7b6297f2 libcamera: stream: Add stream configuration to the stream object
Add a cache of the active stream configuration to the stream object.
This cache is to be updated from the Camera object and can be accessed
read only from both the application and pipeline handlers.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06 07:41:51 +02:00
Kieran Bingham
1b7051b492 libcamera: stream: Construct a stream
Construct a stream object with a default internal pool.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06 07:41:51 +02:00
Niklas Söderlund
e94e52c0cb libcamera: v4l2_device: Update dequeued buffer information
Copy the information from the struct v4l2_buffer when dequeueing the
buffer as applications need this information to make sense of the
captured data.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06 06:49:45 +02:00
Kieran Bingham
83148ce8be libcamera: Add Buffer Management
Provide classes that represent frame buffers and pools of frame buffers.

An image within the system may use one or more Plane objects to track each
plane in the case of multi-planar image formats. The Buffer class manages all
of the data required to render or interpret the raw image data.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06 06:49:19 +02:00
Niklas Söderlund
4a5febd7dd libcamera: streams: extend stream configuration with buffer count
The camera needs to be configured with the number of buffers required to
satisfy the applications use case. While the application can request any
number of buffers, the pipeline must take the constraints of the Linux
driver into consideration.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-04 20:21:19 +01:00
Niklas Söderlund
65ea2422d2 libcamera: camera: extend camera object to support configuration of streams
Extend the camera to support reading and configuring formats for
groups of streams. The implementation in the Camera are minimalistic as
the heavy lifting are done by the pipeline handler implementations.

The most important functionality the camera provides in this context is
validation of data structures passed to it from the application and
access control to the pipeline handler.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01 08:12:18 +01:00
Niklas Söderlund
75476f86d2 libcamera: camera: extend camera object to support streams
A camera consists of one or more video streams originating from the same
video source. The different streams could for example have access to
different hardware blocks in the video pipeline and therefore be able to
process the video source in different ways.

All static information describing each stream need to be recorded at
camera creation. After a camera is created an application can retrieve
the static information about its streams at any time.

Update all pipeline handlers to register one stream per camera, this
will be extended in the future for some of the pipelines.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01 08:11:33 +01:00
Laurent Pinchart
ff96eb2ebb libcamera: camera: Add acquire() and release()
Exclusive access must be obtained before performing operations that
change the device state. Define an internal flag to track ownership and
provide a means of protecting functions that change device
configuration.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-01 08:11:33 +01:00
Niklas Söderlund
51d442d5a1 libcamera: stream: add initial StreamConfiguration structure
Add an initial StreamConfiguration implementation to hold configuration
data for a single stream of a Camera. In its current form not many
configuration parameters are supported but it's expected the number of
options will grow over time.

At this stage the pixel format is represented as an unsigned int to
allow for easy mapping to the V4L2 API. This might be subject to change
in the future as we finalize how libcamera shall represent pixel
formats.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01 08:11:33 +01:00
Niklas Söderlund
50e184d3f1 libcamera: stream: add initial Stream class
Add an initial Stream implementation. The idea is that once capability
support is added to the library each stream will describe its
capabilities using this class. An application will then select one or
more streams based on these capabilities and use them to configure the
camera and capture.

At this stage the Stream class is empty as capabilities are yet to be
added. The class is still useful as it will be used to communicate how
many streams a Camera object provides.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01 08:11:33 +01:00
Laurent Pinchart
92d9df6924 libcamera: camera: Fix operator= definition
The class assignment operator is usually defined as returning a
reference to the object, to allow a = b = c statements. While the return
type makes no difference when deleting the operator in a class
definition, it's still a good practice to use the correct return type.
Fix it in the Camera and CameraManager classes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-31 11:03:21 +02:00
Laurent Pinchart
eae59ca2cd libcamera: signal: Don't use reinterpret_cast<>() to perform downcasts
Use static_cast<>() instead of reinterpret_cast<>() to perform
downcasts, as reinterpret_cast<>() isn't meant (and guaranteed to be
safe) for that purpose.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-27 17:50:29 +02:00
Laurent Pinchart
8897260976 libcamera: camera_manager: Add method to unregister a camera
The new removeCamera() method is meant to be used by pipeline handlers
to unregister a camera in case of device disconnection.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-24 22:24:15 +02:00
Niklas Söderlund
124aaffde0 libcamera: camera: Add disconnection notification
As camera object have the potential to outlive the hardware they
represent, there is a need to inform the camera that the underlying
device has been disconnected, and in turn to notify applications.

Implement a disconnection notification mechanism that can be used by
pipeline handlers to notify the camera of disconnection. The camera then
block all new API calls and emit the disconnected signal.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-24 22:24:15 +02:00
Niklas Söderlund
5b02e03199 libcamera: camera: Associate cameras with their pipeline handler
The PipelineHandler which creates a Camera is responsible for serving
any operation requested by the user. In order forward the public API
calls, the camera needs to store a reference to its pipeline handler.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v1:

- Create pipeline handlers is shared pointers, make them inherit from
  std::enable_shared_from_this<> and stored them in shared pointers.
2019-01-24 22:24:11 +02:00
Laurent Pinchart
4d470eb37f libcamera: event_dispatcher: Add interrupt() function
The new interrupt() function allows interrupting in-progress blocking
processEvents() calls. This is useful to stop running event loops.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-23 18:51:56 +02:00
Laurent Pinchart
21ff749a79 libcamera: camera: Handle camera objects through shared pointers
The Camera class is explicitly reference-counted to manage the lifetime
of camera objects. Replace this open-coded implementation with usage of
the std::shared_ptr<> class.

This API change prevents pipeline handlers from subclassing the Camera
class. This isn't deemed to be an issue. Mark the class final to make
this explicit.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-21 11:13:53 +02:00
Laurent Pinchart
f3695e9b09 libcamera: camera_manager: Register cameras with the camera manager
Cameras are listed through a double indirection, first iterating over
all available pipeline handlers, and then listing the cameras they each
support. To simplify the API make the pipeline handlers register the
cameras with the camera manager directly, which lets the camera manager
easily expose the list of all available cameras.

The PipelineHandler API gets simplified as the handlers don't need to
expose the list of cameras they have created.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-21 11:13:49 +02:00
Laurent Pinchart
32bf7ef239 libcamera: camera_manager: Use std::unique_ptr to store event dispatcher
The CameraManager takes ownership of the dispatcher passed to the
setEventDispatcher() function. Enforces this by using std::unique_ptr<>.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-21 11:13:45 +02:00