summaryrefslogtreecommitdiff
path: root/src/libcamera
AgeCommit message (Collapse)Author
2020-06-29libcamera: raspberrypi: Fail on unsupported stream roleJacopo Mondi
When an unsupported stream roles is requested to generateConfiguration(), the function shall fail instead of simply ignoring the request. 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>
2020-06-29libcamera: raspberrypi: Refuse invalid roles configurationJacopo Mondi
The generateConfiguration() implementation does not check if the requested list of roles can actually be satisfied. The camera API documentation prescribes the function shall fail in that case, instead of silently adjust the returned configuration. Fix this by implementing the same logic as the validate() function implements, as the pipeline handler supports one raw stream and up to two output streams. 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>
2020-06-29libcamera: ipu3: Fix wrong indentationJacopo Mondi
Fix wrong parameter indent in generateConfiguration() function implementation. 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>
2020-06-29libcamera: ipu3: Accept an empty roles listJacopo Mondi
The IPU3 pipeline handler that does not support receiving an empty list of roles at generateConfiguration() time. This contradicts the camera API which allows application to generate empty CameraConfiguration to be later manually filled. Fix this by returning an empty CameraConfiguration if the list of requested roles is empty. While at it, align the style with the other pipeline handlers. 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>
2020-06-29libcamera: ipu3: Improve error on multiple raw streams requestJacopo Mondi
Improve the error message emitted when multiple raw streams are requested. 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>
2020-06-28libcamera: ipu3: imgu: Use unique_ptr for video and subdevicesNiklas Söderlund
Instead of manually deleting the video and subdevices in the destructor use std::unique_ptr. 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>
2020-06-28libcamera: ipu3: imgu: Remove ImgUOutputNiklas Söderlund
The struct ImgUOutput now only contains one member that is in use, the video device. Remove the struct and use the video device directly instead. 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>
2020-06-28libcamera: ipu3: Remove IPU3StreamNiklas Söderlund
The pipeline specific subclass of the pipeline is empty, remove it. 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>
2020-06-28libcamera: ipu3: Remove the active flag from IPU3StreamNiklas Söderlund
The active_ flag is only used inside one function, remove the global flag and handle it inside the single function. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-06-28libcamera: ipu3: Do not duplicate data in IPU3StreamNiklas Söderlund
Do not keep the duplicated ImgUDevice::ImgUOutput information in both the stream and camera data classes. Remove it from the stream and only access it from the camera data class. Which stream is which can instead be checked by comparing it to the known streams in camera data. This match how streams are checked in other parts of the code making the pipeline more coherent. 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>
2020-06-28libcamera: ipu3: imgu: Use specific functions to configure each sinkNiklas Söderlund
When the IPU3 pipeline only provided streams to applications that came from the ImgU it made sense to have a generic function to configure all the different outputs. With the addition of the RAW stream this begins to be cumbersome to read and make sense of in the PipelineHandlerIPU3 code. Replace the generic function that takes a specific argument for which sink to configure with a specific function for each sink. This makes the code easier to follow as it's always clear which of the ImgU sinks are being configured without knowing the content of a generically named variable. It also paves the way for future improvements. 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>
2020-06-28libcamera: ipu3: imgu: Mark things that are internal as privateNiklas Söderlund
Mark all variables and functions that are only used internally as private. 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>
2020-06-28libcamera: ipu3: imgu: Do not cache indexNiklas Söderlund
The numerical index of the imgu is only used to create its name in string form. There is no need to keep it around after that, remove it. 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>
2020-06-28libcamera: ipu3: imgu: Move the ImgUDevice class to separate filesNiklas Söderlund
In preparation of refactoring the IPU3 pipeline handler breakout the ImgUDevice into its own .cpp and .h file, no functional change. 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>
2020-06-28libcamera: ipu3: Remove usage of IPU3CameraData from ImgUDeviceNiklas Söderlund
The IPU3CameraData argument to allocateBuffers() and freeBuffers() is no longer used and can be removed. 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>
2020-06-28libcamera: ipu3: Always import buffers for ImgU sinksNiklas Söderlund
When the IPU3 pipeline was first developed sinks of the ImgU that where not active still needed to have buffers allocated to allow streaming to start. This is no longer true, it's enough that the sinks have imported buffers to allow streaming to start. As we already need to import buffers for stream that are active we can align the two cases and always import buffers. With this there is no longer a reason to store the allocated FrameBuffers to keep them alive and the vector tracking them can be removed. 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>
2020-06-28libcamera: ipu3: Import instead of allocate statistic buffersNiklas Söderlund
Statistics buffers are not yet used by the IPU3 pipeline, they are never queued to the statistics video device or in any other way consumed. The kernel driver will however not allow video streaming to start if buffers are not either allocated or imported on the statistics video device. Instead of allocating the buffers wasting memory that is never used, import buffers. 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>
2020-06-28libcamera: ipu3: Remove unused name_ filed from IPU3StreamNiklas Söderlund
The field is never used, remove it. 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>
2020-06-26libcamera: ipu3: Allow zero-copy RAW stream captureNiklas Söderlund
With the refactored CIO2 interface it's now easy to add zero-copy for buffers in the RAW stream. Use the internally allocated buffers inside the CIO2Device if no buffer for the RAW stream is provided by the application, or use the application-provided buffer if any. 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>
2020-06-26libcamera: ipu3: cio2: Hide buffer allocation and freeing from usersNiklas Söderlund
The allocation and freeing of buffers for the CIO2 is handled in the IPU3 pipeline handlers start() and stop() functions. These functions also call CIO2Device start() and stop() at the appropriate times so move the CIO2 buffer allocation/freeing inside the CIO2Device and reduce the complexity of the exposed interface. 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>
2020-06-26libcamera: ipu3: cio2: Make the V4L2 devices privateNiklas Söderlund
In order to make the CIO2 easier to extend with new features make the V4L2 devices (sensor, CIO2 and video device) private members. This requires a few helper functions to be added to allow for the IPU3 driver to still be able to interact with all parts of the CIO2. These helper functions will later be extended to add new features to the IPU3 pipeline. 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>
2020-06-26libcamera: ipu3: cio2: Add function to generate configurationNiklas Söderlund
Collect the code used to generate configurations for the CIO2 block in the CIO2Device class. This allows simplifying the code and allow further changes to only happen at one code location. 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>
2020-06-26libcamera: ipu3: cio2: Consolidate information about formatsNiklas Söderlund
Instead of spreading the mapping between media bus codes and V4L2 FourCC all over the CIO2 code collect it in a single map and extract the data from it. This is done in preparation of adding PixelFormat information to the mix. 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>
2020-06-26libcamera: ipu3: cio2: Move the CIO2Device class to separate filesNiklas Söderlund
In preparation of refactoring the IPU3 pipeline handler breakout the CIO2Device into its own .cpp and .h file, no functional change. 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>
2020-06-26libcamera: ipu3: Calculate number of buffers for ImgUNiklas Söderlund
Decouple the number of buffers to allocate for the ImgU from the number of buffers allocated for the CIO2. Instead of blindly following the CIO2 pick the maximum number of buffers requested for any stream facing applications. This is potentially wasteful, as each stream could allocate just as many buffers as requested by the application instead of the maximum from the set. But this is not more wasteful than what is already used by the pipeline and should be fixed on top after the decoupling of the two processing units. 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>
2020-06-26libcamera: ipu3: Breakout stream assignment to new functionNiklas Söderlund
Selecting which stream is the most suitable for the requested configuration is mixed with adjusting the requested format when validating configurations. This is hard to read and got worse when support for Bayer formats was added. Break it out to a separate function. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-06-26libcamera: ipu3: Fold mediaBusToFormat() into only callerNiklas Söderlund
Make the code easier to read and refactor. 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>
2020-06-26libcamera: pipeline_handler: Correct small typo in acquireMediaDevice ↵Chris Chinchilla
description Correct a small typo in the method description. Fixes: d6a88607479 ("libcamera: pipeline_handler: Keep track of MediaDevice") Signed-off-by: Chris Chinchilla <chris@gregariousmammal.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-26libcamera: pipeline_handler: Fix incorrect method in CameraData docsChris Chinchilla
The pipeline handler documentation incorrectly references an old API usage of setCameraData, which should have been updated to registerCamera() while updating pipeline handlers to ensure they all have a pipeline-specific "CameraData" allocation. Update the remaining documentation reference. Fixes: b581b9576abd ("libcamera: pipeline_handler: Make pipeline-specific data mandatory") Signed-off-by: Chris Chinchilla <chris@gregariousmammal.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-25libcamera: pipeline: raspberrypi: Add StreamFormats to StreamConfigurationNaushir Patuck
In generateConfiguration(), add the device node specific formats to the StreamConfiguration for each StreamRole requested. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> 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>
2020-06-25libcamera: Add a sharpness strength controlDavid Plowman
The control is a single float value with minimum, default and maximum values. Please read the description for more details. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-25libcamera: pixel_format: Replace hex with format namesKaaira Gupta
Print format names defined in formats namespace instead of the hex values in toString() as they are easier to comprehend. For this add a property of 'name' in PixelFormatInfo' so as to map the formats with their names. Print fourcc for formats which are not used in libcamera. Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> 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>
2020-06-24libcamera: formats: Add formats for IPU3Niklas Söderlund
When replacing DRM FourCCs with libcamera formats IPU3 format descriptors where missing resulting in RAW capture not being possible. Fix this by adding the missing descriptors. Fixes: 56c99424edd64c5a ("libcamera: pipeline: Replace explicit DRM FourCCs with libcamera formats") Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-23libcamera: Add support for planar YUV422 and YUV420 formatsDavid Plowman
These formats can be helpful when downstream applications or libraries support them natively (avoiding a costly conversion). Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Tested-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-22libcamera: ipu3: Remove id from camera namesNiklas Söderlund
The id in the camera name is confusing and is of little use for users. Camera names are not (yet) required to be unique and appending which numerical CIO2 unit the sensor is attached to is just as good as depending on the i2c bus information already present in the entity name. Before this change, $ cam -l Available cameras: 1: ov13858 2-0010 0 2: ov5670 4-0036 1 After this change, $ cam -l Available cameras: 1: ov13858 2-0010 2: ov5670 4-0036 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>
2020-06-22libcamera: stream: Initialize stride and bufferCountNiklas Söderlund
The two public unsigned integer fields of StreamConfiguration, stride and bufferCount where not initialized, fix this to match other members being initialized to their 'zero' state. 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>
2020-06-18libcamera: Replace explicit DRM FourCCs with libcamera formatsLaurent Pinchart
Use the new pixel format constants to replace usage of macros from drm_fourcc.h. 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>
2020-06-18libcamera: pipeline: Replace explicit DRM FourCCs with libcamera formatsLaurent Pinchart
Use the new pixel format constants to replace usage of macros from drm_fourcc.h. The IPU3 pipeline handler still uses DRM FourCCs for IPU3-specific formats that are not defined in the libcamera public API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-06-18libcamera: Define constants for pixel formats in the public APILaurent Pinchart
libcamera uses pixel format FourCC and modifier values from DRM. This requires inclusion of drm_fourcc.h, creating a dependency on a header that is packaged differently between distributions, and causing possible issues with third-party applications. Define constants for the supported pixel formats in the new formats.h public API header, in order to remove the dependency on drm_fourcc.h. The header is generated by a Python script from a list of supported formats. The numerical values for the FourCC and modifier are extracted from drm_fourcc.h by the script, ensuring that numerical values are not inadvertently modified and preserving the direct interoperability. The pixel formats constants can't be generated solely from drm_fourcc.h, as that header defines FourCC values and modifier values, but doesn't list the valid combinations. The supported formats are thus stored in a YAML file, which contains the FourCC and optional modifier for each supported format. We may later extend the YAML file to include formats documentation, and possibly formats metadata to populate the pixelFormatInfo map (in formats.cpp) automatically. Now that two formats.h header are present (one in include/libcamera/ and one in include/libcamera/internal/), we need to explicitly qualify the Doxygen \file directive with a path. 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>
2020-06-17libcamera: StreamConfiguration: Fix typo in documentationPaul Elder
Fix a typo in the documentation in the StreamConfiguration constructor. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-17libcamera: camera_manager: Introduce signals when a camera is added or removedUmang Jain
Emit 'cameraAdded' and 'cameraRemoved' from CameraManager to enable hotplug and hot-unplug support in application like QCam. To avoid use-after-free race between the CameraManager and the application, emit the 'cameraRemoved' with the shared_ptr version of <Camera *>. This requires to change the function signature of CameraManager::removeCamera() API. Also, until now, CameraManager::Private::addCamera() transfers the entire ownership of camera shared_ptr to CameraManager using std::move(). This patch changes the signature of Private::addCamera to accept pass-by-value camera parameter. It is done to make it clear from the caller point of view that the pointer within the caller will still be valid after this function returns. With this change in, we can emit the camera pointer via 'cameraAdded' signal without hitting a segfault. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-17libcamera: device_enumerator: Emit a signal when new devices are addedUmang Jain
Emit a signal whenever new MediaDevices are added to the DeviceEnumerator. This will allow CameraManager to be notified about the new devices and it can re-emumerate all the devices currently present on the system. Device enumeration by the CameraManger is an expensive operation hence, we want one signal emission per 'x' milliseconds to notify multiple devices additions as a single batch, by the DeviceEnumerator. Add a \todo to investigate the support for that. Signed-off-by: Umang Jain <email@uajain.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>
2020-06-17libcamera: camera_manager: Refactor pipelines creation into separate functionUmang Jain
This commit introduces no functional changes. Split pipelines creation code into a separate function, so that the function can be re-used for upcoming hotplug functionality in subsequent commits. Also, fixup correct tag for \todo. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-17libcamera: CameraManager: Drop the vector of created PipelineHandlersUmang Jain
The pipes_ vector was initially used to store pipeline handlers instances with the CameraManager when it cannot be referenced from anywhere else. It was used to retrieve cameras and deleting pipeline handlers when stopping the camera manager. In f3695e9b09ce ("libcamera: camera_manager: Register cameras with the camera manager"), cameras started to get registered directly with camera manager and in 5b02e03199b7 ("libcamera: camera: Associate cameras with their pipeline handler") pipeline handlers started to get stored in a std::shared_ptr<> with each camera starting to hold a strong reference to its associated pipeline-handler. At this point, both the camera manager and the camera held a strong reference to the pipeline handler. Since the additional reference held by the camera manager gets released only on cleanup(), this lurking reference held on pipeline handler did not allow it to get destroyed even when cameras instances have been destroyed. This situation of having a pipeline handler instance around without having a camera may lead to problems (one of them explained below) especially when the camera manager is still running. It was noticed that, there was a dangling driver directory issue (tested for UVC camera - in /sys/bus/usb/drivers/uvcvideo) on 'unbind' → 'bind' operation while the CameraManager is running. The directories were still kept around even after 'unbind' because of the lurking reference of pipeline handler holding onto them. That reference would clear if and only if the CameraManager is stopped and then only directories were getting removed in the above stated path. Rather than writing a fix to release the pipeline handlers' reference from camera manager on camera disconnection, it is decided to eliminate the pipes_ vector from CameraManager moving forwards. There is no point in holding a reference to it from camera manager's point-of-view at this stage. It also helps us to fix the issue as explained above. Now that the pipeline handler instances are referenced via cameras only, it can happen that the destruction of last the camera instance may result in destruction of the pipeline handler itself. Such a possibility exists in PipelineHandler::disconnect(), where the pipeline handler itself can get destroyed while removing the camera. This is acceptable as long as we make sure that there is no access of pipeline handler's members later on in the code path. Address this situation and also add a detailed comment about it. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-15libcamera: v4l2subdev: Print mbus string instead of codeKaaira Gupta
Modify toString() to print mbus format name instead of its hex code as the name is easier to understand. Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-10libcamera: ipa_module: Fix valgrind assertion failureLaurent Pinchart
As the ELF parsing code uses non-const pointers to the ELF mapping, we have to map the module in private read-write mode. This causes issues with valgrind, due to the IPA manager mapping the module in shared read-only mode and valgrind having trouble loading debugging symbols later at dlopen time due to conflicting mappings. This is likely a bug in valgrind (reported as [1]), but we can easily work around it by using shared read-only mappings only. As such a mapping shouldn't be less efficient than private read-write mappings, switch the mapping type. This requires modifying the ELF parsing functions to operate on const memory, which is a good idea anyway as they're not supposed to modify the ELF file. [1] https://bugs.kde.org/show_bug.cgi?id=422601 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>
2020-06-10libcamera: pipeline: rkisp1: Avoid usage of dynamic_cast<>Laurent Pinchart
The logic of the code guarantees that the PipelineHandler pointer passed to the RkISP1Frames constructor is an instance of PipelineHandlerRkISP1. We can thus use static_cast<> instead of dynamic_cast<>. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-06-09libcamera: pipeline: raspberrypi: Use LGPL-2.1 licenseNaushir Patuck
Swap the pipeline handler to use "LGPL-2.1-or-later" license. This is to unify with the libcamera core source code license. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-09libcamera: CameraManager, PipelineHandler: Automatically map devnums to CameraPaul Elder
The V4L2 compatibility layer uses devnum to match video device nodes to libcamera Cameras. Some pipeline handlers don't report a devnum for their camera, which prevents the V4L2 compatibility layer from matching video device nodes to these cameras. To fix this, we first allow the camera manager to map multiple devnums to a camera. Next, we walk the media device and entity list and tell the camera manager to map every one of these devnums that is a video capture node to the camera. Since we decided that all video capture nodes that belong to a camera can be opened via the V4L2 compatibility layer to map to that camera, it would cause confusion for users if some pipeline handlers decided that only specific device nodes would map to the camera. To prevent this confusion, remove the ability for pipeline handlers to declare their own devnum-to-camera mapping. The only pipeline handler that declares the devnum mapping is the UVC pipeline handler, so remove the devnum there. We considered walking the media entity list and taking the devnum from just the one with the default flag set, but we found that some drivers (eg. vimc) don't set this flag for any entity. Instead, we take all the video capture nodes (entities with the sink pad flag set). Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-08libcamera: IPAManager: remove instance() and make createIPA() staticPaul Elder
As the only usage of IPAManager::instance() is by the pipeline handlers to call IPAManager::createIPA(), remove the former and make the latter static. Update the pipeline handlers and tests accordingly. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>