summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/simple
AgeCommit message (Collapse)Author
6 dayslibcamera: pipeline: Rename pipelines to a shorter nameJulien Vuillaumier
The PipelineHandlerFactoryBase class has a name that is propagated to the PipelineHandler instance it creates. In present implementation, this name comes from the REGISTER_PIPELINE_HANDLER registration macro. It corresponds to the stringified name of the PipelineHandler derived class. Therefore, PipelineHandler factories and instances names can be quite long such as "PipelineHandlerRkISP1". A libcamera user may have to explicitly refer to a PipelineHandler name for configuration purpose: one usage of the name can be to define a pipeline handlers match list and their priorities. It is desired, for user convenience, to use a short name to designate a pipeline handler. Reusing the short pipeline names already defined in the meson option files is an existing and consistent way of naming pipelines. This change adds an explicit name parameter to the REGISTER_PIPELINE_HANDLER registration macro. That parameter is used to define the name of a pipeline handler factory, instead of the current pipeline handler class name. Each pipeline registration is updated accordingly. The short name assigned corresponds to the pipeline directory name in the source tree. It is consistent with pipelines names used in meson. Changing the pipeline name has an impact on the IPA modules: each module defines a IPAModuleInfo structure. This structure has a pipelineName member defining the pipeline handler name it shall match with. Therefore, each internal IPA module definition has to be changed to have its IPAModuleInfo pipelineName name updated with the short pipeline handler name. In addition to this pipelineName member, the IPAModuleInfo structure also has a name member, associated to the IPA module name. Having renamed the pipelines to a short name, the pipeline name and the IPA module names of the IPAModuleInfo structure are the same: for in-tree IPA, they correspond to the respective pipeline and IPA subdirectories in the source tree. However the IPA name could be different, for instance with a close source IPA implementation built out-of-tree. Thus, it makes sense to keep the IPA name in that structure, as the 2 definitions may not always be redundant. Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> [Kieran: Adjust for clang-format style fix, reformat commitmsg] Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
12 dayslibcamera: Drop file name from header comment blocksLaurent Pinchart
Source files in libcamera start by a comment block header, which includes the file name and a one-line description of the file contents. While the latter is useful to get a quick overview of the file contents at a glance, the former is mostly a source of inconvenience. The name in the comments can easily get out of sync with the file name when files are renamed, and copy & paste during development have often lead to incorrect names being used to start with. Readers of the source code are expected to know which file they're looking it. Drop the file name from the header comment block. The change was generated with the following script: ---------------------------------------- dirs="include/libcamera src test utils" declare -rA patterns=( ['c']=' \* ' ['cpp']=' \* ' ['h']=' \* ' ['py']='# ' ['sh']='# ' ) for ext in ${!patterns[@]} ; do files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done) pattern=${patterns[${ext}]} for file in $files ; do name=$(basename ${file}) sed -i "s/^\(${pattern}\)${name} - /\1/" "$file" done done ---------------------------------------- This misses several files that are out of sync with the comment block header. Those will be addressed separately and manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-04-16libcamera: pipeline: simple: Enable use of Soft ISP and Soft IPAAndrey Konovalov
To enable the Simple Soft ISP and Soft IPA for simple pipeline handler configure the build with: -Dpipelines=simple -Dipas=simple Also using the Soft ISP for the particular hardware platform must be enabled in the supportedDevices[] table. It is currently enabled for and only for qcom-camss. If the pipeline uses Converter, Soft ISP and Soft IPA aren't available. Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s Tested-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-04-16libcamera: pipeline: simple: Rename converterBuffers_ and related varsAndrey Konovalov
The converterBuffers_ and the converterQueue_ are not that specific to the Converter, and could be used by another entity doing the format conversion. Rename converterBuffers_, converterQueue_, and useConverter_ to conversionBuffers_, conversionQueue_ and useConversion_ to disassociate them from the Converter. Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s Tested-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-04-16libcamera: pipeline: simple: fix size adjustment in validate()Andrey Konovalov
SimpleCameraConfiguration::validate() adjusts the configuration of its streams (if the size is not in the outputSizes) to the captureSize. But the captureSize itself can be not in the outputSizes, and then the adjusted configuration won't be valid resulting in camera configuration failure. Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s Tested-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15libcamera: v4l2_subdevice: Add V4L2Subdevice::Route structureLaurent Pinchart
The V4L2Subdevice class deals with streams in two places: - In routing tables, streams as expressed as a pad number and a stream number in a v4l2_subdev_route instance. - In the format and selection get and set functions, streams as expressed using the Stream structure, which binds the pad number and stream number. Expressing streams in different ways requires pipeline handlers and other helpers to convert between the two representations. This isn't much of an issue yet as libcamera has little stream-aware code, but it is expected to increasingly become a burden. To simplify the API, introduce a V4L2Subdevice::Route structure that mimicks the kernel v4l2_subdev_route structure but represents streams as V4L2Subdevice::Stream instances. This will improve seamless integration of routes, formats and selection rectangles. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15libcamera: v4l2_subdevice: Replace Routing::toString() with operator<<()Laurent Pinchart
The main (and only at the moment) use case for the Routing::toString() function is to print a representation of the routing table in a log message. The function is implemented using an std::stringstream, and the returned std::string is then inserted into an std::ostream. This is inefficient. Replace the function with a specialization of the operator<<() and use it in the caller. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15libcamera: v4l2_subdevice: Rename V4L2SubdeviceFormat::mbus_code to codeLaurent Pinchart
The V4L2SubdeviceFormat::mbus_code member doesn't follow the libcamera coding style as it should use camelCase. Fix it by renaming it to just 'code', to shorten lines in addition to fixing the coding style. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-02-28pipeline: simple: Add support for MediaTek MT8365 platformsSuhrid Subramaniam
The camera pipeline for MediaTek MT8365 consists of the following: Raw sensor (+ external ISP) --> SENINF --> CAMSV30 --> DRAM SENINF (SENsor INterFace) is a CSI-2 receiver. CAMSV30 (Camera Simple Version) is a DMA Engine which bypasses ISP3.0 and writes directly to DRAM. Both SENINF and CAMSV30 are supported by V4L2 drivers. MT8365 platform consists of a hardware converter called MDP which supports up to three streams. Signed-off-by: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-23libcamera: Use CameraConfiguration::orientationJacopo Mondi
Replace the usage of CameraConfiguration::transform with the newly introduced CameraConfiguration::orientation. Rework and rename the CameraSensor::validateTransform(transform) to CameraSensor::computeTransform(orientation), that given the desired image orientation computes the Transform that pipeline handlers should apply to the sensor to obtain it. Port all pipeline handlers to use the newly introduced function. This commit breaks existing applications as it removes the public CameraConfiguration::transform in favour of CameraConfiguration::orientation. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-07-07libcamera: pipeline: simple: Support TI CSI-RXJai Luthra
New TI SoCs from J7 and AM62 family have a camera pipeline that receives data using Cadence's DPHY-RX and CSI-RX bridge. A pixel-grabbing "shim" IP routes this incoming stream of data to the DMA subsystem, to finally store the frame data in memory. The driver for this is not merged in mainline yet, but v7 was posted [1] on linux-media list a few months ago. With some minor fixes, the work-in-progress v8 series [2] works with the simple pipeline handler, so we enable support for this device. Link: https://lore.kernel.org/all/20230314115516.667-1-vaishnav.a@ti.com/ [1] Link: https://github.com/jailuthra/linux/commits/6ff226ca13f34 [2] Signed-off-by: Jai Luthra <j-luthra@ti.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-07-04libcamera: camera: Take span of StreamRole instead of vectorBarnabás Pőcze
Change the parameter type of `generateConfiguration()` from `const std::vector&` to `libcamera::Span`. A span is almost always preferable to a const vector ref because it does not force dynamic allocation when none are needed, and it allows any contiguous container to be used. A new overload is added that accepts an initializer list so that cam->generateConfiguration({ ... }) keeps working. There is no API break since a span can be constructed from a vector and the initializer list overload takes care of the initializer lists, but this change causes an ABI break. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [Kieran: Apply checkstyle fixups] Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-05-03libcamera: pipeline: simple: Add support for ST's DCMIPPDaniel Scally
The STM32 contains a camera pipeline known as the DCMIPP (Digital Camera-Memory Interface Pixel Processor) which receives data from a parallel interface and dumps the post-processed data to memory. The pipeline is capable of some processing in the form of downscaling captured data through cropping or skipping the sensor's output. The simple pipeline handler is quite capable of handling the DCMIPP given its operation is handled entirely through configuring the pads of a media graph, so add support for the driver to the pipeline's supportedDevices array. Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> 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>
2023-05-01pipeline: simple: Validate transformRobert Mader
Just like we do for other pipeline handlers already. This ensures we corretly pass on transforms that are not handled by the sensor - e.g. rotations - back to the app via the config, which is required on devices like the Pinephone. Signed-off-by: Robert Mader <robert.mader@collabora.com> Tested-by: Arnav Singh <me@arnavion.dev> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-09libcamera: converter: Check converter validitySuhrid Subramaniam
The ConverterFactoryBase::create() function returns a nullptr when no converter is found. The only caller, SimpleCameraData::init(), checks if the converter is valid with isValid(), but doesn't check if the pointer is null, which can lead to a crash. We could check both pointer validity and converter validity in the caller, but to limit the complexity in callers, it is better to check the converter validity in the create() function and return a null pointer when no valid converter is found. Signed-off-by: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-12-14libcamera: pipeline: simple: converter: Use generic converter interfaceXavier Roumegue
Move the simple converter implementation to a generic V4L2 M2M class derived from the converter interface. This latter could be used by other pipeline implementations and as base class for customized V4L2 M2M converters. Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-11-09libcamera: pipeline_handler: Return unique_ptr from generateConfiguration()Laurent Pinchart
The PipelineHandler::generateConfiguration() function allocates a CameraConfiguration instance and returns it. The ownership of the instance is transferred to the caller. This is a perfect match for a std::unique_ptr<>, which the Camera::generateConfiguration() function already returns. Update PipelineHandler::generateConfiguration() to match it. This fixes a memory leak in one of the error return paths in the IPU3 pipeline handler. While at it, update the Camera::generateConfiguration() function documentation to drop the sentence that describes the ownership transfer, as that is implied by usage of std::unique_ptr<>. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-08-03libcamera: pipeline: simple: Add support for NXP ISILaurent Pinchart
Several NXP i.MX8 SoCs (such as the i.MX8MN and i.MX8MP) contain a camera pipeline made of sensor interfaces (with parallel and/or CSI-2 receivers) and an image processing engine named ISI. The ISI contains an input crossbar switch and one or more processing pipelines capable of format conversion and scaling. This is a good candidate for the simple pipeline handler as a first step. The i.MX8MP should eventually graduate to having its own pipeline handler as it also contains two ISP instances (supported by the rkisp1 driver). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2022-08-03libcamera: pipeline: simple: Don't disable links carrying other streamsLaurent Pinchart
If a subdev supports the internal routing API, pads unrelated to the pipeline for a given camera sensor may carry streams for other cameras. The link setup logic is updated to take this into account, by avoiding disabling links to unrelated pads. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-08-03libcamera: pipeline: simple: Walk pipeline using subdev internal routingPhi-Bang Nguyen
When traversing the media graph to discover a pipeline from the camera sensor to a video node, all sink-to-source paths inside subdevs are considered. This can lead to invalid paths being followed, when a subdev has restrictions on its internal routing. The V4L2 API supports exposing subdev internal routing to userspace. Make use of this feature, when implemented by a subdev, to restrict the internal paths to the currently active routes. If a subdev doesn't implement the internal routing operations, all source pads are considered, as done today. This change is needed to properly support multiple sensors with devices such as the NXP i.MX8 ISI or the MediaTek i350 and i500 SENINF. Support for changing routes dynamically will be added later when required. Signed-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2022-08-03libcamera: pipeline: simple: Setup links in the context of sink entitiesLaurent Pinchart
To setup links the pipeline handler iterates over all entities in the pipeline and disables all links but the ones we want to enable. Some entities don't allow multiple sink links to be enabled, so the iteration needs to be based on sink entities, disabling all their links first and then enabling the sink link that is part of the pipeline. The loop implementation iterates over all Entity instances, and uses their source link to locate the MediaEntity for the connected sink. The sink entity is then processed in the context of the source's loop iteration. This prevents the code from being able to access extra information about the sink entity, as we only have access to the MediaEntity, not the Entity. To prepare for subdev routing support that will require accessing additional entity information, refactor the loop to process the sink entity in the context of its Entity instance. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2022-08-03libcamera: pipeline: simple: Reset routing table of subdevsJacopo Mondi
Reset the routing table of subdevices supporting the V4L2 streams API to its default state when initializing the pipeline handler. This avoids issues caused by usage of leftover state. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2022-08-03libcamera: v4l2_videodevice: Reintroduce toV4L2PixelFormat()Jacopo Mondi
This is a partial revert of commit 395d43d6d75b ("libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()") The function was removed because it incorrectly maps non-contiguous V4L2 format variants (ie V4L2_PIX_FMT_YUV420M) to the API version supported by the video device (singleplanar API and multiplanar API). It was decided at the time to remove the function and let its users call directly V4L2PixelFormat::fromPixelFormat() which accepts a 'multiplanar' flags. As we aim to associate multiple V4L2PixelFormat to a single libcamera format, the next patches will verify which of them is actually supported by the video device. For now, return the contiguous version unconditionally. Re-introduce V4L2VideoDevice::toV4L2PixelFormat() and convert all the V4L2PixelFormat::fromPixelFormat() users to use it. The V4L2 compatibility layer is the only outlier as it doesn't have a video device to poke, hence it still uses V4L2PixelFormat::fromPixelFormat(). Next patches will implement the device format matching logic and handle the non-contiguous plane issue in V4L2VideoDevice::toV4L2PixelFormat(). Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2022-07-21libcamera: pipeline: simple: converter: Handle unsupported input formatXavier Roumegue
SimpleConverter::formats() should return an empty vector if the input format is not supported by the converter. Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-16libcamera: pipeline: simple: Support scaling on the sensorLaurent Pinchart
As the simple pipeline handler targets simple pipelines on the SoC side, it often gets used with platforms that have a YUV sensor capable of outputting different sizes. Extend the heuristics used for pipeline discovery and configuration to scale as much as possible on the sensor side, in order to minimize the required bandwidth. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-16libcamera: pipeline: simple: Store sensor resolution in configurationLaurent Pinchart
When enumerating the supported configurations, store the corresponding sensor resolution in the SimpleCameraData::Configuration structure and use it when configuring the camera, instead of hardcoding the sensor full resolution. This prepares for support of downscaling in the camera sensor. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-16libcamera: pipeline: simple: Factor out format test to separate functionLaurent Pinchart
To prepare for the implementation of a more complex format discovery method, factor out code that tries a pipeline configuration to a separate function. No functional change intended. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-16libcamera: pipeline: simple: Document the pipeline traversal algorithmLaurent Pinchart
Add a section to the documentation at the top of the file to describe in a bit more details how the media graph is traversed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-16libcamera: pipeline: simple: Improve debug message on config failureLaurent Pinchart
When pipeline configuration fails, print the format returned by the kernel in addition to the one requested by libcamera, to ease debugging. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-01libcamera: Fix incorrect toString() to operator<<() conversionsLaurent Pinchart
Commit 8a845ab078c3 ("libcamera: Replace toString with operator<<() for format classes") incorrectly converted some of the toString() usages, resulting in pointer values being printed instead of formats. Fix it. Fixes: 8a845ab078c3 ("libcamera: Replace toString with operator<<() for format classes") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-05-04libcamera: Replace toString with operator<<() for format classesLaurent Pinchart
Now that format classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-04libcamera: Replace toString with operator<<() for geometry classesLaurent Pinchart
Now that geometry classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-12-29libcamera: pipeline: simple: Rename Entity::link to sourceLinkLaurent Pinchart
The Entity::link member has an ambiguous name. Rename it to sourceLink to clarify that it stores the link on the source pad. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-12-13libcamera: v4l2_subdevice: Add colorSpace field to V4L2SubdeviceFormatDavid Plowman
This adds a ColorSpace field to the V4L2SubdeviceFormat so that we can set and request particular color spaces from V4L2. This commit simply adds the field and fixes some occurrences of brace initializers that would otherwise be broken. A subsequent commit will pass and retrieve the value correctly to/from V4l2 itself. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-12-11libcamera: pipeline: Introduce stopDevice()Jacopo Mondi
Since a queue of waiting Requests has been introduced, not all Requests queued to the PipelineHandler are immediately queued to the device. As a Camera can be stopped at any time, it is required to complete the waiting requests after the ones queued to the device had been completed. Introduce a pure virtual PipelineHandler::stopDevice() function to be implemented by pipeline handlers and make the PipelineHandler::stop() function call it before completing pending requests. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-11-24libcamera: pipeline: Convert to pragma onceKieran Bingham
Remove the verbose #ifndef/#define/#endif pattern for maintaining header idempotency, and replace it with a simple #pragma once. This simplifies the headers, and prevents redundant changes when header files get moved. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-09-07libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()Laurent Pinchart
The V4L2VideoDevice::toV4L2PixelFormat() function is incorrectly implemented, as it will pick a multi-planar format if the device supports the multi-planar API, even if only single-planar formats are supported. This currently works because the implementation calls V4L2PixelFormat::fromPixelFormat(), which ignores the multiplanar argument and always returns a single-planar format. Fixing this isn't trivial. As we don't need to support multi-planar V4L2 formats at this point, drop the function instead of pretending everything is fine, and call V4L2PixelFormat::fromPixelFormat() directly from pipeline handlers. As the single-planar case is the most common, set the multiplanar argument to false by default to avoid long lines. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-08-31libcamera: pipeline: simple: Remove SimplePipelineHandler::activeCamera_Laurent Pinchart
The SimplePipelineHandler activeCamera_ member pointer is set but never used. Drop it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Move bufferReady handler to SimpleCameraDataLaurent Pinchart
To use multiple cameras at the same time, a per-camera buffer ready handler is needed. Move the bufferReady() function connected to the V4L2VideoDevice bufferReady signal from the SimplePipelineHandler class to the SimpleCameraData class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Move converter to SimpleCameraDataLaurent Pinchart
To use multiple cameras at the same time, each camera instance will need its own converter. Store the converter in SimpleCameraData, and open it in init(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Add pipeline pad reservation mechanismLaurent Pinchart
The cameras created by the same pipeline handler instance may share hardware resources, prohibiting usage of multiple cameras concurrently. Implement a heuristic to reserve resources and handle mutual exclusiong in a generic way. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Open all video devices at match() timeLaurent Pinchart
Move opening of video devices at match() time, the same way as subdevs are opened, to make the handling of V4L2 video devices and subdevices more consistent. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Store all entity devices in common mapLaurent Pinchart
Merge the SimplePipelineHandler videos_ and subdevs_ maps, which respectively store V4L2 video devices and subdevices associated with entities, into a single entities_ map that contains an EntityData structure. This gathers all data about entities in a single place, allowing for easy extension of entity data in the future. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Store video node entity in camera dataLaurent Pinchart
Store the entity corresponding to the video node at the end of the pipeline in the SimpleCameraData::entities_ list. This requires special handling of the video node in the loops that iterate over all entities, but will be useful to implement mutually exclusive access to entities for concurrent camera usage. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Delay opening of video device until init()Laurent Pinchart
The video device is currently opened in the SimpleCameraData constructor. This requires opening the video devices on-demand the first time they're accessed, which gets in the way of refactoring of per-entity data storage in the pipeline handler. Move opening of the video device to the SimpleCameraData::init() function. The on-demand open mechanism isn't touched yet, it will be refactored later. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-31libcamera: pipeline: simple: Add sink and source pads to entity dataLaurent Pinchart
Record the sink and source pads through which an entity is traversed in the list of entities stored in the camera data. This prepares for implementing mutually exclusive access to entities between cameras. The debug message that displays detected pipelines now prints pads to describe the pipeline more precisely: [0:00:35.901275750] [260] DEBUG SimplePipeline simple.cpp:404 Found pipeline: [imx290 2-001a|0] -> [0|csis-32e40000.csi|1] -> [0|mxc_isi.0|1] -> [0|mxc_isi.0.capture] Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
2021-08-17libcamera: pipeline: Cast to derived pipeline handler with helpersLaurent Pinchart
Replace manual static casts from the PipelineHandler pointer to a derived class pointer with helper functions in the camera data classes. This simplifies code accessing the pipeline from the camera data. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-17libcamera: pipeline_handler: Drop CameraData classLaurent Pinchart
The CameraData class isn't used anymore. Drop it. 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>
2021-08-16libcamera: pipeline: simple: Migrate to Camera::PrivateLaurent Pinchart
As part of the effort to remove the CameraData class, migrate the pipeline handler-specific camera data from CameraData to the Camera::Private class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-16libcamera: camera: Pass Private pointer to Camera constructorLaurent Pinchart
In order to allow subclassing Camera::Private in pipeline handlers, pass the pointer to the private data to the Camera constructor, and to the Camera::createCamera() function. The Camera::Private id_ and streams_ members now need to be initialized by the Camera constructor instead of the Camera::Private constructor, to allow storage of the streams in a pipeline handler-specific subclass of Camera::Private. 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>