Age | Commit message (Collapse) | Author |
|
Add a V4L2Device for the default video entity in the media graph. The
UVC pipeline needs to search for the entity marked with the
MEDIA_ENT_FL_DEFAULT flag as the entity names in the media graph varies
depending on which device is used.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The name dev_ does a poor job of representing that it holds a media
device, rename it to media_. There is no functional change in this
change just s/dev_/media_/.
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The media entity flags can be useful for pipeline handlers to find the
default device in a media graph which is marked with the
MEDIA_ENT_FL_DEFAULT flag. This will be especially useful for the UVC
pipeline handler where the entity names differ per device.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Create V4L2 devices for the CIO2 capture video nodes and associate them
with the camera they are part of.
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add class definition and methods to associate a Camera with specific data
in the pipeline_handler base class.
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add functions to V4L2Capability to identify if a V4L2 device supports
multiplanar V4L2 APIs.
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Create a udev_monitor in the udev device enumerator to listen to media
device disconnection, and emit the corresponding media device's
disconnect signal in response.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
UVC devices can be hot-unplugged. Mark the corresponding media device as
hotpluggable to ensure proper disconnection support.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Pipeline handlers are responsible for creating camera instances, but
also for destroying them when devices are unplugged. As camera objects
are reference-counted this isn't a straightforward operation and
involves the camera manager and camera object itself. Add two helper
methods in the PipelineHandler base class to register a camera and to
register a media device with the pipeline handler.
When registering a camera, the registerCamera() helper method will add
it to the camera manager. When registering a media device, the
registerMediaDevice() helper method will listen to device disconnection
events, and disconnect all cameras created by the pipeline handler as a
response.
Under the hood the PipelineHandler class needs to keep track of
registered cameras in order to handle disconnection. They can't be
stored as shared pointers as this would create a circular dependency
(the Camera class owns a shared pointer to the pipeline handler). Store
them as weak pointers instead. This is safe as a reference to the camera
is stored in the camera manager, and doesn't get removed until the
camera is unregistered from the manager by the PipelineHandler.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
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>
|
|
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>
|
|
The signal is emitted when the hardware device corresponding to the
media device is unplugged. This will trigger the full unplug handling
chain.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The MediaDevice class will be the entry point to hot-unplug, as it
corresponds to the kernel devices that will report device removal
events. The class will signal media device disconnection to pipeline
handlers, which will clean up resources as a result.
This can't be performed synchronously as references may exist to the
related Camera objects in applications. The MediaDevice object thus
needs to be reference-counted in order to support unplugging, as
otherwise pipeline handlers would be required to drop all the references
to the media device they have borrowed synchronously with the
disconnection signal handler, which would be very error prone (if even
possible at all in a sane way).
Handle MedieDevice instances with std::shared_ptr<> to support this.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
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.
|
|
Nothing should inherit from the factory classes created by the
REGISTER_PIPELINE_HANDLER() macro. Declare them as final instead of only
declaring their create() method final.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Instead of passing the camera manager pointer to the match() function,
and later to more PipelineHandler functions, store it in the
PipelineHandler::manager_ member variable at construction time and
access it from there.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Test that the EventDispatcher::interrupt() function correctly interrupts
the processEvents() function, both when called before processEvents()
and when called while it is running.
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>
|
|
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>
|
|
The ppoll() call can be interrupted if a signal is delivered. Handle the
EINTR error code gracefully by restarting the call. This fixes the
event-dispatcher test failure.
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>
|
|
Add a test to verify that the event dispatcher correctly restarts event
processing when interrupted by a signal. The test currently fails as
this feature isn't implemented.
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>
|
|
There is no need for pipeline_handler.h to include camera.h, instead it
should be included in the source file which needs it;
camera_manager.cpp.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Two incorrect spellings are fixed.
'logr' -> 'log'
'environement' -> 'environment'
Fixes: 747ace042cc1 ("libcamera: log: Get log levels from the environment")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The log levels configuration is stored in category:level pairs, not
category=value. Fix the documentation.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The capabilities structure from the kernel can return capabilities of the
driver, or potentially more specific device capabilities.
Handle this with an inline function 'device_caps()' to return the device
specific capabilities when available, or fall back to the driver capabilities
otherwise.
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The compiler creates a move constructor automatically when none is
supplied, and it does the right thing by default in this case. Using
std::move() inside the function prevents the compiler from doing
return value optimization and actually hinders performances. Using
std::move() in the caller is unnecessary, the move constructor is used
automatically by the compiler.
For all these reasons remove the tentative optimization that resulted in
worse performances and worse code.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
In the case that someone calls CameraManager::start() and it has already
started/enumerated, instead of returning -ENODEV, return -EBUSY.
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Log the IPU3 pipeline using IPU3 log category
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Extend the documentation of the intended usage of DeviceMatch. The
DeviceMatch needs enough information to be able to uniquely identify a
specific media device.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Provide a pipeline handler for uvcvideo devices. The entity names for
UVC devices are different for different cameras so matching on entity
names is not possible in the generic case. This leaves options to create
specialized UVC pipeline handlers if needed to fit a specific model's
needs.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Pipeline handlers such as the upcoming ucvideo handler need the model
name to properly name the Camera objects they create. Store the model
name when querying the media device info and handle it in a similar
fashion as the driver name which is already retrieved.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Do not use the abreviated version for members, variables and getter
methods.
Library-wise rename, no intended functional changes.
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>
|
|
Construct a V4L2Device from a MediaEntity device node path. While at
there mark constructor as explicit to avoid copy-construction.
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>
|
|
And turn it into an OptionsParser object.
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>
|
|
Provide a utility to interact with cameras. This initial state is
limited and only supports listing cameras in the system and selecting a
camera to interact with.
There is not much a interacting possible yet with a camera so the tool
simply exercise the API to get hold of a camera.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
clang-format produces better results than astyle as it can better match
the libcamera coding style. Default to clang-format over astyle, fall
back to astyle if clang-format isn't found, and add a --formatter
command line option to select a formatter manually.
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>
|
|
The initial clang-format options are copied from the Linux kernel style,
with the following differences:
- Use C++11
- Remove the line length limit (to keep the original line breaks)
- Don't indent access modifiers
- Allow short inline functions on a single line
- Move braces to next line after class definition
- Keep braces on the line of the namespace definition
- Replace for-each macros
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Add test for the Intel IPU3 pipeline that lists all the cameras
registered in the system and verifies the result matches the expected.
This test is meant to be run on IPU3 platforms, it gets skipped
otherwise.
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add a pipeline handler for the Intel IPU3 device.
The pipeline handler creates a Camera for each image sensor it finds to be
connected to an IPU3 CSI-2 receiver, and enables the link between the two.
Tested on Soraka, listing detected cameras on the system, verifying the
pipeline handler gets matched and links properly enabled.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Use log categories in the whole existing code base.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
If the LIBCAMERA_LOG_FILE environment variable is set, open the file it
points to and redirect the logger output to it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Set the log level for each log category from the environment variable
LIBCAMERA_LOG_LEVELS.
The variable contains a comma-separated list of category:level pairs,
and category names can include wildcards.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Log categories are used to group log messages by topic. Introduce
support for categories by making the LOG() macro variadic. Support for
configuring log level per category will be introduced in a subsequent
commit.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The MediaEntity::setDeviceNode() function was designed to set the device
node path associated with a MediaEntity. The function was there, but the
devnode_ member field was never actually set. Fix this.
While at there add a getter method for the devnode_ member as it will
soon be used.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Media entities convey information about their main function in the
'function' field of 'struct media_v2_entity'.
Store the main function in the MediaEntity function_ class member and provide
a getter function for that.
While at there update comments, keep the MediaPad description in sync
with the MediaEntity one and remove a stale TODO entry.
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
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>
|
|
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>
|
|
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>
|
|
Object ownership is a complex topic that can lead to many issues, from
memory leak to crashes. Document the rules that libcamera enforces to
make object ownership tracking explicit.
This is a first version of the rules and is expected to be expanded as
the library is developed.
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>
|
|
signal.cpp is missing a \file signal.h Doxygen directive, preventing
documentation from being generated for the Signal class. Fix it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add the move semantics (move constructor and move assignment) to the
allowed C++11 features, as we extensively use them for the unique and
shared pointers.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
|