Skip to content
Snippets Groups Projects
Unverified Commit f736e1e3 authored by Robert Mader's avatar Robert Mader
Browse files

temp/libcamera: upgrade to 0.3.2 (MR 5623)

Rebase our downstream patches and drop the two included in the release.

See https://gitlab.freedesktop.org/camera/libcamera/-/tags/v0.3.2 for
release notes.
[ci:skip-build]: already built successfully in CI
parent 6fdd12b6
No related branches found
No related tags found
No related merge requests found
Pipeline #205341 passed
From cde234eb9b33b1f38848cb4abc196f609be37a3a Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Fri, 20 Sep 2024 12:49:15 +0100
Subject: [PATCH] libcamera: debayer_cpu: Sync DMABUFs
Using `DMA_BUF_IOCTL_SYNC` is required for DMABUFs in order to ensure
correct output. Not doing so currently results in occasional tearing
and/or backlashes in GL/VK clients that use the buffers directly for
rendering.
An alternative approach to have the sync code in `MappedFrameBuffer` was
considered but rejected for now, in order to allow clients more
flexibility.
While the new helper is added to an annoymous namespace, add
timeDiff to the same namespace and remove the static definition as a
drive by.
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Tested-by: Milan Zamazal <mzamazal@redhat.com> # Debix
Tested-by: Hans de Goede <hdegoede@redhat.com> # IPU6 + ov2740
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> # Lenovo X13s + OV5675
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
src/libcamera/software_isp/debayer_cpu.cpp | 32 +++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index f8d2677d..686a3b64 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -12,8 +12,11 @@
#include "debayer_cpu.h"
#include <stdlib.h>
+#include <sys/ioctl.h>
#include <time.h>
+#include <linux/dma-buf.h>
+
#include <libcamera/formats.h>
#include "libcamera/internal/bayer_format.h"
@@ -725,12 +728,33 @@ void DebayerCpu::process4(const uint8_t *src, uint8_t *dst)
}
}
-static inline int64_t timeDiff(timespec &after, timespec &before)
+namespace {
+
+void syncBufferForCPU(FrameBuffer *buffer, uint64_t syncFlags)
+{
+ for (const FrameBuffer::Plane &plane : buffer->planes()) {
+ const int fd = plane.fd.get();
+ struct dma_buf_sync sync = { syncFlags };
+ int ret;
+
+ ret = ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
+ if (ret < 0) {
+ ret = errno;
+ LOG(Debayer, Error)
+ << "Syncing buffer FD " << fd << " with flags "
+ << syncFlags << " failed: " << strerror(ret);
+ }
+ }
+}
+
+inline int64_t timeDiff(timespec &after, timespec &before)
{
return (after.tv_sec - before.tv_sec) * 1000000000LL +
(int64_t)after.tv_nsec - (int64_t)before.tv_nsec;
}
+} /* namespace */
+
void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)
{
timespec frameStartTime;
@@ -740,6 +764,9 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams
clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime);
}
+ syncBufferForCPU(input, DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ);
+ syncBufferForCPU(output, DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE);
+
green_ = params.green;
red_ = swapRedBlueGains_ ? params.blue : params.red;
blue_ = swapRedBlueGains_ ? params.red : params.blue;
@@ -767,6 +794,9 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams
metadata.planes()[0].bytesused = out.planes()[0].size();
+ syncBufferForCPU(output, DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE);
+ syncBufferForCPU(input, DMA_BUF_SYNC_END | DMA_BUF_SYNC_READ);
+
/* Measure before emitting signals */
if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure &&
++measuredFrames_ > DebayerCpu::kFramesToSkip) {
--
2.46.1
From 1fe279d7fcda1b33edd1e82a7a0763d012d1ca7d Mon Sep 17 00:00:00 2001
From 17a054e8e60fa3f6298698aeb06fbe8196ab3dd2 Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Mon, 22 Apr 2024 23:30:31 +0200
Subject: [PATCH 1/4] libcamera: simple: Enable softwareISP for the librem5
......@@ -9,7 +9,7 @@ And - in theory - on similar devices.
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index c050966a..b6b8f854 100644
index 81915573..8ce8baea 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -197,7 +197,7 @@ namespace {
......@@ -22,5 +22,5 @@ index c050966a..b6b8f854 100644
{ "j721e-csi2rx", {}, true },
{ "mtk-seninf", { { "mtk-mdp", 3 } }, false },
--
2.45.2
2.46.1
From 08c1dd69b556b0325fe6cdfea4b28b4f2df90658 Mon Sep 17 00:00:00 2001
From: Luca Weiss <luca@z3ntu.xyz>
Date: Sat, 28 Jan 2023 17:24:03 +0100
Subject: [PATCH] qcam: Decrease minimum width of selector dialog
On phone screens the default width is too wide, so the OK button cannot
be clicked.
Fix this by decreasing the minimum size of the dialog so it fits nicely.
Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
---
src/apps/qcam/cam_select_dialog.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/apps/qcam/cam_select_dialog.cpp b/src/apps/qcam/cam_select_dialog.cpp
index 3c8b12a9..2a600383 100644
--- a/src/apps/qcam/cam_select_dialog.cpp
+++ b/src/apps/qcam/cam_select_dialog.cpp
@@ -25,6 +25,9 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag
/* Use a QFormLayout for the dialog. */
QFormLayout *layout = new QFormLayout(this);
+ /* Decrease minimum width of dialog to fit on narrow screens */
+ setMinimumSize(250, 100);
+
/* Setup the camera id combo-box. */
cameraIdComboBox_ = new QComboBox;
for (const auto &cam : cm_->cameras())
--
2.39.1
From 2531eab53574092da0451f4f3b7e5dbc7f9ecd13 Mon Sep 17 00:00:00 2001
From 5b5a0f92969ad1972c6a9fd7a46ac8f4fedb9389 Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 9 May 2024 21:07:07 +0200
Subject: [PATCH 2/4] libcamera: simple: Force-disable softwareISP for
......@@ -12,7 +12,7 @@ swIsp - at the same time.
1 file changed, 9 insertions(+)
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index b6b8f854..86285bc4 100644
index 8ce8baea..08755b80 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -7,6 +7,7 @@
......@@ -23,7 +23,7 @@ index b6b8f854..86285bc4 100644
#include <iterator>
#include <list>
#include <map>
@@ -1544,6 +1545,14 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
@@ -1542,6 +1543,14 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
swIspEnabled_ = info->swIspEnabled;
......@@ -36,8 +36,8 @@ index b6b8f854..86285bc4 100644
+ }
+
/* Locate the sensors. */
std::vector<MediaEntity *> sensors = locateSensors();
std::vector<MediaEntity *> sensors = locateSensors(media);
if (sensors.empty()) {
--
2.45.2
2.46.1
From 53e200dca1b66d2d51b1ad3546a265a9e146f6c1 Mon Sep 17 00:00:00 2001
From d06e06fa7a050a32d326f6b800efaa5878c18f6c Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Wed, 1 May 2024 18:12:02 +0200
Subject: [PATCH 3/4] libcamera: simple: Enable softISP for the Pinephone
......@@ -15,7 +15,7 @@ improves, this can be dropped again.
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 86285bc4..c2658703 100644
index 08755b80..ffa4f6d6 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -204,7 +204,7 @@ static const SimplePipelineInfo supportedDevices[] = {
......@@ -28,5 +28,5 @@ index 86285bc4..c2658703 100644
} /* namespace */
--
2.45.2
2.46.1
From 12d11a74d3a9bf1a3e5ecf31e15219363925bb60 Mon Sep 17 00:00:00 2001
From 545e8004a73b8606a01d4853fdccb7e20e0cc146 Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Mon, 6 May 2024 21:21:57 +0200
Subject: [PATCH 4/4] libcamera: simple: Skip hwISP formats if swISP is active
......@@ -13,10 +13,10 @@ ISP when the SW ISP is enabled, to ensure we use the later.
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index c2658703..27ac1522 100644
index ffa4f6d6..29320a26 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -652,9 +652,7 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
@@ -651,9 +651,7 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
config.outputFormats = swIsp_->formats(pixelFormat);
config.outputSizes = swIsp_->sizes(pixelFormat, format.size);
if (config.outputFormats.empty()) {
......@@ -28,5 +28,5 @@ index c2658703..27ac1522 100644
} else {
config.outputFormats = { pixelFormat };
--
2.45.2
2.46.1
......@@ -2,8 +2,8 @@
pkgname=libcamera
pkgver=9999
_pkgver=0.3.1
pkgrel=4
_pkgver=0.3.2
pkgrel=5
pkgdesc="Linux camera framework"
url="https://libcamera.org/"
arch="all"
......@@ -42,12 +42,10 @@ subpackages="
$pkgname-tools
"
source="https://gitlab.freedesktop.org/camera/libcamera/-/archive/v$_pkgver/libcamera-v$_pkgver.tar.gz
0001-qcam-Decrease-minimum-width-of-selector-dialog.patch
0001-libcamera-simple-Enable-softwareISP-for-the-librem5.patch
0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch
0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch
0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch
0001-libcamera-debayer_cpu-Sync-DMABUFs.patch
qcam.desktop
90-libcamera.rules
"
......@@ -147,13 +145,11 @@ tools() {
}
sha512sums="
85f62383194ca597baab36375e7b5ee99d6a8580fd54baf2615e5854bef790ef5ae57a92347c7e8408e2b9c04330d467dc56fab1af2f1c478c679a5a05e4f562 libcamera-v0.3.1.tar.gz
69d6e29d764f752feed453b9c0f61c81cdb506eb14893d0d99d0d6834f369f1e816c2381dfab5ad1a744a3d11211af02d75dc041ecc87c7e4f73e2bd34c666c2 0001-qcam-Decrease-minimum-width-of-selector-dialog.patch
a5809b7664685bb44ca05a722655d8b94991c90306b69be1e7b135a1ad72699ab69b0e9bf7edbee041700087b7d7bc7ae1ef704334e7672aa81e9e7c96ccf7f9 0001-libcamera-simple-Enable-softwareISP-for-the-librem5.patch
979259bb16112b1fbbec0543a1d642a65e62f24ba10b229caffe68398da343160d98c2811f923877ce5d2c9a3c8a53205feb2eb4fbaf921612bbc5419d6be1df 0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch
47616a06fad66df31e29ebd9c024c95bdea542dd1f5c0ed448a242e35a6d9909f973a74332bfe084478c91ac7a2d778d7b10270cd493dba07bb8d5ad34e9544c 0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch
685b8cfae3bb9a000d95a36d9daf9d4ff8770fd877e43c69f0fc0768ebd457282f03ec6ad9bf3a33e72765665bbd642af5db66c1a82aac249ce8c2522291dee6 0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch
bbe991bc605b79b8c35a49571398ccf21bd18cb21b62f46340cbbf4fc3ec80226d6573cd0b98ebebb9b210ea37ca21a653626307dcd69c6baf2bebce1b5e8a39 0001-libcamera-debayer_cpu-Sync-DMABUFs.patch
7c0fb86cf8f1c86496fac91cf75a689d0fd0cec08d2e2f86d096d984404c1e130b9bba19622cd67098ba09adff74178b39ebe94a19c9b25b0a12f7e30e506823 libcamera-v0.3.2.tar.gz
ac7df3e4509ae874199810057f4d8416da71720c15534578cc352608a8ae228dfa4814f9eb995d55422124e542b68819625c8dfe18121a3888d9b2238a5923ef 0001-libcamera-simple-Enable-softwareISP-for-the-librem5.patch
9b6da8bd11ff9d8400ed721fbbeb960ac8753c078fdd971d786a446a9f96fea19dfc55be2705dc44a152e11de996f88139c1d24637bffc257da5083d19fe80c9 0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch
0fc6a1108c4e905d2d422a664622dc25ec459f13765b5711ad009d4df0fd0cceda8cd067a18e5e54eb2346b292481952161e72deb03d416ba80b300256c25e40 0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch
35c74746453f4c2e24a2185331afabcf64e3af01bec2462ec09940518cda0e91c4a1f33853b4b009e1f8352af3c606fbd4b4d3791ffbba0f610f19538380c4c8 0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch
22167a4eceb6d1b40b0b7c45fdf116c71684f5340de7f767535cb8e160ad9d2ae0f00cb3d461f73a344520a48a4641cf46226841d78bee06bfbfd2a91337f754 qcam.desktop
cb4eb19eec766f1b8667a8b7c9d5f7d44a2dce79fddfdf3b6e3d1849066cebe79f82566bdcf6659c7ddf4faaf233d5adac10cda636935785e5305e2b7e9b34a9 90-libcamera.rules
"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment