summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/vimc.cpp
blob: b1e2d32c8ba2e23b63f35f8780be243ebce258d6 (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
83
84
85
86
87
88
89
90
91
92
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2018, Google Inc.
 *
 * vimc.cpp - Pipeline handler for the vimc device
 */

#include <libcamera/camera.h>

#include "device_enumerator.h"
#include "pipeline_handler.h"

namespace libcamera {

class PipeHandlerVimc : public PipelineHandler
{
public:
	PipeHandlerVimc();
	~PipeHandlerVimc();

	bool match(DeviceEnumerator *enumerator);

	unsigned int count();
	Camera *camera(unsigned int id) final;

private:
	DeviceInfo *info_;
	Camera *camera_;
};

PipeHandlerVimc::PipeHandlerVimc()
	: info_(nullptr), camera_(nullptr)
{
}

PipeHandlerVimc::~PipeHandlerVimc()
{
	if (camera_)
		camera_->put();

	if (info_)
		info_->release();
}

unsigned int PipeHandlerVimc::count()
{
	return 1;
}

Camera *PipeHandlerVimc::camera(unsigned int id)
{
	if (id != 0)
		return nullptr;

	return camera_;
}

bool PipeHandlerVimc::match(DeviceEnumerator *enumerator)
{
	DeviceMatch dm("vimc");

	dm.add("Raw Capture 0");
	dm.add("Raw Capture 1");
	dm.add("RGB/YUV Capture");
	dm.add("Sensor A");
	dm.add("Sensor B");
	dm.add("Debayer A");
	dm.add("Debayer B");
	dm.add("RGB/YUV Input");
	dm.add("Scaler");

	info_ = enumerator->search(dm);
	if (!info_)
		return false;

	info_->acquire();

	/*
	 * NOTE: A more complete Camera implementation could
	 * be passed the DeviceInfo(s) it controls here or
	 * a reference to the PipelineHandler. Which method
	 * will be chosen depends on how the Camera
	 * object is modeled.
	 */
	camera_ = new Camera("Dummy VIMC Camera");

	return true;
}

REGISTER_PIPELINE_HANDLER(PipeHandlerVimc);

} /* namespace libcamera */