diff options
| author | Thomas Roos <throos@amazon.de> | 2025-01-21 07:53:46 +0100 |
|---|---|---|
| committer | Armin Kuster <akuster808@gmail.com> | 2025-02-04 14:40:32 -0800 |
| commit | 0bd3f27be016b7f0935b2ed5b0dc481689cf10ef (patch) | |
| tree | d0007c9ff3c38a239e4da0ae81c98999933afa51 | |
| parent | dda0d53326017d6758ec6bdfdaf2f484c089d13f (diff) | |
| download | meta-openembedded-0bd3f27be016b7f0935b2ed5b0dc481689cf10ef.tar.gz | |
libcamera: backport 0.4.0 from master-next
This is done because libcamera 0.2. is broken,
probablay because of 0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch
Tested good with upstream version.
See more details here:
https://github.com/openembedded/meta-openembedded/issues/919
and here:
https://github.com/raspberrypi/rpicam-apps/issues/654
Signed-off-by: Thomas Roos <throos@amazon.de>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
| -rw-r--r-- | meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipu3-Use-posix-basename.patch | 71 | ||||
| -rw-r--r-- | meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch | 43 | ||||
| -rw-r--r-- | meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch | 128 | ||||
| -rw-r--r-- | meta-multimedia/recipes-multimedia/libcamera/libcamera_0.4.0.bb (renamed from meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb) | 11 |
4 files changed, 5 insertions, 248 deletions
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipu3-Use-posix-basename.patch b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipu3-Use-posix-basename.patch deleted file mode 100644 index 9e4adf3d8d..0000000000 --- a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipu3-Use-posix-basename.patch +++ /dev/null | |||
| @@ -1,71 +0,0 @@ | |||
| 1 | From 35d2acc61b1b27c0810a80cd21de65f29dc79df7 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sun, 24 Mar 2024 11:27:21 -0700 | ||
| 4 | Subject: [PATCH] ipu3: Use posix basename | ||
| 5 | |||
| 6 | musl does not implement GNU basename extention and with latest musl | ||
| 7 | the prototype from string.h is also removed [1] which now results in | ||
| 8 | compile errors e.g. | ||
| 9 | |||
| 10 | ../git/utils/ipu3/ipu3-pack.c:21:47: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] | ||
| 11 | |||
| 12 | These utilities are using this function in usage() which is used just | ||
| 13 | before program exit. Always use the basename APIs from libgen.h which is | ||
| 14 | posix implementation | ||
| 15 | |||
| 16 | [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 | ||
| 17 | |||
| 18 | Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-March/041180.html] | ||
| 19 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 20 | --- | ||
| 21 | utils/ipu3/ipu3-pack.c | 4 ++-- | ||
| 22 | utils/ipu3/ipu3-unpack.c | 3 ++- | ||
| 23 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
| 24 | |||
| 25 | diff --git a/utils/ipu3/ipu3-pack.c b/utils/ipu3/ipu3-pack.c | ||
| 26 | index decbfc6c..23d2db8b 100644 | ||
| 27 | --- a/utils/ipu3/ipu3-pack.c | ||
| 28 | +++ b/utils/ipu3/ipu3-pack.c | ||
| 29 | @@ -8,6 +8,7 @@ | ||
| 30 | |||
| 31 | #include <errno.h> | ||
| 32 | #include <fcntl.h> | ||
| 33 | +#include <libgen.h> | ||
| 34 | #include <stdint.h> | ||
| 35 | #include <stdio.h> | ||
| 36 | #include <string.h> | ||
| 37 | @@ -15,9 +16,8 @@ | ||
| 38 | #include <sys/types.h> | ||
| 39 | #include <unistd.h> | ||
| 40 | |||
| 41 | -static void usage(const char *argv0) | ||
| 42 | +static void usage(char *argv0) | ||
| 43 | { | ||
| 44 | - | ||
| 45 | printf("Usage: %s input-file output-file\n", basename(argv0)); | ||
| 46 | printf("Convert unpacked RAW10 Bayer data to the IPU3 packed Bayer formats\n"); | ||
| 47 | printf("If the output-file '-', output data will be written to standard output\n"); | ||
| 48 | diff --git a/utils/ipu3/ipu3-unpack.c b/utils/ipu3/ipu3-unpack.c | ||
| 49 | index 9d2c1200..1505a970 100644 | ||
| 50 | --- a/utils/ipu3/ipu3-unpack.c | ||
| 51 | +++ b/utils/ipu3/ipu3-unpack.c | ||
| 52 | @@ -8,6 +8,7 @@ | ||
| 53 | |||
| 54 | #include <errno.h> | ||
| 55 | #include <fcntl.h> | ||
| 56 | +#include <libgen.h> | ||
| 57 | #include <stdint.h> | ||
| 58 | #include <stdio.h> | ||
| 59 | #include <string.h> | ||
| 60 | @@ -15,7 +16,7 @@ | ||
| 61 | #include <sys/types.h> | ||
| 62 | #include <unistd.h> | ||
| 63 | |||
| 64 | -static void usage(const char *argv0) | ||
| 65 | +static void usage(char *argv0) | ||
| 66 | { | ||
| 67 | printf("Usage: %s input-file output-file\n", basename(argv0)); | ||
| 68 | printf("Unpack the IPU3 raw Bayer format to 16-bit Bayer\n"); | ||
| 69 | -- | ||
| 70 | 2.44.0 | ||
| 71 | |||
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch deleted file mode 100644 index c336e92548..0000000000 --- a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | From 11cc6dbd45f0880beea64cdc514f57484b90bc39 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Tue, 20 Feb 2024 18:44:23 -0800 | ||
| 4 | Subject: [PATCH] rpi: Use malloc instead of variable length arrays | ||
| 5 | |||
| 6 | Clang-18+ diagnoses this as error | ||
| 7 | |||
| 8 | | ../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]; | ||
| 9 | | | ^ | ||
| 10 | |||
| 11 | Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040529.html] | ||
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 13 | |||
| 14 | s | ||
| 15 | --- | ||
| 16 | src/ipa/rpi/controller/rpi/alsc.cpp | 7 +++++-- | ||
| 17 | 1 file changed, 5 insertions(+), 2 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp | ||
| 20 | index 8a205c60..a7d42614 100644 | ||
| 21 | --- a/src/ipa/rpi/controller/rpi/alsc.cpp | ||
| 22 | +++ b/src/ipa/rpi/controller/rpi/alsc.cpp | ||
| 23 | @@ -496,8 +496,8 @@ void resampleCalTable(const Array2D<double> &calTableIn, | ||
| 24 | * Precalculate and cache the x sampling locations and phases to save | ||
| 25 | * recomputing them on every row. | ||
| 26 | */ | ||
| 27 | - int xLo[X], xHi[X]; | ||
| 28 | - double xf[X]; | ||
| 29 | + int *xLo = (int*)malloc(X), *xHi = (int*)malloc(X); | ||
| 30 | + double *xf = (double*)malloc(X); | ||
| 31 | double scaleX = cameraMode.sensorWidth / | ||
| 32 | (cameraMode.width * cameraMode.scaleX); | ||
| 33 | double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth; | ||
| 34 | @@ -539,6 +539,9 @@ void resampleCalTable(const Array2D<double> &calTableIn, | ||
| 35 | *(out++) = above * (1 - yf) + below * yf; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | + free(xf); | ||
| 39 | + free(xHi); | ||
| 40 | + free(xLo); | ||
| 41 | } | ||
| 42 | |||
| 43 | /* Calculate chrominance statistics (R/G and B/G) for each region. */ | ||
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch deleted file mode 100644 index 473820653e..0000000000 --- a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0002-options-Replace-use-of-VLAs-in-C.patch +++ /dev/null | |||
| @@ -1,128 +0,0 @@ | |||
| 1 | From 6e4736180fcaffdb06acf52fd3eb50ba5baa3d2a Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Wed, 31 Jan 2024 21:04:28 -0800 | ||
| 4 | Subject: [PATCH] options: Replace use of VLAs in C++ | ||
| 5 | |||
| 6 | Clang++ 18 is fussy about this with new warning checks. | ||
| 7 | |||
| 8 | ../git/src/apps/common/options.cpp:882:20: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] | ||
| 9 | 882 | char shortOptions[optionsMap_.size() * 3 + 2]; | ||
| 10 | | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 11 | |||
| 12 | Therefore replace using VLAs with alloca and malloc/free | ||
| 13 | |||
| 14 | Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2024-February/040381.html] | ||
| 15 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 16 | --- | ||
| 17 | src/apps/common/options.cpp | 12 ++++++++++-- | ||
| 18 | src/libcamera/ipc_unixsocket.cpp | 13 +++++++++---- | ||
| 19 | 2 files changed, 19 insertions(+), 6 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp | ||
| 22 | index 4f7e8691..3656f3c1 100644 | ||
| 23 | --- a/src/apps/common/options.cpp | ||
| 24 | +++ b/src/apps/common/options.cpp | ||
| 25 | @@ -879,8 +879,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) | ||
| 26 | * Allocate short and long options arrays large enough to contain all | ||
| 27 | * options. | ||
| 28 | */ | ||
| 29 | - char shortOptions[optionsMap_.size() * 3 + 2]; | ||
| 30 | - struct option longOptions[optionsMap_.size() + 1]; | ||
| 31 | + char *shortOptions = (char*)malloc(optionsMap_.size() * 3 + 2); | ||
| 32 | + struct option *longOptions = (struct option*)malloc(sizeof(struct option) * (optionsMap_.size() + 1)); | ||
| 33 | unsigned int ids = 0; | ||
| 34 | unsigned int idl = 0; | ||
| 35 | |||
| 36 | @@ -935,12 +935,16 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) | ||
| 37 | std::cerr << argv[optind - 1] << std::endl; | ||
| 38 | |||
| 39 | usage(); | ||
| 40 | + free(shortOptions); | ||
| 41 | + free(longOptions); | ||
| 42 | return options; | ||
| 43 | } | ||
| 44 | |||
| 45 | const Option &option = *optionsMap_[c]; | ||
| 46 | if (!parseValue(option, optarg, &options)) { | ||
| 47 | usage(); | ||
| 48 | + free(shortOptions); | ||
| 49 | + free(longOptions); | ||
| 50 | return options; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | @@ -949,10 +953,14 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) | ||
| 54 | std::cerr << "Invalid non-option argument '" << argv[optind] | ||
| 55 | << "'" << std::endl; | ||
| 56 | usage(); | ||
| 57 | + free(shortOptions); | ||
| 58 | + free(longOptions); | ||
| 59 | return options; | ||
| 60 | } | ||
| 61 | |||
| 62 | options.valid_ = true; | ||
| 63 | + free(shortOptions); | ||
| 64 | + free(longOptions); | ||
| 65 | return options; | ||
| 66 | } | ||
| 67 | |||
| 68 | diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp | ||
| 69 | index 1980d374..3bd861cb 100644 | ||
| 70 | --- a/src/libcamera/ipc_unixsocket.cpp | ||
| 71 | +++ b/src/libcamera/ipc_unixsocket.cpp | ||
| 72 | @@ -8,6 +8,7 @@ | ||
| 73 | #include "libcamera/internal/ipc_unixsocket.h" | ||
| 74 | |||
| 75 | #include <array> | ||
| 76 | +#include <cstdint> | ||
| 77 | #include <poll.h> | ||
| 78 | #include <string.h> | ||
| 79 | #include <sys/socket.h> | ||
| 80 | @@ -247,8 +248,8 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, | ||
| 81 | iov[0].iov_base = const_cast<void *>(buffer); | ||
| 82 | iov[0].iov_len = length; | ||
| 83 | |||
| 84 | - char buf[CMSG_SPACE(num * sizeof(uint32_t))]; | ||
| 85 | - memset(buf, 0, sizeof(buf)); | ||
| 86 | + char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); | ||
| 87 | + memset((void*)buf, 0, sizeof(buf)); | ||
| 88 | |||
| 89 | struct cmsghdr *cmsg = (struct cmsghdr *)buf; | ||
| 90 | cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); | ||
| 91 | @@ -270,9 +271,11 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length, | ||
| 92 | int ret = -errno; | ||
| 93 | LOG(IPCUnixSocket, Error) | ||
| 94 | << "Failed to sendmsg: " << strerror(-ret); | ||
| 95 | + free(buf); | ||
| 96 | return ret; | ||
| 97 | } | ||
| 98 | |||
| 99 | + free(buf); | ||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | |||
| 103 | @@ -283,8 +286,8 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, | ||
| 104 | iov[0].iov_base = buffer; | ||
| 105 | iov[0].iov_len = length; | ||
| 106 | |||
| 107 | - char buf[CMSG_SPACE(num * sizeof(uint32_t))]; | ||
| 108 | - memset(buf, 0, sizeof(buf)); | ||
| 109 | + char *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t))); | ||
| 110 | + memset((void*)buf, 0, sizeof(buf)); | ||
| 111 | |||
| 112 | struct cmsghdr *cmsg = (struct cmsghdr *)buf; | ||
| 113 | cmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t)); | ||
| 114 | @@ -305,12 +308,14 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, | ||
| 115 | if (ret != -EAGAIN) | ||
| 116 | LOG(IPCUnixSocket, Error) | ||
| 117 | << "Failed to recvmsg: " << strerror(-ret); | ||
| 118 | + free(buf); | ||
| 119 | return ret; | ||
| 120 | } | ||
| 121 | |||
| 122 | if (fds) | ||
| 123 | memcpy(fds, CMSG_DATA(cmsg), num * sizeof(uint32_t)); | ||
| 124 | |||
| 125 | + free(buf); | ||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.4.0.bb index 45d6be31ec..682e56739f 100644 --- a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.2.0.bb +++ b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.4.0.bb | |||
| @@ -11,12 +11,9 @@ LIC_FILES_CHKSUM = "\ | |||
| 11 | SRC_URI = " \ | 11 | SRC_URI = " \ |
| 12 | git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master \ | 12 | git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master \ |
| 13 | file://0001-media_device-Add-bool-return-type-to-unlock.patch \ | 13 | file://0001-media_device-Add-bool-return-type-to-unlock.patch \ |
| 14 | file://0002-options-Replace-use-of-VLAs-in-C.patch \ | ||
| 15 | file://0001-rpi-Use-alloca-instead-of-variable-length-arrays.patch \ | ||
| 16 | file://0001-ipu3-Use-posix-basename.patch \ | ||
| 17 | " | 14 | " |
| 18 | 15 | ||
| 19 | SRCREV = "89227a428a82e724548399d35c98ea89566f9045" | 16 | SRCREV = "35ed4b91291d9f3d08e4b51acfb51163e65df8f8" |
| 20 | 17 | ||
| 21 | PE = "1" | 18 | PE = "1" |
| 22 | 19 | ||
| @@ -25,10 +22,11 @@ S = "${WORKDIR}/git" | |||
| 25 | DEPENDS = "python3-pyyaml-native python3-jinja2-native python3-ply-native python3-jinja2-native udev gnutls chrpath-native libevent libyaml" | 22 | DEPENDS = "python3-pyyaml-native python3-jinja2-native python3-ply-native python3-jinja2-native udev gnutls chrpath-native libevent libyaml" |
| 26 | DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'qt', 'qtbase qtbase-native', '', d)}" | 23 | DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'qt', 'qtbase qtbase-native', '', d)}" |
| 27 | 24 | ||
| 28 | PACKAGES =+ "${PN}-gst" | 25 | PACKAGES =+ "${PN}-gst ${PN}-pycamera" |
| 29 | 26 | ||
| 30 | PACKAGECONFIG ??= "" | 27 | PACKAGECONFIG ??= "" |
| 31 | PACKAGECONFIG[gst] = "-Dgstreamer=enabled,-Dgstreamer=disabled,gstreamer1.0 gstreamer1.0-plugins-base" | 28 | PACKAGECONFIG[gst] = "-Dgstreamer=enabled,-Dgstreamer=disabled,gstreamer1.0 gstreamer1.0-plugins-base" |
| 29 | PACKAGECONFIG[pycamera] = "-Dpycamera=enabled,-Dpycamera=disabled,python3 python3-pybind11" | ||
| 32 | 30 | ||
| 33 | LIBCAMERA_PIPELINES ??= "auto" | 31 | LIBCAMERA_PIPELINES ??= "auto" |
| 34 | 32 | ||
| @@ -46,7 +44,7 @@ RDEPENDS:${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'wayland qt', 'qtwayla | |||
| 46 | inherit meson pkgconfig python3native | 44 | inherit meson pkgconfig python3native |
| 47 | 45 | ||
| 48 | do_configure:prepend() { | 46 | do_configure:prepend() { |
| 49 | sed -i -e 's|py_compile=True,||' ${S}/utils/ipc/mojo/public/tools/mojom/mojom/generate/template_expander.py | 47 | sed -i -e 's|py_compile=True,||' ${S}/utils/codegen/ipc/mojo/public/tools/mojom/mojom/generate/template_expander.py |
| 50 | } | 48 | } |
| 51 | 49 | ||
| 52 | do_install:append() { | 50 | do_install:append() { |
| @@ -72,6 +70,7 @@ do_package_recalculate_ipa_signatures() { | |||
| 72 | 70 | ||
| 73 | FILES:${PN} += " ${libexecdir}/libcamera/v4l2-compat.so" | 71 | FILES:${PN} += " ${libexecdir}/libcamera/v4l2-compat.so" |
| 74 | FILES:${PN}-gst = "${libdir}/gstreamer-1.0" | 72 | FILES:${PN}-gst = "${libdir}/gstreamer-1.0" |
| 73 | FILES:${PN}-pycamera = "${PYTHON_SITEPACKAGES_DIR}/libcamera" | ||
| 75 | 74 | ||
| 76 | # libcamera-v4l2 explicitly sets _FILE_OFFSET_BITS=32 to get access to | 75 | # libcamera-v4l2 explicitly sets _FILE_OFFSET_BITS=32 to get access to |
| 77 | # both 32 and 64 bit file APIs. | 76 | # both 32 and 64 bit file APIs. |
