Skip to content

Commit 950cef1

Browse files
committed
Merge branch 'master' into next
2 parents 0788a2a + 4e9be7d commit 950cef1

File tree

89 files changed

+2760
-655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2760
-655
lines changed

Documentation/contributing.rst

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,34 @@ to the public. Point your IRC client to #libcamera to say hello, or use the
3030

3131
.. _WebChat: https://webchat.oftc.net/?channels=libcamera
3232

33+
The IRC channel is also bridged and accessible via `Matrix`_ in the #libcamera
34+
room:
35+
36+
.. _Matrix: https://matrix.to/#/#libcamera:matrix.org
37+
3338
Source Code
3439
-----------
3540

36-
libcamera is in early stages of development, and no releases are available yet.
41+
libcamera is in active development, including investigations into what a 'good'
42+
API is for the implementation. We can't guarantee we have all features
43+
implemented, or designed correctly yet, and we have plans to make considerable
44+
changes to the API and ABI in our roadmap.
45+
46+
Even so, we provide periodic 'releases' to support distributions and packaging
47+
teams. To support this we are currently making releases of the 0.y.z version
48+
scheme, loosely following semver.
49+
50+
In the foreseeable future, the following applies:
51+
52+
0.y.z : Active development, but with ABI breakage detection. The 0.y
53+
version will bump on an ABI/API breakage. Ongoing development will
54+
increment the .z version component. Therefore, pre 1.0 'y' is a
55+
close equivalent to a major release.
56+
57+
1.y.z : Stable API and ABI guarantees on the Major version number.
58+
Following semantic versioning as documented at https://semver.org/
59+
60+
3761
The source code is available from the project's `git tree`_.
3862

3963
.. code-block:: shell
@@ -42,17 +66,21 @@ The source code is available from the project's `git tree`_.
4266
4367
.. _git tree: https://git.libcamera.org/libcamera/libcamera.git/
4468

45-
A mirror is also hosted on `LinuxTV`_.
69+
A development mirror is also hosted on `Freedesktop`_.
70+
71+
.. _Freedesktop: https://gitlab.freedesktop.org/camera/libcamera
72+
73+
Freedesktop also provides our CI and `testing pipeline`_.
4674

47-
.. _LinuxTV: https://git.linuxtv.org/libcamera.git/
75+
.. _testing pipeline: https://gitlab.freedesktop.org/camera/libcamera/-/pipelines
4876

4977
Issue Tracker
5078
-------------
5179

52-
Our `issue tracker`_ tracks all bugs, issues and feature requests. All issues
53-
are publicly visible, and you can register for an account to create new issues.
80+
Our `issue tracker`_ also hosted at Freedesktop tracks all bugs, issues and
81+
feature requests.
5482

55-
.. _issue tracker: https://bugs.libcamera.org/
83+
.. _issue tracker: https://gitlab.freedesktop.org/camera/libcamera/-/issues
5684

5785
Documentation
5886
-------------

Documentation/gen-doxyfile.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,25 @@
1212
import sys
1313

1414

15-
def fill_template(template, data):
16-
17-
template = open(template, 'rb').read()
18-
template = template.decode('utf-8')
19-
template = string.Template(template)
20-
21-
return template.substitute(data)
22-
23-
2415
def main(argv):
2516

2617
parser = argparse.ArgumentParser()
2718
parser.add_argument('-o', dest='output', metavar='file',
2819
type=argparse.FileType('w', encoding='utf-8'),
2920
default=sys.stdout,
3021
help='Output file name (default: standard output)')
31-
parser.add_argument('template', metavar='doxyfile.tmpl', type=str,
22+
parser.add_argument('template', metavar='doxyfile.tmpl',
23+
type=argparse.FileType('r', encoding='utf-8'),
3224
help='Doxyfile template')
3325
parser.add_argument('inputs', type=str, nargs='*',
3426
help='Input files')
3527

3628
args = parser.parse_args(argv[1:])
3729

3830
inputs = [f'"{os.path.realpath(input)}"' for input in args.inputs]
39-
data = fill_template(args.template, {'inputs': (' \\\n' + ' ' * 25).join(inputs)})
31+
data = string.Template(args.template.read()).substitute({
32+
'inputs': (' \\\n' + ' ' * 25).join(inputs),
33+
})
4034
args.output.write(data)
4135

4236
return 0

include/libcamera/geometry.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ class Size
108108
return *this;
109109
}
110110

111+
Size &transpose()
112+
{
113+
std::swap(width, height);
114+
return *this;
115+
}
116+
111117
[[nodiscard]] constexpr Size alignedDownTo(unsigned int hAlignment,
112118
unsigned int vAlignment) const
113119
{

include/libcamera/internal/camera_sensor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class CameraSensor
7373
virtual int sensorInfo(IPACameraSensorInfo *info) const = 0;
7474
virtual Transform computeTransform(Orientation *orientation) const = 0;
7575
virtual BayerFormat::Order bayerOrder(Transform t) const = 0;
76+
virtual Orientation mountingOrientation() const = 0;
7677

7778
virtual const ControlInfoMap &controls() const = 0;
7879
virtual ControlList getControls(Span<const uint32_t> ids) = 0;

include/libcamera/internal/converter.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <libcamera/base/signal.h>
2323

2424
#include <libcamera/geometry.h>
25+
#include "libcamera/internal/v4l2_request.h"
2526

2627
namespace libcamera {
2728

@@ -46,7 +47,7 @@ class Converter
4647
Up,
4748
};
4849

49-
Converter(MediaDevice *media, Features features = Feature::None);
50+
Converter(std::shared_ptr<MediaDevice> media, Features features = Feature::None);
5051
virtual ~Converter();
5152

5253
virtual int loadConfiguration(const std::string &filename) = 0;
@@ -79,7 +80,8 @@ class Converter
7980
virtual void stop() = 0;
8081

8182
virtual int queueBuffers(FrameBuffer *input,
82-
const std::map<const Stream *, FrameBuffer *> &outputs) = 0;
83+
const std::map<const Stream *, FrameBuffer *> &outputs,
84+
const V4L2Request *request = nullptr) = 0;
8385

8486
virtual int setInputCrop(const Stream *stream, Rectangle *rect) = 0;
8587
virtual std::pair<Rectangle, Rectangle> inputCropBounds() = 0;
@@ -107,7 +109,7 @@ class ConverterFactoryBase
107109

108110
const std::vector<std::string> &compatibles() const { return compatibles_; }
109111

110-
static std::unique_ptr<Converter> create(MediaDevice *media);
112+
static std::unique_ptr<Converter> create(std::shared_ptr<MediaDevice> media);
111113
static std::vector<ConverterFactoryBase *> &factories();
112114
static std::vector<std::string> names();
113115

@@ -116,7 +118,8 @@ class ConverterFactoryBase
116118

117119
static void registerType(ConverterFactoryBase *factory);
118120

119-
virtual std::unique_ptr<Converter> createInstance(MediaDevice *media) const = 0;
121+
virtual std::unique_ptr<Converter>
122+
createInstance(std::shared_ptr<MediaDevice> media) const = 0;
120123

121124
std::string name_;
122125
std::vector<std::string> compatibles_;
@@ -131,7 +134,7 @@ class ConverterFactory : public ConverterFactoryBase
131134
{
132135
}
133136

134-
std::unique_ptr<Converter> createInstance(MediaDevice *media) const override
137+
std::unique_ptr<Converter> createInstance(std::shared_ptr<MediaDevice> media) const override
135138
{
136139
return std::make_unique<_Converter>(media);
137140
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2+
/*
3+
* Copyright (C) 2025, Ideas on Board Oy
4+
*
5+
* DW100 Dewarp Engine integration
6+
*/
7+
8+
#pragma once
9+
10+
#include <memory>
11+
#include <queue>
12+
13+
#include <libcamera/control_ids.h>
14+
#include <libcamera/controls.h>
15+
#include <libcamera/framebuffer.h>
16+
17+
#include "libcamera/internal/converter/converter_dw100_vertexmap.h"
18+
#include "libcamera/internal/converter/converter_v4l2_m2m.h"
19+
#include "libcamera/internal/device_enumerator.h"
20+
21+
namespace libcamera {
22+
23+
class MediaDevice;
24+
class Rectangle;
25+
class Stream;
26+
27+
class ConverterDW100Module
28+
{
29+
public:
30+
virtual ~ConverterDW100Module() = default;
31+
32+
static std::unique_ptr<ConverterDW100Module> createModule(DeviceEnumerator *enumerator);
33+
34+
int init(const YamlObject &params);
35+
36+
int configure(const StreamConfiguration &inputCfg,
37+
const std::vector<std::reference_wrapper<StreamConfiguration>>
38+
&outputCfg);
39+
bool isConfigured(const Stream *stream) const;
40+
41+
Size adjustInputSize(const PixelFormat &pixFmt, const Size &size,
42+
Converter::Alignment align = Converter::Alignment::Down);
43+
Size adjustOutputSize(const PixelFormat &pixFmt, const Size &size,
44+
Converter::Alignment align = Converter::Alignment::Down);
45+
46+
int exportBuffers(const Stream *stream, unsigned int count,
47+
std::vector<std::unique_ptr<FrameBuffer>> *buffers);
48+
int validateOutput(StreamConfiguration *cfg, bool *adjusted,
49+
Converter::Alignment align = Converter::Alignment::Down);
50+
int queueBuffers(FrameBuffer *input,
51+
const std::map<const Stream *, FrameBuffer *> &outputs);
52+
53+
int start();
54+
void stop();
55+
56+
void updateControlInfos(const Stream *stream, ControlInfoMap::Map &infos);
57+
void setControls(const Stream *stream, const ControlList &controls);
58+
void populateMetadata(const Stream *stream, ControlList &meta);
59+
60+
void setSensorCrop(const Rectangle &rect);
61+
void setTransform(const Stream *stream, const Transform &transform);
62+
63+
Signal<FrameBuffer *> inputBufferReady;
64+
Signal<FrameBuffer *> outputBufferReady;
65+
66+
private:
67+
ConverterDW100Module(std::shared_ptr<MediaDevice> media);
68+
69+
int applyControls(const Stream *stream, const V4L2Request *request);
70+
void reinitRequest(V4L2Request *request);
71+
72+
struct DewarpParms {
73+
Matrix<double, 3, 3> cm;
74+
std::vector<double> coeffs;
75+
};
76+
77+
struct VertexMapInfo {
78+
Dw100VertexMap map;
79+
bool update;
80+
};
81+
82+
std::map<const Stream *, VertexMapInfo> vertexMaps_;
83+
std::optional<DewarpParms> dewarpParams_;
84+
unsigned int inputBufferCount_;
85+
V4L2M2MConverter converter_;
86+
Rectangle sensorCrop_;
87+
bool running_;
88+
89+
std::vector<std::unique_ptr<V4L2Request>> requests_;
90+
std::queue<V4L2Request *> availableRequests_;
91+
};
92+
93+
} /* namespace libcamera */
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2+
/*
3+
* Copyright (C) 2025, Ideas on Board Oy
4+
*
5+
* DW100 vertex map interface
6+
*/
7+
8+
#pragma once
9+
10+
#include <assert.h>
11+
#include <cmath>
12+
#include <stdint.h>
13+
#include <vector>
14+
15+
#include <libcamera/base/span.h>
16+
17+
#include <libcamera/geometry.h>
18+
#include <libcamera/transform.h>
19+
20+
#include "libcamera/internal/matrix.h"
21+
#include "libcamera/internal/vector.h"
22+
23+
namespace libcamera {
24+
25+
class Dw100VertexMap
26+
{
27+
public:
28+
enum ScaleMode {
29+
Fill = 0,
30+
Crop = 1,
31+
};
32+
33+
void applyLimits();
34+
void setInputSize(const Size &size)
35+
{
36+
inputSize_ = size;
37+
scalerCrop_ = Rectangle(size);
38+
}
39+
40+
void setSensorCrop(const Rectangle &rect) { sensorCrop_ = rect; }
41+
42+
void setScalerCrop(const Rectangle &rect) { scalerCrop_ = rect; }
43+
const Rectangle &effectiveScalerCrop() const { return effectiveScalerCrop_; }
44+
45+
void setOutputSize(const Size &size) { outputSize_ = size; }
46+
const Size &outputSize() const { return outputSize_; }
47+
48+
void setTransform(const Transform &transform) { transform_ = transform; }
49+
const Transform &transform() const { return transform_; }
50+
51+
void setScale(const float scale) { scale_ = scale; }
52+
float effectiveScale() const { return (effectiveScaleX_ + effectiveScaleY_) * 0.5; }
53+
54+
void setRotation(const float rotation) { rotation_ = rotation; }
55+
float rotation() const { return rotation_; }
56+
57+
void setOffset(const Point &offset) { offset_ = offset; }
58+
const Point &effectiveOffset() const { return effectiveOffset_; }
59+
60+
void setMode(const ScaleMode mode) { mode_ = mode; }
61+
ScaleMode mode() const { return mode_; }
62+
63+
int setDewarpParams(const Matrix<double, 3, 3> &cm, const Span<const double> &coeffs);
64+
bool dewarpParamsValid() { return dewarpParamsValid_; }
65+
66+
void setLensDewarpEnable(bool enable) { lensDewarpEnable_ = enable; }
67+
bool lensDewarpEnable() { return lensDewarpEnable_; }
68+
69+
std::vector<uint32_t> getVertexMap();
70+
71+
private:
72+
Vector<double, 2> dewarpPoint(const Vector<double, 2> &p);
73+
74+
Rectangle scalerCrop_;
75+
Rectangle sensorCrop_;
76+
Transform transform_ = Transform::Identity;
77+
Size inputSize_;
78+
Size outputSize_;
79+
Point offset_;
80+
double scale_ = 1.0;
81+
double rotation_ = 0.0;
82+
ScaleMode mode_ = Fill;
83+
double effectiveScaleX_;
84+
double effectiveScaleY_;
85+
Point effectiveOffset_;
86+
Rectangle effectiveScalerCrop_;
87+
88+
Matrix<double, 3, 3> dewarpM_ = Matrix<double, 3, 3>::identity();
89+
std::array<double, 12> dewarpCoeffs_;
90+
bool lensDewarpEnable_ = true;
91+
bool dewarpParamsValid_ = false;
92+
};
93+
94+
} /* namespace libcamera */

0 commit comments

Comments
 (0)