summaryrefslogtreecommitdiff
path: root/src/qcam/assets/feathericons/file-text.svg
blob: 4197ddd404714c08245208a9db762f8836726d74 (plain)
1
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
id='n97' href='#n97'>97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2021, Google Inc.
 *
 * Test:
 * - Multiple reconfigurations of the Camera without stopping the CameraManager
 * - Validate there are no file descriptor leaks when using IPC
 */

#include <dirent.h>
#include <fstream>
#include <iostream>

#include <libcamera/base/event_dispatcher.h>
#include <libcamera/base/file.h>
#include <libcamera/base/thread.h>
#include <libcamera/base/timer.h>

#include <libcamera/framebuffer_allocator.h>

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

using namespace libcamera;
using namespace std;
using namespace std::chrono_literals;

namespace {

class CameraReconfigure : public CameraTest, public Test
{
public:
	/* Initialize CameraTest with isolated IPA */
	CameraReconfigure()
		: CameraTest(kCamId_, true)
	{
	}

private:
	static constexpr const char *kCamId_ = "platform/vimc.0 Sensor B";
	static constexpr const char *kIpaProxyName_ = "vimc_ipa_proxy";
	static constexpr unsigned int kNumOfReconfigures_ = 10;

	void requestComplete(Request *request)
	{
		if (request->status() != Request::RequestComplete)
			return;

		const Request::BufferMap &buffers = request->buffers();

		const Stream *stream = buffers.begin()->first;
		FrameBuffer *buffer = buffers.begin()->second;

		/* Reuse the request and re-queue it with the same buffers. */
		request->reuse();
		request->addBuffer(stream, buffer);
		camera_->queueRequest(request);
	}

	int startAndStop()
	{
		StreamConfiguration &cfg = config_->at(0);

		if (camera_->acquire()) {
			cerr << "Failed to acquire the camera" << endl;
			return TestFail;
		}

		if (camera_->configure(config_.get())) {
			cerr << "Failed to set default configuration" << endl;
			return TestFail;
		}

		Stream *stream = cfg.stream();

		/*
		 * The configuration is consistent so we can re-use the
		 * same buffer allocation for each run.
		 */