summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline
AgeCommit message (Collapse)Author
22 hourslibcamera: Drop remaining file name from header comment blocksHEADmasterLaurent 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 blocks in all remaining locations that were not caught by the automated script as they are out of sync with the file name. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
31 hourspipeline: rpi: Avoid duplicating size range for the same pixel formatDavid Plowman
Some V4L2 formats translate to the same pixel format, e.g. YU12 and YM12 both produce YUV420. In this case our ISP driver advertises the same size range for both, but we must not record the same thing twice for the same pixel format (which will cause a failure later on). Instead, ignore the V4l2 format if the pixel format has already been seen. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
47 hourslibcamera: 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: internal: Move SharedMemObject class to a common directoryAndrey Konovalov
Move SharedMemObject class out of RPi namespace and put it into include/libcamera/internal so that everyone could use it. 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> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> 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: internal: Move dma_heaps.[h, cpp] to common directoriesAndrey Konovalov
DmaHeap class is useful outside the RPi pipeline handler too. Move dma_heaps.h and dma_heaps.cpp to common directories. Update the build files and RPi vc4 pipeline handler accordingly. 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: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> 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-26libcamera: pipeline: Add Mali-C55 ISP pipelineJacopo Mondi
Add a pipeline handler for the Mali-C55 ISP. The pipeline doesn't currently support an IPA and does not run any 3a algorithm but only handles the media graph topology and formats/sizes configuration Co-developed-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Acked-by: Nayden Kanchev <nayden.kanchev@arm.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15libcamera: camera_sensor: Expose the Bayer orderLaurent Pinchart
Pipeline handlers may need to know the Bayer order produced by the sensor when a Transform is applied (horizontal or vertical flip). This is currently implemented manually in the Raspberry Pi pipeline handler. Move the implementation to the CameraSensor class to make it usable in other pipeline handlers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@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>
2024-02-27libcamera: Use utils::to_underlying()Laurent Pinchart
Replace manual implementations of the utils::to_underlying() helper with calls to the function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2024-02-23pipeline: rpi: vc4: Use an unpacked format if no packed one is availableDavid Plowman
When validating a stream, and no valid packed pixel format can be found, see if an unpacked format can be used instead. This is particularly helpful for 8 (and 16) bit raw formats, where asking for a packed format would previously have failed. Now the configuration will be adjusted to give you a format (in fact, the only format) that will work. 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>
2024-01-23pipeline: rpi: Always initialize the embedded buffer in tryRunPipelineElias Naur
Vc4CameraData::findMatchBuffers() may return successfully with a null embedded buffer, in which case the embedded buffer id would be left uninitialized. Without this change, libcamera v0.2.0 usually crashes for me with an assertion error: ipa_base.cpp:397 assertion "it != buffers_.end()" failed in prepareIsp() Signed-off-by: Elias Naur <mail@eliasnaur.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-12-21pipeline: rpi: Respect provided strideWilliam Vinnicombe
When converting from StreamConfiguration to V4L2DeviceFormat, the stride was being dropped with the result that users could not request a custom stride. Set the stride in the V4L2DeviceFormat to prevent this happening. Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-12-07meson: Tag all installed filesLaurent Pinchart
Meson uses tags to sort installed files in categories, and makes it possible to install a subset of the files using the '--tags' argument to 'meson install'. This is typically used by distributions to split the runtime, development and documentation files into separate packages. By default, meson tries to guess the correct tag for installed files, but can't always do so properly. Mark the install targets that meson can't guess with the correct install_tag. As the feature has been introduced in meson 0.60, bump the minimum meson version. The latest LTS release of all major distributions that libcamera currently targets ship a recent enough meson version. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-11-21pipeline: rpi: Add some useful logging messagesNaushir Patuck
Add a bunch of logging messages that have come in handy debugging various issues with the pipeline handler code. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-11-06pipeline: rpi: vc4: Fix drop frame bug when no ISP streams are configuredNaushir Patuck
If no ISP output streams are configured, the ISP output count is skipped for the the low res stream, and causes the drop frame logic to fail because of a count mismatch. This in-turn stops any requests from completing correctly. Fix this by ensuring the low res output is counted correctly when no ISP output streams are configured. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-11-06pipeline: rpi: Remove unused variableNaushir Patuck
The entityControls variable is unused, remove it. Signed-off-by: Naushir Patuck <naush@raspberrypi.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-10-18pipeline: rpi: vc4: Allocate more embedded data buffersWilliam Vinnicombe
If the pipeline runs out of embedded data buffers, then it will pass the frame to the IPA without the metadata. The IPA then has to use the delayed controls as inputs to the algorithms. This can cause problems with the subsequent algorithms if the sensor did not action the controls, especially with the autofocus as that doesn't have controls which can be passed in lieu of the metadata. Reduce the likelihood of this by increasing the number of embedded data buffers, as they are small so a generous number can be allocated. Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18pipeline: rpi: Make color space members in RPiCameraConfiguration publicNaushir Patuck
This allows them to be accessed by the pipeline handlers when needed. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18pipeline: rpi: Move flip handling validation codeNaushir Patuck
Move the handling of Bayer order changes due to flips to run before platformValidate(). This removes the need for this code to be split between platformValidate() and validate() as it is right now. Also add some validation to ensure the vc4 pipeline handler only supports CSI2 packing or no packing. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18pipeline: rpi: Add SW downscale status to RPi::StreamNaushir Patuck
Record if additional software downscaling is needed for a particular stream in the RPi::Stream class. Additional software downscaling may be needed if the user required downscale factor is greater than what the ISP hardware is capable of. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18mojom: pipeline: ipa: rpi: Add fields for PiSP objectsNaushir Patuck
Add the PiSP Frontend and Backend SharedMemObject file descriptors to the ipa::init() call. This will allow the pipeline handler to pass these objects to the IPA after construction. Add a flag to indicate if buffer swaps are needed when starting the ISP for the stitch block. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18pipeline: rpi: Add SharedMemObject classNaushir Patuck
Add new SharedMemObject class that wraps a memfd memory allocation and constructs a templated object in the memory. With appropriate locking, this object can then be shared across different processes using the associated allocation file handle. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18pipeline: rpi: Add Recurrent and Needs32bitConv flags to RPi::StreamNaushir Patuck
Add a new "Recurrent" stream flag. This flag indicates the stream buffer handling/management happend from the pipeline handler exclusively. This is used for TDN/Stitch and Config streams. Add a new Needs32bitConv stream flag to indicate that this stream needs a software postprocessing conversion run on it before returning out to the application. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18pipeline: rpi: Add RequiresMmap flag to RPi::StreamNaushir Patuck
Add a new RequiresMmap flag to the RPi::Stream class indicating that buffers handled by the stream must be mmapped after allocation and cached internally. Add a new member function getBuffer(id) which can be used to obtain the mapped buffers for a given buffer id. Add a new member function acquireBuffer() which can be used to obtain any mapped buffer that has not already been acquired by the caller. As a drive-by, add the <algorithm> header to rpi_stream.cpp as it is needed for the std::find_if() function. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-27libcamera: rpi: Simplify validate() and configure() for YUV/RGB streamsNaushir Patuck
This commit simplifies the validate() and configure() calls in the pipeline handler in a number of ways: - Determine the V4L2DeviceFormat structure fields for all streams in validate(), cache them and reuse in configure() instead of re-generating this structure multiple times. - Remove setting a default pixel format in validate(), this code patch will not be used. - Use the recently added updateStreamConfig() and toV4L2DeviceFormat() helpers to populate fields in the V4L2DeviceFormat and StreamConfiguration structures to reduce code duplication. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Change default stream formatsNaushir Patuck
Switch to XRGB8888 as a default Viewfinder role output format, this is a more correct description of the ISP hardware output, and what is accepted by the Raspberry Pi hardware. Switch to YUV420 as a default output format for everything else, as this format is best supported by encoding (e.g. H.264, JPEG) sinks on the Raspberry Pi platform. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Simplify validate() and configure() for RAW streamsNaushir Patuck
This commit simplifies the validate() and configure() calls in the pipeline handler in a number of ways: - Only pass the RPiCameraConfiguration structure into platformValidate() and platformConfigure(). - Determine the V4L2DeviceFormat structure fields for all streams in validate(), cache them and reuse in configure() instead of re-generating this structure multiple times. - Use the recently added updateStreamConfig() and toV4L2DeviceFormat() helpers to populate fields in the V4L2DeviceFormat and StreamConfiguration structures to reduce code duplication. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Add some helpers to PipelineHandlerBaseNaushir Patuck
Add a helper updateStreamConfig() that updates the format related fields in a StreamConfiguration from a given V4L2DeviceFormat structure. Add and override to the toV4L2DeviceFormat() helper that returns a V4L2DeviceFormat structure populated from the format related fields in a StreamConfiguration. Both these helper functions will be used in a future commit to simplify the Raspberry Pi pipeline handler configuration/validation code. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Cache rawStreams and outStreamsNaushir Patuck
Currently, the stream configuration is stored in two vectors, rawStreams and outStreams for convenience. However, these vectors are constructed in both platformValidate() and platformConfigure(). This change caches these vectors in the RPiCameraConfiguration class to construct them only once in platformValidate(). Pass a pointer to the current configuration to platformValidate() and platformConfigure() so that they can access the streams vectors. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Make isRaw/isYuv/isRgb static functionsNaushir Patuck
Move the existing isRaw()/isYuv()/isRgb()into a static function of PipelineHandlerBase. This will allow them to be shared with the pipeline handler derived class. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Fix wrong comment indentationJacopo Mondi
The closing line of a comment block was aligned with spaces and not tabs. Fix it. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Allow platformValidate() to adjust format stridesNaushir Patuck
Propagate any changes to the format stride done by platformValidate(). The stride value may be adjusted for performace reasons. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27libcamera: rpi: Handle SensorConfigurationJacopo Mondi
Handle the SensorConfiguration provided by the application in the pipeline validate() and configure() call chains. During validation, first make sure SensorConfiguration is valid, then handle it to compute the sensor format. For the VC4 platform where the RAW stream follows the sensor's configuration adjust the RAW stream configuration to match the sensor configuration. Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-04pipeline: rpi: Simplify buffer id generationNaushir Patuck
Replace the buffer id generation in RPi::Stream with a simple integer counter since ids don't get recycled any more. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-04pipeline: rpi: Rename RPi::Stream::setExternalBuffer()Naushir Patuck
Since we don't distinguish between externally and internally allocated dma bufs, rename this function to setExportedBuffer() to clearer on its function. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-04pipeline: rpi: Remove additional external dma buf handling logicNaushir Patuck
There is no need to distinguish between dma bufs allocated outside of libcamera and internally allocated buffers. As such, remove all the special case handling of such buffers. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-04pipeline: rpi: Increase buffer import count to 32Naushir Patuck
Hardcode the maximum number of buffers imported to the V4L2 video device to 32. This only has a minor disadvantage of over-allocating cache slots and V4L2 buffer indexes, but does allow more headroom for using dma buffers allocated from outside of libcamera. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-31pipeline: rpi: Don't call toV4L2DeviceFormat() from validate()Naushir Patuck
Don't make an unnecessary call to toV4L2DeviceFormat() from validate() to get a V4L2DeviceFormat. Instead, the conversion can happen directly from the RAW stream PixelFormat. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-07-24libcamera: rpi: pipeline_base: Cache sensor formatJacopo Mondi
The format to be applied on the sensor is selected by two criteria: the desired output size and the bit depth. As the selection depends on the presence of a RAW stream and the streams configuration is handled in validate() there is no need to re-compute the format in configure(). Centralize the computation of the sensor format in validate() and remove it from configure(). Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-24libcamera: rpi: pipeline_base: Move findBestFormat to CameraDataJacopo Mondi
The findBestFormat() helper operates on the list of sensor formats, which is owned by the CameraData class. Move the function to that class as well to: 1) Avoid passing the list of formats to the function 2) Remove a static helper in favour of a class function 3) Allow subclasses with access to CameraData to call the function Move to the CameraData class the scoreFormat helper as well. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-24libcamera: rpi: pipeline_base: Remove populateSensorFormats()Jacopo Mondi
populateSensorFormats() is a static helper that is called from a single place and performs a simple loop over the sensor camera formats. Remove it and in-line it in the caller to remove one static helper from the pipeline_base.cpp file. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-07pipeline: rpi: Account for Bayer packing when validating formatNaushir Patuck
RPiCameraConfiguration::validate() did not account for user supplied Bayer packing when validating the RAW stream configuration. Fix this by seeing what packing (if any) has been specified selecting the output RAW stream format. Fixes: 6c71ee1f1530 ("pipeline: raspberrypi: Introduce PipelineHandlerBase class") Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@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>