mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-14 16:09:51 +03:00
ipa: camera_sensor_helper: Add AR0521 support
Add support for OnSemi AR0521 5Mpx image sensor to libipa. The sensor analogue gain is implemented as a coarse and a fine factor, with the coarse gain being a power of two and the fine gain being a value in the [1.0, 2.0[ range. The mapping between gain codes and gain values is tabulated in the datasheet, and the table values are very close but not identical to the mathematical model. Compute the gain using the model to keep the code shorter, if this causes precision issues the calculation could be replaced with a table. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
f66a5c447b
commit
ff9b8befbb
1 changed files with 29 additions and 0 deletions
|
@ -366,6 +366,35 @@ 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:
|
||||
static constexpr double kStep_ = 16;
|
||||
};
|
||||
|
||||
uint32_t CameraSensorHelperAr0521::gainCode(double gain) const
|
||||
{
|
||||
gain = std::clamp(gain, 1.0, 15.5);
|
||||
unsigned int coarse = std::log2(gain);
|
||||
unsigned int fine = (gain / (1 << coarse) - 1) * kStep_;
|
||||
|
||||
return (coarse << 4) | (fine & 0xf);
|
||||
}
|
||||
|
||||
double CameraSensorHelperAr0521::gain(uint32_t gainCode) const
|
||||
{
|
||||
unsigned int coarse = gainCode >> 4;
|
||||
unsigned int fine = gainCode & 0xf;
|
||||
|
||||
return (1 << coarse) * (1 + fine / kStep_);
|
||||
}
|
||||
|
||||
REGISTER_CAMERA_SENSOR_HELPER("ar0521", CameraSensorHelperAr0521)
|
||||
|
||||
class CameraSensorHelperImx219 : public CameraSensorHelper
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue