libcamera v0.5.1
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
software_isp.h
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2023, Linaro Ltd
4 *
5 * Simple software ISP implementation
6 */
7
8#pragma once
9
10#include <deque>
11#include <functional>
12#include <initializer_list>
13#include <map>
14#include <memory>
15#include <stdint.h>
16#include <string>
17#include <tuple>
18#include <vector>
19
21#include <libcamera/base/log.h>
25
26#include <libcamera/geometry.h>
28
29#include <libcamera/ipa/soft_ipa_interface.h>
30#include <libcamera/ipa/soft_ipa_proxy.h>
31
33#include "libcamera/internal/dma_buf_allocator.h"
35#include "libcamera/internal/shared_mem_object.h"
36#include "libcamera/internal/software_isp/debayer_params.h"
37
38namespace libcamera {
39
40class DebayerCpu;
41class FrameBuffer;
42class PixelFormat;
43class Stream;
45
47
48class SoftwareIsp : public Object
49{
50public:
51 SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
52 ControlInfoMap *ipaControls);
54
55 int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }
56
57 bool isValid() const;
58
59 std::vector<PixelFormat> formats(PixelFormat input);
60
61 SizeRange sizes(PixelFormat inputFormat, const Size &inputSize);
62
63 std::tuple<unsigned int, unsigned int>
64 strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
65
66 int configure(const StreamConfiguration &inputCfg,
67 const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,
68 const ipa::soft::IPAConfigInfo &configInfo);
69
70 int exportBuffers(const Stream *stream, unsigned int count,
71 std::vector<std::unique_ptr<FrameBuffer>> *buffers);
72
73 void processStats(const uint32_t frame, const uint32_t bufferId,
74 const ControlList &sensorControls);
75
76 int start();
77 void stop();
78
79 void queueRequest(const uint32_t frame, const ControlList &controls);
80 int queueBuffers(uint32_t frame, FrameBuffer *input,
81 const std::map<const Stream *, FrameBuffer *> &outputs);
82
83 void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output);
84
90
91private:
92 void saveIspParams();
93 void setSensorCtrls(const ControlList &sensorControls);
94 void statsReady(uint32_t frame, uint32_t bufferId);
95 void inputReady(FrameBuffer *input);
96 void outputReady(FrameBuffer *output);
97
98 std::unique_ptr<DebayerCpu> debayer_;
99 Thread ispWorkerThread_;
100 SharedMemObject<DebayerParams> sharedParams_;
101 DebayerParams debayerParams_;
102 DmaBufAllocator dmaHeap_;
103 bool ccmEnabled_;
104
105 std::unique_ptr<ipa::soft::IPAProxySoft> ipa_;
106 std::deque<FrameBuffer *> queuedInputBuffers_;
107 std::deque<FrameBuffer *> queuedOutputBuffers_;
108};
109
110} /* namespace libcamera */
A camera sensor.
Utilities to help constructing class interfaces.
A abstract camera sensor.
Definition camera_sensor.h:39
A map of ControlId to ControlInfo.
Definition controls.h:367
Associate a list of ControlId with their values for an object.
Definition controls.h:411
Class for debayering on the CPU.
Definition debayer_cpu.h:28
Helper class for dma-buf allocations.
Definition dma_buf_allocator.h:24
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:49
Object(Object *parent=nullptr)
Construct an Object instance.
Definition object.cpp:69
Create and manage cameras based on a set of media devices.
Definition pipeline_handler.h:35
libcamera image pixel format
Definition pixel_format.h:17
Helper class to allocate an object in shareable memory.
Definition shared_mem_object.h:60
Generic signal and slot communication mechanism.
Definition signal.h:39
Describe a range of sizes.
Definition geometry.h:199
Describe a two-dimensional size.
Definition geometry.h:51
Class for the Software ISP.
Definition software_isp.h:49
int loadConfiguration(const std::string &filename)
Load a configuration from a file.
Definition software_isp.h:55
Signal< FrameBuffer * > inputBufferReady
A signal emitted when the input frame buffer completes.
Definition software_isp.h:85
Signal< const ControlList & > setSensorControls
A signal emitted when the values to write to the sensor controls are ready.
Definition software_isp.h:89
Signal< uint32_t, const ControlList & > metadataReady
A signal emitted when the metadata for IPA is ready.
Definition software_isp.h:88
Signal< uint32_t, uint32_t > ispStatsReady
A signal emitted when the statistics for IPA are ready.
Definition software_isp.h:87
SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, ControlInfoMap *ipaControls)
Constructs SoftwareIsp object.
Definition software_isp.cpp:76
Signal< FrameBuffer * > outputBufferReady
A signal emitted when the output frame buffer completes.
Definition software_isp.h:86
Video stream for a camera.
Definition stream.h:76
Data structures related to geometric objects.
Logging infrastructure.
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:51
Namespace for libcamera controls.
Definition control_ids.h:21
Top-level libcamera namespace.
Definition backtrace.h:17
Base object to support automatic signal disconnection.
Create pipelines and cameras from a set of media devices.
libcamera pixel format
Signal & slot implementation.
Struct to hold the debayer parameters.
Definition debayer_params.h:18
Configuration parameters for a stream.
Definition stream.h:40
Thread support.