summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_manager.cpp
AgeCommit message (Collapse)Author
2019-04-26libcamera: Remove outdated \todo commentsLaurent Pinchart
Some \todo comments are outdated and refer to tasks that have been completed. Remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-19libcamera: Include header related to source file firstLaurent Pinchart
Include the header file corresponding to the source file in the very first position. This complies with the Google C++ coding style guideliens, and helps ensuring that the headers are self-contained. Three bugs are already caught by this change (missing includes or forward declarations) in device_enumerator.h, event_dispatcher_poll.h and pipeline_handler.h. Fix them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-19libcamera: Document documentation style and update the code accordinglyLaurent Pinchart
The documentation style for the Doxygen comment blocks is inconsistent in the library. Document the expectations and update all existing comment blocks to match. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-27libcamera: align the documentation for numeric error codesNiklas Söderlund
Rapid growth of the library have resulted in slightly different wording to document that a function returns 0 on success or a negative error code otherwise. Align all different variations. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-24libcamera: camera_manager: Add method to unregister a cameraLaurent Pinchart
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-24libcamera: camera: Associate cameras with their pipeline handlerNiklas Söderlund
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-24libcamera: pipeline_handler: Store the camera manager pointerLaurent Pinchart
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>
2019-01-23libcamera: fix odd include file hierarchyNiklas Söderlund
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>
2019-01-22libcamera: camera_manager: Return EBUSY if enumerator existsKieran Bingham
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>
2019-01-21libcamera: Use log categoriesLaurent Pinchart
Use log categories in the whole existing code base. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-21libcamera: camera: Handle camera objects through shared pointersLaurent Pinchart
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-21libcamera: camera_manager: Register cameras with the camera managerLaurent Pinchart
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-21libcamera: camera_manager: Use std::unique_ptr to store event dispatcherLaurent Pinchart
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-16libcamera: camera_manager: Turn enumerator into a unique_ptr<>Laurent Pinchart
Convey the fact that the CameraManager class owns the DeviceEnumerator instance it creates by using std::unique_ptr<> to store the pointer. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-16libcamera: pipeline_handler: Rename handlers() method to factories()Laurent Pinchart
The PipelineHandlerFactory::handlers() static method returns a list of factories, not a list of handlers. Rename it accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-16libcamera: camera_manager: Improve class documentationLaurent Pinchart
Move documentation from the \file directive to the CameraManager class, as it documents the class, not the file. Improve the documentation to provide a brief overview of how the camera manager operates, and fix a few typos and inconsistencies. The documentation mentions hotplug even though it isn't implement yet, as this is a planned feature. More improvements are needed for the documentation of the CameraManager member functions, and will be added as part of the API improvements in the near future. 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-16libcamera: pipeline_handler: Don't index factories by nameLaurent Pinchart
Pipeline handler factories are register in a map indexed by their name, and the list of names is used to expose the factories and look them up. This is unnecessary cumbersome, we can instead store factories in a vector and expose it directly. The pipeline factory users will still have access to the factory names through the factory name() function. The PipelineHandlerFactory::create() method becomes so simple that it can be inlined in its single caller, removing the unneeded usage of the DeviceEnumerator in the factory. 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-08libcamera: Add a poll-based event dispatcherLaurent Pinchart
Provide a poll-based event dispatcher implementation as convenience for applications that don't need a custom event loop. The poll-based dispatcher is automatically instantiated if the application doesn't provide its own dispatcher. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-08libcamera: Add event notification infrastructureLaurent Pinchart
Add three new classes, EventDispatcher, EventNotifier and Timer, that define APIs for file descriptor event notification and timers. The implementation of the EventDispatcher is meant to be provided to libcamera by the application. The event dispatcher is integrated twith the camera manager to implement automatic registration of timers and events. 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-08libcamera: camera_manager: Make the class a singletonLaurent Pinchart
There can only be a single camera manager instance in the application. Creating it as a singleton helps avoiding mistakes. It also allows the camera manager to be used as a storage of global data, such as the future event dispatcher. 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>
2018-12-31libcamera: camera_manager: add CameraManager classNiklas Söderlund
Provide a CameraManager class which will handle listing, instancing, destruction and lifetime management of cameras. 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>