summaryrefslogtreecommitdiff
path: root/src/ipa/libipa/camera_sensor_helper.cpp
AgeCommit message (Collapse)Author
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 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-05-27libipa: camera_sensor_helper: Add Sony IMX477 helperNaushir Patuck
Add support for the Sony IMX477 sensor in the camera helper database. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-26ipa: camera_sensor_helper: Fix equation in exponential gain documentationLaurent Pinchart
The exponential gain documentation is missing a '\' in the equation. Fix t. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-05-13libipa: camera_sensor_helper: Add OV5675 helperQuentin Schulz
The OV5675 is an OmniVision sensor with a linear gain model, expressed in 1/128 steps. Cc: Quentin Schulz <foss+libcamera@0leil.net> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-04-01libipa: camera_sensor_helper: Add OV5640 helperPaul Elder
The OV5640 is an OmniVision sensor with a linear gain model, expressed in 1/16 steps. Signed-off-by: Paul Elder <paul.elder@ideasonboard.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-04-01libipa: camera_sensor_helper: Add IMX296 helperLaurent Pinchart
The IMX296 is a Sony sensor that expresses its gain in 0.1dB units. It thus maps to the exponential gain model. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-04-01libipa: camera_sensor_helper: Add IMX290 helperLaurent Pinchart
The IMX290 is a Sony sensor that expresses its gain in 0.3dB units. It thus maps to the exponential gain model. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-04-01libipa: camera_sensor_helper: Implement exponential gain modelLaurent Pinchart
The CameraSensorHelper specifies two gain models, linear and exponential. They are modelled after the MIPI CCS specification. Only the linear model has been implemented, the exponential model was left for later. We now need to support sensors that configure their gain in a hardware register with a value expressed in dB. This has similarities with the MIPI CCS exponential gain model, but is only has an exponential factor, while CCS also allows sensors to support a configurable linear factor. The full CCS exponential model needs two values (for the linear and exponential factors) to express a gain, while IPAs use a single linear gain value internally. However, the exponential gain model example in the CCS specification has a fixed linear factor, which may indicate that it could be common for sensors that implement the exponential gain model to only use the exponential factor. For this reason, implement the exponential gain model with a fixed linear factor, but with a sensor-specific coefficient for the exponential factor that allows expressing the gain in dB (or other logarithmical units) instead of limiting it to powers of 2 as in the MIPI CCS specification. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-04-01libipa: camera_sensor_helper: Reorganize gain constantsLaurent Pinchart
To prepare for other gain models than the linear model, store the gain constants in a union with per-model members. Due to the lack of designated initializer support in gcc with C++17, initializing a single complex structure that includes a union will be difficult. Split the gain model type to a separate variable to work around this issue. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-03-17libipa: Add CameraSensorHelper for OV2740Daniel Scally
The datasheet for the OV2740 gives 0x80 as 1x gain, so real gain is GainCode / 128. Signed-off-by: Daniel Scally <djrscally@gmail.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-11-29libipa: Correct IMX219 in CameraSensorHelperJean-Michel Hautbois
The equation is badly reported in the CameraSensorHelper, as m1 and c0 are inverted. Correct it to have a proper gain calculation. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-09libcamera: Rename 'method' to 'function'Laurent Pinchart
Usage of 'method' to refer to member functions comes from Java. The C++ standard uses the term 'function' only. Replace 'method' with 'function' or 'member function' through the whole code base and documentation. While at it, fix two typos (s/backeng/backend/). The BoundMethod and Object::invokeMethod() are left as-is here, and will be addressed separately. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-25libipa: Add CameraSensorHelper for ov8865Daniel Scally
Add a CameraSensorHelperOv8865 class. The gain coefficients are gleaned from the datasheet; the lowest 7 bits are reported there as fractional bits, so real gain is val/128. Signed-off-by: Daniel Scally <djrscally@gmail.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-23libipa: Add CameraSensorHelper for IMX258Umang Jain
Extend the CameraSensorHelper factory with support for the IMX258 sensor found in the Nautilus Chromebook. The values are read by manually tweaking the IMX258 kernel driver. The IMX258 kernel driver hints that the sensor may be compatible with the MIPI CCS specification, as the register set matches. The values for analog gain constants are obtained by reading the register indexes, corresponding to the analog gain constants, as mentioned in MIPI CCS v1.1 specification. The values have further been confirmed by Dave Stevenson as being those specified in the datasheet. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-15libipa: Correct OV5670 CameraSensorHelper gain valuesJean-Michel Hautbois
The datasheet states that the low 7 bits are fraction bits. real_gain = GainCode/128 For example, 0x080 is 1x gain, 0x100 is 2x gain. It means that we should have m0=1 and c1=128. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-15libipa: Add CameraSensorHelper for OV13858Jean-Michel Hautbois
Extend the CameraSensorHelper factory with support for an OV13858 sensor as found in the Soraka Chromebook. The datasheet states that low 7 bits are fraction bits, so the gain is calculated as gainCode=128*gain. According to the formula, it means m0=1 and c1=128. m1 then has to be 0, and c0=0. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-09ipa: libipa: Fixups in CameraSensorHelpersJean-Michel Hautbois
A few lines needed to be wrapped under 80 lines. Remove some unneeded documentation and minor typos. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-28ipa: Create a camera sensor helper classJean-Michel Hautbois
For various sensor operations, it may be needed to do sensor specific computations, like analogue gain or vertical blanking. This commit introduces a new camera sensor helper in libipa which aims to solve this specific issue. It is based on the MIPI alliance Specification for Camera Command Set and implements, for now, only the analogue "Global gain" mode. Setting analogue gain for a specific sensor is not a straightforward operation, as one needs to know how the gain is calculated for it. Three helpers are created in this patch: imx219, ov5670 and ov5693. Adding a new sensor is pretty straightforward as one only needs to implement the sub-class for it and register that class to the CameraSensorHelperFactory. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>