summaryrefslogtreecommitdiff
path: root/src/libcamera/include
AgeCommit message (Collapse)Author
2019-02-14libcamera: v4l2_subdevice: Forward-declare MediaEntityJacopo Mondi
The V4L2Subdevice class uses MediaEntity instances, and the corresponding header is not included. Fix this by forward declaring the MediaEntity class. Fixes: 468176fa07d9 ("libcamera: Add V4L2Subdevice") 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-02-13libcamera: v4l2_device: importBuffers supportKieran Bingham
Provide the ability to import a BufferPool into the V4L2Device allowing external dmabuf backed buffers to be queued. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-13libcamera: v4l2_device: Simplify exportBuffers()Kieran Bingham
exportBuffers() can only operate on an existing BufferPool allocation. The pool identifies its size through its .count() method. Passing a count in to the exportBuffers() call is redundant and can be incorrect if the value is not the same as the BufferPool size. Simplify the function and remove the unnecessary argument, correcting all uses throughout the code base. While we're here, remove the createBuffers() helper from the V4L2DeviceTest which only served to obfuscate which pool the buffers were being allocated for. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-11libcamera: v4l2_device: Inherit from Loggable to print device node nameLaurent Pinchart
Automate printing of device node name in log messages by inheriting from the Loggable class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-11libcamera: log: Allow extending log messagesLaurent Pinchart
Introduce a base Loggable class that can be inherited from by other classes to support adding per-instance information to the log messages. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-11libcamera: pipeline_handler: Reorder member declaration orderLaurent Pinchart
Reorder the member declaration order in the PipelineHandler class to match the control flow order, and to declare variables after methods according to the coding style. Update the documentation accordingly, preserving the order within the public, protected and private sections, but grouping related methods together between the sections. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06libcamera: pipeline_handler: Extend the interface to support captureNiklas Söderlund
In order to support capture, the pipeline handler needs methods to allocate and free buffers, to start and stop the capture and to queue requests. Define those interfaces in the PipelineHandler class and implement them as stubs in the existing pipeline handlers. This initial implementation only considers the allocation of new buffers. Future work would need to expand this to also cover importing buffers from an external source. 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-06libcamera: Add V4L2SubdeviceJacopo Mondi
Add V4L2Subdevice class that provides an interface to interact with V4L2 defined sub-devices. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06libcamera: Add geometry.hJacopo Mondi
Add geometry-related definitions in the geometry.h internal header. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06libcamera: v4l2_device: Implement stream{On,Off}Kieran Bingham
Support starting and stopping a stream on a V4L2 device. Buffers must be queued before the stream is started. 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-06libcamera: v4l2_device: Implement queue/dequeue operationsKieran Bingham
Provide queueBuffer() and dequeueBuffer() methods to interact with the V4L2Device. Buffers will be directly referenced from the bufferPool of the V4L2Device based on the index in the pool. The V4L2Device is now opened in non-blocking mode in order to avoid blocking the dequeueBuffer() method. A signal is emitted when a buffer is ready and has been dequeued. 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-06libcamera: v4l2_device: Request buffers from the deviceKieran Bingham
Provide an exportBuffers() function which allocates buffers with the MMAP method, exports them using the dmabuf API and populates the given BufferPool. 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-05libcamera: v4l2_device: Construct from MediaEntity*Jacopo Mondi
The V4L2Device constructor wants a "const MediaEntity &", while entities are usually retrieved by pointer before being used to construct a V4L2Device. Change the constructor argument to "const MediaEntity *". Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-03libcamera: v4l2_device: Rename plane format fieldsJacopo Mondi
Rename the number of valid plane formats to 'planesCount' and the actual per-plane size information array to 'planes'. Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-03libcamera: v4l2_device: Rename parameters to s/g_fmtJacopo Mondi
Rename parameters to get and set format functions to expand 'fmt' to 'format'. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-03libcamera: v4l2_device: Rename format() method to getFormat()Jacopo Mondi
Rename format() to getFormat() to reflect the v4l2 API names more closely. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-01libcamera: pipeline: extend pipelines to support stream configurationNiklas Söderlund
All streams which are to be used for capture need to be configured at the same time. This allows the pipeline handler to take any dependencies between the different streams and their configuration into account when setting up the hardware. Extend the pipeline API and all pipeline implementations with two new functions, one to read a default configuration and one to set a new configuration. Both functions operate on a group of streams which the pipeline handler should consider when performing the operations. In the current implemented pipelines this is rather easy as they only have one stream each per camera. Furthermore as there is yet no way for the pipeline handlers to interact with the hardware all they do is return a null format, log that a default configuration has been requested and log that a new configuration has been set. Future work based on more components are needed to make the pipelines return a good default format and actually interact with the hardware. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-29libcamera: v4l2_device: Add methods to get/set formatJacopo Mondi
Add methods to set and get the image format programmed on a V4L2Device for both the single and multi planar use case. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-29libcamera: v4l2-format: Add V4L2DeviceFormatJacopo Mondi
Add a V4L2DeviceFormat class aimed to be used to provide format configuration requests to a V4L2Device. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-27libcamera: v4l2_device: Fix operator= definitionJacopo Mondi
While the C++ allows the redefinition of operator= to return an arbitrary type, it is customary to return a reference to the assigned value type. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-27libcamera: pipeline: sort forward declarations of classesNiklas Söderlund
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-26libcamera: pipeline: Fix operator= declarationJacopo Mondi
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-01-26libcamera: media_device: Fallback to legacy ioctls on older kernelsLaurent Pinchart
Prior to kernel v4.19, the MEDIA_IOC_G_TOPOLOGY ioctl didn't expose entity flags. Fallback to calling MEDIA_IOC_ENUM_ENTITIES for each entity to retrieve the flags in that case. Fixes: 67d313240c9b ("libcamera: pipeline: uvcvideo: create a V4L2Device for the default video entity") 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-01-25libcamera: MediaEntity: expose the entity flagsNiklas Söderlund
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>
2019-01-25libcamera: pipeline_handler: Add CameraDataJacopo Mondi
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>
2019-01-25libcamera: v4l2_device: Identify multiplanar formatsJacopo Mondi
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>
2019-01-25libcamera: device_enumerator: Add hotplug supportLaurent Pinchart
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>
2019-01-25libcamera: pipeline_handler: Add camera disconnection supportNiklas Söderlund
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>
2019-01-24libcamera: media_device: Add disconnected signalLaurent Pinchart
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>
2019-01-24libcamera: device_enumerator: Reference-count MediaDevice instancesLaurent Pinchart
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>
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: Declare factory children classes as finalLaurent Pinchart
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>
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: event_dispatcher: Add interrupt() functionLaurent Pinchart
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-23libcamera: event_dispatcher_poll: Handle interrupted ppoll() callsLaurent Pinchart
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>
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-23libcamera: v4l2device: Obtain device capabilitiesKieran Bingham
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>
2019-01-22libcamera: media_device: expose media graph model nameNiklas Söderlund
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>
2019-01-22libcamera: Global s/devnode/deviceNode renameJacopo Mondi
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>
2019-01-22libcamera: v4l2_device: Add MediaEntity contructorJacopo Mondi
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>
2019-01-21libcamera: log: Add log categoriesLaurent Pinchart
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>
2019-01-21libcamera: media_object: Set devnode in MediaEntityJacopo Mondi
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>
2019-01-21libcamera: media_object: Add functions to entitiesJacopo Mondi
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>
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-19libcamera: utils: Don't use C++17 nested namespacesLaurent Pinchart
Nesting namespace names in a single namespace declaration is a C++17 feature. As libcamera depends on C++11 only, nest two separate namespace declarations instead. Reported-by: Shik Chen <shik@google.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-17libcamera: Add V4L2 Device objectKieran Bingham
Provide a helper V4L2 device object capable of interacting with the V4L2 Linux Kernel APIs. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-17libcamera: log: Fix coding style warningsKieran Bingham
The checkstyle utility highlights some minor warnings against the logger implementation. Fix these up. Fixes: edbd2059d8a4 ("libcamera: Add initial logger") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
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: utils: Implement C++14 make_unique<>()Laurent Pinchart
C++14 introduces std::make_unique<>() that makes it easier to initialize unique_ptr<> instances. As libcamera is limited to C++11, implement our own version of the function in the libcamera::utils namespace. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-16libcamera: device_enumerator: Don't mark the search() function as constLaurent Pinchart
While the DeviceEnumerator::search() function doesn't modify the instance directly, it returns a non-const pointer to a MediaEntity that is owned by the DeviceEnumerator instance. This breaks the const semantics. Don't mark the function as const. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>