summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-10-16ipa: rkisp1: Initialize FrameContext.agc.meteringModepfc/rkisp1-free-runJacopo Mondi
The RkISP1 AGC algorithms assumes the metering mode to be "MeteringMatrix" and pre-fill an array of weights associated with it stored in meteringModes_[MeteringMatrix] when intializing the algorithm in parseMeteringModes(). It laters fetches the weights when computing parameters using the FrameContext.agc.meteringMode as index of the meteringModes_ array. When a Request gets queued to the algorithm, the FrameContext.agc.meteringMode index is populated from the algorithm's active state, and optionally updated if the application has specified a different metering mode. In case of Request underrun however, a non-initialized FrameContext gets provided to the algorithm, causing an (unhandled) exception when accessing the meteringModes_ array. Fix this by intializing the AGC metering mode to a supported value coming from the ActiveState in IPAFrameContext::init(). Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-16libipa: FCQueue: Initialize FrameContext with activeStateJacopo Mondi
Pass to the FCQueue the algorithm's active state to use the most recent state of IPA algorithms to initialize a FrameContext. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-16libipa: FCQueue: Make sure FrameContext#0 is initializedJacopo Mondi
Some IPA modules, like the RkISP1 one, call FCQueue::get(0) at IPA::start() time, before any frame context has been allocated with FCQueue::alloc() called at queueRequest() time. The FCQueue implementation aims to detect when a FrameContext is get() before it is alloc()-ated, Warns about it, and initializes the FrameContext before returning it. In case of frame#0, a get() preceding an alloc() call is not detected as the "frame == frameContext.frame" test returns success, as FrameContexts are zeroed by default. As a result, the first returned FrameContext is not initialized. Explicitly test for frame#0 to make sure the FrameContext is initialized if get(0) is called before alloc(0). To avoid re-initializing a frame context, in case alloc() has been called correctly before get(), introduce an "initialised" state variable that tracks the FrameContext initialisation state. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-16libipa: FCQueue: Fix documentation warning for contexts_Jacopo Mondi
Fix the following documentation warning in libipa: warning: Member contexts_ (variable) of class libcamera::ipa::FCQueue is not documented. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-16libipa: FrameContext: Move init() to FrameContextJacopo Mondi
The FCtQueue structure initializes a new FrameContext using its init() function. In case of request underrun, where a FrameContext is initialized without application's controls being supplied, the FrameContext needs to be initialized to default values. In order to allow the single IPAs to initialize a FrameContext to the desired default values, move the init() function to the FrameContext structure, which each IPA derives to a per-IPA type. In this way each IPA can override the FrameContext::init() function and initialize the FrameContext to the desired default values. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-11rkisp1_path: Allow to pre-queue video buffersJacopo Mondi
In order to pre-queue video buffers, the memory management mode of the video device should be switched to DMABUF and the buffer cache needs to be initialized. This is done by the V4L2VideoDevice::importBuffers() function. Currently the RkISP1Path class calls importBuffers() in its start() function, preventing buffer pre-queueing before starting the video device. Break out the buffer import operation to a pre-queue buffer function to allow buffer pre-queueing. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-11libcamera: v4l2_videodevice: Do not hide frame dropsJacopo Mondi
We want to be able to identify them correctly. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-11WIP: rework rkisp1 pipelineJacopo Mondi
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-11rkisp1: Remove Request from FrameInfoJacopo Mondi
So that we can run without users requests. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-11rkisp1: Export buffers from main and self pathsJacopo Mondi
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-11[HACK] cam: Do not allocate buffers or queue requestsJacopo Mondi
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-09gitignore: Add venv directory to gitignoreStefan Klug
The python venv module is the standard way of creating virtual python environments. 'venv' is a commonly used name for the corresponding directory. For example in the tuning docs we propose to execute 'python -m venv venv' to setup a local virtual environment. During development I often have these scattered around in the source tree and they show up as untracked files in git. Add venv to .gitignore to prevent that. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-10-09libcamera: rkisp1: Clamp stream configuration to ISP limit on raw pathUmang Jain
Commit 761545407c76 ("pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline") introduced a mechanism to determine maximum supported sensor resolution and filter out resolutions that cannot be supported by the ISP. However, it missed to update the raw stream configuration path, where it should have clamped the raw stream configuration size to the maximum sensor supported resolution. This patch fixes the above issue and can be confirmed with IMX283 on i.MX8MP: From: ($) cam -c1 -srole=raw,width=5472,height=3072 INFO Camera camera.cpp:1197 configuring streams: (0) 5472x3648-SRGGB12 ERROR RkISP1 rkisp1_path.cpp:425 Unable to configure capture in 5472x3648-SRGGB12 Failed to configure camera Failed to start camera session To: ($) cam -c1 -srole=raw,width=5472,height=3072 INFO Camera camera.cpp:1197 configuring streams: (0) 4096x3072-SRGGB12 cam0: Capture until user interrupts by SIGINT 536.082380 (0.00 fps) cam0-stream0 seq: 000000 bytesused: 25165824 536.182378 (10.00 fps) cam0-stream0 seq: 000001 bytesused: 25165824 536.282375 (10.00 fps) cam0-stream0 seq: 000002 bytesused: 25165824 ... Fixes: 761545407c76 ("pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline") Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-10-09libcamera: rkisp1: Integrate SensorConfiguration supportUmang Jain
Integrate the RkISP1 pipeline handler to support sensor configuration provided by applications through CameraConfiguration::sensorConfig. The SensorConfiguration must be validated on both RkISP1Path (mainPath and selfPath), so the parameters of RkISP1Path::validate() have been updated to include sensorConfig. The camera configuration will be marked as invalid when the sensor configuration is supplied, if: - Invalid sensor configuration (SensorConfiguration::isValid()) - Bit depth not supported by RkISP1 pipeline - Sensor configuration output size is larger than maximum supported sensor's size on RkISP1 pipeline - No matching sensor configuration output size supplied by the sensor Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Tested-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-10-08hooks: pre-push: Verify that co-authors have a SoB lineLaurent Pinchart
The Co-developed-by tag must be followed by a corresponding SoB line. Enforce this rule in the git pre-push hook. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-10-08Documentation: guides: Fix FileSink source linkUmang Jain
Fix the 'class FileSink' source link which got broken due to commit 84ad104499d9e ("Move test applications to src/apps/"). Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-10-08ipa: rpi: awb: Add a bias to the AWB searchNaushir Patuck
In the case of an AWB search failure, the current algorithm logic will return a point on the CT curve closest to where the search finisned. This can be quite undesirable. Instead, add some bias params to the AWB algorithm which will direct the search to a set CT value in the case where statistics become unreliable causing the search to fail. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-10-08ipa: rpi: awb: Add a const for the default colour temperatureNaushir Patuck
A default CT of 4500K is used in a couple of places. Add a constexpr value for the default CT value and use it instead. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-10-08libcamera: camera: Fix CameraConfiguration spelling errorUmang Jain
The documentation of CameraConfiguration::validate() has one misspelled "CameraConfiguration". Fix it. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-10-03libcamera: software_isp: Improve wording in a commentMilan Zamazal
A minor wording improvement suggested on refactoring review. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-10-03libcamera: yaml_parser: Take string keys in `std::string_view`Barnabás Pőcze
In many cases a static string literal is used as key. Thus having the argument type be `const std::string&` is suboptimal since an `std::string` object needs to be constructed before the call. C++17 introduced `std::string_view`, using which the call can be done with less overhead, as the `std::string_view` is non-owning and may be passed in registers entirely. So make `YamlObject::{contains,operator[]}` take the string keys in `std::string_view`s. Unfortunately, that is not sufficient yet, because `std::map::find()` takes an reference to `const key_type`, which would be `const std::string&` in the case of `YamlParser`. However, with a transparent comparator such as `std::less<>` `std::map::find()` is able to accept any object as the argument, and it forwards it to the comparator. So make `YamlParser::dictionary_` use `std::less<>` as the comparator to enable the use of `std::map::find()` with any type of argument. 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> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-10-01libcamera: android: Add face detection control supportHarvey Yang
Allow Android HAL adapter to pass the face detection metadata control to the pipeline and also send face detection metadata to the camera client if the pipeline generates it. Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>
2024-10-01libcamera: control_ids_draft: Add face detection controlsYudhistira Erlandinata
Add FaceDetectMode, FaceDetectFaceRectangles, FaceDetectFaceScores, and FaceDetectFaceLandmark. Also add ControlTypePoint for supporting FaceDetectFaceLandmark. Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org> Co-developed-by: Becker Hsieh <beckerh@chromium.org> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>
2024-10-01libcamera: controls: Add ControlTypePointYudhistira Erlandinata
Add a control_type<> specialization for libcamera::Point to allow storing data of that type in a ControlValue instance. The new control type will be used by controls introduced in the next patches. Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org> Co-developed-by: Becker Hsieh <beckerh@chromium.org> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-10-01libcamera: geometry: Add two-point Rectangle constructorYudhistira Erlandinata
Add a constructor to the Rectangle class that accepts two points. The constructed Rectangle spans all the space between the two given points. Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>
2024-10-01libcamera: geometry: Clarify Rectangle's top-left cornerJacopo Mondi
The libcamera::Rectangle class allows defining rectangles regardless of the orientation of the reference system where a rectangle is used in. This implies that, depending on the reference system in use, the rectangle's top-left corner, as defined by libcamera, doesn't correspond to the visual top-left position. ^ | | ------------------- | ^ | h | | | y| o---->------------- | w -------------------------------> (0,0) x (0,0) x ------------------------------> | w y| o---->------------- | | | h | v | | ------------------- | V Clarify that a Rectangle's top-left corner corresponds to the point with the smaller x and y coordinates and that the horizontal and vertical dimensions are obtained by positive increments along the corresponding axes. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2024-09-30libcamera: Replace last users of math.hLaurent Pinchart
As described in the coding style document, libcamera favours <cmath> over <math.h>. Replace the last few occurrences of the latter with the former and adapt the code accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2024-09-30ipa: rpi: Replace last users of math.hLaurent Pinchart
As described in the coding style document, libcamera favours <cmath> over <math.h>. Replace the last few occurrences of the latter with the former in the Raspberry Pi IPA and adapt the code accordingly. In some cases, the <math.h> include is simply dropped as it isn't needed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2024-09-30libcamera: Replace usage of lroundf() with std::lround()Laurent Pinchart
As explained in the coding style document, usage of std::lround() is preferred over lroundf() as it picks the correct function based on the argument type. Replace calls to lroundf() with std::lround() through libcamera. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-09-30ipa: rpi: Use std::abs()Laurent Pinchart
As explained in the coding style document, usage of std::abs() is preferred over abs() or fabs() as it picks the correct function based on the argument type. Replace calls to abs() and fabs() with std::abs() in the Raspberry Pi algorithms. This fixes a reported warning from clang: ../src/ipa/rpi/controller/rpi/awb.cpp:508:6: error: using integer absolute value function 'abs' when argument is of floating point type [-Werror,-Wabsolute-value] if (abs(denominator) > eps) { ^ ../src/ipa/rpi/controller/rpi/awb.cpp:508:6: note: use function 'std::abs' instead if (abs(denominator) > eps) { ^~~ std::abs Reported-by: Maarten Lankhorst <dev@lankhorst.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-30libcamera: controls: Handle enum values without a castLaurent Pinchart
When constructing a ControlValue from an enum value, an explicit cast to int32_t is needed as we use int32_t as the underlying type for all enumerated controls. This makes users of ControlValue more complex. To simplify them, specialize the control_type template for enum types, to support construction of ControlValue directly without a cast. 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-09-30libcamera: v4l2_videodevice: Add getSelection() functionLaurent Pinchart
The V4L2VideoDevice class implements setSelection() but not getSelection(). The latter is useful for instance to query crop bounds. Implement the function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-09-30apps: cam: Print an error when outputting DNG and DNG support is missingLaurent Pinchart
When DNG support is missing, the cam application ignores the .dng suffix of the file pattern and writes raw binary data instead, without notifying the user. This leads to confusion. Fix it by printing an error message. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-09-30apps: Replace HAVE_DNG with HAVE_TIFFLaurent Pinchart
Support for DNG capture is conditioned by the availability of libtiff, which is indicated by the HAVE_TIFF macro set by meson. The dng_writer.h header then defines HAVE_DNG, which is used in a couple of places to conditionally compile DNG-related code. Most of the other locations where conditional compilation is required use HAVE_TIFF. Using both HAVE_TIFF and HAVE_DNG is confusing. HAVE_DNG would be a better name, but as the macro is defined in dng_writer.h, it would require all files that need to test for DNG support to include that header. Failure to include it (directly or indirectly) would result in the code covered by the macro to be silently disabled. To avoid the confusion, standardize on using HAVE_TIFF everywhere and drop HAVE_DNG. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-09-30pipeline: rkisp1: Filter out sensor sizes not supported by the pipelineUmang Jain
It is possible that the maximum sensor size (returned by CameraSensor::resolution()) is not supported by the pipeline. In such cases, a filter function is required to filter out resolutions of the camera sensor, which cannot be supported by the pipeline. Introduce the filter function filterSensorResolution() in RkISP1Path class and use it for validate() and generateConfiguration(). The maximum sensor resolution is picked from that filtered set of resolutions instead of CameraSensor::resolution(). Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-09-28libcamera: rkisp1: Eliminate hard-coded resizer limitsUmang Jain
The minResolution_ and maxResolution_ limits are dynamically queried in populateFormats() from the RkISP1Path video node. Therefore, initializing these limits with the resizer limits in the constructor is unnecessary. This change allows us to remove the hard-coded max/min resolution limits of the resizer from RkISP1Path, simplifying its constructor further. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2024-09-27pipeline: simple: Increase buffer count to fourRobert Mader
Which is not only what many other pipeline handlers use, but also a good lower limit when dealing with DRM and similar APIs. Even Mesas EGL and Vulkan WSI implementations use for the reason outlined in mesa commit 992a2dbba80aba35efe83202e1013bd6143f0dba: > When the compositor is directly scanning out from the application's buffer it > may end up holding on to three buffers. These are the one that is is currently > scanning out from, one that has been given to DRM as the next buffer to flip > to, and one that has been attached and will be given to DRM as soon as the > previous flip completes. When we attach a fourth buffer to the compositor it > should replace that third buffer so we should get a release event immediately > after that. This patch therefore also changes the number of buffer slots to 4 > so that we can accomodate that situation. Given the popularity of this buffer number the bump should be unlikely to cause problems. At the same time it may help with performance or even work around glitches. The previous number was introduced in commit a8964c28c80fb520ee3c7b10143371081d41405a without mentioning a specific reason against the change at hand. Signed-off-by: Robert Mader <robert.mader@collabora.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Update black level only on exposure changesMilan Zamazal
The black level is likely to get updated, if ever, only after exposure or gain changes. Don't compute its possible updates if exposure and gain are unchanged. It's probably not worth trying to implement something more sophisticated. Better to spend the effort on supporting tuning files. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Move exposure+gain to an algorithm moduleMilan Zamazal
This is the last step to fully convert software ISP to Algorithm-based processing. The newly introduced frameContext.sensor parameters are set, and the updated code moved, before calling Algorithm::process() to have the values up-to-date in stats processing. Resolves software ISP TODO #10. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Use DelayedControlsMilan Zamazal
Use the standard libcamera mechanism to report the "current" controls rather than delaying updates by counting from the last update. A problem is that with software ISP we cannot be sure about the sensor delay. The original implementation simply skips exposure updates for 2 frames, which should be enough in most cases. After this change, we assume the delay being exactly 2 frames, which may or may not be correct and may work with outdated values if the delay is shorter. According to Kieran, the wrong parts are also wrong on the IPU3/RKISP1/Mali pipelines and only RPi have this correct. We need to fix this, by correctly specifying the gains in the libipa camera sensor helpers. The sooner the better because this change could introduce a risk of increasing oscillations. This patch also prepares moving exposure+gain to an algorithm module where the original delay mechanism would be a (possibly unnecessary) complication. Resolves software ISP TODO #11 + #12. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Use floating point for color parametersMilan Zamazal
It's more natural to represent color gains as floating point numbers rather than using a particular pixel-related representation. double is used rather than float because it's a more common floating point type in libcamera algorithms. Otherwise there is no obvious reason to select one over the other here. The constructed color tables still use integer representation for efficiency. Black level still uses pixel (integer) values, for consistency with other libcamera parts. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Move color handling to an algorithm moduleMilan Zamazal
After black level handling has been moved to an algorithm module, white balance and the construction of color tables can be moved to algorithm modules too. This time, the moved code is split between stats processing and parameter construction methods. It is also split to two algorithm modules: - White balance computation. - Gamma table computation and color lookup tables construction. While this applies the color gains computed by the white balance algorithm, it is not directly related to white balance. And we may want to modify the color lookup tables in future according to other parameters than just gamma and white balance gains. Gamma table computation and color lookup tables construction could be split to separate algorithms too. But there is no big need for that now so they are kept together for simplicity. This is the only part of the software ISP algorithms that sets the parameters so emitting setIspParams can be moved to prepare() method. A more natural representation of the gains (and black level) would be floating point numbers. This is not done here in order to minimize changes in code movements. It will be addressed in a followup patch. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Acked-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Move black level to an algorithm moduleMilan Zamazal
The black level determination, already present as a separate class, can be moved to the prepared Algorithm processing structure. It is the first of the current software ISP algorithms that is called in the stats processing sequence, which means it is also the first one that should be moved to the new structure. Stats processing starts with calling Algorithm-based processing so the call order of the algorithms is retained. Movement of this algorithm is relatively straightforward because all it does is processing stats. The comment about getting black level from the tuning files is dropped. The black level will be taken from CameraSensorHelper if available and that will be implemented in one of the followup patches. Black level is now recomputed on each stats processing. In a future patch, after DelayedControls are used, this will be changed to recompute the black level only after exposure/gain changes. The black level depends on the sensor used, the computed value can be reused in a followup capture sessions with the same sensor. Thus it is sufficient to (re)set the initial value in BlackLevel::init. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Call Algorithm::processMilan Zamazal
This patch adds Algorithm::process call for the defined algorithms. This is preparation only since there are currently no Algorithm based algorithms defined. As software ISP currently doesn't produce any metadata, a dummy and unused metadata instance is created to satisfy Algorithm::process API. This should be changed in future. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Call Algorithm::prepareMilan Zamazal
This patch adds Algorithm::prepare call for the defined algorithms. This is preparation only since there are currently no Algorithm based algorithms defined. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Call Algorithm::queueRequestMilan Zamazal
This patch adds Algorithm::queueRequest call for the defined algorithms. As there are currently no control knobs in software ISP nor the corresponding queueRequest call chain, the patch also introduces the queueRequest methods and calls from the pipeline to the IPA. This is preparation only since there are currently no Algorithm based algorithms defined and no current software ISP algorithms support control knobs. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Call Algorithm::configureMilan Zamazal
This patch adds Algorithm::configure call for the defined algorithms. This is preparation only since there are currently no Algorithm based algorithms defined. A part of this change is passing IPAConfigInfo instead of ControlInfoMap to configure() calls as this is what Algorithm::configure expects. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Create algorithmsMilan Zamazal
We are ready to introduce algorithms now. First, let's create algorithms. The algorithms are not called yet, calls to them will be added in followup patches. The maximum number of contexts is set to the same value as in hardware pipelines. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Track and pass frame idsMilan Zamazal
A previous preparation patch implemented passing frame ids to stats processing but without actual meaningful frame id value passed there. This patch extends that by actually providing the frame id and passing it through to the stats processor. The frame id is taken from the request sequence number, the same as in hardware pipelines. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-27libcamera: software_isp: Remove final dots in debayer.cpp docstringsMilan Zamazal
The policy and the style checker require that \brief, \param and \return texts don't finish with a dot. This needs to be fixed in debayer.cpp. Also leading spaces in a \return statement are removed from there. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>