summaryrefslogtreecommitdiff
path: root/src/ipa
AgeCommit message (Collapse)Author
2022-11-12ipa: rkisp1: Add rudimentary LSC tables for imx219Paul Elder
Add rudimentary LSC tables for imx219. These were generated with the rkisp1 tuning script from libtuning [1], using an imx8mp (debix) and a white computer monitor, at only a single color temperature of 5800. [1] https://lists.libcamera.org/pipermail/libcamera-devel/2022-October/035017.html Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-11-12ipa: rkisp1: Take into account color temperature during LSC algorithmFlorian Sylvestre
Add coefficients sets in the YAML tuning file to allow using different set depending of the image color temperature (provided by AWB algorithm). During processing, LSC algorithm computes coefficients by doing a linear interpolation between the two closer set. Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-09ipa: rkisp1: Move shutter speed and analogue gain limits from agc to sensorLaurent Pinchart
The limits for the shutter speed and analogue gain are stored in IPASessionConfiguration::agc. While they're related to the AGC, they are properties of the sensor, and are stored in the session configuration by the IPA module, not the AGC algorithm. Move them to the IPASessionConfiguration::sensor structure where they belong. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-11-09ipa: Sort algorithm operations based on calling orderLaurent Pinchart
Reorder functions in the base ipa::Algorithm and its derived classes to match the calling order: queueRequest(), prepare() and process(). This makes the code flow easier to read. No functional change intended. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-11-03ipa: rkisp1: Compute LSC algorithm parameter during configureFlorian Sylvestre
LSC gradient parameters are currently computed during prepare() phase. Because these parameters can be computed only one time and stay constant for each frame after, move the computation to the configure() function. Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2022-10-28ipa: raspberrypi: awb: Update colour temperature whenever manual gains changeDavid Plowman
Previously we only did this when the system starts (on the first switch_mode). Now we do it whenever the manual colour gains are updated. To facilitate this, this R/B vs. colour temperature inverse functions are stored persistently in the AwbConfig. Signed-off-by: David Plowman <david.plowman@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>
2022-10-28ipa: raspberry: replace abs() with std::abs()Nicholas Roth
pwl.cpp uses abs() instead of std::abs(), which causes unexpected behavior in the Clang compiler used for Android. Replace with C++-standard absolute value function std::abs(), which supports double-precision absolute values in a standard way. Signed-off-by: Nicholas Roth <nicholas@rothemail.net> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-28ipa: add missing thread-safety annotationsNicholas Roth
The raspberrypi IPA is missing thread-safety annotations, which breaks the build. Add required thread-safety annotations. ../src/ipa/raspberrypi/controller/metadata.h:108:31: error: mutex 'mutex_' is still held at the end of function [-Werror,-Wthread-safety-analysis] void lock() { mutex_.lock(); } ^ ../src/ipa/raspberrypi/controller/metadata.h:108:23: note: mutex acquired here void lock() { mutex_.lock(); } ^ ../src/ipa/raspberrypi/controller/metadata.h:109:25: error: releasing mutex 'mutex_' that was not held [-Werror,-Wthread-safety-analysis] void unlock() { mutex_.unlock(); } ^ Signed-off-by: Nicholas Roth <nicholas@rothemail.net> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-24ipa: ipu3: Fill AGC and AWB metadata in algorithmsLaurent Pinchart
Fill the frame metadata in the AGC and AWB algorithm's prepare() function. This removes the need to fill metadata manually in the IPA module's processStatsBuffer() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-24ipa: rkisp1: Fill AGC and AWB metadataLaurent Pinchart
Fill the frame metadata in the AGC and AWB algorithm's prepare() function. Additional metadata for other algorithms will be addressed later. 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-10-24ipa: Pass metadata to Algorithm::process() functionLaurent Pinchart
Extend the Algorithm::process() function with a metadata control list, to be filled by individual algorithms with frame metadata. Update the rkisp1 and ipu3 IPA modules accordingly, and drop the dead code in the IPARkISP1::prepareMetadata() function while at it. This only creates the infrastructure, filling metadata in individual algorithms will be handled separately. 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-10-20ipa: raspberrypi: Rename ov9281.json to ov9281_mono.jsonNaushir Patuck
The recent change to the naming scheme for the camera tuning files failed to rename ov9281.json, causing the sensor to fail to load. Since this is a mono sensor module, rename this file to ov9281_mono.json. Fixes: 820607b195ff: ("pipeline: raspberrypi: Update naming convention for tuning files") Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-19ipa: rkisp1: Downgrade sensor controls range message to DebugLaurent Pinchart
There's no need to print the exposure and gain control ranges as an Info message. Downgrade it to Debug. While at it, print the ranges using the "[min, max]" syntax. 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-10-19ipa: Drop period at end of \brief or \paramLaurent Pinchart
A few periods crept in at the end of Doxygen \brief or \param statements in the src/ipa/ directory. Remove them all in one go. 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-10-18ipa: vimc: Add Flags to parametersPaul Elder
For the purpose of testing serializing/deserializing Flags in function parameters, add an enum class TestFlags and Flags<TestFlags> to some function parameters, both for input and output and Signals. While at it, update the ipa_interface_test. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: vimc: Add IPAOperationCode to init() parameter listPaul Elder
For the purpose of testing serializing/deserializing enums in function parameters, add IPAOperationCode to the parameter list of init(). Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Extract line length from the embedded data parserNaushir Patuck
Update the imx219, imx477 and imx519 parsers to extract the line length values from the embedded data stream and use these values in the deviceStatus metadata, replacing the DelayedControls provided values. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Allow full line length controlNaushir Patuck
Rename CamHelper::getVBlanking to CamHelper::getBlanking, and update the calculations in that function to return both horizontal and vertical blanking values for a given exposure time and frame duration limits. The calculations are setup such that vertical blanking is extended to the maximum allowable value, and any remainder gets put into horizontal blanking. The calculated horizontal blanking value is now returned to the pipeline handler to pass into DelayedControls to program into the sensor. Update the IPA to now specify the maximum frame duration from the maximum horizontal + vertical blanking values provided by the sensor mode. Additionally, the IPA now uses the frame specific horizontal blanking value (as returned by DelayedControls) in all instances. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Add line length to DeviceStatusNaushir Patuck
Add a lineLength field to the DeviceStatus structure to store the line length used for a particular frame. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Add line length calculations helper functionsNaushir Patuck
Add CamHelper::hblankToLineLength() to calculate the line length duration from the horizontal blanking (in pixels) value. Add CamHelper::lineLengthToHblank() to calculate the horizontal blanking (in pixels) value from the line length duration. Add CamHelper::lineLengthPckToDuration() to calculate the line length duration from the line length in pixels. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Add pixel clock rate to the CameraMode structureNaushir Patuck
The pixel clock rate will be used in subsequent commits to calculate line length durations. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18pipeline: ipa: raspberrypi: Add HBLANK control to DelayedControlsNaushir Patuck
Update CamHelper::getDelays() to return the sensor HBLANK delay. The HBLANK delay is set to the same value as VBLANK delay for all sensors in the Raspberry Pi IPA. Return the HBLANK gain delay from the IPA to the pipeline handler, and initialise DelayedControls to handle V4L2_CID_HBLANK with this delay value. As a drive-by, check that the V4L2_CID_HBLANK control is available when calling IPARPi::configure(). Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Remove initialized_ field from CamHelperNaushir Patuck
Given that the single user of the CamHelper is the Raspberry Pi IPA, the initialized_ field check is unnecessary. Remove the check and the field. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Pass lineLength into the CamHelper APINaushir Patuck
Update CamHelper::exposureLines() and CamHelper::exposure() to take a line length duration parameter for use in the exposure calculations. For now, only use the minimum line length for all the calculations to match the existing IPA behavior. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18ipa: raspberrypi: Add minimum and maximum line length fields to CameraModeNaushir Patuck
Add fields for minimum and maximum line length duration to the CameraMode structure. This replaces the existing lineLength field. Any use of the existing lineLength field is replaced by the new minLineLength field, as logically we always want to use the fastest sensor readout by default. As a drive-by cosmetic change, split all fields in the CameraMode structure into separate lines. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18camera_sensor: Add minimum and maximum line length to IPACameraSensorInfoNaushir Patuck
Add fields for minimum and maximum line length (in units of pixels) to the IPACameraSensorInfo structure. This replaces the existing lineLength field. Update the ipu3, raspberrypi and rkisp1 IPAs to use IPACameraSensorInfo::minLineLength instead of IPACameraSensorInfo::lineLength, as logically we will always want to use the fastest sensor readout by default. Since the IPAs now use minLineLength for their calculations, set the starting value of the V4L2_CID_HBLANK control to its minimum in CameraSensor::init(). Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-10ipa: rkisp1: Drop use of utils::defoptLaurent Pinchart
utils::defopt causes compilation issues on gcc 8.0.0 to gcc 8.3.0, likely due to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521 that was fixed in gcc 8.4.0. gcc 8.3.0 may be considered old (libcamera requires gcc-8 or newer), but it is shipped by Debian 10 that has LTS support until mid-2024. As no workaround has been found to fix compilation on gcc 8.3.0 while still retaining the functionality of utils::defopt, stop using it in the RkISP1 IPA module. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-07ipa: raspberrypi: Remove unneeded Span castsLaurent Pinchart
Commit 09c1b081baa2 ("libcamera: controls: Generate and use fixed-sized Span types") added explicit Span casts for fixed extent spans that were required due to the ControlList::set() function that takes an std::initializer_list not being able to infer a control size from template arguments. This has now been fixed, so the casts are not needed anymore. Drop them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Christian Rauch <Rauch.Christian@gmx.de> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2022-10-07ipa: camera_sensor_helper: Implement factories through class templatesLaurent Pinchart
The REGISTER_CAMERA_SENSOR_HELPER() macro defines a class type that inherits from the CameraSensorHelperFactory class, and implements a constructor and createInstance() function. Replace the code generation through macro with the C++ equivalent, a class template, as done by the Algorithm factory. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-07ipa: camera_sensor_helper: Return unique_ptr from createInstanceLaurent Pinchart
Avoid naked pointer with memory allocation by returning a unique_ptr from CameraSensorHelperFactory::createInstance(), in order to increase memory allocation safety. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-07ipa: camera_sensor_helper: Make registerType() and createInstance() privateLaurent Pinchart
The CameraSensorHelperFactory registerType() and createInstance() functions are called by the CameraSensorHelperFactory class only. Make them private. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-07ipa: camera_sensor_helper: Make factory createInstance() function constLaurent Pinchart
The CameraSensorHelperFactory::createInstance() function has no need to modify the factory instance. Make it const. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-07ipa: ipu3: Fix minor Doxygen issues in IPAFrameContextLaurent Pinchart
The IPAFrameContext documentation has a spurious Doxygen \struct statement that is not needed, and uses a \struct instead of a \var in another location. Fix both issues. This doesn't cause any change in the generated documentation. Note that the Doxygen output for IPAFrameContext is incorrect, documentation is missing for all members. This is caused by using "." instead of "::" in our documentation, which we currently do because the correct syntax produces Doxygen warnings (and still incorrect output). See https://github.com/doxygen/doxygen/issues/9343. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-05ipa: raspberrypi: Fix the imx296 mono tuning black levelNaushir Patuck
The sensor black level is 60 (in 10-bits), fix this in the mono variant tuning file. 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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-05ipa: raspberrypi: Add a tuning file for the colour variant of IMX296Naushir Patuck
Add the tuning file (imx296.json) for the colour variant of the IMX296 sensor. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-05pipeline: raspberrypi: Update naming convention for tuning filesNaushir Patuck
Append "_mono" to the sensor name when generating the tuning filename for monochrome sensor variants. So the new naming convention is as follows: <sensor_name>.json - Standard colour sensor variant <sensor_name>_mono.json - Monochrome sensor variant Rename the existing imx296.json file to imx296_mono.json as this tuning file is based on the monochrome variant of the IMX296. 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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-04ipa: raspberrypi: Limit minimum exposure time for the IMX296Naushir Patuck
Limit the minimum allowable exposure time to a single line in the IMX296 camera helper. This equates to approximately 30us. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-04ipa: raspberrypi: Fix sensor delays for the IMX296Naushir Patuck
The IMX296 implements a 2 frame delay for exposure, gain and vertical blanking changes. Report this in the camera helper. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-03ipa: ipu3: Correct context during configure()Kieran Bingham
The introduction of the FCQueue in the IPU3 inadvertently introduced a bug which cleared the initialisation of the session configuration immediately after some parameters had been set. Furthermore, it cleared and never re-initialised the sensor line duration property, which was previously only set during the call to init(). Move the clearing of the contexts from the updateSessionConfiguration() call to the earliest opportunity in configure(), and immediately re-initialise the sensor parameters. Bug: https://bugs.libcamera.org/show_bug.cgi?id=151 Fixes: 85c5c47325ab ("ipa: ipu3: Use the FCQueue") Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-01ipa: rkisp1: Remove initialized_ flags from algorithmsLaurent Pinchart
Multiple algorithms have an initialized_ flag that they set to true at the end of the init() function, and check at the beginning of prepare() to skip preparation. This serves no real purpose, as the flag can only be false if init() fails, in which case the IPA module initialization as a whole will fail. Drop the initialized_ flags. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-09-30Documentation: Add missing SPDX headersLaurent Pinchart
Two documentation files are missing SPDX headers. Add them, with the CC-BY-SA-4.0 license that covers all the libcamera documentation. 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-09-28ipa: rkisp1: awb: Remove bias from gain calculationLaurent Pinchart
The red and blue gains are computed by dividing the green mean by the red and blue means respectively. An offset of 1 is added to the dividers to avoid divisions by zero. This introduces a bias in the gain values. Fix it by clamping the divisors to a minimum of 1.0 instead of adding an offset. 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-09-28ipa: rkisp1: awb: Freeze AWB when means are too smallLaurent Pinchart
When the RGB means are too small, gains and color temperature can't be meaningfully calculated. Freeze the AWB in that case, using the previously calculated values. 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-09-28ipa: rkisp1: awb: Clamp gains to prevent divisions by zeroLaurent Pinchart
The gain values are currently clamped to the range [0.0, 3.996] used by the hardware. A zero value makes little sense, as it would completely remove the contribution of the corresponding color channel from the AWB accumulators, but worse, would lead to divisions by zero when calculating the raw means in subsequent iterations. Prevent this by setting the minimum gain value to 1/256. While at it, clamp the gain values before filtering them, to improve the stability of the control loop. 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-09-28ipa: rkisp1: awb: Prevent RGB means from being negativeLaurent Pinchart
Due to hardware rounding errors in the YCbCr means, the calculated RGB means may be negative. This would lead to negative gains, messing up calculation. Prevent this by clamping the means to positive values. 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-09-28ipa: rkisp1: awb: Log means, gains and temperature in debug messageLaurent Pinchart
Extend the debug message in Awb::process() to log the means and color temperature in addition to the gains. This is useful for debugging the algorithm behaviour. While at it, set the showpoint flag to print a fixed number of digits after the decimal point, making logs more readable. 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-09-28ipa: rkisp1: awb: Add support for RGB meansQuentin Schulz
RkISP actually supports two modes for color means, RGB and YCbCr. The variables where the means are stored are identically named regardless of the color means mode that's been selected. Since the gains are computed in RGB mode, a conversion needs to be done when the mode is YCbCr, which is unnecessary when RGB mode is selected. This adds support for RGB means mode too, by checking at runtime which mode is selected at a given time. The default is still set to YCbCr mode for now. Cc: Quentin Schulz <foss+libcamera@0leil.net> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> 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-09-28ipa: rkisp1: awb: Store color temperature as an integerLaurent Pinchart
The color temperature doesn't need floating point precision, and is calculated by Awb::estimateCCT() as an unsigned integer. Store it with the same data type in the frame context. 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-09-28ipa: rkisp1: awb: Use frame context to fix gains calculationsLaurent Pinchart
The AWB statistics are computed after the ISP applies the colour gains. This means that the red, green and blue means do not match the data coming directly from the sensor, but are multiplied by the colour gains that were used for the frame on which the statistics have been computed. The AWB algorithm needs to take this into account when calculating the colour gains for the next frame. Do so by dividing the means by the gains that were applied to the frame, retrieved from the frame context. 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-09-28ipa: rkisp1: Document the active state and frame contextLaurent Pinchart
Now that data used by algorithms has been partitioned between the active state and frame context, we have a better view of the role of each of those structures. Document them appropriately. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>