libcamera v0.7.2 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
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 ValueNode &params);
35
36 int configure(const StreamConfiguration &inputCfg,
37 const std::vector<std::reference_wrapper<const 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 VertexMapInfo {
73 Dw100VertexMap map;
74 bool update;
75 };
76
77 std::map<const Stream *, VertexMapInfo> vertexMaps_;
78 std::optional<Dw100VertexMap::DewarpParams> dewarpParams_;
79 unsigned int inputBufferCount_;
80 V4L2M2MConverter converter_;
81 Rectangle sensorCrop_;
82 bool running_;
83
84 std::vector<std::unique_ptr<V4L2Request>> requests_;
85 std::queue<V4L2Request *> availableRequests_;
86};
87
88} /* 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:233
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:54
libcamera::ConverterDW100Module::configure
int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< const StreamConfiguration > > &outputCfg)
Configure a set of output stream conversion from an input stream.
Definition converter_dw100.cpp:164
libcamera::ConverterDW100Module::setControls
void setControls(const Stream *stream, const ControlList &controls)
Set libcamera controls.
Definition converter_dw100.cpp:384
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:214
libcamera::ConverterDW100Module::start
int start()
Start the converter streaming operation.
Definition converter_dw100.cpp:298
libcamera::ConverterDW100Module::setTransform
void setTransform(const Stream *stream, const Transform &transform)
Set transform.
Definition converter_dw100.cpp:467
libcamera::ConverterDW100Module::stop
void stop()
Stop the converter streaming operation.
Definition converter_dw100.cpp:337
libcamera::ConverterDW100Module::updateControlInfos
void updateControlInfos(const Stream *stream, ControlInfoMap::Map &infos)
Update the controls.
Definition converter_dw100.cpp:353
libcamera::ConverterDW100Module::init
int init(const ValueNode &params)
Initialize the module with configuration data.
Definition converter_dw100.cpp:101
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:224
libcamera::ConverterDW100Module::isConfigured
bool isConfigured(const Stream *stream) const
Check if a given stream is configured.
Definition converter_dw100.cpp:196
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:204
libcamera::ConverterDW100Module::populateMetadata
void populateMetadata(const Stream *stream, ControlList &meta)
Retrieve updated metadata.
Definition converter_dw100.cpp:418
libcamera::ConverterDW100Module::setSensorCrop
void setSensorCrop(const Rectangle &rect)
Set sensor crop rectangle.
Definition converter_dw100.cpp:449
libcamera::ConverterDW100Module::queueBuffers
int queueBuffers(FrameBuffer *input, const std::map< const Stream *, FrameBuffer * > &outputs)
Queue buffers to converter device.
Definition converter_dw100.cpp:254
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:27
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
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::V4L2M2MConverter
The V4L2 M2M converter implements the converter interface based on V4L2 M2M device.
Definition converter_v4l2_m2m.h:38
libcamera::V4L2Request
V4L2Request object and API.
Definition v4l2_request.h:22
libcamera::ValueNode
A class representing a tree structure of values.
Definition value_node.h:27
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