summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller
AgeCommit message (Collapse)Author
2023-05-04pipeline: ipa: raspberrypi: Refactor and move the Raspberry Pi codeNaushir Patuck
Split the Raspberry Pi pipeline handler and IPA source code into common and VC4/BCM2835 specific file structures. For the pipeline handler, the common code files now live in src/libcamera/pipeline/rpi/common/ and the VC4-specific files in src/libcamera/pipeline/rpi/vc4/. For the IPA, the common code files now live in src/ipa/rpi/{cam_helper,controller}/ and the vc4 specific files in src/ipa/rpi/vc4/. With this change, the camera tuning files are now installed under share/libcamera/ipa/rpi/vc4/. To build the pipeline and IPA, the meson configuration options have now changed from "raspberrypi" to "rpi/vc4": meson setup build -Dipas=rpi/vc4 -Dpipelines=rpi/vc4 Signed-off-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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-03-31ipa: raspberrypi: Generalise the focus reporting codeNaushir Patuck
Use the generalised focus statistics structure to compute the centre window focus FoM value. This avoids needed to hard-code a specific grid size. Remove the focus reporting algorithm as the functionality is duplicated by this bit of IPA code. Remove focus_status.h as it is no longer needed. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31ipa: raspberrypi: Generalise the autofocus algorithmNick Hollinghurst
Remove any hard-coded assumptions about the target hardware platform from the autofocus algorithm. Instead, use the "target" string provided by the camera tuning config and generalised statistics structures to determing parameters such as grid and region sizes. Additionally, PDAF statistics are represented by a generalised region statistics structure to be device agnostic. These changes also require the autofocus algorithm to initialise region weights on the first frame's prepare()/process() call rather than during initialisation. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31ipa: raspberrypi: Generalise the agc algorithmNaushir Patuck
Remove any hard-coded assumptions about the target hardware platform from the AGC algorithm. Instead, use the "target" string provided by the camera tuning config and generalised statistics structures to determing parameters such as grid and region sizes. This change replaces all hard-coded arrays with equivalent std::vector types. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31ipa: raspberrypi: Make RegionStats::get() always return a Region structNaushir Patuck
Update the overloaded RegionStats::get() and RegionStats::getFloating() member functions to return a Region struct for consistency. 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-03-31ipa: raspberrypi: Generalise the contrast algorithmNaushir Patuck
Generalise the contrast algorithm code by removing any hard-coded assumptions about the target hardware platform. Instead, the algorithm code creates a generic Pwl that gets returned to the IPA, where it gets converted to the bcm2835 hardware specific lookup table. As a drive-by, remove an unused mutex. 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-03-31ipa: raspberrypi: alsc: Use a better type name for sparse arraysDavid Plowman
The algorithm uses the data type std::vector<std::array<double, 4>> to represent the large sparse matrices that are XY (X, Y being the ALSC grid size) high but with only 4 non-zero elements on each row. Replace this slightly long type name by SparseArray<double>. No functional changes. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31ipa: raspberrypi: alsc: Replace std::vectors by Array2D classDavid Plowman
The Array2D class is a very thin wrapper round std::vector that can be used almost identically in the code, but it carries its 2D size with it so that we aren't passing it around all the time. All the std::vectors that were X * Y in size (X and Y being the ALSC grid size) have been replaced. The sparse matrices that are XY * 4 in size have not been as they are somewhat different, are used differently, require more code changes, and actually make things more confusing if everything looks like an Array2D but are not the same. There should be no change in algorithm behaviour at all. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31ipa: raspberrypi: Generalise the ALSC algorithmNaushir Patuck
Remove any hard-coded assumptions about the target hardware platform from the ALSC algorithm. Instead, use the "target" string provided by the camera tuning config and generalised statistics structures to determing parameters such as grid and region sizes. The ALSC calculations use run-time allocated arrays/vectors on every frame. Allocating these might add a non-trivial run-time penalty. Replace these dynamic allocations with a set of reusable pre-allocated vectors during the init phase. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: David Plowman <david.plowman@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>
2023-03-31ipa: raspberrypi: Add hardware configuration to the controllerNaushir Patuck
Add a new Controller::HardwareConfig structure that captures the hardware statistics grid/histogram sizes and pipeline widths. This ensures there is a single centralised places for these parameters. Add a getHardwareConfig() helper function to retrieve these values for a given hardware target. Update the statistics populating routine in the IPA to use the values from this structure instead of the hardcoded numbers. 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>
2023-03-31ipa: raspberrypi Store the target string in the controllerNaushir Patuck
The target string may be used by algorithms to determine the running hardware target. Store the target string provided by the camera tuning files in the controller state. Add a getTarget() member function to retrieve this string. Validate the correct hardware target ("bcm2835") during the IPA initialisation phase. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-28ipa: raspberrypi: Ensure shutter speed and gain are clipped in the AGCNaushir Patuck
Make a copy of the CameraMode structure on a switch mode call. This replaces the existing lastSensitivity_ field. Limit the AGC gain calculations to the minimum value given by the CameraMode structure. The maximum value remains unclipped as any gain over the sensor maximum will be made up by digital gain. Rename clipShutter to limitShutter for consistency, and have the latter limit the shutter speed to both upper and lower bounds. 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-03-28ipa: raspberrypi: Add sensor mode limits to CameraModeNaushir Patuck
Add fields in the CameraMode structure to capture the mode specific limits for analogue gain and shutter speed. For convenience, also add fields for minimum and maximum frame durations. Populate these new fields when setting up the CameraMode structure. 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-03-21ipa: raspberrypi: Fix crash under LTODave Jones
When compiled with LTO (the default on Ubuntu), the global static objects camHelpers and algorithms cause a crash in raspberrypi_ipa_proxy at runtime as they're not allocated by the time the registration routines execute. This is a fairly crude fix which just converts the global static objects into local static objects inside an equivalently named function. Signed-off-by: Dave Jones <dave.jones@canonical.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-07ipa: raspberrypi: agc: Fix overflow in Y value calculationDavid Plowman
The maxVal variable in the computeInitialY function needs to be a uint64_t, otherwise the subsequent multiplications in the function can overflow on relatively high resolution images (when the counts in the regions go over 16 bits). Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09ipa: raspberrypi: Normalise region sums to 16-bitsNaushir Patuck
The VC4 ISP uses a pipeline bit-depth of 13-bits. The AGC algorithm needs to know this bit-depth when computing the Y value for the image. Instead of hardcoding the VC4 bit-depth in the AGC source code, normalise all region sums to 16-bits when filling the Statistics structure. AWB and ALSC are agnostic about pipeline depth, so do not need changing. 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>
2023-02-09ipa: raspberrypi: Use the generic statistics structure in the algorithmsNaushir Patuck
Repurpose the StatisticsPtr type from being a shared_ptr<bcm2835_isp_stats> to shared_ptr<RPiController::Statistics>. This removes any hardware specific header files and structures from the algorithms source code. Add a new function in the Raspberry Pi IPA to populate the generic statistics structure from the values provided by the hardware in the bcm2835_isp_stats structure. Update the Lux, AWB, AGC, ALSC, Contrast, and Focus algorithms to use the generic statistics structure appropriately in their calculations. Additionally, remove references to any hardware specific headers and defines in these source files. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Tested-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09ipa: raspberrypi: awb: Delay release of the statistics bufferNaushir Patuck
Release the statistics buffer after running the through the AWB calculations. Only the "counted" statistics are copied out to a local structure, so keeping the statistics buffer allows the algorithm to see the "uncounted" statistics as well. This is currently handled by hard-coding the total number of statistics regions regions based on the structure definition in the bcm2835_isp_stats structure. 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>
2023-02-09ipa: raspberrypi: histogram: Add a constructor for an empty histogramNaushir Patuck
Add a default constructor to the RPiController::Histogram class that creates an empty histogram. Since this is a cumulative histogram, push a value of 0 into the first (and only) bin to signify this. 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>
2023-02-09ipa: raspberrypi: Generalise statisticsNaushir Patuck
At present, the controller algorithms access the bcm2835_isp_stats structure, which is hardware specific. It would be desirable to abstract out the statistics structure to remove hardware specific headers from the algorithms source files. Define a new templated RegionStats class that encompasses region based statistics generated by the ISP. For the VC4 ISP, this can be used to hold RGB sums and focus FoM values. Define a new Statistics structure that holds all the VC4 ISP statistics output. This includes AGC histograms, AGC/AWB region sums and focus FoM regions. 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>
2023-01-30ipa: raspberrypi: Add lens position to DeviceStatusNaushir Patuck
Add the current frame's lens position (in dioptres) to the DeviceStatus structure. This value is obtained from the AfAlgorithm::getLensPosition() member function. Return this lens position back to the pipeline handler to store in the metadata field of the request. As a drive-by, fixup some inaccurate comments in the DeviceStatus structure. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Nick Hollinghurst nick.hollinghurst@raspberrypi.com Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30ipa: raspberrypi: First version of autofocus algorithm using PDAFNick Hollinghurst
Provide the first version of the Raspberry Pi autofocus algorithm. This implementation uses a hybrid of contrast detect autofocus (CDAF) and phase detect autofocus (PDAF) statistics. PDAF is always preferred over CDAF due to having less "hunting" behavior. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30ipa: raspberrypi: Add autofocus algorithm interface headersNick Hollinghurst
Add a new AfAlgorithm class that defines the interface for the Raspberry Pi autofocus algorithm. Add an AfStatus structure that returns the results of the autofocus algorithm back to the IPA. Add a structure for PDAF statistics provided by supported sensors for use with an autofocus algorithm. This structure is currently based on the IMX708's PDAF "Type 1" statistics. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-11-29ipa: raspberrypi: agc: Fix digital gain calculation for manual modeNaushir Patuck
The digital gain calculation uses a total exposure value computed with the current AGC state. However, this is wrong in the case of manual shutter/gain controls, as the total exposure value used must be the value computed when the AGC sent the manual shutter/gain controls to the pipeline handler to action. To fix this, the IPA now adds the historical AgcStatus structure to the metadata (tagged with "agc.delayed_status"). This historical AgcStatus structure contains the total exposure value calculated when the AGC sent the manual shutter/gain controls to the pipeline handler. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Tested-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-11-29ipa: raspberrypi: Add RPiController::Metadata::mergeCopyNaushir Patuck
Add a new member function to RPiController::Metadata that copies unique key/value pairs from one object to the other. This is different from std::map::merge that would remove the key/value pairs from the source object. 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>
2022-11-21ipa: raspberrypi: Remove generic "pause" mechanism from AlgorithmNick Hollinghurst
No existing Algorithm used the base pause(), resume() functions or the paused_ flag, nor is there a need for a generic pause API. Remove these. The AGC and AWB algorithms now have methods named disableAuto(), enableAuto() which better describe their functionality. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@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-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 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-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-07-29ipa: raspberry: awb: Include <functional>Jacopo Mondi
Building on gcc8 on Debian 10 fails with asyncThread_ = std::thread(std::bind(&Awb::asyncFunc, this)); ../src/ipa/raspberrypi/controller/rpi/awb.cpp:177:34: note: ‘std::bind’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’? Fix that by including <functional> in awb.cpp. Fixes: c1597f989654 ("ipa: raspberrypi: Use YamlParser to replace dependency on boost") Reported-by: https://buildbot.libcamera.org/#/builders/6/builds/414 Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2022-07-28ipa: raspberrypi: Add functional include to pwl.hEric Curtin
The Pwl class uses std::function, defined in <functional>, without including the header directly. This results in a compilation error with the Fedora 36 compiler toolchain (gcc 12.1.1): In file included from ../src/ipa/raspberrypi/controller/rpi/awb.h:14, from ../src/ipa/raspberrypi/controller/rpi/awb.cpp:14: ../src/ipa/raspberrypi/controller/rpi/../pwl.h:97:18: error: 'std::function' has not been declared 97 | void map(std::function<void(double x, double y)> f) const; | ^~~ Fix it by including <functional>. Fixes: c1597f989654 ("ipa: raspberrypi: Use YamlParser to replace dependency on boost") Signed-off-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-28ipa: raspberrypi: Remove unused Controller constructorNaushir Patuck
The Controller(char const *jsonFilename) is not valid anymore since Controller::read() can now return an error on a failure. Additionally, this constructor is not actually used, so remove it. Signed-off-by: Naushir Patuck <naush@raspberrypi.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>
2022-07-28ipa: raspberrypi: agc: Use YamlObject::getList()Laurent Pinchart
Replace the manual implementation of the readList() functions with YamlObject::getList(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com>
2022-07-28ipa: raspberrypi: Introduce version 2.0 format for the camera tuning fileNaushir Patuck
The existing tuning file format (version 1.0) requires the controller algorithms to run in the same order as listed in the JSON structure. The JSON specification does not mandate any such ordering, but the Boost JSON parser would maintain this order. In order to remove this reliance on the parser to provide ordering, introduce a new version 2.0 format for the camera tuning file. In this version, the algorithms are specified in a top level list node ("algorithms"), which does require strict ordering of the elements. A "version" node is added to distinguish between the version 1.0 and 2.0 formats. The absence of the "version" node implies version 1.0. A "target" node is also added to specify the target platform for this configuration. Update the controller to support either version of the tuning file by looking at the version node. CreateAlgorithm member function to now load and configure each algorithm. Additionally, make CreateAlgorithm a private member, it does not get called externally. If a version 1.0 format tuning file is used, throw a warning message indicating it will be soon deprecated. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-28ipa: raspberrypi: Use YamlParser to replace dependency on boostLaurent Pinchart
The Raspberry Pi IPA module depends on boost only to parse the JSON tuning data files. As libcamera depends on libyaml, use the YamlParser class to parse those files and drop the dependency on boost. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2022-07-28ipa: raspberrypi: Replace Fatal log by error propagationLaurent Pinchart
Replace the Fatal log messages that cause an abort during tuning data read with Error messages and proper error propagation to the caller. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com>
2022-07-28ipa: raspberrypi: Propagate errors from AGC metering tuning data readLaurent Pinchart
Update the AGC metering functions that deal with reading tuning data to propagate errors to the caller, using std::tie and std::tuple to group the error code and return value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com>
2022-07-28ipa: raspberrypi: Return an error code from Algorithm::read()Laurent Pinchart
When encountering errors, the Algorithm::read() function either uses LOG(Fatal) or throws exceptions from the boost property_tree functions. To prepare for replacing boost JSON parse with the YamlParser class, give the Algorithm::read() function the ability to return an error code, and propagate it all the way to the IPA module init() function. All algorithm classes return a hardcoded 0 value for now, subsequent commits will change that. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com>
2022-07-27ipa: raspberrypi: agc: Fix log message prefixesNaushir Patuck
Remove "Agc:" as that gets prefixed by the logging system. s/AgcConfig/AgcMeteringMode/ and s/AgcConfig/AgcMeteringMode where appropriate. 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-07-27ipa: raspberrypi: Remove #define constantsNaushir Patuck
Replace all #define constant values with equivalent constexpr definitions. As a drive-by, remove the CAMERA_MODE_NAME_LEN constant as it is unused. 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-07-27ipa: raspberryip: Remove all exception throw statementsNaushir Patuck
Replace all exception throw statements with LOG(RPi*, Fatal) error messages. 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-07-27raspberrypi: Update Copyright statement in all Raspberry Pi source filesNaushir Patuck
s/Raspberry Pi (Trading) Limited/Raspberry Pi Ltd/ to reflect the new Raspberry Pi entity name. 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-07-27ipa: raspberrypi: Rename header files from *.hpp to *.hNaushir Patuck
As per the libcamera coding guidelines, rename all .hpp header files to .h. 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-07-27ipa: raspberrypi: Remove extern "C" declarationsNaushir Patuck
Since the controller header files are now C++ specific, remove the extern "C" declarations. 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-07-27ipa: raspberrypi: Change to C style code commentsNaushir Patuck
As part of the on-going refactor efforts for the source files in src/ipa/raspberrypi/, switch all C++ style comments to C style comments. 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-07-27ipa: raspberrypi: Code refactoring to match style guidelinesNaushir Patuck
Refactor all the source files in src/ipa/raspberrypi/ to match the recommended formatting guidelines for the libcamera project. The vast majority of changes in this commit comprise of switching from snake_case to CamelCase, and starting class member functions with a lower case character. 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-06-29ipa: raspberrypi: Use std::optional in DeviceStatusNaushir Patuck
Switch the aperture, lens_position, and flash_intensity fields in the DeviceStatus structure to use std::optional instead of using invalid default values. 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: Kieran Bingham <kieran.bingham@ideasonboard.com>