summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/rkisp1/rkisp1_path.h
blob: e2eb1be9a445ba41ea420ed30e4ef6b609f29169 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2020, Google Inc.
 *
 * rkisp1path.h - Rockchip ISP1 path helper
 */
#ifndef __LIBCAMERA_PIPELINE_RKISP1_PATH_H__
#define __LIBCAMERA_PIPELINE_RKISP1_PATH_H__

#include <vector>

#include <libcamera/camera.h>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
#include <libcamera/signal.h>
#include <libcamera/span.h>

#include "libcamera/internal/v4l2_videodevice.h"

namespace libcamera {

class MediaDevice;
class V4L2Subdevice;
struct StreamConfiguration;
struct V4L2SubdeviceFormat;

class RkISP1Path
{
public:
	RkISP1Path(const char *name, const Span<const PixelFormat> &formats,
		   const Size &minResolution, const Size &maxResolution);
	~RkISP1Path();

	bool init(MediaDevice *media);

	StreamConfiguration generateConfiguration(const Size &resolution);
	CameraConfiguration::Status validate(StreamConfiguration *cfg);

	int configure(const StreamConfiguration &config,
		      const V4L2SubdeviceFormat &inputFormat);

	int exportBuffers(unsigned int bufferCount,
			  std::vector<std::unique_ptr<FrameBuffer>> *buffers)
	{
		return video_->exportBuffers(bufferCount, buffers);
	}

	int start();
	void stop();

	int queueBuffer(FrameBuffer *buffer) { return video_->queueBuffer(buffer); }
	Signal<FrameBuffer *> &bufferReady() { return video_->bufferReady; }

private:
	static constexpr unsigned int RKISP1_BUFFER_COUNT = 4;

	const char *name_;
	bool running_;

	const Span<const PixelFormat> formats_;
	const Size minResolution_;
	const Size maxResolution_;

	V4L2Subdevice *resizer_;
	V4L2VideoDevice *video_;
};

class RkISP1MainPath : public RkISP1Path
{
public:
	RkISP1MainPath();
};

class RkISP1SelfPath : public RkISP1Path
{
public:
	RkISP1SelfPath();
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_PIPELINE_RKISP1_PATH_H__ */