libcamera: include/libcamera/internal/converter/converter_dw100.h Source File

libcamera v0.7.0 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
converter_dw100.h
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
21namespace libcamera {
22
23class MediaDevice;
24class Rectangle;
25class Stream;
26
27 class ConverterDW100Module
28{
29public:
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
66private:
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 */
libcamera::ControlInfoMap::Map
std::unordered_map< const ControlId *, ControlInfo > Map
The base std::unsorted_map<> container.
Definition controls.h:367
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
libcamera::ConverterDW100Module::validateOutput
int validateOutput(StreamConfiguration *cfg, bool *adjusted, Converter::Alignment align=Converter::Alignment::Down)
Validate and possibily adjust cfg to a valid converter output.
Definition converter_dw100.cpp:213
libcamera::ConverterDW100Module::outputBufferReady
Signal< FrameBuffer * > outputBufferReady
A signal emitted on each frame buffer completion of the output queue.
Definition converter_dw100.h:64
libcamera::ConverterDW100Module::createModule
static std::unique_ptr< ConverterDW100Module > createModule(DeviceEnumerator *enumerator)
Create a ConverterDW100Module.
Definition converter_dw100.cpp:53
libcamera::ConverterDW100Module::init
int init(const YamlObject &params)
Initialize the module with configuration data.
Definition converter_dw100.cpp:100
libcamera::ConverterDW100Module::setControls
void setControls(const Stream *stream, const ControlList &controls)
Set libcamera controls.
Definition converter_dw100.cpp:364
libcamera::ConverterDW100Module::adjustOutputSize
Size adjustOutputSize(const PixelFormat &pixFmt, const Size &size, Converter::Alignment align=Converter::Alignment::Down)
Adjust the converter output size to a valid value.
Definition converter_dw100.cpp:194
libcamera::ConverterDW100Module::start
int start()
Start the converter streaming operation.
Definition converter_dw100.cpp:278
libcamera::ConverterDW100Module::setTransform
void setTransform(const Stream *stream, const Transform &transform)
Set transform.
Definition converter_dw100.cpp:447
libcamera::ConverterDW100Module::stop
void stop()
Stop the converter streaming operation.
Definition converter_dw100.cpp:317
libcamera::ConverterDW100Module::updateControlInfos
void updateControlInfos(const Stream *stream, ControlInfoMap::Map &infos)
Update the controls.
Definition converter_dw100.cpp:333
libcamera::ConverterDW100Module::exportBuffers
int exportBuffers(const Stream *stream, unsigned int count, std::vector< std::unique_ptr< FrameBuffer > > *buffers)
Export buffers from the converter device.
Definition converter_dw100.cpp:204
libcamera::ConverterDW100Module::isConfigured
bool isConfigured(const Stream *stream) const
Check if a given stream is configured.
Definition converter_dw100.cpp:176
libcamera::ConverterDW100Module::inputBufferReady
Signal< FrameBuffer * > inputBufferReady
A signal emitted when the input frame buffer completes.
Definition converter_dw100.h:63
libcamera::ConverterDW100Module::adjustInputSize
Size adjustInputSize(const PixelFormat &pixFmt, const Size &size, Converter::Alignment align=Converter::Alignment::Down)
Adjust the converter input size to a valid value.
Definition converter_dw100.cpp:184
libcamera::ConverterDW100Module::configure
int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfg)
Configure a set of output stream conversion from an input stream.
Definition converter_dw100.cpp:144
libcamera::ConverterDW100Module::populateMetadata
void populateMetadata(const Stream *stream, ControlList &meta)
Retrieve updated metadata.
Definition converter_dw100.cpp:398
libcamera::ConverterDW100Module::setSensorCrop
void setSensorCrop(const Rectangle &rect)
Set sensor crop rectangle.
Definition converter_dw100.cpp:429
libcamera::ConverterDW100Module::queueBuffers
int queueBuffers(FrameBuffer *input, const std::map< const Stream *, FrameBuffer * > &outputs)
Queue buffers to converter device.
Definition converter_dw100.cpp:234
libcamera::Converter::Alignment
Alignment
The alignment mode specified when adjusting the converter input or output sizes.
Definition converter.h:45
libcamera::Converter::Alignment::Down
@ Down
Adjust the Converter sizes to a smaller valid size.
Definition converter.h:46
libcamera::DeviceEnumerator
Enumerate, store and search media devices.
Definition device_enumerator.h:38
libcamera::Dw100VertexMap
Helper class to compute dw100 vertex maps.
Definition converter_dw100_vertexmap.h:26
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
libcamera::Matrix
Matrix class.
Definition matrix.h:31
libcamera::MediaDevice
The MediaDevice represents a Media Controller device with its full graph of connected objects.
Definition media_device.h:28
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::Rectangle
Describe a rectangle's position and dimensions.
Definition geometry.h:247
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera::Size
Describe a two-dimensional size.
Definition geometry.h:51
libcamera::Stream
Video stream for a camera.
Definition stream.h:76
libcamera::V4L2Request
V4L2Request object and API.
Definition v4l2_request.h:22
libcamera::YamlObject
A class representing the tree structure of the YAML content.
Definition yaml_parser.h:28
control_ids.h
Camera controls identifiers.
controls.h
Framework to manage controls related to an object.
converter_v4l2_m2m.h
V4L2 M2M based converter.
device_enumerator.h
Enumeration and matching of media devices.
framebuffer.h
Frame buffer handling.
libcamera::controls
Namespace for libcamera controls.
Definition control_ids.h:22
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::Transform
Transform
Enum to represent a 2D plane transform.
Definition transform.h:14
libcamera::StreamConfiguration
Configuration parameters for a stream.
Definition stream.h:40