summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/Doxyfile-common.in3
-rw-r--r--Documentation/guides/pipeline-handler.rst10
-rw-r--r--meson.build2
-rw-r--r--src/apps/cam/drm.cpp25
-rw-r--r--src/ipa/simple/algorithms/ccm.cpp60
-rw-r--r--src/ipa/simple/algorithms/ccm.h11
-rw-r--r--src/ipa/simple/ipa_context.h4
-rw-r--r--src/libcamera/pipeline/ipu3/cio2.h2
-rw-r--r--src/libcamera/pipeline/mali-c55/mali-c55.cpp7
9 files changed, 99 insertions, 25 deletions
diff --git a/Documentation/Doxyfile-common.in b/Documentation/Doxyfile-common.in
index 045c19dd..58afea1c 100644
--- a/Documentation/Doxyfile-common.in
+++ b/Documentation/Doxyfile-common.in
@@ -57,7 +57,8 @@ GENERATE_LATEX = NO
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
-INCLUDE_PATH = "@TOP_SRCDIR@/include/libcamera"
+INCLUDE_PATH = "@TOP_BUILDDIR@/include" \
+ "@TOP_SRCDIR@/include"
INCLUDE_FILE_PATTERNS = *.h
IMAGE_PATH = "@TOP_SRCDIR@/Documentation/images"
diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst
index fe752975..0d5df726 100644
--- a/Documentation/guides/pipeline-handler.rst
+++ b/Documentation/guides/pipeline-handler.rst
@@ -213,7 +213,7 @@ implementations for the overridden class members.
std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;
int start(Camera *camera, const ControlList *controls) override;
- void stop(Camera *camera) override;
+ void stopDevice(Camera *camera) override;
int queueRequestDevice(Camera *camera, Request *request) override;
@@ -247,7 +247,7 @@ implementations for the overridden class members.
return -1;
}
- void PipelineHandlerVivid::stop(Camera *camera)
+ void PipelineHandlerVivid::stopDevice(Camera *camera)
{
}
@@ -1152,7 +1152,7 @@ available to the devices which have to be started and ready to produce
images. At the end of a capture session the ``Camera`` device needs to be
stopped, to gracefully clean up any allocated memory and stop the hardware
devices. Pipeline handlers implement two functions for these purposes, the
-``start()`` and ``stop()`` functions.
+``start()`` and ``stopDevice()`` functions.
The memory initialization phase that happens at ``start()`` time serves to
configure video devices to be able to use memory buffers exported as dma-buf
@@ -1255,8 +1255,8 @@ algorithms, or other devices you should also stop them.
.. _releaseBuffers: https://libcamera.org/api-html/classlibcamera_1_1V4L2VideoDevice.html#a191619c152f764e03bc461611f3fcd35
Of course we also need to handle the corresponding actions to stop streaming on
-a device, Add the following to the ``stop`` function, to stop the stream with
-the `streamOff`_ function and release all buffers.
+a device, Add the following to the ``stopDevice()`` function, to stop the
+stream with the `streamOff`_ function and release all buffers.
.. _streamOff: https://libcamera.org/api-html/classlibcamera_1_1V4L2VideoDevice.html#a61998710615bdf7aa25a046c8565ed66
diff --git a/meson.build b/meson.build
index 9ba5e2ca..4ed8017e 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@
project('libcamera', 'c', 'cpp',
meson_version : '>= 0.63',
- version : '0.5.0',
+ version : '0.5.1',
default_options : [
'werror=true',
'warning_level=2',
diff --git a/src/apps/cam/drm.cpp b/src/apps/cam/drm.cpp
index 47bbb6b0..f4b47097 100644
--- a/src/apps/cam/drm.cpp
+++ b/src/apps/cam/drm.cpp
@@ -450,8 +450,6 @@ int Device::openCard()
}
for (struct dirent *res; (res = readdir(folder));) {
- uint64_t cap;
-
if (strncmp(res->d_name, "card", 4))
continue;
@@ -465,15 +463,22 @@ int Device::openCard()
}
/*
- * Skip devices that don't support the modeset API, to avoid
- * selecting a DRM device corresponding to a GPU. There is no
- * modeset capability, but the kernel returns an error for most
- * caps if mode setting isn't support by the driver. The
- * DRM_CAP_DUMB_BUFFER capability is one of those, other would
- * do as well. The capability value itself isn't relevant.
+ * Skip non-display devices. While this could in theory be done
+ * by checking for support of the mode setting API, some
+ * out-of-tree render-only GPU drivers (namely powervr)
+ * incorrectly set the DRIVER_MODESET driver feature. Check for
+ * the presence of at least one CRTC, encoder and connector
+ * instead.
*/
- ret = drmGetCap(fd_, DRM_CAP_DUMB_BUFFER, &cap);
- if (ret < 0) {
+ std::unique_ptr<drmModeRes, decltype(&drmModeFreeResources)> resources{
+ drmModeGetResources(fd_),
+ &drmModeFreeResources
+ };
+ if (!resources ||
+ resources->count_connectors <= 0 ||
+ resources->count_crtcs <= 0 ||
+ resources->count_encoders <= 0) {
+ resources.reset();
drmClose(fd_);
fd_ = -1;
continue;
diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp
index d5ba928d..0a98406c 100644
--- a/src/ipa/simple/algorithms/ccm.cpp
+++ b/src/ipa/simple/algorithms/ccm.cpp
@@ -3,7 +3,7 @@
* Copyright (C) 2024, Ideas On Board
* Copyright (C) 2024-2025, Red Hat Inc.
*
- * Color correction matrix
+ * Color correction matrix + saturation
*/
#include "ccm.h"
@@ -13,6 +13,8 @@
#include <libcamera/control_ids.h>
+#include "libcamera/internal/matrix.h"
+
namespace {
constexpr unsigned int kTemperatureThreshold = 100;
@@ -35,28 +37,77 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
}
context.ccmEnabled = true;
+ context.ctrlMap[&controls::Saturation] = ControlInfo(0.0f, 2.0f, 1.0f);
+
+ return 0;
+}
+
+int Ccm::configure(IPAContext &context,
+ [[maybe_unused]] const IPAConfigInfo &configInfo)
+{
+ context.activeState.knobs.saturation = std::optional<double>();
return 0;
}
+void Ccm::queueRequest(typename Module::Context &context,
+ [[maybe_unused]] const uint32_t frame,
+ [[maybe_unused]] typename Module::FrameContext &frameContext,
+ const ControlList &controls)
+{
+ const auto &saturation = controls.get(controls::Saturation);
+ if (saturation.has_value()) {
+ context.activeState.knobs.saturation = saturation;
+ LOG(IPASoftCcm, Debug) << "Setting saturation to " << saturation.value();
+ }
+}
+
+void Ccm::applySaturation(Matrix<float, 3, 3> &ccm, float saturation)
+{
+ /* https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion */
+ const Matrix<float, 3, 3> rgb2ycbcr{
+ { 0.256788235294, 0.504129411765, 0.0979058823529,
+ -0.148223529412, -0.290992156863, 0.439215686275,
+ 0.439215686275, -0.367788235294, -0.0714274509804 }
+ };
+ const Matrix<float, 3, 3> ycbcr2rgb{
+ { 1.16438356164, 0, 1.59602678571,
+ 1.16438356164, -0.391762290094, -0.812967647235,
+ 1.16438356164, 2.01723214285, 0 }
+ };
+ const Matrix<float, 3, 3> saturationMatrix{
+ { 1, 0, 0,
+ 0, saturation, 0,
+ 0, 0, saturation }
+ };
+ ccm = ycbcr2rgb * saturationMatrix * rgb2ycbcr * ccm;
+}
+
void Ccm::prepare(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)
{
+ auto &saturation = context.activeState.knobs.saturation;
+
const unsigned int ct = context.activeState.awb.temperatureK;
- /* Change CCM only on bigger temperature changes. */
+ /* Change CCM only on saturation or bigger temperature changes. */
if (frame > 0 &&
- utils::abs_diff(ct, lastCt_) < kTemperatureThreshold) {
+ utils::abs_diff(ct, lastCt_) < kTemperatureThreshold &&
+ saturation == lastSaturation_) {
frameContext.ccm.ccm = context.activeState.ccm.ccm;
context.activeState.ccm.changed = false;
return;
}
lastCt_ = ct;
+ lastSaturation_ = saturation;
Matrix<float, 3, 3> ccm = ccm_.getInterpolated(ct);
+ if (saturation)
+ applySaturation(ccm, saturation.value());
context.activeState.ccm.ccm = ccm;
frameContext.ccm.ccm = ccm;
+ frameContext.saturation = saturation;
context.activeState.ccm.changed = true;
}
@@ -67,6 +118,9 @@ void Ccm::process([[maybe_unused]] IPAContext &context,
ControlList &metadata)
{
metadata.set(controls::ColourCorrectionMatrix, frameContext.ccm.ccm.data());
+
+ const auto &saturation = frameContext.saturation;
+ metadata.set(controls::Saturation, saturation.value_or(1.0));
}
REGISTER_IPA_ALGORITHM(Ccm, "Ccm")
diff --git a/src/ipa/simple/algorithms/ccm.h b/src/ipa/simple/algorithms/ccm.h
index f4e2b85b..8279a3d5 100644
--- a/src/ipa/simple/algorithms/ccm.h
+++ b/src/ipa/simple/algorithms/ccm.h
@@ -7,6 +7,8 @@
#pragma once
+#include <optional>
+
#include "libcamera/internal/matrix.h"
#include <libipa/interpolator.h>
@@ -24,6 +26,12 @@ public:
~Ccm() = default;
int init(IPAContext &context, const YamlObject &tuningData) override;
+ int configure(IPAContext &context,
+ const IPAConfigInfo &configInfo) override;
+ void queueRequest(typename Module::Context &context,
+ const uint32_t frame,
+ typename Module::FrameContext &frameContext,
+ const ControlList &controls) override;
void prepare(IPAContext &context,
const uint32_t frame,
IPAFrameContext &frameContext,
@@ -34,7 +42,10 @@ public:
ControlList &metadata) override;
private:
+ void applySaturation(Matrix<float, 3, 3> &ccm, float saturation);
+
unsigned int lastCt_;
+ std::optional<float> lastSaturation_;
Interpolator<Matrix<float, 3, 3>> ccm_;
};
diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
index 88cc6c35..a471b80a 100644
--- a/src/ipa/simple/ipa_context.h
+++ b/src/ipa/simple/ipa_context.h
@@ -63,6 +63,7 @@ struct IPAActiveState {
struct {
/* 0..2 range, 1.0 = normal */
std::optional<double> contrast;
+ std::optional<float> saturation;
} knobs;
};
@@ -75,11 +76,14 @@ struct IPAFrameContext : public FrameContext {
int32_t exposure;
double gain;
} sensor;
+
struct {
double red;
double blue;
} gains;
+
std::optional<double> contrast;
+ std::optional<float> saturation;
};
struct IPAContext {
diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
index 963c2f6b..3aa3a1ca 100644
--- a/src/libcamera/pipeline/ipu3/cio2.h
+++ b/src/libcamera/pipeline/ipu3/cio2.h
@@ -66,8 +66,6 @@ public:
private:
void freeBuffers();
- void cio2BufferReady(FrameBuffer *buffer);
-
std::unique_ptr<CameraSensor> sensor_;
std::unique_ptr<V4L2Subdevice> csi2_;
std::unique_ptr<V4L2VideoDevice> output_;
diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp
index f5260f5f..4acc091b 100644
--- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp
+++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp
@@ -157,15 +157,16 @@ int MaliC55CameraData::init()
*/
sensor_ = CameraSensorFactoryBase::create(entity_);
if (!sensor_)
- return ret;
+ return -ENODEV;
const MediaPad *sourcePad = entity_->getPadByIndex(0);
MediaEntity *csiEntity = sourcePad->links()[0]->sink()->entity();
csi_ = std::make_unique<V4L2Subdevice>(csiEntity);
- if (csi_->open()) {
+ ret = csi_->open();
+ if (ret) {
LOG(MaliC55, Error) << "Failed to open CSI-2 subdevice";
- return false;
+ return ret;
}
return 0;