summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/geq.h
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2022-10-22 00:01:50 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2022-11-25 15:37:41 +0900
commitf715a75843edece43acc97a64567d656e9c6df44 (patch)
treebee234f103f75447d82d134394d4c636d05b180a /src/ipa/raspberrypi/controller/rpi/geq.h
parent280e4acf9422821ff9b647e682da9d666c3bb825 (diff)
utils: libtuning: modules: alsc: Add rkisp1 LSC module
Add an LSC module for RkISP1. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/geq.h')
0 files changed, 0 insertions, 0 deletions
ef='#n125'>125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (C) 2019, Raspberry Pi (Trading) Limited
 *
 * cam_helper_imx219.cpp - camera helper for imx219 sensor
 */

#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

/*
 * We have observed the imx219 embedded data stream randomly return junk
 * reister values.  Do not rely on embedded data until this has been resolved.
 */
#define ENABLE_EMBEDDED_DATA 0

#include "cam_helper.hpp"
#if ENABLE_EMBEDDED_DATA
#include "md_parser.hpp"
#else
#include "md_parser_rpi.hpp"
#endif

using namespace RPi;

/* Metadata parser implementation specific to Sony IMX219 sensors. */

class MdParserImx219 : public MdParserSmia
{
public:
	MdParserImx219();
	Status Parse(void *data) override;
	Status GetExposureLines(unsigned int &lines) override;
	Status GetGainCode(unsigned int &gain_code) override;
private:
	/* Offset of the register's value in the metadata block. */
	int reg_offsets_[3];
	/* Value of the register, once read from the metadata block. */
	int reg_values_[3];
};

class CamHelperImx219 : public CamHelper
{
public:
	CamHelperImx219();
	uint32_t GainCode(double gain) const override;
	double Gain(uint32_t gain_code) const override;
	unsigned int MistrustFramesModeSwitch() const override;
	bool SensorEmbeddedDataPresent() const override;
	CamTransform GetOrientation() const override;
};

CamHelperImx219::CamHelperImx219()
#if ENABLE_EMBEDDED_DATA
	: CamHelper(new MdParserImx219())
#else
	: CamHelper(new MdParserRPi())
#endif
{
}

uint32_t CamHelperImx219::GainCode(double gain) const
{
	return (uint32_t)(256 - 256 / gain);
}

double CamHelperImx219::Gain(uint32_t gain_code) const
{
	return 256.0 / (256 - gain_code);
}

unsigned int CamHelperImx219::MistrustFramesModeSwitch() const
{
	/*
	 * For reasons unknown, we do occasionally get a bogus metadata frame
	 * at a mode switch (though not at start-up). Possibly warrants some
	 * investigation, though not a big deal.
	 */
	return 1;
}

bool CamHelperImx219::SensorEmbeddedDataPresent() const
{
	return ENABLE_EMBEDDED_DATA;
}

CamTransform CamHelperImx219::GetOrientation() const
{
	/* Camera is "upside down" on this board. */
	return CamTransform_HFLIP | CamTransform_VFLIP;
}

static CamHelper *Create()
{
	return new CamHelperImx219();
}

static RegisterCamHelper reg("imx219", &Create);

/*
 * We care about one gain register and a pair of exposure registers. Their I2C
 * addresses from the Sony IMX219 datasheet:
 */
#define GAIN_REG 0x157
#define EXPHI_REG 0x15A
#define EXPLO_REG 0x15B

/*