From 25b8ec7da7a8f3989b30eb37349ef05274748a32 Mon Sep 17 00:00:00 2001 From: Mohsen Zahraee Date: Sun, 3 Mar 2024 12:13:22 +0330 Subject: [PATCH 1/4] bugfix libcamera crash --- .../recipes-multimedia/libcamera-apps/libcamera-apps_git.bb | 6 +++--- .../recipes-multimedia/libcamera/libcamera_%.bbappend | 2 -- files/custom-licenses/Broadcom-RPi | 0 3 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_%.bbappend mode change 100644 => 100755 files/custom-licenses/Broadcom-RPi diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera-apps/libcamera-apps_git.bb b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera-apps/libcamera-apps_git.bb index dc0714576..1bcd22366 100644 --- a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera-apps/libcamera-apps_git.bb +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera-apps/libcamera-apps_git.bb @@ -8,12 +8,12 @@ LICENSE = "BSD-2-Clause" LIC_FILES_CHKSUM = "file://license.txt;md5=a0013d1b383d72ba4bdc5b750e7d1d77" SRC_URI = "\ - git://github.com/raspberrypi/libcamera-apps.git;protocol=https;branch=main \ + git://github.com/raspberrypi/rpicam-apps.git;protocol=https;branch=main \ file://0001-utils-version.py-use-usr-bin-env-in-shebang.patch \ file://0002-Revert-Support-compressed-pixel-formats-when-saving-.patch \ " PV = "1.4.2+git${SRCPV}" -SRCREV = "9ae39f85ae6bee9761c36b9b5b80d675bc1fa369" +SRCREV = "4ffc10ed0c65e0be30935037f43391c8395a685d" S = "${WORKDIR}/git" @@ -33,7 +33,7 @@ NEON_FLAGS = "" NEON_FLAGS:aarch64 = "-Dneon_flags=arm64" NEON_FLAGS:arm:raspberrypi3 = "-Dneon_flags=armv8-neon" NEON_FLAGS:arm:raspberrypi4 = "-Dneon_flags=armv8-neon" -EXTRA_OEMESON += "${NEON_FLAGS}" +EXTRA_OEMESON += "${NEON_FLAGS} -Denable_opencv=true -Denable_tflite=true" # QA Issue: /usr/bin/camera-bug-report contained in package libcamera-apps requires /usr/bin/python3 do_install:append() { diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_%.bbappend b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_%.bbappend deleted file mode 100644 index 541c49cd1..000000000 --- a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_%.bbappend +++ /dev/null @@ -1,2 +0,0 @@ -PACKAGECONFIG[raspberrypi] = "-Dpipelines=rpi/vc4 -Dipas=rpi/vc4 -Dcpp_args=-Wno-unaligned-access" -PACKAGECONFIG:append:rpi = " raspberrypi" diff --git a/files/custom-licenses/Broadcom-RPi b/files/custom-licenses/Broadcom-RPi old mode 100644 new mode 100755 From e936cdccaa73a86a0c9e3fcd2b6edb04c7c588d2 Mon Sep 17 00:00:00 2001 From: Mohsen Zahraee Date: Sun, 3 Mar 2024 12:15:51 +0330 Subject: [PATCH 2/4] add support raspberry libcamera branch --- ...evice-Add-bool-return-type-to-unlock.patch | 59 ++++++++++++ ...ca-instead-of-variable-length-arrays.patch | 34 +++++++ ...002-options-Replace-use-of-VLAs-in-C.patch | 91 +++++++++++++++++++ .../libcamera/libcamera_0.2.0.bb | 78 ++++++++++++++++ 4 files changed, 262 insertions(+) create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_0.2.0.bb diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch new file mode 100644 index 000000000..12f034eff --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch @@ -0,0 +1,59 @@ +From 6914c4fd3d53c0c6ea304123bf57429bb64ec16f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 31 Jan 2024 21:01:27 -0800 +Subject: [PATCH 1/2] media_device: Add bool return type to unlock() + +unlock uses lockf which is marked with __attribute__ +((warn_unused_result)) and compilers warn about it and some treat +-Wunused-result as error with -Werror turned on, It would be good to +check if lockf failed or succeeded, however, that piece is not changed +with this, this fixes build with clang++ 18 + + ../git/src/libcamera/media_device.cpp:167:2: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result] + 167 | lockf(fd_.get(), F_ULOCK, 0); + | ^~~~~ ~~~~~~~~~~~~~~~~~~~~~ + 1 error generated. + +Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040380.html] +Signed-off-by: Khem Raj +--- + include/libcamera/internal/media_device.h | 2 +- + src/libcamera/media_device.cpp | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h +index eb8cfde4..b09dfd16 100644 +--- a/include/libcamera/internal/media_device.h ++++ b/include/libcamera/internal/media_device.h +@@ -33,7 +33,7 @@ public: + bool busy() const { return acquired_; } + + bool lock(); +- void unlock(); ++ bool unlock(); + + int populate(); + bool isValid() const { return valid_; } +diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp +index 2949816b..eaa2fdb0 100644 +--- a/src/libcamera/media_device.cpp ++++ b/src/libcamera/media_device.cpp +@@ -159,12 +159,12 @@ bool MediaDevice::lock() + * + * \sa lock() + */ +-void MediaDevice::unlock() ++bool MediaDevice::unlock() + { + if (!fd_.isValid()) +- return; ++ return false; + +- lockf(fd_.get(), F_ULOCK, 0); ++ return lockf(fd_.get(), F_ULOCK, 0) == 0; + } + + /** +-- +2.43.0 + diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch new file mode 100644 index 000000000..a6526d590 --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch @@ -0,0 +1,34 @@ +From 7982e55ce3a8b3c60a47258ff7d37d0dd78c303d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 20 Feb 2024 18:44:23 -0800 +Subject: [PATCH] rpi: Use alloca instead of variable length arrays + +Clang-18+ diagnoses this as error + +| ../git/src/ipa/rpi/controller/rpi/alsc.cpp:499:10: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] | 499 | int xLo[X], xHi[X]; +| | ^ + +Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040529.html] +Signed-off-by: Khem Raj +--- + src/ipa/rpi/controller/rpi/alsc.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp +index 8a205c60..8c0ae8eb 100644 +--- a/src/ipa/rpi/controller/rpi/alsc.cpp ++++ b/src/ipa/rpi/controller/rpi/alsc.cpp +@@ -496,8 +496,8 @@ void resampleCalTable(const Array2D &calTableIn, + * Precalculate and cache the x sampling locations and phases to save + * recomputing them on every row. + */ +- int xLo[X], xHi[X]; +- double xf[X]; ++ int *xLo = (int*)alloca(X), *xHi = (int*)alloca(X); ++ double *xf = (double*)alloca(X); + double scaleX = cameraMode.sensorWidth / + (cameraMode.width * cameraMode.scaleX); + double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth; +-- +2.43.2 + diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch new file mode 100644 index 000000000..95f321782 --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch @@ -0,0 +1,91 @@ +From c80d273a57547aec9353d888aa316bf6560cf1ba Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 31 Jan 2024 21:04:28 -0800 +Subject: [PATCH 2/2] options: Replace use of VLAs in C++ + +Clang++ 18 is fussy about this with new warning checks. + + ../git/src/apps/common/options.cpp:882:20: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] + 882 | char shortOptions[optionsMap_.size() * 3 + 2]; + | ^~~~~~~~~~~~~~~~~~~~~~~~~~ + +Therefore replace using VLAs with alloca and malloc/free + +Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040381.html] +Signed-off-by: Khem Raj +--- + src/apps/common/options.cpp | 4 ++-- + src/libcamera/ipc_unixsocket.cpp | 12 ++++++++---- + 2 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp +index 4f7e8691..b020f603 100644 +--- a/src/apps/common/options.cpp ++++ b/src/apps/common/options.cpp +@@ -879,8 +879,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) + * Allocate short and long options arrays large enough to contain all + * options. + */ +- char shortOptions[optionsMap_.size() * 3 + 2]; +- struct option longOptions[optionsMap_.size() + 1]; ++ char *shortOptions = (char*)alloca(optionsMap_.size() * 3 + 2); ++ struct option *longOptions = (struct option*)alloca(optionsMap_.size() + 1); + unsigned int ids = 0; + unsigned int idl = 0; + +diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp +index 1980d374..3a7f8ee6 100644 +--- a/src/libcamera/ipc_unixsocket.cpp ++++ b/src/libcamera/ipc_unixsocket.cpp +@@ -247,8 +247,8 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, + iov[0].iov_base = const_cast(buffer); + iov[0].iov_len = length; + +- char buf[CMSG_SPACE(num * sizeof(uint32_t))]; +- memset(buf, 0, sizeof(buf)); ++ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); ++ memset((void*)buf, 0, sizeof(buf)); + + struct cmsghdr *cmsg = (struct cmsghdr *)buf; + cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); +@@ -270,9 +270,11 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, + int ret = -errno; + LOG(IPCUnixSocket, Error) + << "Failed to sendmsg: " << strerror(-ret); ++ free(buf); + return ret; + } + ++ free(buf); + return 0; + } + +@@ -283,8 +285,8 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, + iov[0].iov_base = buffer; + iov[0].iov_len = length; + +- char buf[CMSG_SPACE(num * sizeof(uint32_t))]; +- memset(buf, 0, sizeof(buf)); ++ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); ++ memset((void*)buf, 0, sizeof(buf)); + + struct cmsghdr *cmsg = (struct cmsghdr *)buf; + cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); +@@ -305,12 +307,14 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, + if (ret != -EAGAIN) + LOG(IPCUnixSocket, Error) + << "Failed to recvmsg: " << strerror(-ret); ++ free(buf); + return ret; + } + + if (fds) + memcpy(fds, CMSG_DATA(cmsg), num * sizeof(uint32_t)); + ++ free(buf); + return 0; + } + +-- +2.43.0 + diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_0.2.0.bb b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_0.2.0.bb new file mode 100644 index 000000000..3106b8984 --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libcamera/libcamera_0.2.0.bb @@ -0,0 +1,78 @@ +SUMMARY = "Linux libcamera framework" +SECTION = "libs" + +LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later" + +LIC_FILES_CHKSUM = "\ + file://LICENSES/GPL-2.0-or-later.txt;md5=fed54355545ffd980b814dab4a3b312c \ + file://LICENSES/LGPL-2.1-or-later.txt;md5=2a4f4fd2128ea2f65047ee63fbca9f68 \ +" + +SRC_URI = " \ + git://github.com/raspberrypi/libcamera.git;protocol=https;branch=main \ +" + +SRCREV = "075b54d5229d0894109e7cbb4bb890bc48bb37e8" + +PE = "1" + +S = "${WORKDIR}/git" + +DEPENDS = "python3-pyyaml-native python3-jinja2-native python3-ply-native python3-jinja2-native udev gnutls chrpath-native libevent libyaml lttng-ust python3-pybind11 libpisp" +DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'qt', 'qtbase qtbase-native', '', d)}" + +PACKAGES =+ "${PN}-gst" + +PACKAGECONFIG ??= "" +PACKAGECONFIG[gst] = "-Dgstreamer=enabled,-Dgstreamer=disabled,gstreamer1.0 gstreamer1.0-plugins-base" + +LIBCAMERA_PIPELINES ??= "auto" + +EXTRA_OEMESON = " \ + -Dpipelines=${LIBCAMERA_PIPELINES} \ + -Dv4l2=true \ + -Dcam=enabled \ + -Dlc-compliance=disabled \ + -Dtest=false \ + -Ddocumentation=disabled \ + -Dipas=rpi/vc4,rpi/pisp \ + -Dpipelines=rpi/vc4,rpi/pisp -Dipas=rpi/vc4,rpi/pisp -Dv4l2=true -Dgstreamer=enabled \ + -Dqcam=disabled \ + -Dpycamera=disabled \ +" + +RDEPENDS:${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'wayland qt', 'qtwayland', '', d)}" + +inherit meson pkgconfig python3native + +do_configure:prepend() { + sed -i -e 's|py_compile=True,||' ${S}/utils/ipc/mojo/public/tools/mojom/mojom/generate/template_expander.py +} + +do_install:append() { + chrpath -d ${D}${libdir}/libcamera.so + chrpath -d ${D}${libexecdir}/libcamera/v4l2-compat.so +} + +do_package:append() { + bb.build.exec_func("do_package_recalculate_ipa_signatures", d) +} + +do_package_recalculate_ipa_signatures() { + local modules + for module in $(find ${PKGD}/usr/lib/libcamera -name "*.so.sign"); do + module="${module%.sign}" + if [ -f "${module}" ] ; then + modules="${modules} ${module}" + fi + done + + ${S}/src/ipa/ipa-sign-install.sh ${B}/src/ipa-priv-key.pem "${modules}" +} + +FILES:${PN} += " ${libexecdir}/libcamera/v4l2-compat.so" +FILES:${PN}-gst = "${libdir}/gstreamer-1.0" + +# libcamera-v4l2 explicitly sets _FILE_OFFSET_BITS=32 to get access to +# both 32 and 64 bit file APIs. +GLIBC_64BIT_TIME_FLAGS = "" From 78ca8b8e89eee5f312937d61254efe022ff7be05 Mon Sep 17 00:00:00 2001 From: Mohsen Zahraee Date: Sun, 3 Mar 2024 12:18:54 +0330 Subject: [PATCH 3/4] add libisp for build with libcamera --- ...evice-Add-bool-return-type-to-unlock.patch | 59 ++++++++++++ ...ca-instead-of-variable-length-arrays.patch | 34 +++++++ ...002-options-Replace-use-of-VLAs-in-C.patch | 91 +++++++++++++++++++ .../recipes-multimedia/libpisp/libpisp.bb | 49 ++++++++++ 4 files changed, 233 insertions(+) create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch create mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libpisp.bb diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch new file mode 100644 index 000000000..12f034eff --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch @@ -0,0 +1,59 @@ +From 6914c4fd3d53c0c6ea304123bf57429bb64ec16f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 31 Jan 2024 21:01:27 -0800 +Subject: [PATCH 1/2] media_device: Add bool return type to unlock() + +unlock uses lockf which is marked with __attribute__ +((warn_unused_result)) and compilers warn about it and some treat +-Wunused-result as error with -Werror turned on, It would be good to +check if lockf failed or succeeded, however, that piece is not changed +with this, this fixes build with clang++ 18 + + ../git/src/libcamera/media_device.cpp:167:2: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result] + 167 | lockf(fd_.get(), F_ULOCK, 0); + | ^~~~~ ~~~~~~~~~~~~~~~~~~~~~ + 1 error generated. + +Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040380.html] +Signed-off-by: Khem Raj +--- + include/libcamera/internal/media_device.h | 2 +- + src/libcamera/media_device.cpp | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h +index eb8cfde4..b09dfd16 100644 +--- a/include/libcamera/internal/media_device.h ++++ b/include/libcamera/internal/media_device.h +@@ -33,7 +33,7 @@ public: + bool busy() const { return acquired_; } + + bool lock(); +- void unlock(); ++ bool unlock(); + + int populate(); + bool isValid() const { return valid_; } +diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp +index 2949816b..eaa2fdb0 100644 +--- a/src/libcamera/media_device.cpp ++++ b/src/libcamera/media_device.cpp +@@ -159,12 +159,12 @@ bool MediaDevice::lock() + * + * \sa lock() + */ +-void MediaDevice::unlock() ++bool MediaDevice::unlock() + { + if (!fd_.isValid()) +- return; ++ return false; + +- lockf(fd_.get(), F_ULOCK, 0); ++ return lockf(fd_.get(), F_ULOCK, 0) == 0; + } + + /** +-- +2.43.0 + diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch new file mode 100644 index 000000000..a6526d590 --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch @@ -0,0 +1,34 @@ +From 7982e55ce3a8b3c60a47258ff7d37d0dd78c303d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 20 Feb 2024 18:44:23 -0800 +Subject: [PATCH] rpi: Use alloca instead of variable length arrays + +Clang-18+ diagnoses this as error + +| ../git/src/ipa/rpi/controller/rpi/alsc.cpp:499:10: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] | 499 | int xLo[X], xHi[X]; +| | ^ + +Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040529.html] +Signed-off-by: Khem Raj +--- + src/ipa/rpi/controller/rpi/alsc.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp +index 8a205c60..8c0ae8eb 100644 +--- a/src/ipa/rpi/controller/rpi/alsc.cpp ++++ b/src/ipa/rpi/controller/rpi/alsc.cpp +@@ -496,8 +496,8 @@ void resampleCalTable(const Array2D &calTableIn, + * Precalculate and cache the x sampling locations and phases to save + * recomputing them on every row. + */ +- int xLo[X], xHi[X]; +- double xf[X]; ++ int *xLo = (int*)alloca(X), *xHi = (int*)alloca(X); ++ double *xf = (double*)alloca(X); + double scaleX = cameraMode.sensorWidth / + (cameraMode.width * cameraMode.scaleX); + double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth; +-- +2.43.2 + diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch new file mode 100644 index 000000000..95f321782 --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch @@ -0,0 +1,91 @@ +From c80d273a57547aec9353d888aa316bf6560cf1ba Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 31 Jan 2024 21:04:28 -0800 +Subject: [PATCH 2/2] options: Replace use of VLAs in C++ + +Clang++ 18 is fussy about this with new warning checks. + + ../git/src/apps/common/options.cpp:882:20: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] + 882 | char shortOptions[optionsMap_.size() * 3 + 2]; + | ^~~~~~~~~~~~~~~~~~~~~~~~~~ + +Therefore replace using VLAs with alloca and malloc/free + +Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040381.html] +Signed-off-by: Khem Raj +--- + src/apps/common/options.cpp | 4 ++-- + src/libcamera/ipc_unixsocket.cpp | 12 ++++++++---- + 2 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp +index 4f7e8691..b020f603 100644 +--- a/src/apps/common/options.cpp ++++ b/src/apps/common/options.cpp +@@ -879,8 +879,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) + * Allocate short and long options arrays large enough to contain all + * options. + */ +- char shortOptions[optionsMap_.size() * 3 + 2]; +- struct option longOptions[optionsMap_.size() + 1]; ++ char *shortOptions = (char*)alloca(optionsMap_.size() * 3 + 2); ++ struct option *longOptions = (struct option*)alloca(optionsMap_.size() + 1); + unsigned int ids = 0; + unsigned int idl = 0; + +diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp +index 1980d374..3a7f8ee6 100644 +--- a/src/libcamera/ipc_unixsocket.cpp ++++ b/src/libcamera/ipc_unixsocket.cpp +@@ -247,8 +247,8 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, + iov[0].iov_base = const_cast(buffer); + iov[0].iov_len = length; + +- char buf[CMSG_SPACE(num * sizeof(uint32_t))]; +- memset(buf, 0, sizeof(buf)); ++ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); ++ memset((void*)buf, 0, sizeof(buf)); + + struct cmsghdr *cmsg = (struct cmsghdr *)buf; + cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); +@@ -270,9 +270,11 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, + int ret = -errno; + LOG(IPCUnixSocket, Error) + << "Failed to sendmsg: " << strerror(-ret); ++ free(buf); + return ret; + } + ++ free(buf); + return 0; + } + +@@ -283,8 +285,8 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, + iov[0].iov_base = buffer; + iov[0].iov_len = length; + +- char buf[CMSG_SPACE(num * sizeof(uint32_t))]; +- memset(buf, 0, sizeof(buf)); ++ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); ++ memset((void*)buf, 0, sizeof(buf)); + + struct cmsghdr *cmsg = (struct cmsghdr *)buf; + cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); +@@ -305,12 +307,14 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, + if (ret != -EAGAIN) + LOG(IPCUnixSocket, Error) + << "Failed to recvmsg: " << strerror(-ret); ++ free(buf); + return ret; + } + + if (fds) + memcpy(fds, CMSG_DATA(cmsg), num * sizeof(uint32_t)); + ++ free(buf); + return 0; + } + +-- +2.43.0 + diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libpisp.bb b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libpisp.bb new file mode 100644 index 000000000..4d1bf97c2 --- /dev/null +++ b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libpisp.bb @@ -0,0 +1,49 @@ +SUMMARY = "Linux libcamera framework" +SECTION = "libs" + +LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later" + +LIC_FILES_CHKSUM = "\ + file://LICENSES/GPL-2.0-only.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ +" + +SRC_URI = " \ + git://github.com/raspberrypi/libpisp.git;protocol=https;branch=main \ +" + +SRCREV = "6e3a53d137f47bf359801a30b58e47efd3c7b8a3" + +PE = "1" + +S = "${WORKDIR}/git" + +DEPENDS = "nlohmann-json" +#DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'qt', 'qtbase qtbase-native', '', d)}" + +PACKAGES =+ "${PN}-gst" + +#PACKAGECONFIG ??= "" +#PACKAGECONFIG[gst] = "-Dgstreamer=enabled,-Dgstreamer=disabled,gstreamer1.0 gstreamer1.0-plugins-base" + +#LIBCAMERA_PIPELINES ??= "auto" + +EXTRA_OEMESON = " \ + " + +RDEPENDS:${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'wayland qt', 'qtwayland', '', d)}" + +inherit meson pkgconfig python3native + +do_configure:prepend() { + #sed -i -e 's|py_compile=True,||' ${S}/utils/ipc/mojo/public/tools/mojom/mojom/generate/template_expander.py +} + +do_install:append() { + #chrpath -d ${D}${libdir}/libcamera.so + #chrpath -d ${D}${libexecdir}/libcamera/v4l2-compat.so +} + + +# libcamera-v4l2 explicitly sets _FILE_OFFSET_BITS=32 to get access to +# both 32 and 64 bit file APIs. +GLIBC_64BIT_TIME_FLAGS = "" From 5aa9929eb3af097f26927fe9fe66d8c66578a8cf Mon Sep 17 00:00:00 2001 From: Mohsen Zahraee Date: Sun, 3 Mar 2024 18:36:32 +0330 Subject: [PATCH 4/4] delete wrong files --- ...evice-Add-bool-return-type-to-unlock.patch | 59 ------------ ...ca-instead-of-variable-length-arrays.patch | 34 ------- ...002-options-Replace-use-of-VLAs-in-C.patch | 91 ------------------- 3 files changed, 184 deletions(-) delete mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch delete mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch delete mode 100644 dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch deleted file mode 100644 index 12f034eff..000000000 --- a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-media_device-Add-bool-return-type-to-unlock.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 6914c4fd3d53c0c6ea304123bf57429bb64ec16f Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 31 Jan 2024 21:01:27 -0800 -Subject: [PATCH 1/2] media_device: Add bool return type to unlock() - -unlock uses lockf which is marked with __attribute__ -((warn_unused_result)) and compilers warn about it and some treat --Wunused-result as error with -Werror turned on, It would be good to -check if lockf failed or succeeded, however, that piece is not changed -with this, this fixes build with clang++ 18 - - ../git/src/libcamera/media_device.cpp:167:2: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result] - 167 | lockf(fd_.get(), F_ULOCK, 0); - | ^~~~~ ~~~~~~~~~~~~~~~~~~~~~ - 1 error generated. - -Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040380.html] -Signed-off-by: Khem Raj ---- - include/libcamera/internal/media_device.h | 2 +- - src/libcamera/media_device.cpp | 6 +++--- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h -index eb8cfde4..b09dfd16 100644 ---- a/include/libcamera/internal/media_device.h -+++ b/include/libcamera/internal/media_device.h -@@ -33,7 +33,7 @@ public: - bool busy() const { return acquired_; } - - bool lock(); -- void unlock(); -+ bool unlock(); - - int populate(); - bool isValid() const { return valid_; } -diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp -index 2949816b..eaa2fdb0 100644 ---- a/src/libcamera/media_device.cpp -+++ b/src/libcamera/media_device.cpp -@@ -159,12 +159,12 @@ bool MediaDevice::lock() - * - * \sa lock() - */ --void MediaDevice::unlock() -+bool MediaDevice::unlock() - { - if (!fd_.isValid()) -- return; -+ return false; - -- lockf(fd_.get(), F_ULOCK, 0); -+ return lockf(fd_.get(), F_ULOCK, 0) == 0; - } - - /** --- -2.43.0 - diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch deleted file mode 100644 index a6526d590..000000000 --- a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 7982e55ce3a8b3c60a47258ff7d37d0dd78c303d Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Tue, 20 Feb 2024 18:44:23 -0800 -Subject: [PATCH] rpi: Use alloca instead of variable length arrays - -Clang-18+ diagnoses this as error - -| ../git/src/ipa/rpi/controller/rpi/alsc.cpp:499:10: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] | 499 | int xLo[X], xHi[X]; -| | ^ - -Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040529.html] -Signed-off-by: Khem Raj ---- - src/ipa/rpi/controller/rpi/alsc.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp -index 8a205c60..8c0ae8eb 100644 ---- a/src/ipa/rpi/controller/rpi/alsc.cpp -+++ b/src/ipa/rpi/controller/rpi/alsc.cpp -@@ -496,8 +496,8 @@ void resampleCalTable(const Array2D &calTableIn, - * Precalculate and cache the x sampling locations and phases to save - * recomputing them on every row. - */ -- int xLo[X], xHi[X]; -- double xf[X]; -+ int *xLo = (int*)alloca(X), *xHi = (int*)alloca(X); -+ double *xf = (double*)alloca(X); - double scaleX = cameraMode.sensorWidth / - (cameraMode.width * cameraMode.scaleX); - double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth; --- -2.43.2 - diff --git a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch b/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch deleted file mode 100644 index 95f321782..000000000 --- a/dynamic-layers/multimedia-layer/recipes-multimedia/libpisp/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch +++ /dev/null @@ -1,91 +0,0 @@ -From c80d273a57547aec9353d888aa316bf6560cf1ba Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 31 Jan 2024 21:04:28 -0800 -Subject: [PATCH 2/2] options: Replace use of VLAs in C++ - -Clang++ 18 is fussy about this with new warning checks. - - ../git/src/apps/common/options.cpp:882:20: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] - 882 | char shortOptions[optionsMap_.size() * 3 + 2]; - | ^~~~~~~~~~~~~~~~~~~~~~~~~~ - -Therefore replace using VLAs with alloca and malloc/free - -Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040381.html] -Signed-off-by: Khem Raj ---- - src/apps/common/options.cpp | 4 ++-- - src/libcamera/ipc_unixsocket.cpp | 12 ++++++++---- - 2 files changed, 10 insertions(+), 6 deletions(-) - -diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp -index 4f7e8691..b020f603 100644 ---- a/src/apps/common/options.cpp -+++ b/src/apps/common/options.cpp -@@ -879,8 +879,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) - * Allocate short and long options arrays large enough to contain all - * options. - */ -- char shortOptions[optionsMap_.size() * 3 + 2]; -- struct option longOptions[optionsMap_.size() + 1]; -+ char *shortOptions = (char*)alloca(optionsMap_.size() * 3 + 2); -+ struct option *longOptions = (struct option*)alloca(optionsMap_.size() + 1); - unsigned int ids = 0; - unsigned int idl = 0; - -diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp -index 1980d374..3a7f8ee6 100644 ---- a/src/libcamera/ipc_unixsocket.cpp -+++ b/src/libcamera/ipc_unixsocket.cpp -@@ -247,8 +247,8 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, - iov[0].iov_base = const_cast(buffer); - iov[0].iov_len = length; - -- char buf[CMSG_SPACE(num * sizeof(uint32_t))]; -- memset(buf, 0, sizeof(buf)); -+ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); -+ memset((void*)buf, 0, sizeof(buf)); - - struct cmsghdr *cmsg = (struct cmsghdr *)buf; - cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); -@@ -270,9 +270,11 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, - int ret = -errno; - LOG(IPCUnixSocket, Error) - << "Failed to sendmsg: " << strerror(-ret); -+ free(buf); - return ret; - } - -+ free(buf); - return 0; - } - -@@ -283,8 +285,8 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, - iov[0].iov_base = buffer; - iov[0].iov_len = length; - -- char buf[CMSG_SPACE(num * sizeof(uint32_t))]; -- memset(buf, 0, sizeof(buf)); -+ char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); -+ memset((void*)buf, 0, sizeof(buf)); - - struct cmsghdr *cmsg = (struct cmsghdr *)buf; - cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); -@@ -305,12 +307,14 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, - if (ret != -EAGAIN) - LOG(IPCUnixSocket, Error) - << "Failed to recvmsg: " << strerror(-ret); -+ free(buf); - return ret; - } - - if (fds) - memcpy(fds, CMSG_DATA(cmsg), num * sizeof(uint32_t)); - -+ free(buf); - return 0; - } - --- -2.43.0 -