diff --git a/temp/libcamera/0001-libcamera-simple-Enable-softwareISP-for-the-librem5.patch b/temp/libcamera/0001-libcamera-simple-Enable-softwareISP-for-the-librem5.patch new file mode 100644 index 000000000..5d98bad51 --- /dev/null +++ b/temp/libcamera/0001-libcamera-simple-Enable-softwareISP-for-the-librem5.patch @@ -0,0 +1,26 @@ +From 278114dc6f3db69bacd80327516bc397dd1b881f Mon Sep 17 00:00:00 2001 +From: Robert Mader +Date: Mon, 22 Apr 2024 23:30:31 +0200 +Subject: [PATCH 1/4] libcamera: simple: Enable softwareISP for the librem5 + +And - in theory - on similar devices. +--- + src/libcamera/pipeline/simple/simple.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp +index db3575c3..ac792b35 100644 +--- a/src/libcamera/pipeline/simple/simple.cpp ++++ b/src/libcamera/pipeline/simple/simple.cpp +@@ -198,7 +198,7 @@ namespace { + + static const SimplePipelineInfo supportedDevices[] = { + { "dcmipp", {}, false }, +- { "imx7-csi", { { "pxp", 1 } }, false }, ++ { "imx7-csi", { { "pxp", 1 } }, true }, + { "j721e-csi2rx", {}, false }, + { "mtk-seninf", { { "mtk-mdp", 3 } }, false }, + { "mxc-isi", {}, false }, +-- +2.45.1 + diff --git a/temp/libcamera/0001-qcam-Decrease-minimum-width-of-selector-dialog.patch b/temp/libcamera/0001-qcam-Decrease-minimum-width-of-selector-dialog.patch new file mode 100644 index 000000000..a23c45206 --- /dev/null +++ b/temp/libcamera/0001-qcam-Decrease-minimum-width-of-selector-dialog.patch @@ -0,0 +1,32 @@ +From 08c1dd69b556b0325fe6cdfea4b28b4f2df90658 Mon Sep 17 00:00:00 2001 +From: Luca Weiss +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 +--- + 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 + diff --git a/temp/libcamera/0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch b/temp/libcamera/0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch new file mode 100644 index 000000000..327817295 --- /dev/null +++ b/temp/libcamera/0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch @@ -0,0 +1,43 @@ +From f430e03c6b155d0e841db33020d53cac566a420e Mon Sep 17 00:00:00 2001 +From: Robert Mader +Date: Thu, 9 May 2024 21:07:07 +0200 +Subject: [PATCH 2/4] libcamera: simple: Force-disable softwareISP for + millipixels + +As the later uses libcamera and requires raw-streams to get passed +through. In the future, libcamera will likely support both - raw and +swIsp - at the same time. +--- + src/libcamera/pipeline/simple/simple.cpp | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp +index ac792b35..0ccbfa90 100644 +--- a/src/libcamera/pipeline/simple/simple.cpp ++++ b/src/libcamera/pipeline/simple/simple.cpp +@@ -7,6 +7,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -1546,6 +1547,14 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) + + swIspEnabled_ = info->swIspEnabled; + ++ std::string comm_string; ++ std::ifstream("/proc/self/comm") >> comm_string; ++ if (comm_string == "millipixels") { ++ LOG(SimplePipeline, Warning) ++ << "Detected millipixels, disabling swIsp"; ++ swIspEnabled_ = false; ++ } ++ + /* Locate the sensors. */ + std::vector sensors = locateSensors(); + if (sensors.empty()) { +-- +2.45.1 + diff --git a/temp/libcamera/0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch b/temp/libcamera/0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch new file mode 100644 index 000000000..0d994510e --- /dev/null +++ b/temp/libcamera/0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch @@ -0,0 +1,32 @@ +From ac83a8feb2d7d9539456dd301c08f89f1cd08b7d Mon Sep 17 00:00:00 2001 +From: Robert Mader +Date: Wed, 1 May 2024 18:12:02 +0200 +Subject: [PATCH 3/4] libcamera: simple: Enable softISP for the Pinephone + +In theory the PP should be able to use the actual HW ISP, however in +practice this does not work well yet - especially as the driver for the +front camera in Megi differs heavily from the upstream one. + +Thus enable the swISP to make both cameras work reliably for now. This +is essentially what Megapixels does as well. If the HW ISP situation +improves, this can be dropped again. +--- + src/libcamera/pipeline/simple/simple.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp +index 0ccbfa90..71a44237 100644 +--- a/src/libcamera/pipeline/simple/simple.cpp ++++ b/src/libcamera/pipeline/simple/simple.cpp +@@ -204,7 +204,7 @@ static const SimplePipelineInfo supportedDevices[] = { + { "mtk-seninf", { { "mtk-mdp", 3 } }, false }, + { "mxc-isi", {}, false }, + { "qcom-camss", {}, true }, +- { "sun6i-csi", {}, false }, ++ { "sun6i-csi", {}, true }, + }; + + } /* namespace */ +-- +2.45.1 + diff --git a/temp/libcamera/0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch b/temp/libcamera/0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch new file mode 100644 index 000000000..39c936ec7 --- /dev/null +++ b/temp/libcamera/0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch @@ -0,0 +1,32 @@ +From 0e10f1da5892156dc31445918303dc5eb80f9d0f Mon Sep 17 00:00:00 2001 +From: Robert Mader +Date: Mon, 6 May 2024 21:21:57 +0200 +Subject: [PATCH 4/4] libcamera: simple: Skip hwISP formats if swISP is active + +On devices like the Pinephone libcamera will advertise support for +formats provided by the HW ISP and the SW ISP at the same time. The +reason why we enable the SW ISP in the first place is, however, that the +HW ISP does not work reliable atm. Thus filter out formats from the HW +ISP when the SW ISP is enabled, to ensure we use the later. +--- + src/libcamera/pipeline/simple/simple.cpp | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp +index 71a44237..36604a83 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) + config.outputFormats = swIsp_->formats(pixelFormat); + config.outputSizes = swIsp_->sizes(pixelFormat, format.size); + if (config.outputFormats.empty()) { +- /* Do not use swIsp for unsupported pixelFormat's. */ +- config.outputFormats = { pixelFormat }; +- config.outputSizes = config.captureSize; ++ continue; + } + } else { + config.outputFormats = { pixelFormat }; +-- +2.45.1 + diff --git a/temp/libcamera/90-libcamera.rules b/temp/libcamera/90-libcamera.rules new file mode 100644 index 000000000..c6b5a214a --- /dev/null +++ b/temp/libcamera/90-libcamera.rules @@ -0,0 +1 @@ +SUBSYSTEM=="dma_heap",GROUP="video",MODE="0660" diff --git a/temp/libcamera/APKBUILD b/temp/libcamera/APKBUILD new file mode 100644 index 000000000..1ca52ac23 --- /dev/null +++ b/temp/libcamera/APKBUILD @@ -0,0 +1,157 @@ +# Forked from Alpine for temporary downstream patches + +pkgname=libcamera +pkgver=9999 +_pkgver=0.3.0 +pkgrel=0 +pkgdesc="Linux camera framework" +url="https://libcamera.org/" +arch="all" +license="LGPL-2.1-or-later AND GPL-2.0-or-later" +depends_dev=" + eudev-dev + glib-dev + gnutls-dev + gst-plugins-bad-dev + qt5-qtbase-dev + " +# upstream calls 'date' with a non-POSIX option so we pull in coreutils +makedepends="$depends_dev + coreutils + doxygen + graphviz + gtest-dev + libevent-dev + libunwind-dev + linux-headers + meson + py3-jinja2 + py3-ply + py3-sphinx + py3-yaml + qt5-qttools-dev + yaml-dev + " +subpackages=" + $pkgname-dbg + $pkgname-dev + $pkgname-doc + qcam + $pkgname-gstreamer + $pkgname-v4l2 + $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 + qcam.desktop + 90-libcamera.rules + " +builddir="$srcdir/$pkgname-v$_pkgver" +# gstreamer tests fail +# manual strip because ipa .sign files depend on the file contents- have to re-sign after strip +options="!strip !check" + +case "$CARCH" in +arm*|aarch64) + subpackages="$subpackages $pkgname-raspberrypi" + ;; +esac + +case "$CARCH" in +ppc64le|s390x|riscv64|loongarch64) + # doesn't install any ipa + ;; +*) + depends="$pkgname-ipa=$pkgver-r$pkgrel" + subpackages="$subpackages $pkgname-ipa" + ;; +esac + +build() { + abuild-meson \ + -Dv4l2=true \ + -Dwerror=false \ + . output + meson compile -C output +} + +check() { + meson test --no-rebuild -C output --print-errorlogs +} + +package() { + DESTDIR="$pkgdir" meson install --no-rebuild -C output + install -Dm644 -t "$pkgdir"/usr/share/applications "$srcdir"/qcam.desktop + + # manual strip first.. + scanelf --recursive \ + --nobanner \ + --etype "ET_DYN,ET_EXEC" \ + --format "%F" \ + "$pkgdir" \ + | while read -r file; do + strip "$file" + done + + install -Dm644 "$srcdir"/90-libcamera.rules \ + -t "$pkgdir"/lib/udev/rules.d/ +} + +ipa() { + depends="" + amove usr/lib/libcamera + # then sign ipa's + local ipa + for ipa in "$subpkgdir"/usr/lib/libcamera/ipa*.so; do + msg "signing $ipa" + "$builddir"/src/ipa/ipa-sign.sh \ + "$(find "$builddir"/output -type f -iname "*ipa-priv-key.pem")" \ + "$ipa" \ + "$ipa".sign + done +} + +qcam() { + depends="" + amove usr/bin/qcam + + amove usr/share/applications/qcam.desktop +} + +gstreamer() { + depends="" + amove usr/lib/gstreamer-1.0 +} + +v4l2() { + depends="" + amove usr/libexec/libcamera/v4l2-compat.so +} + +raspberrypi() { + depends="" + amove usr/share/libcamera/ipa/rpi + amove usr/libexec/libcamera/raspberrypi_ipa_proxy + amove usr/share/libcamera/pipeline/rpi/vc4 +} + +tools() { + depends="" + amove usr/bin/cam + amove usr/bin/lc-compliance +} + +sha512sums=" +d232593b6cc7f2b772e8cd0b6751fee00ddbde256328c4cf7162726d4766149afca36411075e2b55a8a009d52758f01874ff08b947b508dbe5e3059fa4a92c86 libcamera-v0.3.0.tar.gz +69d6e29d764f752feed453b9c0f61c81cdb506eb14893d0d99d0d6834f369f1e816c2381dfab5ad1a744a3d11211af02d75dc041ecc87c7e4f73e2bd34c666c2 0001-qcam-Decrease-minimum-width-of-selector-dialog.patch +495bc434fe188d0b83c88325657946e57b0a31d34d5249d8ea02fbfb4025ff15080a5da6bf61866eeffa63dad9b2b9a7b8abb456a306da8925c39775eda339bb 0001-libcamera-simple-Enable-softwareISP-for-the-librem5.patch +26b274c32c9fc0d8220f58c7e37f6c0c9e590b2ff07adbc908b4c38ae4b7104639bb8ecf57b2faa15d2fae932d0021b51ad6a31a8762a05d3f876d55f0fef242 0002-libcamera-simple-Force-disable-softwareISP-for-milli.patch +68b66432d3e60adc7329713b1362d023244516b697fbcb67112d9aad1367d2c65a100470b1ab6747074ca2717ec18e848b3888b382f75be1646e182894c6a37c 0003-libcamera-simple-Enable-softISP-for-the-Pinephone.patch +4bfc5c35cf6bc8f1695744486a43695efa7bef5ce1c3bc93bda227832d08394f3bb0115863f7a30a8adfc4c93af293cdd5063fdb78f8d850f4d0c2ac7b1ff123 0004-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch +22167a4eceb6d1b40b0b7c45fdf116c71684f5340de7f767535cb8e160ad9d2ae0f00cb3d461f73a344520a48a4641cf46226841d78bee06bfbfd2a91337f754 qcam.desktop +444a0a52b374751c388f807b6adcc63b36488547adaa5fb70b606dc5646132b1a893a76254236b5c80f3a6d041a4597d413e050af0323cd05626d758190838e2 90-libcamera.rules +" diff --git a/temp/libcamera/qcam.desktop b/temp/libcamera/qcam.desktop new file mode 100644 index 000000000..c3585419a --- /dev/null +++ b/temp/libcamera/qcam.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=QCam +GenericName=Camera Demo App +Comment=Take photos with camera exposed by libcamera +Exec=qcam +Type=Application +Terminal=false +StartupNotify=true