[libcamera-devel] [PATCH 1/2] ipa: camera_sensor_helper: Add AR0521 support
Kieran Bingham
kieran.bingham at ideasonboard.com
Tue Nov 22 11:59:23 CET 2022
Quoting Jacopo Mondi via libcamera-devel (2022-11-07 13:22:12)
> Add support for OnSemi AR0521 5Mpx image sensor to libipa.
>
> The sensor implments a gain model realized via a piecewise exponential
> gain function defined by a table available in the sensor's application
> developer guide.
>
> Add support for the sensor using a dedicated CameraSensorHelper
> instance.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> src/ipa/libipa/camera_sensor_helper.cpp | 45 +++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
> index 35056bec80c3..cb5cdf1d1e54 100644
> --- a/src/ipa/libipa/camera_sensor_helper.cpp
> +++ b/src/ipa/libipa/camera_sensor_helper.cpp
> @@ -366,6 +366,51 @@ static constexpr double expGainDb(double step)
> return log2_10 * step / 20;
> }
>
> +class CameraSensorHelperAr0521 : public CameraSensorHelper
> +{
> +public:
> + uint32_t gainCode(double gain) const override;
> + double gain(uint32_t gainCode) const override;
> +
> +private:
> + const unsigned int kStep_ = 16;
> +};
> +
> +uint32_t CameraSensorHelperAr0521::gainCode(double gain) const
> +{
> + unsigned int coarse = 0;
> +
> + if (gain < 2.02) {
> + coarse = 0;
> + } else if (gain < 4.21) {
> + coarse = 1;
> + } else if (gain < 7.95) {
> + coarse = 2;
> + } else if (gain < 15.28) {
> + coarse = 3;
> + } else {
> + LOG(CameraSensorHelper, Error) << "Gain too high: " << gain;
> + gain = 15.28;
> + coarse = 3;
> + }
> +
> + unsigned int exp = 1 << coarse;
> + unsigned int fine = kStep_ * (gain - exp) / exp;
> +
> + return (coarse << 4) | (fine & 0xf);
Wow - more complex than our other CameraSensorHelpers, but that's
exactly why we have these CameraSensorHelper instances!
While I haven't seen the documentation corresponding to this, it seems
like it's doing reasonable things so:
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> +}
> +
> +double CameraSensorHelperAr0521::gain(uint32_t gainCode) const
> +{
> + unsigned int coarse = gainCode >> 4;
> + unsigned int fine = gainCode & 0xf;
> + unsigned int exp = 1 << coarse;
> +
> + return exp + (exp * fine / kStep_);
> +}
> +
> +REGISTER_CAMERA_SENSOR_HELPER("ar0521", CameraSensorHelperAr0521)
> +
> class CameraSensorHelperImx219 : public CameraSensorHelper
> {
> public:
> --
> 2.38.1
>
More information about the libcamera-devel
mailing list