Loading...
Searching...
No Matches
software_isp.h
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2023, Linaro Ltd
*
* Simple software ISP implementation
*/
#pragma once
#include <deque>
#include <functional>
#include <initializer_list>
#include <map>
#include <memory>
#include <stdint.h>
#include <string>
#include <tuple>
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
#include <libcamera/base/thread.h>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
#include <libcamera/ipa/soft_ipa_interface.h>
#include <libcamera/ipa/soft_ipa_proxy.h>
#include "libcamera/internal/camera_sensor.h"
#include "libcamera/internal/dma_buf_allocator.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/shared_mem_object.h"
#include "libcamera/internal/software_isp/debayer_params.h"
namespace libcamera {
class Debayer;
class FrameBuffer;
class PixelFormat;
class Stream;
struct StreamConfiguration;
LOG_DECLARE_CATEGORY(SoftwareIsp)
class SoftwareIsp : public Object
{
public:
SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
ControlInfoMap *ipaControls);
~SoftwareIsp();
int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }
bool isValid() const;
std::vector<PixelFormat> formats(PixelFormat input);
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize);
std::tuple<unsigned int, unsigned int>
strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
int configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,
const ipa::soft::IPAConfigInfo &configInfo);
int exportBuffers(const Stream *stream, unsigned int count,
std::vector<std::unique_ptr<FrameBuffer>> *buffers);
void processStats(const uint32_t frame, const uint32_t bufferId,
const ControlList &sensorControls);
int start();
void stop();
void queueRequest(const uint32_t frame, const ControlList &controls);
int queueBuffers(uint32_t frame, FrameBuffer *input,
const std::map<const Stream *, FrameBuffer *> &outputs);
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output);
Signal<FrameBuffer *> inputBufferReady;
Signal<FrameBuffer *> outputBufferReady;
Signal<uint32_t, uint32_t> ispStatsReady;
Signal<uint32_t, const ControlList &> metadataReady;
Signal<const ControlList &> setSensorControls;
private:
void saveIspParams();
void setSensorCtrls(const ControlList &sensorControls);
void statsReady(uint32_t frame, uint32_t bufferId);
void inputReady(FrameBuffer *input);
void outputReady(FrameBuffer *output);
std::unique_ptr<Debayer> debayer_;
Thread ispWorkerThread_;
SharedMemObject<DebayerParams> sharedParams_;
DebayerParams debayerParams_;
DmaBufAllocator dmaHeap_;
bool ccmEnabled_;
std::unique_ptr<ipa::soft::IPAProxySoft> ipa_;
std::deque<FrameBuffer *> queuedInputBuffers_;
std::deque<FrameBuffer *> queuedOutputBuffers_;
};
} /* namespace libcamera */
camera_sensor.h
A camera sensor.
class.h
Utilities to help constructing class interfaces.
libcamera::CameraSensor
A abstract camera sensor.
Definition camera_sensor.h:40
libcamera::ControlInfoMap
A map of ControlId to ControlInfo.
Definition controls.h:365
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
libcamera::Debayer
Base debayering class.
Definition debayer.h:36
libcamera::DmaBufAllocator
Helper class for dma-buf allocations.
Definition dma_buf_allocator.h:24
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
libcamera::Object::Object
Object(Object *parent=nullptr)
Construct an Object instance.
Definition object.cpp:69
libcamera::PipelineHandler
Create and manage cameras based on a set of media devices.
Definition pipeline_handler.h:34
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::SharedMemObject
Helper class to allocate an object in shareable memory.
Definition shared_mem_object.h:60
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera::SizeRange
Describe a range of sizes.
Definition geometry.h:205
libcamera::Size
Describe a two-dimensional size.
Definition geometry.h:51
libcamera::SoftwareIsp
Class for the Software ISP.
Definition software_isp.h:49
libcamera::SoftwareIsp::loadConfiguration
int loadConfiguration(const std::string &filename)
Load a configuration from a file.
Definition software_isp.h:55
libcamera::SoftwareIsp::inputBufferReady
Signal< FrameBuffer * > inputBufferReady
A signal emitted when the input frame buffer completes.
Definition software_isp.h:85
libcamera::SoftwareIsp::setSensorControls
Signal< const ControlList & > setSensorControls
A signal emitted when the values to write to the sensor controls are ready.
Definition software_isp.h:89
libcamera::SoftwareIsp::metadataReady
Signal< uint32_t, const ControlList & > metadataReady
A signal emitted when the metadata for IPA is ready.
Definition software_isp.h:88
libcamera::SoftwareIsp::ispStatsReady
Signal< uint32_t, uint32_t > ispStatsReady
A signal emitted when the statistics for IPA are ready.
Definition software_isp.h:87
libcamera::SoftwareIsp::SoftwareIsp
SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, ControlInfoMap *ipaControls)
Constructs SoftwareIsp object.
Definition software_isp.cpp:80
libcamera::SoftwareIsp::outputBufferReady
Signal< FrameBuffer * > outputBufferReady
A signal emitted when the output frame buffer completes.
Definition software_isp.h:86
libcamera::Stream
Video stream for a camera.
Definition stream.h:76
geometry.h
Data structures related to geometric objects.
log.h
Logging infrastructure.
LOG_DECLARE_CATEGORY
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:51
libcamera::controls
Namespace for libcamera controls.
Definition control_ids.h:22
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
object.h
Base object to support automatic signal disconnection.
pipeline_handler.h
Create pipelines and cameras from a set of media devices.
pixel_format.h
libcamera pixel format
signal.h
Signal & slot implementation.
libcamera::DebayerParams
Struct to hold the debayer parameters.
Definition debayer_params.h:20
libcamera::StreamConfiguration
Configuration parameters for a stream.
Definition stream.h:40
thread.h
Thread support.