summaryrefslogtreecommitdiff
path: root/utils/hooks/post-commit
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2022-03-25 09:08:58 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-03-28 02:16:35 +0300
commit6ab7d87ff2e63b6eb70a006944cd5096f9f4a6f0 (patch)
tree4b01b570589534d6620f52e6459fdbbc9f4878ab /utils/hooks/post-commit
parent73c07bf2895e2cb3a40a4d80d6572d3bd4ae6969 (diff)
pipeline: raspberrypi: Free buffers in the RPiCamera destructor and re-configure
Currently, all framebuffer allocations get freed and cleared on a stop in PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then called without an intermediate PipelineHandlerRPi::configure(), it will re-allocate and prepare all the buffers again, which is unnecessary. Fix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(), but insted doing it in PipelineHandlerRPi::configure(), as the buffers might have to be resized. Add a flag to indicate that buffer allocations need to be done on the next call to PipelineHandlerRPi::start(). Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Tested-by: David Plowman <david.plowman@raspberrypi.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>
Diffstat (limited to 'utils/hooks/post-commit')
0 files changed, 0 insertions, 0 deletions
href='#n63'>63 64 65 66 67
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (C) 2021, Raspberry Pi (Trading) Limited
 *
 * cam_helper_imx290.cpp - camera helper for imx290 sensor
 */

#include <math.h>

#include "cam_helper.hpp"

using namespace RPiController;

class CamHelperImx290 : public CamHelper
{
public:
	CamHelperImx290();
	uint32_t GainCode(double gain) const override;
	double Gain(uint32_t gain_code) const override;
	void GetDelays(int &exposure_delay, int &gain_delay,
		       int &vblank_delay) 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 = 2;
};

CamHelperImx290::CamHelperImx290()
	: CamHelper(nullptr, frameIntegrationDiff)
{
}

uint32_t CamHelperImx290::GainCode(double gain) const
{
	int code = 66.6667 * log10(gain);
	return std::max(0, std::min(code, 0xf0));
}

double CamHelperImx290::Gain(uint32_t gain_code) const
{
	return pow(10, 0.015 * gain_code);
}

void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,
				int &vblank_delay) const
{
	exposure_delay = 2;
	gain_delay = 2;
	vblank_delay = 2;
}

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

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

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