Loading...
Searching...
No Matches
converter_dw100.h
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2025, Ideas on Board Oy
*
* DW100 Dewarp Engine integration
*/
#pragma once
#include <memory>
#include <queue>
#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include <libcamera/framebuffer.h>
#include "libcamera/internal/converter/converter_dw100_vertexmap.h"
#include "libcamera/internal/converter/converter_v4l2_m2m.h"
#include "libcamera/internal/device_enumerator.h"
namespace libcamera {
class MediaDevice;
class Rectangle;
class Stream;
class ConverterDW100Module
{
public:
virtual ~ConverterDW100Module() = default;
static std::unique_ptr<ConverterDW100Module> createModule(DeviceEnumerator *enumerator);
int init(const YamlObject &params);
int configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<StreamConfiguration>>
&outputCfg);
bool isConfigured(const Stream *stream) const;
Size adjustInputSize(const PixelFormat &pixFmt, const Size &size,
Converter::Alignment align = Converter::Alignment::Down);
Size adjustOutputSize(const PixelFormat &pixFmt, const Size &size,
Converter::Alignment align = Converter::Alignment::Down);
int exportBuffers(const Stream *stream, unsigned int count,
std::vector<std::unique_ptr<FrameBuffer>> *buffers);
int validateOutput(StreamConfiguration *cfg, bool *adjusted,
Converter::Alignment align = Converter::Alignment::Down);
int queueBuffers(FrameBuffer *input,
const std::map<const Stream *, FrameBuffer *> &outputs);
int start();
void stop();
void updateControlInfos(const Stream *stream, ControlInfoMap::Map &infos);
void setControls(const Stream *stream, const ControlList &controls);
void populateMetadata(const Stream *stream, ControlList &meta);
void setSensorCrop(const Rectangle &rect);
void setTransform(const Stream *stream, const Transform &transform);
Signal<FrameBuffer *> inputBufferReady;
Signal<FrameBuffer *> outputBufferReady;
private:
ConverterDW100Module(std::shared_ptr<MediaDevice> media);
int applyControls(const Stream *stream, const V4L2Request *request);
void reinitRequest(V4L2Request *request);
struct DewarpParms {
Matrix<double, 3, 3> cm;
std::vector<double> coeffs;
};
struct VertexMapInfo {
Dw100VertexMap map;
bool update;
};
std::map<const Stream *, VertexMapInfo> vertexMaps_;
std::optional<DewarpParms> dewarpParams_;
unsigned int inputBufferCount_;
V4L2M2MConverter converter_;
Rectangle sensorCrop_;
bool running_;
std::vector<std::unique_ptr<V4L2Request>> requests_;
std::queue<V4L2Request *> availableRequests_;
};
} /* 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:40
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