[libcamera-devel,v7,0/5] generate and use fixed-sized Span Control types
mbox series

Message ID 20220604211148.188421-1-Rauch.Christian@gmx.de
Headers show
Series
  • generate and use fixed-sized Span Control types
Related show

Message

Christian Rauch June 4, 2022, 9:11 p.m. UTC
Hello,

Compared to the previous version, this 1) avoids a couple of more "value_or" fallbacks if the validity of a control value or property was previously checked with "contains" and 2) avoids references to potential invalid control values or properties. The last point fixes compiler errors reported by clang.

Best,

Christian Rauch (5):
  libcamera: controls: Use std::optional to handle invalid control
    values
  libcamera: ipu3: Fix rogue whitespace
  libcamera: controls: Define size of array controls as a shape vector
  libcamera: controls: Generate fixed- and variable-sized Span Controls
  libcamera: controls: Apply explicit fixed-sized Span type casts

 include/libcamera/controls.h                  |  7 ++--
 src/android/camera_capabilities.cpp           | 12 +++----
 src/android/camera_device.cpp                 | 21 ++++++------
 src/android/camera_hal_manager.cpp            |  2 +-
 src/cam/main.cpp                              |  4 +--
 src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++++------
 src/libcamera/control_ids.yaml                |  4 +--
 src/libcamera/pipeline/ipu3/ipu3.cpp          | 11 +++----
 .../pipeline/raspberrypi/raspberrypi.cpp      |  9 +++---
 src/libcamera/property_ids.yaml               |  4 +--
 src/qcam/dng_writer.cpp                       | 22 ++++++-------
 utils/gen-controls.py                         | 32 +++++++++++++------
 12 files changed, 81 insertions(+), 68 deletions(-)

--
2.34.1

Comments

Laurent Pinchart June 4, 2022, 10:47 p.m. UTC | #1
Hi Christian,

Thank you for the patches.

On Sat, Jun 04, 2022 at 10:11:43PM +0100, Christian Rauch via libcamera-devel wrote:
> Hello,
> 
> Compared to the previous version, this 1) avoids a couple of more
> "value_or" fallbacks if the validity of a control value or property
> was previously checked with "contains" and 2) avoids references to
> potential invalid control values or properties. The last point fixes
> compiler errors reported by clang.

I'm afraid I'm still seeing compilation errors :-( Here are a few:


aarch64-buildroot-linux-gnu-g++ -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
In file included from ../../include/libcamera/camera.h:20,
                 from ../../src/android/camera_capabilities.h:17,
                 from ../../src/android/camera_capabilities.cpp:8:
In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
    inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
../../include/libcamera/controls.h:381:37: error: ‘*(const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::<unnamed>))’ may be used uninitialized [-Werror=maybe-uninitialized]
  381 |                         return std::nullopt;
      |                                     ^~~~~~~
../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
  381 |                         return std::nullopt;
      |                                     ^~~~~~~
In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
    inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
../../include/libcamera/controls.h:381:37: error: ‘((const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::_M_payload.std::_Optional_payload<libcamera::Size, true, true, true>::<unnamed>.std::_Optional_payload_base<libcamera::Size>::_M_payload)))[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
  381 |                         return std::nullopt;
      |                                     ^~~~~~~
../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
  381 |                         return std::nullopt;
      |                                     ^~~~~~~


g++-10.3.1 -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/libexif -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
In file included from ../../include/libcamera/camera.h:20,
                 from ../../src/android/camera_capabilities.h:17,
                 from ../../src/android/camera_capabilities.cpp:8:
../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
../../include/libcamera/controls.h:381:16: error: ‘<anonymous>’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  381 |    return std::nullopt;
      |                ^~~~~~~
../../include/libcamera/controls.h:381:16: error: ‘*((void*)&<anonymous> +4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]


g++-8.4.0 -Isrc/ipa/raspberrypi/ipa_rpi.so.p -Isrc/ipa/raspberrypi -I../../src/ipa/raspberrypi -Iinclude -I../../include -Isrc/ipa -I../../src/ipa -I../../src/ipa/raspberrypi/controller -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wl,--start-group -lstdc++fs -Wl,--end-group -Wshadow -include config.h -fPIC -DBOOST_ALL_NO_LIB -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -MF src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o.d -o src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -c ../../src/ipa/raspberrypi/raspberrypi.cpp
../../src/ipa/raspberrypi/raspberrypi.cpp: In member function ‘void libcamera::ipa::RPi::IPARPi::reportMetadata()’:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: error: no matching function for call to ‘libcamera::Span<const int, 4>::Span(<brace-enclosed initializer list>)’
         blackLevelStatus->black_level_b }));
                                          ^
In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
../../include/libcamera/base/span.h:189:12: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<T, Extent>&) [with T = const int; long unsigned int Extent = 4]’
  constexpr Span(const Span &other) noexcept = default;
            ^~~~
../../include/libcamera/base/span.h:189:12: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const libcamera::Span<const int, 4>&’
../../include/libcamera/base/span.h:181:21: note: candidate: ‘template<class U, long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<U, N>&, std::enable_if_t<(std::is_convertible<_Up (*)[], _Tp (*)[]>::value && (N == Extent)), std::nullptr_t>)’
  explicit constexpr Span(const Span<U, N> &s,
                     ^~~~
../../include/libcamera/base/span.h:181:21: note:   template argument deduction/substitution failed:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘U’
         blackLevelStatus->black_level_b }));
                                          ^
In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
../../include/libcamera/base/span.h:168:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(const Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
  explicit constexpr Span(const Container &cont,
                     ^~~~
../../include/libcamera/base/span.h:168:21: note:   template argument deduction/substitution failed:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
         blackLevelStatus->black_level_b }));
                                          ^
In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
../../include/libcamera/base/span.h:156:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
  explicit constexpr Span(Container &cont,
                     ^~~~
../../include/libcamera/base/span.h:156:21: note:   template argument deduction/substitution failed:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
         blackLevelStatus->black_level_b }));
                                          ^
In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
../../include/libcamera/base/span.h:146:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
  constexpr Span(const std::array<value_type, N> &arr,
            ^~~~
../../include/libcamera/base/span.h:146:12: note:   template argument deduction/substitution failed:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
         blackLevelStatus->black_level_b }));
                                          ^
In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
../../include/libcamera/base/span.h:136:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
  constexpr Span(std::array<value_type, N> &arr,
            ^~~~
../../include/libcamera/base/span.h:136:12: note:   template argument deduction/substitution failed:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
         blackLevelStatus->black_level_b }));
                                          ^
In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
../../include/libcamera/base/span.h:126:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::element_type (&)[N], std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
  constexpr Span(element_type (&arr)[N],
            ^~~~
../../include/libcamera/base/span.h:126:12: note:   template argument deduction/substitution failed:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   mismatched types ‘int’ and ‘short unsigned int’
         blackLevelStatus->black_level_b }));
                                          ^
In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
../../include/libcamera/base/span.h:120:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::pointer) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*]’
  explicit constexpr Span(pointer first, [[maybe_unused]] pointer last)
                     ^~~~
../../include/libcamera/base/span.h:120:21: note:   candidate expects 2 arguments, 1 provided
../../include/libcamera/base/span.h:115:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::size_type) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*; libcamera::Span<T, Extent>::size_type = long unsigned int]’
  explicit constexpr Span(pointer ptr, [[maybe_unused]] size_type count)
                     ^~~~
../../include/libcamera/base/span.h:115:21: note:   candidate expects 2 arguments, 1 provided
../../include/libcamera/base/span.h:110:12: note: candidate: ‘template<bool Dependent, class> constexpr libcamera::Span<T, Extent>::Span()’
  constexpr Span() noexcept
            ^~~~
../../include/libcamera/base/span.h:110:12: note:   template argument deduction/substitution failed:
../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   candidate expects 0 arguments, 1 provided
         blackLevelStatus->black_level_b }));
                                          ^

> Christian Rauch (5):
>   libcamera: controls: Use std::optional to handle invalid control
>     values
>   libcamera: ipu3: Fix rogue whitespace
>   libcamera: controls: Define size of array controls as a shape vector
>   libcamera: controls: Generate fixed- and variable-sized Span Controls
>   libcamera: controls: Apply explicit fixed-sized Span type casts
> 
>  include/libcamera/controls.h                  |  7 ++--
>  src/android/camera_capabilities.cpp           | 12 +++----
>  src/android/camera_device.cpp                 | 21 ++++++------
>  src/android/camera_hal_manager.cpp            |  2 +-
>  src/cam/main.cpp                              |  4 +--
>  src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++++------
>  src/libcamera/control_ids.yaml                |  4 +--
>  src/libcamera/pipeline/ipu3/ipu3.cpp          | 11 +++----
>  .../pipeline/raspberrypi/raspberrypi.cpp      |  9 +++---
>  src/libcamera/property_ids.yaml               |  4 +--
>  src/qcam/dng_writer.cpp                       | 22 ++++++-------
>  utils/gen-controls.py                         | 32 +++++++++++++------
>  12 files changed, 81 insertions(+), 68 deletions(-)
Christian Rauch June 4, 2022, 11:13 p.m. UTC | #2
Hi Laurent,

Can you let me know which commands (full command line) you run to
configure and build the project?

I tried this with gcc:
  CC=gcc-12 CXX=g++-12 meson build -Dandroid=enabled -Dwarning_level=2

and clang:
  CC=clang CXX=clang++ meson build -Dandroid=enabled -Dwarning_level=2

on Ubuntu 22.04, but I cannot reproduce this.

Are you cross-compiling this?

Best,
Christian


Am 04.06.22 um 23:47 schrieb Laurent Pinchart:
> Hi Christian,
>
> Thank you for the patches.
>
> On Sat, Jun 04, 2022 at 10:11:43PM +0100, Christian Rauch via libcamera-devel wrote:
>> Hello,
>>
>> Compared to the previous version, this 1) avoids a couple of more
>> "value_or" fallbacks if the validity of a control value or property
>> was previously checked with "contains" and 2) avoids references to
>> potential invalid control values or properties. The last point fixes
>> compiler errors reported by clang.
>
> I'm afraid I'm still seeing compilation errors :-( Here are a few:
>
>
> aarch64-buildroot-linux-gnu-g++ -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> In file included from ../../include/libcamera/camera.h:20,
>                  from ../../src/android/camera_capabilities.h:17,
>                  from ../../src/android/camera_capabilities.cpp:8:
> In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
>     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> ../../include/libcamera/controls.h:381:37: error: ‘*(const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::<unnamed>))’ may be used uninitialized [-Werror=maybe-uninitialized]
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
> In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
>     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> ../../include/libcamera/controls.h:381:37: error: ‘((const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::_M_payload.std::_Optional_payload<libcamera::Size, true, true, true>::<unnamed>.std::_Optional_payload_base<libcamera::Size>::_M_payload)))[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
>
>
> g++-10.3.1 -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/libexif -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> In file included from ../../include/libcamera/camera.h:20,
>                  from ../../src/android/camera_capabilities.h:17,
>                  from ../../src/android/camera_capabilities.cpp:8:
> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> ../../include/libcamera/controls.h:381:16: error: ‘<anonymous>’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   381 |    return std::nullopt;
>       |                ^~~~~~~
> ../../include/libcamera/controls.h:381:16: error: ‘*((void*)&<anonymous> +4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
>
> g++-8.4.0 -Isrc/ipa/raspberrypi/ipa_rpi.so.p -Isrc/ipa/raspberrypi -I../../src/ipa/raspberrypi -Iinclude -I../../include -Isrc/ipa -I../../src/ipa -I../../src/ipa/raspberrypi/controller -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wl,--start-group -lstdc++fs -Wl,--end-group -Wshadow -include config.h -fPIC -DBOOST_ALL_NO_LIB -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -MF src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o.d -o src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -c ../../src/ipa/raspberrypi/raspberrypi.cpp
> ../../src/ipa/raspberrypi/raspberrypi.cpp: In member function ‘void libcamera::ipa::RPi::IPARPi::reportMetadata()’:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: error: no matching function for call to ‘libcamera::Span<const int, 4>::Span(<brace-enclosed initializer list>)’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:189:12: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<T, Extent>&) [with T = const int; long unsigned int Extent = 4]’
>   constexpr Span(const Span &other) noexcept = default;
>             ^~~~
> ../../include/libcamera/base/span.h:189:12: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const libcamera::Span<const int, 4>&’
> ../../include/libcamera/base/span.h:181:21: note: candidate: ‘template<class U, long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<U, N>&, std::enable_if_t<(std::is_convertible<_Up (*)[], _Tp (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   explicit constexpr Span(const Span<U, N> &s,
>                      ^~~~
> ../../include/libcamera/base/span.h:181:21: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘U’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:168:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(const Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
>   explicit constexpr Span(const Container &cont,
>                      ^~~~
> ../../include/libcamera/base/span.h:168:21: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:156:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
>   explicit constexpr Span(Container &cont,
>                      ^~~~
> ../../include/libcamera/base/span.h:156:21: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:146:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   constexpr Span(const std::array<value_type, N> &arr,
>             ^~~~
> ../../include/libcamera/base/span.h:146:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:136:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   constexpr Span(std::array<value_type, N> &arr,
>             ^~~~
> ../../include/libcamera/base/span.h:136:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:126:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::element_type (&)[N], std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   constexpr Span(element_type (&arr)[N],
>             ^~~~
> ../../include/libcamera/base/span.h:126:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   mismatched types ‘int’ and ‘short unsigned int’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:120:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::pointer) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*]’
>   explicit constexpr Span(pointer first, [[maybe_unused]] pointer last)
>                      ^~~~
> ../../include/libcamera/base/span.h:120:21: note:   candidate expects 2 arguments, 1 provided
> ../../include/libcamera/base/span.h:115:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::size_type) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*; libcamera::Span<T, Extent>::size_type = long unsigned int]’
>   explicit constexpr Span(pointer ptr, [[maybe_unused]] size_type count)
>                      ^~~~
> ../../include/libcamera/base/span.h:115:21: note:   candidate expects 2 arguments, 1 provided
> ../../include/libcamera/base/span.h:110:12: note: candidate: ‘template<bool Dependent, class> constexpr libcamera::Span<T, Extent>::Span()’
>   constexpr Span() noexcept
>             ^~~~
> ../../include/libcamera/base/span.h:110:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   candidate expects 0 arguments, 1 provided
>          blackLevelStatus->black_level_b }));
>                                           ^
>
>> Christian Rauch (5):
>>   libcamera: controls: Use std::optional to handle invalid control
>>     values
>>   libcamera: ipu3: Fix rogue whitespace
>>   libcamera: controls: Define size of array controls as a shape vector
>>   libcamera: controls: Generate fixed- and variable-sized Span Controls
>>   libcamera: controls: Apply explicit fixed-sized Span type casts
>>
>>  include/libcamera/controls.h                  |  7 ++--
>>  src/android/camera_capabilities.cpp           | 12 +++----
>>  src/android/camera_device.cpp                 | 21 ++++++------
>>  src/android/camera_hal_manager.cpp            |  2 +-
>>  src/cam/main.cpp                              |  4 +--
>>  src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++++------
>>  src/libcamera/control_ids.yaml                |  4 +--
>>  src/libcamera/pipeline/ipu3/ipu3.cpp          | 11 +++----
>>  .../pipeline/raspberrypi/raspberrypi.cpp      |  9 +++---
>>  src/libcamera/property_ids.yaml               |  4 +--
>>  src/qcam/dng_writer.cpp                       | 22 ++++++-------
>>  utils/gen-controls.py                         | 32 +++++++++++++------
>>  12 files changed, 81 insertions(+), 68 deletions(-)
>
Christian Rauch June 6, 2022, 9:55 a.m. UTC | #3
Hi Laurent,

I set up a CI workflow on GitHub for building libcamera on amd64 [1] and
aarch64 [2] with g++ and clang++.

All of those setups pass the build without issues [3], [4].

Do you have an idea how I have to change the configuration to reproduce
the issues that you encountered?

Best,
Christian

[1]
https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main.yml
[2]
https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main_aarch64.yml

[3] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079999
[4] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079998


Am 04.06.22 um 23:47 schrieb Laurent Pinchart:
> Hi Christian,
>
> Thank you for the patches.
>
> On Sat, Jun 04, 2022 at 10:11:43PM +0100, Christian Rauch via libcamera-devel wrote:
>> Hello,
>>
>> Compared to the previous version, this 1) avoids a couple of more
>> "value_or" fallbacks if the validity of a control value or property
>> was previously checked with "contains" and 2) avoids references to
>> potential invalid control values or properties. The last point fixes
>> compiler errors reported by clang.
>
> I'm afraid I'm still seeing compilation errors :-( Here are a few:
>
>
> aarch64-buildroot-linux-gnu-g++ -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> In file included from ../../include/libcamera/camera.h:20,
>                  from ../../src/android/camera_capabilities.h:17,
>                  from ../../src/android/camera_capabilities.cpp:8:
> In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
>     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> ../../include/libcamera/controls.h:381:37: error: ‘*(const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::<unnamed>))’ may be used uninitialized [-Werror=maybe-uninitialized]
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
> In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
>     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> ../../include/libcamera/controls.h:381:37: error: ‘((const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::_M_payload.std::_Optional_payload<libcamera::Size, true, true, true>::<unnamed>.std::_Optional_payload_base<libcamera::Size>::_M_payload)))[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
>   381 |                         return std::nullopt;
>       |                                     ^~~~~~~
>
>
> g++-10.3.1 -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/libexif -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> In file included from ../../include/libcamera/camera.h:20,
>                  from ../../src/android/camera_capabilities.h:17,
>                  from ../../src/android/camera_capabilities.cpp:8:
> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> ../../include/libcamera/controls.h:381:16: error: ‘<anonymous>’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   381 |    return std::nullopt;
>       |                ^~~~~~~
> ../../include/libcamera/controls.h:381:16: error: ‘*((void*)&<anonymous> +4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
>
> g++-8.4.0 -Isrc/ipa/raspberrypi/ipa_rpi.so.p -Isrc/ipa/raspberrypi -I../../src/ipa/raspberrypi -Iinclude -I../../include -Isrc/ipa -I../../src/ipa -I../../src/ipa/raspberrypi/controller -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wl,--start-group -lstdc++fs -Wl,--end-group -Wshadow -include config.h -fPIC -DBOOST_ALL_NO_LIB -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -MF src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o.d -o src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -c ../../src/ipa/raspberrypi/raspberrypi.cpp
> ../../src/ipa/raspberrypi/raspberrypi.cpp: In member function ‘void libcamera::ipa::RPi::IPARPi::reportMetadata()’:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: error: no matching function for call to ‘libcamera::Span<const int, 4>::Span(<brace-enclosed initializer list>)’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:189:12: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<T, Extent>&) [with T = const int; long unsigned int Extent = 4]’
>   constexpr Span(const Span &other) noexcept = default;
>             ^~~~
> ../../include/libcamera/base/span.h:189:12: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const libcamera::Span<const int, 4>&’
> ../../include/libcamera/base/span.h:181:21: note: candidate: ‘template<class U, long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<U, N>&, std::enable_if_t<(std::is_convertible<_Up (*)[], _Tp (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   explicit constexpr Span(const Span<U, N> &s,
>                      ^~~~
> ../../include/libcamera/base/span.h:181:21: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘U’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:168:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(const Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
>   explicit constexpr Span(const Container &cont,
>                      ^~~~
> ../../include/libcamera/base/span.h:168:21: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:156:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
>   explicit constexpr Span(Container &cont,
>                      ^~~~
> ../../include/libcamera/base/span.h:156:21: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:146:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   constexpr Span(const std::array<value_type, N> &arr,
>             ^~~~
> ../../include/libcamera/base/span.h:146:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:136:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   constexpr Span(std::array<value_type, N> &arr,
>             ^~~~
> ../../include/libcamera/base/span.h:136:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:126:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::element_type (&)[N], std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>   constexpr Span(element_type (&arr)[N],
>             ^~~~
> ../../include/libcamera/base/span.h:126:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   mismatched types ‘int’ and ‘short unsigned int’
>          blackLevelStatus->black_level_b }));
>                                           ^
> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> ../../include/libcamera/base/span.h:120:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::pointer) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*]’
>   explicit constexpr Span(pointer first, [[maybe_unused]] pointer last)
>                      ^~~~
> ../../include/libcamera/base/span.h:120:21: note:   candidate expects 2 arguments, 1 provided
> ../../include/libcamera/base/span.h:115:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::size_type) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*; libcamera::Span<T, Extent>::size_type = long unsigned int]’
>   explicit constexpr Span(pointer ptr, [[maybe_unused]] size_type count)
>                      ^~~~
> ../../include/libcamera/base/span.h:115:21: note:   candidate expects 2 arguments, 1 provided
> ../../include/libcamera/base/span.h:110:12: note: candidate: ‘template<bool Dependent, class> constexpr libcamera::Span<T, Extent>::Span()’
>   constexpr Span() noexcept
>             ^~~~
> ../../include/libcamera/base/span.h:110:12: note:   template argument deduction/substitution failed:
> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   candidate expects 0 arguments, 1 provided
>          blackLevelStatus->black_level_b }));
>                                           ^
>
>> Christian Rauch (5):
>>   libcamera: controls: Use std::optional to handle invalid control
>>     values
>>   libcamera: ipu3: Fix rogue whitespace
>>   libcamera: controls: Define size of array controls as a shape vector
>>   libcamera: controls: Generate fixed- and variable-sized Span Controls
>>   libcamera: controls: Apply explicit fixed-sized Span type casts
>>
>>  include/libcamera/controls.h                  |  7 ++--
>>  src/android/camera_capabilities.cpp           | 12 +++----
>>  src/android/camera_device.cpp                 | 21 ++++++------
>>  src/android/camera_hal_manager.cpp            |  2 +-
>>  src/cam/main.cpp                              |  4 +--
>>  src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++++------
>>  src/libcamera/control_ids.yaml                |  4 +--
>>  src/libcamera/pipeline/ipu3/ipu3.cpp          | 11 +++----
>>  .../pipeline/raspberrypi/raspberrypi.cpp      |  9 +++---
>>  src/libcamera/property_ids.yaml               |  4 +--
>>  src/qcam/dng_writer.cpp                       | 22 ++++++-------
>>  utils/gen-controls.py                         | 32 +++++++++++++------
>>  12 files changed, 81 insertions(+), 68 deletions(-)
>
Kieran Bingham June 7, 2022, 10:41 p.m. UTC | #4
Quoting Christian Rauch via libcamera-devel (2022-06-06 10:55:18)
> Hi Laurent,
> 
> I set up a CI workflow on GitHub for building libcamera on amd64 [1] and
> aarch64 [2] with g++ and clang++.

If we merge these files in our repository - will they run for any user
who pushes a branch on their own fork of libcamera on github?

If so - perhaps we should add them.


> All of those setups pass the build without issues [3], [4].
> 
> Do you have an idea how I have to change the configuration to reproduce
> the issues that you encountered?

These look like they're running an emultated aarch64 environment to be
able to use arm64 compilers 'natively'.

I wonder if the difference is due to using a native compiler vs a cross
compiler.

I've been building a docker container that supports cross compilation
for RPi/ARM64 - So I wonder if we can also pre-build some containers
with the dependencies met to speed up builds of multiple different
configurations (and tests) without spending all the CI cycles installing
packages...

--
Kieran


> 
> Best,
> Christian
> 
> [1]
> https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main.yml
> [2]
> https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main_aarch64.yml
> 
> [3] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079999
> [4] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079998
> 
> 
> Am 04.06.22 um 23:47 schrieb Laurent Pinchart:
> > Hi Christian,
> >
> > Thank you for the patches.
> >
> > On Sat, Jun 04, 2022 at 10:11:43PM +0100, Christian Rauch via libcamera-devel wrote:
> >> Hello,
> >>
> >> Compared to the previous version, this 1) avoids a couple of more
> >> "value_or" fallbacks if the validity of a control value or property
> >> was previously checked with "contains" and 2) avoids references to
> >> potential invalid control values or properties. The last point fixes
> >> compiler errors reported by clang.
> >
> > I'm afraid I'm still seeing compilation errors :-( Here are a few:
> >
> >
> > aarch64-buildroot-linux-gnu-g++ -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> > In file included from ../../include/libcamera/camera.h:20,
> >                  from ../../src/android/camera_capabilities.h:17,
> >                  from ../../src/android/camera_capabilities.cpp:8:
> > In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
> >     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> > ../../include/libcamera/controls.h:381:37: error: ‘*(const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::<unnamed>))’ may be used uninitialized [-Werror=maybe-uninitialized]
> >   381 |                         return std::nullopt;
> >       |                                     ^~~~~~~
> > ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> > ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
> >   381 |                         return std::nullopt;
> >       |                                     ^~~~~~~
> > In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
> >     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> > ../../include/libcamera/controls.h:381:37: error: ‘((const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::_M_payload.std::_Optional_payload<libcamera::Size, true, true, true>::<unnamed>.std::_Optional_payload_base<libcamera::Size>::_M_payload)))[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
> >   381 |                         return std::nullopt;
> >       |                                     ^~~~~~~
> > ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> > ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
> >   381 |                         return std::nullopt;
> >       |                                     ^~~~~~~
> >
> >
> > g++-10.3.1 -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/libexif -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> > In file included from ../../include/libcamera/camera.h:20,
> >                  from ../../src/android/camera_capabilities.h:17,
> >                  from ../../src/android/camera_capabilities.cpp:8:
> > ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> > ../../include/libcamera/controls.h:381:16: error: ‘<anonymous>’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >   381 |    return std::nullopt;
> >       |                ^~~~~~~
> > ../../include/libcamera/controls.h:381:16: error: ‘*((void*)&<anonymous> +4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >
> >
> > g++-8.4.0 -Isrc/ipa/raspberrypi/ipa_rpi.so.p -Isrc/ipa/raspberrypi -I../../src/ipa/raspberrypi -Iinclude -I../../include -Isrc/ipa -I../../src/ipa -I../../src/ipa/raspberrypi/controller -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wl,--start-group -lstdc++fs -Wl,--end-group -Wshadow -include config.h -fPIC -DBOOST_ALL_NO_LIB -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -MF src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o.d -o src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -c ../../src/ipa/raspberrypi/raspberrypi.cpp
> > ../../src/ipa/raspberrypi/raspberrypi.cpp: In member function ‘void libcamera::ipa::RPi::IPARPi::reportMetadata()’:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: error: no matching function for call to ‘libcamera::Span<const int, 4>::Span(<brace-enclosed initializer list>)’
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > ../../include/libcamera/base/span.h:189:12: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<T, Extent>&) [with T = const int; long unsigned int Extent = 4]’
> >   constexpr Span(const Span &other) noexcept = default;
> >             ^~~~
> > ../../include/libcamera/base/span.h:189:12: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const libcamera::Span<const int, 4>&’
> > ../../include/libcamera/base/span.h:181:21: note: candidate: ‘template<class U, long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<U, N>&, std::enable_if_t<(std::is_convertible<_Up (*)[], _Tp (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> >   explicit constexpr Span(const Span<U, N> &s,
> >                      ^~~~
> > ../../include/libcamera/base/span.h:181:21: note:   template argument deduction/substitution failed:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘U’
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > ../../include/libcamera/base/span.h:168:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(const Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
> >   explicit constexpr Span(const Container &cont,
> >                      ^~~~
> > ../../include/libcamera/base/span.h:168:21: note:   template argument deduction/substitution failed:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > ../../include/libcamera/base/span.h:156:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
> >   explicit constexpr Span(Container &cont,
> >                      ^~~~
> > ../../include/libcamera/base/span.h:156:21: note:   template argument deduction/substitution failed:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > ../../include/libcamera/base/span.h:146:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> >   constexpr Span(const std::array<value_type, N> &arr,
> >             ^~~~
> > ../../include/libcamera/base/span.h:146:12: note:   template argument deduction/substitution failed:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > ../../include/libcamera/base/span.h:136:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> >   constexpr Span(std::array<value_type, N> &arr,
> >             ^~~~
> > ../../include/libcamera/base/span.h:136:12: note:   template argument deduction/substitution failed:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > ../../include/libcamera/base/span.h:126:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::element_type (&)[N], std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> >   constexpr Span(element_type (&arr)[N],
> >             ^~~~
> > ../../include/libcamera/base/span.h:126:12: note:   template argument deduction/substitution failed:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   mismatched types ‘int’ and ‘short unsigned int’
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > ../../include/libcamera/base/span.h:120:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::pointer) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*]’
> >   explicit constexpr Span(pointer first, [[maybe_unused]] pointer last)
> >                      ^~~~
> > ../../include/libcamera/base/span.h:120:21: note:   candidate expects 2 arguments, 1 provided
> > ../../include/libcamera/base/span.h:115:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::size_type) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*; libcamera::Span<T, Extent>::size_type = long unsigned int]’
> >   explicit constexpr Span(pointer ptr, [[maybe_unused]] size_type count)
> >                      ^~~~
> > ../../include/libcamera/base/span.h:115:21: note:   candidate expects 2 arguments, 1 provided
> > ../../include/libcamera/base/span.h:110:12: note: candidate: ‘template<bool Dependent, class> constexpr libcamera::Span<T, Extent>::Span()’
> >   constexpr Span() noexcept
> >             ^~~~
> > ../../include/libcamera/base/span.h:110:12: note:   template argument deduction/substitution failed:
> > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   candidate expects 0 arguments, 1 provided
> >          blackLevelStatus->black_level_b }));
> >                                           ^
> >
> >> Christian Rauch (5):
> >>   libcamera: controls: Use std::optional to handle invalid control
> >>     values
> >>   libcamera: ipu3: Fix rogue whitespace
> >>   libcamera: controls: Define size of array controls as a shape vector
> >>   libcamera: controls: Generate fixed- and variable-sized Span Controls
> >>   libcamera: controls: Apply explicit fixed-sized Span type casts
> >>
> >>  include/libcamera/controls.h                  |  7 ++--
> >>  src/android/camera_capabilities.cpp           | 12 +++----
> >>  src/android/camera_device.cpp                 | 21 ++++++------
> >>  src/android/camera_hal_manager.cpp            |  2 +-
> >>  src/cam/main.cpp                              |  4 +--
> >>  src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++++------
> >>  src/libcamera/control_ids.yaml                |  4 +--
> >>  src/libcamera/pipeline/ipu3/ipu3.cpp          | 11 +++----
> >>  .../pipeline/raspberrypi/raspberrypi.cpp      |  9 +++---
> >>  src/libcamera/property_ids.yaml               |  4 +--
> >>  src/qcam/dng_writer.cpp                       | 22 ++++++-------
> >>  utils/gen-controls.py                         | 32 +++++++++++++------
> >>  12 files changed, 81 insertions(+), 68 deletions(-)
> >
Kieran Bingham June 7, 2022, 10:42 p.m. UTC | #5
Quoting Kieran Bingham (2022-06-07 23:41:13)
> Quoting Christian Rauch via libcamera-devel (2022-06-06 10:55:18)
> > Hi Laurent,
> > 
> > I set up a CI workflow on GitHub for building libcamera on amd64 [1] and
> > aarch64 [2] with g++ and clang++.
> 
> If we merge these files in our repository - will they run for any user
> who pushes a branch on their own fork of libcamera on github?
> 
> If so - perhaps we should add them.
> 
> 
> > All of those setups pass the build without issues [3], [4].
> > 
> > Do you have an idea how I have to change the configuration to reproduce
> > the issues that you encountered?
> 
> These look like they're running an emultated aarch64 environment to be
> able to use arm64 compilers 'natively'.
> 
> I wonder if the difference is due to using a native compiler vs a cross
> compiler.
> 
> I've been building a docker container that supports cross compilation
> for RPi/ARM64 - So I wonder if we can also pre-build some containers
> with the dependencies met to speed up builds of multiple different
> configurations (and tests) without spending all the CI cycles installing
> packages...
> 

Still a work in progress but this is what I was describing above : 
 https://gist.github.com/kbingham/b35cc1402d02b0ef41b450941ad8f0c3

> --
> Kieran
> 
> 
> > 
> > Best,
> > Christian
> > 
> > [1]
> > https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main.yml
> > [2]
> > https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main_aarch64.yml
> > 
> > [3] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079999
> > [4] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079998
> > 
> > 
> > Am 04.06.22 um 23:47 schrieb Laurent Pinchart:
> > > Hi Christian,
> > >
> > > Thank you for the patches.
> > >
> > > On Sat, Jun 04, 2022 at 10:11:43PM +0100, Christian Rauch via libcamera-devel wrote:
> > >> Hello,
> > >>
> > >> Compared to the previous version, this 1) avoids a couple of more
> > >> "value_or" fallbacks if the validity of a control value or property
> > >> was previously checked with "contains" and 2) avoids references to
> > >> potential invalid control values or properties. The last point fixes
> > >> compiler errors reported by clang.
> > >
> > > I'm afraid I'm still seeing compilation errors :-( Here are a few:
> > >
> > >
> > > aarch64-buildroot-linux-gnu-g++ -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> > > In file included from ../../include/libcamera/camera.h:20,
> > >                  from ../../src/android/camera_capabilities.h:17,
> > >                  from ../../src/android/camera_capabilities.cpp:8:
> > > In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
> > >     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> > > ../../include/libcamera/controls.h:381:37: error: ‘*(const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::<unnamed>))’ may be used uninitialized [-Werror=maybe-uninitialized]
> > >   381 |                         return std::nullopt;
> > >       |                                     ^~~~~~~
> > > ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> > > ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
> > >   381 |                         return std::nullopt;
> > >       |                                     ^~~~~~~
> > > In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
> > >     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
> > > ../../include/libcamera/controls.h:381:37: error: ‘((const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::_M_payload.std::_Optional_payload<libcamera::Size, true, true, true>::<unnamed>.std::_Optional_payload_base<libcamera::Size>::_M_payload)))[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
> > >   381 |                         return std::nullopt;
> > >       |                                     ^~~~~~~
> > > ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> > > ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
> > >   381 |                         return std::nullopt;
> > >       |                                     ^~~~~~~
> > >
> > >
> > > g++-10.3.1 -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/libexif -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
> > > In file included from ../../include/libcamera/camera.h:20,
> > >                  from ../../src/android/camera_capabilities.h:17,
> > >                  from ../../src/android/camera_capabilities.cpp:8:
> > > ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
> > > ../../include/libcamera/controls.h:381:16: error: ‘<anonymous>’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > >   381 |    return std::nullopt;
> > >       |                ^~~~~~~
> > > ../../include/libcamera/controls.h:381:16: error: ‘*((void*)&<anonymous> +4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > >
> > >
> > > g++-8.4.0 -Isrc/ipa/raspberrypi/ipa_rpi.so.p -Isrc/ipa/raspberrypi -I../../src/ipa/raspberrypi -Iinclude -I../../include -Isrc/ipa -I../../src/ipa -I../../src/ipa/raspberrypi/controller -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wl,--start-group -lstdc++fs -Wl,--end-group -Wshadow -include config.h -fPIC -DBOOST_ALL_NO_LIB -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -MF src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o.d -o src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -c ../../src/ipa/raspberrypi/raspberrypi.cpp
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp: In member function ‘void libcamera::ipa::RPi::IPARPi::reportMetadata()’:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: error: no matching function for call to ‘libcamera::Span<const int, 4>::Span(<brace-enclosed initializer list>)’
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > > ../../include/libcamera/base/span.h:189:12: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<T, Extent>&) [with T = const int; long unsigned int Extent = 4]’
> > >   constexpr Span(const Span &other) noexcept = default;
> > >             ^~~~
> > > ../../include/libcamera/base/span.h:189:12: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const libcamera::Span<const int, 4>&’
> > > ../../include/libcamera/base/span.h:181:21: note: candidate: ‘template<class U, long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<U, N>&, std::enable_if_t<(std::is_convertible<_Up (*)[], _Tp (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> > >   explicit constexpr Span(const Span<U, N> &s,
> > >                      ^~~~
> > > ../../include/libcamera/base/span.h:181:21: note:   template argument deduction/substitution failed:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘U’
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > > ../../include/libcamera/base/span.h:168:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(const Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
> > >   explicit constexpr Span(const Container &cont,
> > >                      ^~~~
> > > ../../include/libcamera/base/span.h:168:21: note:   template argument deduction/substitution failed:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > > ../../include/libcamera/base/span.h:156:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
> > >   explicit constexpr Span(Container &cont,
> > >                      ^~~~
> > > ../../include/libcamera/base/span.h:156:21: note:   template argument deduction/substitution failed:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > > ../../include/libcamera/base/span.h:146:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> > >   constexpr Span(const std::array<value_type, N> &arr,
> > >             ^~~~
> > > ../../include/libcamera/base/span.h:146:12: note:   template argument deduction/substitution failed:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > > ../../include/libcamera/base/span.h:136:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> > >   constexpr Span(std::array<value_type, N> &arr,
> > >             ^~~~
> > > ../../include/libcamera/base/span.h:136:12: note:   template argument deduction/substitution failed:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > > ../../include/libcamera/base/span.h:126:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::element_type (&)[N], std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
> > >   constexpr Span(element_type (&arr)[N],
> > >             ^~~~
> > > ../../include/libcamera/base/span.h:126:12: note:   template argument deduction/substitution failed:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   mismatched types ‘int’ and ‘short unsigned int’
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > > In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
> > > ../../include/libcamera/base/span.h:120:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::pointer) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*]’
> > >   explicit constexpr Span(pointer first, [[maybe_unused]] pointer last)
> > >                      ^~~~
> > > ../../include/libcamera/base/span.h:120:21: note:   candidate expects 2 arguments, 1 provided
> > > ../../include/libcamera/base/span.h:115:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::size_type) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*; libcamera::Span<T, Extent>::size_type = long unsigned int]’
> > >   explicit constexpr Span(pointer ptr, [[maybe_unused]] size_type count)
> > >                      ^~~~
> > > ../../include/libcamera/base/span.h:115:21: note:   candidate expects 2 arguments, 1 provided
> > > ../../include/libcamera/base/span.h:110:12: note: candidate: ‘template<bool Dependent, class> constexpr libcamera::Span<T, Extent>::Span()’
> > >   constexpr Span() noexcept
> > >             ^~~~
> > > ../../include/libcamera/base/span.h:110:12: note:   template argument deduction/substitution failed:
> > > ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   candidate expects 0 arguments, 1 provided
> > >          blackLevelStatus->black_level_b }));
> > >                                           ^
> > >
> > >> Christian Rauch (5):
> > >>   libcamera: controls: Use std::optional to handle invalid control
> > >>     values
> > >>   libcamera: ipu3: Fix rogue whitespace
> > >>   libcamera: controls: Define size of array controls as a shape vector
> > >>   libcamera: controls: Generate fixed- and variable-sized Span Controls
> > >>   libcamera: controls: Apply explicit fixed-sized Span type casts
> > >>
> > >>  include/libcamera/controls.h                  |  7 ++--
> > >>  src/android/camera_capabilities.cpp           | 12 +++----
> > >>  src/android/camera_device.cpp                 | 21 ++++++------
> > >>  src/android/camera_hal_manager.cpp            |  2 +-
> > >>  src/cam/main.cpp                              |  4 +--
> > >>  src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++++------
> > >>  src/libcamera/control_ids.yaml                |  4 +--
> > >>  src/libcamera/pipeline/ipu3/ipu3.cpp          | 11 +++----
> > >>  .../pipeline/raspberrypi/raspberrypi.cpp      |  9 +++---
> > >>  src/libcamera/property_ids.yaml               |  4 +--
> > >>  src/qcam/dng_writer.cpp                       | 22 ++++++-------
> > >>  utils/gen-controls.py                         | 32 +++++++++++++------
> > >>  12 files changed, 81 insertions(+), 68 deletions(-)
> > >
Christian Rauch June 8, 2022, 12:05 a.m. UTC | #6
Am 07.06.22 um 23:41 schrieb Kieran Bingham:
> Quoting Christian Rauch via libcamera-devel (2022-06-06 10:55:18)
>> Hi Laurent,
>>
>> I set up a CI workflow on GitHub for building libcamera on amd64 [1] and
>> aarch64 [2] with g++ and clang++.
>
> If we merge these files in our repository - will they run for any user
> who pushes a branch on their own fork of libcamera on github?
>
> If so - perhaps we should add them.
>
Yes, they would -- after changing the 'branches' to "master". But those
are GitHub specific files and are not reusable by any other hosting
provider. Not sure if you are ok with adding "unused" files to the repo.
I created those mainly to test it for myself. But of course, you can use
them too.
>
>> All of those setups pass the build without issues [3], [4].
>>
>> Do you have an idea how I have to change the configuration to reproduce
>> the issues that you encountered?
>
> These look like they're running an emultated aarch64 environment to be
> able to use arm64 compilers 'natively'.

That's correct. There are no native arm64 build servers for GitHub right
now. The build will be slower, due to the emulation, but the outcome
should be the same as running on hardware. I think this is how
distributions compile their "arm64" or "riscv64" packages.

>
> I wonder if the difference is due to using a native compiler vs a cross
> compiler.

This could be. But I don't know how to set up cross-compilation with all
those dependencies. It's rather trivial for C/C++ projects that do not
have to link other libraries, but I have no experience in
cross-compiling complex projects.
>
> I've been building a docker container that supports cross compilation
> for RPi/ARM64 - So I wonder if we can also pre-build some containers
> with the dependencies met to speed up builds of multiple different
> configurations (and tests) without spending all the CI cycles installing
> packages...

Indeed. Using a docker image that already has all the dependencies
installed will speed up the workflow a lot.
However, I am using "plain" docker images regularly to verify that the
installation intructions with the dependencies are also valid. E.g. I
noticed that "libpython3-dev" is missing as optional dependency in the
official "Getting Started" instructions.

I will have a look into using this "--cross-file" option that you
referenced in your other email.

>
> --
> Kieran
>
>
>>
>> Best,
>> Christian
>>
>> [1]
>> https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main.yml
>> [2]
>> https://github.com/christianrauch/libcamera-ci/blob/ci/.github/workflows/main_aarch64.yml
>>
>> [3] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079999
>> [4] https://github.com/christianrauch/libcamera-ci/actions/runs/2445079998
>>
>>
>> Am 04.06.22 um 23:47 schrieb Laurent Pinchart:
>>> Hi Christian,
>>>
>>> Thank you for the patches.
>>>
>>> On Sat, Jun 04, 2022 at 10:11:43PM +0100, Christian Rauch via libcamera-devel wrote:
>>>> Hello,
>>>>
>>>> Compared to the previous version, this 1) avoids a couple of more
>>>> "value_or" fallbacks if the validity of a control value or property
>>>> was previously checked with "contains" and 2) avoids references to
>>>> potential invalid control values or properties. The last point fixes
>>>> compiler errors reported by clang.
>>>
>>> I'm afraid I'm still seeing compilation errors :-( Here are a few:
>>>
>>>
>>> aarch64-buildroot-linux-gnu-g++ -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
>>> In file included from ../../include/libcamera/camera.h:20,
>>>                  from ../../src/android/camera_capabilities.h:17,
>>>                  from ../../src/android/camera_capabilities.cpp:8:
>>> In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
>>>     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
>>> ../../include/libcamera/controls.h:381:37: error: ‘*(const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::<unnamed>))’ may be used uninitialized [-Werror=maybe-uninitialized]
>>>   381 |                         return std::nullopt;
>>>       |                                     ^~~~~~~
>>> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
>>> ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
>>>   381 |                         return std::nullopt;
>>>       |                                     ^~~~~~~
>>> In member function ‘std::optional<_Tp> libcamera::ControlList::get(const libcamera::Control<T>&) const [with T = libcamera::Size]’,
>>>     inlined from ‘int CameraCapabilities::initializeStaticMetadata()’ at ../../src/android/camera_capabilities.cpp:1053:46:
>>> ../../include/libcamera/controls.h:381:37: error: ‘((const unsigned int*)((char*)&<unnamed> + offsetof(std::optional<libcamera::Size>,std::optional<libcamera::Size>::<unnamed>.std::_Optional_base<libcamera::Size, true, true>::_M_payload.std::_Optional_payload<libcamera::Size, true, true, true>::<unnamed>.std::_Optional_payload_base<libcamera::Size>::_M_payload)))[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
>>>   381 |                         return std::nullopt;
>>>       |                                     ^~~~~~~
>>> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
>>> ../../include/libcamera/controls.h:381:37: note: ‘<anonymous>’ declared here
>>>   381 |                         return std::nullopt;
>>>       |                                     ^~~~~~~
>>>
>>>
>>> g++-10.3.1 -Isrc/android/libcamera-hal.so.p -Isrc/android -I../../src/android -I../../include/android/hardware/libhardware/include -I../../include/android/metadata -I../../include/android/system/core/include -Iinclude -I../../include -I../../subprojects/libyuv/include -Isubprojects/libyuv/__CMake_build -I../../subprojects/libyuv/__CMake_build -Isubprojects/libyuv -I../../subprojects/libyuv -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/libexif -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wshadow -include config.h -fPIC -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -MF src/android/libcamera-hal.so.p/camera_capabilities.cpp.o.d -o src/android/libcamera-hal.so.p/camera_capabilities.cpp.o -c ../../src/android/camera_capabilities.cpp
>>> In file included from ../../include/libcamera/camera.h:20,
>>>                  from ../../src/android/camera_capabilities.h:17,
>>>                  from ../../src/android/camera_capabilities.cpp:8:
>>> ../../include/libcamera/controls.h: In member function ‘int CameraCapabilities::initializeStaticMetadata()’:
>>> ../../include/libcamera/controls.h:381:16: error: ‘<anonymous>’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>   381 |    return std::nullopt;
>>>       |                ^~~~~~~
>>> ../../include/libcamera/controls.h:381:16: error: ‘*((void*)&<anonymous> +4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>
>>>
>>> g++-8.4.0 -Isrc/ipa/raspberrypi/ipa_rpi.so.p -Isrc/ipa/raspberrypi -I../../src/ipa/raspberrypi -Iinclude -I../../include -Isrc/ipa -I../../src/ipa -I../../src/ipa/raspberrypi/controller -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include -fdiagnostics-color=always -fsanitize=address -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -O3 -Wl,--start-group -lstdc++fs -Wl,--end-group -Wshadow -include config.h -fPIC -DBOOST_ALL_NO_LIB -DLIBCAMERA_BASE_PRIVATE -MD -MQ src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -MF src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o.d -o src/ipa/raspberrypi/ipa_rpi.so.p/raspberrypi.cpp.o -c ../../src/ipa/raspberrypi/raspberrypi.cpp
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp: In member function ‘void libcamera::ipa::RPi::IPARPi::reportMetadata()’:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: error: no matching function for call to ‘libcamera::Span<const int, 4>::Span(<brace-enclosed initializer list>)’
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
>>> ../../include/libcamera/base/span.h:189:12: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<T, Extent>&) [with T = const int; long unsigned int Extent = 4]’
>>>   constexpr Span(const Span &other) noexcept = default;
>>>             ^~~~
>>> ../../include/libcamera/base/span.h:189:12: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const libcamera::Span<const int, 4>&’
>>> ../../include/libcamera/base/span.h:181:21: note: candidate: ‘template<class U, long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const libcamera::Span<U, N>&, std::enable_if_t<(std::is_convertible<_Up (*)[], _Tp (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>>>   explicit constexpr Span(const Span<U, N> &s,
>>>                      ^~~~
>>> ../../include/libcamera/base/span.h:181:21: note:   template argument deduction/substitution failed:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘U’
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
>>> ../../include/libcamera/base/span.h:168:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(const Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
>>>   explicit constexpr Span(const Container &cont,
>>>                      ^~~~
>>> ../../include/libcamera/base/span.h:168:21: note:   template argument deduction/substitution failed:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
>>> ../../include/libcamera/base/span.h:156:21: note: candidate: ‘template<class Container> constexpr libcamera::Span<T, Extent>::Span(Container&, std::enable_if_t<((((! libcamera::details::is_span<Container>::value) && (! libcamera::details::is_array<Container>::value)) && (! std::is_array<_Up>::value)) && std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(cont))>::type (*)[], T (*)[]>::value), std::nullptr_t>)’
>>>   explicit constexpr Span(Container &cont,
>>>                      ^~~~
>>> ../../include/libcamera/base/span.h:156:21: note:   template argument deduction/substitution failed:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘Container’
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
>>> ../../include/libcamera/base/span.h:146:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(const std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>>>   constexpr Span(const std::array<value_type, N> &arr,
>>>             ^~~~
>>> ../../include/libcamera/base/span.h:146:12: note:   template argument deduction/substitution failed:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
>>> ../../include/libcamera/base/span.h:136:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(std::array<typename std::remove_cv< <template-parameter-1-1> >::type, N>&, std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>>>   constexpr Span(std::array<value_type, N> &arr,
>>>             ^~~~
>>> ../../include/libcamera/base/span.h:136:12: note:   template argument deduction/substitution failed:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   couldn't deduce template parameter ‘N’
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
>>> ../../include/libcamera/base/span.h:126:12: note: candidate: ‘template<long unsigned int N> constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::element_type (&)[N], std::enable_if_t<(std::is_convertible<typename std::remove_pointer<decltype (libcamera::utils::data(arr))>::type (*)[], T (*)[]>::value && (N == Extent)), std::nullptr_t>)’
>>>   constexpr Span(element_type (&arr)[N],
>>>             ^~~~
>>> ../../include/libcamera/base/span.h:126:12: note:   template argument deduction/substitution failed:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   mismatched types ‘int’ and ‘short unsigned int’
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>> In file included from ../../src/ipa/raspberrypi/raspberrypi.cpp:20:
>>> ../../include/libcamera/base/span.h:120:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::pointer) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*]’
>>>   explicit constexpr Span(pointer first, [[maybe_unused]] pointer last)
>>>                      ^~~~
>>> ../../include/libcamera/base/span.h:120:21: note:   candidate expects 2 arguments, 1 provided
>>> ../../include/libcamera/base/span.h:115:21: note: candidate: ‘constexpr libcamera::Span<T, Extent>::Span(libcamera::Span<T, Extent>::pointer, libcamera::Span<T, Extent>::size_type) [with T = const int; long unsigned int Extent = 4; libcamera::Span<T, Extent>::pointer = const int*; libcamera::Span<T, Extent>::size_type = long unsigned int]’
>>>   explicit constexpr Span(pointer ptr, [[maybe_unused]] size_type count)
>>>                      ^~~~
>>> ../../include/libcamera/base/span.h:115:21: note:   candidate expects 2 arguments, 1 provided
>>> ../../include/libcamera/base/span.h:110:12: note: candidate: ‘template<bool Dependent, class> constexpr libcamera::Span<T, Extent>::Span()’
>>>   constexpr Span() noexcept
>>>             ^~~~
>>> ../../include/libcamera/base/span.h:110:12: note:   template argument deduction/substitution failed:
>>> ../../src/ipa/raspberrypi/raspberrypi.cpp:520:42: note:   candidate expects 0 arguments, 1 provided
>>>          blackLevelStatus->black_level_b }));
>>>                                           ^
>>>
>>>> Christian Rauch (5):
>>>>   libcamera: controls: Use std::optional to handle invalid control
>>>>     values
>>>>   libcamera: ipu3: Fix rogue whitespace
>>>>   libcamera: controls: Define size of array controls as a shape vector
>>>>   libcamera: controls: Generate fixed- and variable-sized Span Controls
>>>>   libcamera: controls: Apply explicit fixed-sized Span type casts
>>>>
>>>>  include/libcamera/controls.h                  |  7 ++--
>>>>  src/android/camera_capabilities.cpp           | 12 +++----
>>>>  src/android/camera_device.cpp                 | 21 ++++++------
>>>>  src/android/camera_hal_manager.cpp            |  2 +-
>>>>  src/cam/main.cpp                              |  4 +--
>>>>  src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++++------
>>>>  src/libcamera/control_ids.yaml                |  4 +--
>>>>  src/libcamera/pipeline/ipu3/ipu3.cpp          | 11 +++----
>>>>  .../pipeline/raspberrypi/raspberrypi.cpp      |  9 +++---
>>>>  src/libcamera/property_ids.yaml               |  4 +--
>>>>  src/qcam/dng_writer.cpp                       | 22 ++++++-------
>>>>  utils/gen-controls.py                         | 32 +++++++++++++------
>>>>  12 files changed, 81 insertions(+), 68 deletions(-)
>>>