# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Copyright (C) 2020, Google Inc.
#
%YAML 1.2
---
formats:
- R8:
fourcc: DRM_FORMAT_R8
- RGB565:
fourcc: DRM_FORMAT_RGB565
- RGB565_BE:
fourcc: DRM_FORMAT_RGB565
big_endian: true
- RGB888:
fourcc: DRM_FORMAT_RGB888
- BGR888:
fourcc: DRM_FORMAT_BGR888
- XRGB8888:
fourcc: DRM_FORMAT_XRGB8888
- XBGR8888:
fourcc: DRM_FORMAT_XBGR8888
- RGBX8888:
fourcc: DRM_FORMAT_RGBX8888
- BGRX8888:
fourcc: DRM_FORMAT_BGRX8888
- ARGB8888:
fourcc: DRM_FORMAT_ARGB8888
- ABGR8888:
fourcc: DRM_FORMAT_ABGR8888
- RGBA8888:
fourcc: DRM_FORMAT_RGBA8888
- BGRA8888:
fourcc: DRM_FORMAT_BGRA8888
- YUYV:
fourcc: DRM_FORMAT_YUYV
- YVYU:
fourcc: DRM_FORMAT_YVYU
- UYVY:
fourcc: DRM_FORMAT_UYVY
- VYUY:
fourcc: DRM_FORMAT_VYUY
- NV12:
fourcc: DRM_FORMAT_NV12
- NV21:
fourcc: DRM_FORMAT_NV21
- NV16:
fourcc: DRM_FORMAT_NV16
- NV61:
fourcc: DRM_FORMAT_NV61
- NV24:
fourcc: DRM_FORMAT_NV24
- NV42:
fourcc: DRM_FORMAT_NV42
- YUV420:
fourcc: DRM_FORMAT_YUV420
- YVU420:
fourcc: DRM_FORMAT_YVU420
- YUV422:
fourcc: DRM_FORMAT_YUV422
- MJPEG:
fourcc: DRM_FORMAT_MJPEG
- SRGGB8:
fourcc: DRM_FORMAT_SRGGB8
- SGRBG8:
fourcc: DRM_FORMAT_SGRBG8
- SGBRG8:
fourcc: DRM_FORMAT_SGBRG8
- SBGGR8:
fourcc: DRM_FORMAT_SBGGR8
- SRGGB10:
fourcc: DRM_FORMAT_SRGGB10
- SGRBG10:
fourcc: DRM_FORMAT_SGRBG10
- SGBRG10:
fourcc: DRM_FORMAT_SGBRG10
- SBGGR10:
fourcc: DRM_FORMAT_SBGGR10
- SRGGB12:
fourcc: DRM_FORMAT_SRGGB12
- SGRBG12:
fourcc: DRM_FORMAT_SGRBG12
- SGBRG12:
fourcc: DRM_FORMAT_SGBRG12
- SBGGR12:
fourcc: DRM_FORMAT_SBGGR12
- SRGGB16:
fourcc: DRM_FORMAT_SRGGB16
- SGRBG16:
fourcc: DRM_FORMAT_SGRBG16
- SGBRG16:
fourcc: DRM_FORMAT_SGBRG16
- SBGGR16:
fourcc: DRM_FORMAT_SBGGR16
- SRGGB10_CSI2P:
fourcc: DRM_FORMAT_SRGGB10
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SGRBG10_CSI2P:
fourcc: DRM_FORMAT_SGRBG10
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SGBRG10_CSI2P:
fourcc: DRM_FORMAT_SGBRG10
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SBGGR10_CSI2P:
fourcc: DRM_FORMAT_SBGGR10
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SRGGB12_CSI2P:
fourcc: DRM_FORMAT_SRGGB12
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SGRBG12_CSI2P:
fourcc: DRM_FORMAT_SGRBG12
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SGBRG12_CSI2P:
fourcc: DRM_FORMAT_SGBRG12
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SBGGR12_CSI2P:
fourcc: DRM_FORMAT_SBGGR12
mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SRGGB10_IPU3:
fourcc: DRM_FORMAT_SRGGB10
mod: IPU3_FORMAT_MOD_PACKED
- SGRBG10_IPU3:
fourcc: DRM_FORMAT_SGRBG10
mod: IPU3_FORMAT_MOD_PACKED
- SGBRG10_IPU3:
fourcc: DRM_FORMAT_SGBRG10
mod: IPU3_FORMAT_MOD_PACKED
- SBGGR10_IPU3:
fourcc: DRM_FORMAT_SBGGR10
mod: IPU3_FORMAT_MOD_PACKED
...
c90df7c9433c54790'>controller/controller.cpp
blob: d3433ad2e7e8266a3c1623a60c7cfe9f4e45e82d (
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
93
94
95
96
97
98
99
100
101
102
103
104
|
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (C) 2019, Raspberry Pi (Trading) Limited
*
* controller.cpp - ISP controller
*/
#include <libcamera/base/log.h>
#include "algorithm.hpp"
#include "controller.hpp"
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
using namespace RPiController;
using namespace libcamera;
LOG_DEFINE_CATEGORY(RPiController)
Controller::Controller()
: switch_mode_called_(false) {}
Controller::Controller(char const *json_filename)
: switch_mode_called_(false)
{
Read(json_filename);
Initialise();
}
Controller::~Controller() {}
void Controller::Read(char const *filename)
{
boost::property_tree::ptree root;
boost::property_tree::read_json(filename, root);
for (auto const &key_and_value : root) {
Algorithm *algo = CreateAlgorithm(key_and_value.first.c_str());
if (algo) {
algo->Read(key_and_value.second);
algorithms_.push_back(AlgorithmPtr(algo));
} else
LOG(RPiController, Warning)
<< "No algorithm found for \"" << key_and_value.first << "\"";
}
}
Algorithm *Controller::CreateAlgorithm(char const *name)
{
auto it = GetAlgorithms().find(std::string(name));
return it != GetAlgorithms().end() ? (*it->second)(this) : nullptr;
}
void Controller::Initialise()
{
for (auto &algo : algorithms_)
algo->Initialise();
}
void Controller::SwitchMode(CameraMode const &camera_mode, Metadata *metadata)
{
for (auto &algo : algorithms_)
algo->SwitchMode(camera_mode, metadata);
switch_mode_called_ = true;
}
void Controller::Prepare(Metadata *image_metadata)
{
assert(switch_mode_called_);
for (auto &algo : algorithms_)
if (!algo->IsPaused())
algo->Prepare(image_metadata);
}
void Controller::Process(StatisticsPtr stats, Metadata *image_metadata)
{
assert(switch_mode_called_);
for (auto &algo : algorithms_)
if (!algo->IsPaused())
algo->Process(stats, image_metadata);
}
Metadata &Controller::GetGlobalMetadata()
{
return global_metadata_;
}
Algorithm *Controller::GetAlgorithm(std::string const &name) const
{
// The passed name must be the entire algorithm name, or must match the
// last part of it with a period (.) just before.
size_t name_len = name.length();
for (auto &algo : algorithms_) {
char const *algo_name = algo->Name();
size_t algo_name_len = strlen(algo_name);
if (algo_name_len >= name_len &&
strcasecmp(name.c_str(),
algo_name + algo_name_len - name_len) == 0 &&
(name_len == algo_name_len ||
algo_name[algo_name_len - name_len - 1] == '.'))
return algo.get();
}
return nullptr;
}
|