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
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/* 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 <libcamera/stream.h>
#include "device_enumerator.h"
#include "log.h"
#include "media_device.h"
#include "pipeline_handler.h"
namespace libcamera {
LOG_DEFINE_CATEGORY(VIMC)
class PipeHandlerVimc : public PipelineHandler
{
public:
PipeHandlerVimc(CameraManager *manager);
~PipeHandlerVimc();
std::map<Stream *, StreamConfiguration>
streamConfiguration(Camera *camera,
std::vector<Stream *> &streams) override;
int configureStreams(Camera *camera,
std::map<Stream *, StreamConfiguration> &config) override;
bool match(DeviceEnumerator *enumerator);
private:
std::shared_ptr<MediaDevice> media_;
Stream stream_;
};
PipeHandlerVimc::PipeHandlerVimc(CameraManager *manager)
: PipelineHandler(manager), media_(nullptr)
{
}
PipeHandlerVimc::~PipeHandlerVimc()
{
if (media_)
media_->release();
}
std::map<Stream *, StreamConfiguration>
PipeHandlerVimc::streamConfiguration(Camera *camera,
std::vector<Stream *> &streams)
{
std::map<Stream *, StreamConfiguration> configs;
StreamConfiguration config{};
LOG(VIMC, Info) << "TODO: Return a good default format";
configs[&stream_] = config;
return configs;
}
int PipeHandlerVimc::configureStreams(Camera *camera,
std::map<Stream *, StreamConfiguration> &config)
{
StreamConfiguration *cfg = &config[&stream_];
LOG(VIMC, Info) << "TODO: Configure the camera for resolution "
<< cfg->width << "x" << cfg->height;
return 0;
}
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");
media_ = std::move(enumerator->search(dm));
if (!media_)
return false;
media_->acquire();
std::vector<Stream *> streams{ &stream_ };
std::shared_ptr<Camera> camera = Camera::create(this, "Dummy VIMC Camera", streams);
registerCamera(std::move(camera));
return true;
}
REGISTER_PIPELINE_HANDLER(PipeHandlerVimc);
} /* namespace libcamera */
|