Skip to content

Kbingham/pi5/imx283 imx335 #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/ipa/rpi/cam_helper/cam_helper_imx335.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (C) 2023, Ideas on Board Oy.
*
* cam_helper_Imx335.cpp - camera information for Imx335 sensor
*/

#include <assert.h>

#include "cam_helper.h"
#include "math.h"
using namespace RPiController;

class CamHelperImx335 : public CamHelper
{
public:
CamHelperImx335();
uint32_t gainCode(double gain) const override;
double gain(uint32_t gainCode) const override;
unsigned int hideFramesModeSwitch() const override;

private:
/*
* Smallest difference between the frame length and integration time,
* in units of lines.
*/
static constexpr int frameIntegrationDiff = 9;
static constexpr uint32_t maxGainCode = 100;
};

/*
* Imx335 doesn't output metadata, so we have to use the "unicam parser" which
* works by counting frames.
*/

CamHelperImx335::CamHelperImx335()
: CamHelper({}, frameIntegrationDiff)
{
}

uint32_t CamHelperImx335::gainCode(double gain) const
{
/* Validate me:
* The value which is 10/3 times the gain is set to register.
* (0.3 dB step)
* When set to 6 dB: 6 × 10/3 = 20d; GAIN [7:0] = 14h
*/
uint32_t code = 10 * std::log10(gain) * 10 / 3;
return std::min(code, maxGainCode);
}

double CamHelperImx335::gain(uint32_t gainCode) const
{
return std::pow(10.0, gainCode / (10 * 10/3));
}

unsigned int CamHelperImx335::hideFramesModeSwitch() const
{
/* After a mode switch, we seem to get 1 bad frame. */
return 1;
}


static CamHelper *create()
{
return new CamHelperImx335();
}

static RegisterCamHelper reg("imx335", &create);
1 change: 1 addition & 0 deletions src/ipa/rpi/cam_helper/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rpi_ipa_cam_helper_sources = files([
'cam_helper_imx283.cpp',
'cam_helper_imx290.cpp',
'cam_helper_imx296.cpp',
'cam_helper_imx335.cpp',
'cam_helper_imx415.cpp',
'cam_helper_imx477.cpp',
'cam_helper_imx500.cpp',
Expand Down
Loading