/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _LINUX_UDMABUF_H #define _LINUX_UDMABUF_H #include #include #define UDMABUF_FLAGS_CLOEXEC 0x01 struct udmabuf_create { __u32 memfd; __u32 flags; __u64 offset; __u64 size; }; struct udmabuf_create_item { __u32 memfd; __u32 __pad; __u64 offset; __u64 size; }; struct udmabuf_create_list { __u32 flags; __u32 count; struct udmabuf_create_item list[]; }; #define UDMABUF_CREATE _IOW('u', 0x42, struct udmabuf_create) #define UDMABUF_CREATE_LIST _IOW('u', 0x43, struct udmabuf_create_list) #endif /* _LINUX_UDMABUF_H */ src='/logo.png' alt='cgit logo'/> index : libcamera/pinchartl/libcamera.git
Laurent Pinchart's clone of libcameragit repository hosting on libcamera.org
summaryrefslogtreecommitdiff
blob: 8ca10fd1ee9d15c0c6133f7c548fc5e2efb89160 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2021-2022, Ideas On Board
 *
 * filter.cpp - RkISP1 Filter control
 */

#include "filter.h"

#include <cmath>

#include <libcamera/base/log.h>

#include <libcamera/control_ids.h>

/**
 * \file filter.h
 */

namespace libcamera {

namespace ipa::rkisp1::algorithms {

/**
 * \class Filter
 * \brief RkISP1 Filter control
 *
 * Denoise and Sharpness filters will be applied by RkISP1 during the
 * demosaicing step. The denoise filter is responsible for removing noise from
 * the image, while the sharpness filter will enhance its acutance.
 *
 * \todo In current version the denoise and sharpness control is based on user
 * controls. In a future version it should be controlled automatically by the
 * algorithm.
 */

LOG_DEFINE_CATEGORY(RkISP1Filter)

static constexpr uint32_t kFiltLumWeightDefault = 0x00022040;
static constexpr uint32_t kFiltModeDefault = 0x000004f2;

/**
 * \copydoc libcamera::ipa::Algorithm::queueRequest
 */
void Filter::queueRequest(IPAContext &context,
			  [[maybe_unused]] const uint32_t frame,
			  const ControlList &controls)
{
	auto &filter = context.frameContext.filter;

	const auto &sharpness = controls.get(controls::Sharpness);
	if (sharpness) {
		filter.sharpness = std::round(std::clamp(*sharpness, 0.0f, 10.0f));
		filter.updateParams = true;

		LOG(RkISP1Filter, Debug) << "Set sharpness to " << *sharpness;
	}

	const auto &denoise = controls.get(controls::draft::NoiseReductionMode);
	if (denoise) {
		LOG(RkISP1Filter, Debug) << "Set denoise to " << *denoise;

		switch (*denoise) {
		case controls::draft::NoiseReductionModeOff:
			filter.denoise = 0;
			filter.updateParams = true;
			break;
		case controls::draft::NoiseReductionModeMinimal:
			filter.denoise = 1;
			filter.updateParams = true;
			break;
		case controls::draft::NoiseReductionModeHighQuality:
		case controls::draft::NoiseReductionModeFast:
			filter.denoise = 3;
			filter.updateParams = true;
			break;
		default:
			LOG(RkISP1Filter, Error)
				<< "Unsupported denoise value "
				<< *denoise;
		}
	}
}

/**
 * \copydoc libcamera::ipa::Algorithm::prepare
 */
void Filter::prepare(IPAContext &context, rkisp1_params_cfg *params)
{
	auto &filter = context.frameContext.filter;

	/* Check if the algorithm configuration has been updated. */
	if (!filter.updateParams)
		return;

	filter.updateParams = false;