summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/alsc.cpp
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2021-06-10 16:50:26 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-12-04 23:05:05 +0200
commit1af788a8fb37bd5695b572bb3506409949c06485 (patch)
treefe97948c9d8cac8f25152bc37047c5331e8a24bf /src/ipa/raspberrypi/controller/rpi/alsc.cpp
parent415ac123997f86ebf6d7994020fd017a6bfa5f27 (diff)
libcamera: pipeline: raspberrypi: DmaHeaps: Use UniqueFD for a file descriptor
Manages a file descriptor owned by DmaHeaps for a dma handle by UniqueFD. Furthermore, DmaHeaps::alloc() creates a new file descriptor and the returned file descriptor is owned by a caller. This also clarifies it by changing the returned value to UniqueFD. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/alsc.cpp')
0 files changed, 0 insertions, 0 deletions
' href='#n123'>123 124 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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * libcamera Camera API tests
 */

#include <iostream>

#include "camera_test.h"
#include "test.h"

using namespace std;

namespace {

class Statemachine : public CameraTest, public Test
{
public:
	Statemachine()
		: CameraTest("VIMC Sensor B")
	{
	}

protected:
	int testAvailable()
	{
		/* Test operations which should fail. */
		if (camera_->configure(defconf_.get()) != -EACCES)
			return TestFail;

		if (camera_->createRequest())
			return TestFail;

		if (camera_->start() != -EACCES)
			return TestFail;

		Request request(camera_.get());
		if (camera_->queueRequest(&request) != -EACCES)
			return TestFail;

		if (camera_->stop() != -EACCES)
			return TestFail;

		/* Test operations which should pass. */
		if (camera_->release())
			return TestFail;

		/* Test valid state transitions, end in Acquired state. */
		if (camera_->acquire())
			return TestFail;

		return TestPass;
	}

	int testAcquired()
	{
		/* Test operations which should fail. */
		if (camera_->acquire() != -EBUSY)
			return TestFail;

		if (camera_->createRequest())
			return TestFail;

		if (camera_->start() != -EACCES)
			return TestFail;

		Request request(camera_.get());
		if (camera_->queueRequest(&request) != -EACCES)
			return TestFail;

		if (camera_->stop() != -EACCES)
			return TestFail;

		/* Test valid state transitions, end in Configured state. */
		if (camera_->release())
			return TestFail;

		if (camera_->acquire())
			return TestFail;

		if (camera_->configure(defconf_.get()))
			return TestFail;

		return TestPass;
	}

	int testConfigured()
	{
		/* Test operations which should fail. */
		if (camera_->acquire() != -EBUSY)
			return TestFail;

		Request request1(camera_.get());
		if (camera_->queueRequest(&request1) != -EACCES)
			return TestFail;

		if (camera_->stop() != -EACCES)
			return TestFail;

		/* Test operations which should pass. */
		Request *request2 = camera_->createRequest();
		if (!request2)
			return TestFail;

		/* Never handed to hardware so need to manually delete it. */
		delete request2;

		/* Test valid state transitions, end in Running state. */
		if (camera_->release())
			return TestFail;

		if (camera_->acquire())
			return TestFail;

		if (camera_->configure(defconf_.get()))
			return TestFail;

		/* Use internally allocated buffers. */
		allocator_ = FrameBufferAllocator::create(camera_);
		Stream *stream = *camera_->streams().begin();
		if (allocator_->allocate(stream) < 0)
			return TestFail;

		if (camera_->start())
			return TestFail;

		return TestPass;
	}

	int testRuning()
	{
		/* Test operations which should fail. */
		if (camera_->acquire() != -EBUSY)
			return TestFail;

		if (camera_->release() != -EBUSY)
			return TestFail;

		if (camera_->configure(defconf_.get()) != -EACCES)
			return TestFail;

		if (camera_->start() != -EACCES)
			return TestFail;

		/* Test operations which should pass. */
		Request *request = camera_->createRequest();
		if (!request)
			return TestFail;

		Stream *stream = *camera_->streams().begin();
		if (request->addBuffer(stream, allocator_->buffers(stream)[0].get()))
			return TestFail;

		if (camera_->queueRequest(request))
			return TestFail;

		/* Test valid state transitions, end in Available state. */
		if (camera_->stop())
			return TestFail;

		delete allocator_;

		if (camera_->release())
			return TestFail;

		return TestPass;
	}

	int init() override
	{
		if (status_ != TestPass)