summaryrefslogtreecommitdiff
path: root/src/v4l2/v4l2_camera_file.h
blob: 1a7b6a63ae951e88f72759ba4add5f5b68cc85ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2020, Google Inc.
 *
 * v4l2_camera_file.h - V4L2 compatibility camera file information
 */

#pragma once

#include <string>

#include <linux/videodev2.h>

class V4L2CameraProxy;

class V4L2CameraFile
{
public:
	V4L2CameraFile(int dirfd, const char *path, int efd, bool nonBlocking,
		       V4L2CameraProxy *proxy);
	~V4L2CameraFile();

	V4L2CameraProxy *proxy() const { return proxy_; }

	bool nonBlocking() const { return nonBlocking_; }
	int efd() const { return efd_; }

	enum v4l2_priority priority() const { return priority_; }
	void setPriority(enum v4l2_priority priority) { priority_ = priority; }

	const std::string &description() const;

private:
	V4L2CameraProxy *proxy_;

	std::string description_;
	bool nonBlocking_;
	int efd_;
	enum v4l2_priority priority_;
};
~Algorithm() {} virtual int init([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const YamlObject &tuningData) { return 0; } virtual int configure([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const typename Module::Config &configInfo) { return 0; } virtual void prepare([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const uint32_t frame, [[maybe_unused]] typename Module::FrameContext &frameContext, [[maybe_unused]] typename Module::Params *params) { } virtual void queueRequest([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const uint32_t frame, [[maybe_unused]] typename Module::FrameContext &frameContext, [[maybe_unused]] const ControlList &controls) { } virtual void process([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const uint32_t frame, [[maybe_unused]] typename Module::FrameContext &frameContext, [[maybe_unused]] const typename Module::Stats *stats) { } }; template<typename _Module> class AlgorithmFactoryBase { public: AlgorithmFactoryBase(const char *name) : name_(name) { _Module::registerAlgorithm(this); } virtual ~AlgorithmFactoryBase() = default; const std::string &name() const { return name_; } virtual std::unique_ptr<Algorithm<_Module>> create() const = 0; private: std::string name_; }; template<typename _Algorithm> class AlgorithmFactory : public AlgorithmFactoryBase<typename _Algorithm::Module> { public: AlgorithmFactory(const char *name) : AlgorithmFactoryBase<typename _Algorithm::Module>(name) { } ~AlgorithmFactory() = default; std::unique_ptr<Algorithm<typename _Algorithm::Module>> create() const override { return std::make_unique<_Algorithm>(); } }; #define REGISTER_IPA_ALGORITHM(algorithm, name) \ static AlgorithmFactory<algorithm> global_##algorithm##Factory(name); } /* namespace ipa */ } /* namespace libcamera */