Commit graph

10 commits

Author SHA1 Message Date
Jean-Michel Hautbois
93802f600c ipa: ipu3: Move IPU3 agc into algorithms
Now that the interface is properly used by the AGC class, move it into
ipa::ipu3::algorithms and let the loops do the calls.
As we need to exchange the exposure_ and gain_ by passing them through the
FrameContext, use the calculated values in setControls() function to
ease the reading.

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-08-20 12:11:29 +02:00
Jean-Michel Hautbois
16266def40 ipa: ipu3: convert AGC to the new algorithm interface
In preparation for using the AGC through the new algorithm interfaces,
convert the existing code to use the new function types.

Now that the process call is rewritten, re-enable the compiler flag to
warn when a function declaration hides virtual functions from a base class
(-Woverloaded-virtual).

We never use converged_ so remove its declaration. The controls may not
need to be updated at each call, but it should be decided on the context
side and not by a specific call by using a lock status in the Agc
structure for instance.

As the params_ local variable is not useful anymore, remove it here
too.

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-08-20 12:11:29 +02:00
Jean-Michel Hautbois
fcf56b9716 ipa: ipu3: Introduce a modular tone mapping algorithm
Introduce a new algorithm to manage the tone mapping handling of the
IPU3.

The initial algorithm is chosen to configure the gamma contrast curve
which moves the implementation out of AWB for simplicity. As it is
initialised with a default gamma value of 1.1, there is no need to use
the default table at initialisation anymore.

This demonstrates the way to use process() call when the EventStatReady
comes in. The function calculates the LUT in the context of a frame, and
when prepare() is called, the parameters are filled with the updated
values.

AGC is modified to take the new process interface into account.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
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-08-20 12:11:28 +02:00
Jacopo Mondi
9947b4cf38 ipa: ipu3: Tidy-up includes
Tidy-up a bit the inclusions directive in the IPU3 IPA module.

In detail:
- ipu3.cpp is missing inclusions for:
  std::abs from <cmath>
  std::map from <map>
  std::min/max from <algorithm>
  std::numeric_limits from <limits>
  std::unique_ptr from <memory>
  std::vector from <vector>

  and does not require <sys/mman.h>

- ipu3_agc has two not used inclusions in the header file and one the cpp file
  and is missing <chrono> for std::literals::chrono_literals

- ipu3_awb is missing <algorithm> for std::sort and does not use
  <numeric> or <unordered_map>

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-08-12 10:08:32 +02:00
Jean-Michel Hautbois
8738d539f4 ipa: ipu3: Initialize CameraSensorHelper at IPU3 init stage
In order for the CameraSensorHelper to be instantiated, we need to find
its factory using the camera sensor model name stored in
IPASettings::sensorModel. As we don't need to do it at each configure
call (the sensor is not changing in-between), implement the init call in
IPAIPU3 to do that.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-28 10:54:43 +02:00
Kieran Bingham
27aff949fb libcamera/base: Move extended base functionality
Move the functionality for the following components to the new
base support library:

 - BoundMethod
 - EventDispatcher
 - EventDispatcherPoll
 - Log
 - Message
 - Object
 - Signal
 - Semaphore
 - Thread
 - Timer

While it would be preferable to see these split to move one component
per commit, these components are all interdependent upon each other,
which leaves us with one big change performing the move for all of them.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25 16:11:08 +01:00
Umang Jain
750019bf55 ipa: ipu3: Use libcamera::utils::Duration helper class for durations
std::chrono::Duration is provided quite conveniently by
libcamera::utils::Duration wrapper. Port IPAIPU3 to use that
for duration-type entities (such as exposure time), such that
it becomes consistent with rest of the codebase.

The commit doesn't introduce any functional changes.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2021-06-24 10:27:49 +05:30
Umang Jain
384a53d3cd ipa: ipu3: Calculate line duration from IPACameraSensorInfo
Squash \todo by calculating line duration from IPACameraSensorInfo,
now passed in, to IPU3Agc::initialise().

Since line duration is now calculated from real values, store it as a
private member in IPU3Agc class. As a further step, replace the
associated global constant, kMaxExposureTime, with a private IPU3Agc
class member as well, and assign its value correspondingly in
IPU3Agc::initialise(), similar to previous precedence.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-06-08 16:26:06 +05:30
Umang Jain
378f572e7f ipa: ipc: Rename CameraSensorInfo to IPACameraSensorInfo
This matches the naming convention for IPA IPC.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.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>
2021-05-24 14:13:32 +03:00
Jean-Michel Hautbois
9e1bd62de3 ipa: ipu3: Add support for IPU3 AEC/AGC algorithm
Implement basic auto-exposure (AE) and auto-gain (AG) correction functions.
The functions computeTargetExposure() and computeGain() are adapted from
the Raspberry Pi AGC implementation to suit the IPU3 structures, and
filtering is added to reduce visible stepsize when there are large
exposure changes.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:13:03 +01:00