Commit graph

2535 commits

Author SHA1 Message Date
Umang Jain
332870ea2b test: bayer-format: Rectify internal header's #include path
libcamera internal headers are not available system-wide. Hence,
directive `#include <libcamera/internal/header.h>` is wrong. Fix it
by using "" for the #include directive.

Fixes: e09c487b97 ("test: Add unit tests for the BayerFormat class")
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-05 10:32:33 +02:00
Umang Jain
08f7469617 src: android: Rectify internal header's #include path
libcamera internal headers are not installed system-wide. Hence, any
inclusion of internal headers should follow the #include directive
form:
	#include "libcamera/internal/header.h"

This was not the case for a few of the class in android HAL. Fix them.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-05 10:30:32 +02:00
Sebastian Fricke
093b71b24a pipeline: rkisp1: Add check for non-existent frame info
Add a check, that makes sure that the given FrameBuffer is associated
to a RkISP1FrameInfo instance. The current code tries to access the
frame info without checking if it actually exists.

Fixes: 0eb65e14e ("libcamera: pipeline: rkisp1: Attach to an IPA")

Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-03 13:31:25 +01:00
Kieran Bingham
3a1f67a803 src: meson: Define system paths
Define libcamera specific system paths for use within the library code
base. These can be used to identify system configuration files and
shared data.

Also, make use of the new system path variables and map the ipa paths
upon the libcamera system path, making use of the new shorter syntax for
join_paths().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-30 11:53:09 +01:00
Kieran Bingham
7065ad84f0 libcamera: internal: log: Report function on asserts
Report the function which fails an assertion as well as the actual
assertion.

This now reports as:

[30:08:53.218816270] [226567] FATAL default request.cpp:150 assertion "d" failed in reuse()
rather than:
[30:11:05.271888926] [228531] FATAL default request.cpp:150 assertion "d" failed

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-27 22:50:23 +01:00
Paul Elder
0f2189ba30 ipa: mojom: Put core.mojom in the libcamera namespace
Put core.mojom in the libcamera namespace, as all structs that are
defined in core.mojom are meant to be in that namespace. Fix the structs
that are used in the other mojom files accordingly.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 17:34:58 +09:00
Paul Elder
078fbff8f4 utils: ipc: Use the proper namespace for mojom structs
Structs defined in mojom previously used the namespace of the mojom file
that was being used as the source. This is obviously not the correct
namespace for structs that are defined in core.mojom. Fix the jinja
function for getting the element type including namespace, and use it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 17:34:58 +09:00
Paul Elder
17e8f6f71c utils: ipc: Include instead of forward-declare CameraSensorInfo
For structs defined in core.mojom that have the skipHeader tag, if
they're only used in function parameters (in a mojom file) then a
forward-declaration is sufficient. However, if the struct is used in
another struct in a mojom file, then the forward-declaration is
insufficient, and the definition needs to be included. Do so for
CameraSensorInfo, which is the only forward-declared struct in
ipa_interface.h, and update the documentation comment.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 17:34:55 +09:00
Sebastian Fricke
446cb01d14 ipa: cam_helper: Correct a wrong choice of term
Sensors provide embedded data buffers and not metadata buffers,
replace the incorrect term with the correct one.

Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 09:54:25 +03:00
Sebastian Fricke
2d95f773ab ipa: cam_helper_imx219: Rework comment
Fix two typos and improve the sentence.

Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 09:54:13 +03:00
Hirokazu Honda
c3ab0fa0ce libcamera: V4L2Device: Use Span in updateControls()
V4L2Device::updateControls() takes two arguments, raw array and
its size, for the v4l2_ext_control values. This replaces it with
libcamera::Span.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26 16:40:13 +03:00
Hirokazu Honda
3c0e99e034 libcamera: V4L2Device: Replace VLA with std::vector in setControls()
The original code uses Variable-Length-Array, which is not
officially supported in C++. This replaces the array with
std::vector.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26 16:40:10 +03:00
Hirokazu Honda
3252631fbd libcamera: V4L2Device: Replace VLA with std::vector in getControls()
The original code uses Variable-Length-Array, which is not officially
supported in C++. This replaces the array with std::vector.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26 16:39:54 +03:00
Jean-Michel Hautbois
8a2fb73337 ipa: rkisp1: Move the IPA to the ipa::rkisp1 namespace
Simplify name-spacing of the RKISP1 components by placing it in the
ipa::rkisp1 namespace directly.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-26 10:24:11 +02:00
Kieran Bingham
883334135b libcamera: pipeline: ipu3: Cancel unused buffers
When the CIO2 returns a cancelled buffer, we will not queue buffers
to the IMGU.

These buffers should be explicitly marked as cancelled to ensure
the application knows there is no valid metadata or frame data
provided in the buffer.

Provide a cancel() method on the FrameBuffer to allow explicitly
cancelling a buffer.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Kieran Bingham
0abed64843 libcamera: pipeline: rkisp1: Fail RkISP1FrameInfo can't be found
The RkISP1FrameInfo structure associated data sent to the IPA and is
essential for handling events.

If it can not be found, this is a fatal error which must be fixed.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Kieran Bingham
47c12e2635 libcamera: pipeline: ipu3: frames: Fail if the FrameInfo can't be found
The FrameInfo structure associates the data sent to the IPA
and is essential for handling events.

If it can not be found, this is a fatal error which must be fixed.

While we're changing the line, also correct a spelling error for
'Information'.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Kieran Bingham
ec5d4acfca libcamera: camera: Assert pipelines complete all requests
When the camera manager calls stop on a pipeline, it is expected that
the pipeline handler guarantees all requests are returned back to the
application before the camera has stopped.

Ensure that this guarantee is met by providing an accessor on the
pipeline handler to validate that all pending requests are removed.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Jean-Michel Hautbois
7e0da7c349 ipa: ipu3: fix coverity issues in AWB
The BNR configuration structure has inconsistent initialisation of two
members.

This was picked up by Coverity, after merge.
While this code is still functional, fix them to be consistent with the
other initialisations within the struct.

Reported-by: Coverity CID=320056
Reported-by: Coverity CID=320058
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:06 +01:00
Jean-Michel Hautbois
9e1bd62de3 ipa: ipu3: Add support for IPU3 AEC/AGC algorithm
Implement basic auto-exposure (AE) and auto-gain (AG) correction functions.
The functions computeTargetExposure() and computeGain() are adapted from
the Raspberry Pi AGC implementation to suit the IPU3 structures, and
filtering is added to reduce visible stepsize when there are large
exposure changes.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:13:03 +01:00
Jean-Michel Hautbois
b2ddc9b118 ipa: ipu3: Add support for IPU3 AWB algorithm
The IPA will locally modify the parameters before they are passed down
to the ImgU. Use a local parameter object to give a reference to those
algorithms.

Inherit from the Algorithm class to implement basic AWB functions.

The configure() call will set exposure and gain to their minimum value,
so while AGC is not there, the frames will be dark.

Once AWB is done, a color temperature is estimated and a default CCM matrix
will be used (yet to be tuned).
Implement a basic "grey-world" AWB algorithm just for demonstration purpose.

The BDS output size is passed by the pipeline handler to the IPA.
The best grid is then calculated to maximize the number of pixels taken
into account in each cells.

As commented in the source code, it can be improved, as it has (at least)
one limitation: if a cell is big (say 128 pixels wide) and indicated as
saturated, it won't be taken into account at all.
Maybe is it possible to have a smaller one, at the cost of a few pixels
to lose, in which case we can center the grid using the x_start and
y_start parameters.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:12:53 +01:00
Jean-Michel Hautbois
3ebb692f32 ipa: ipu3: Add a histogram class
This class will be used at least by AGC algorithm when quantiles are
needed for example. It stores a cumulative frequency histogram. Going from
cumulative frequency back to per-bin values is a single subtraction, while
going the other way is a loop.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:12:40 +01:00
Jean-Michel Hautbois
d5168b503a ipa: Add a common interface for algorithm objects
In order to instantiate and use algorithms (AWB, AGC, etc.)
there is a need for a common class to define mandatory methods.

Instead of reinventing the wheel, reuse what Raspberry Pi has done and
adapt to the minimum requirements expected.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:12:23 +01:00
Niklas Söderlund
b2cc8a2f57 lc-compliance: simple_capture: Handle unsupported roles
It's valid for a camera to return a nullptr if the requested set of
roles can not be satisfied. This is not correctly handled by
lc-compliance which instead crashes, fix this.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
2021-04-21 20:05:21 +02:00
Jacopo Mondi
e58b5fa39f libcamera: class: Drop 'klass' argument from documentation
The LIBCAMERA_D_PTR() and LIBCAMERA_O_PTR() macros do not require an
argument, but the version of the macro consumed by Doxygen does.

Fix this by removing the klass parameter from both macros in their
documentation version.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-21 09:53:08 +02:00
Jacopo Mondi
1fca6228fe libcamera: Drop argument from LIBCAMERA_DECLARE_PRIVATE
The LIBCAMERA_DECLARE_PRIVATE() macro, used by the library classes
that inherit from libcamera::Extensible in order to implement the
PIMPL pattern, expands to:

public:									\
	class Private;							\
	friend class Private;

The 'klass' argument is not used and it might confuse developers as
it might hint that the class that defines the pattern's implementation
can be freely named, while it is actually hardcoded to 'Private'.

Drop the argument from the macro definition.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hanlin Chen <hanlinchen@google.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-21 09:52:34 +02:00
Hirokazu Honda
d40430116b android: CameraDevice: Fix Camera3RequestDescriptor leakage
CameraDevice creates Camera3RequestDescriptor in
processCaptureRequest() and disallocates in requestComplete().
Camera3RequestDescriptor can never be destroyed if
requestComplete() is never called. This avoid the memory
leakage by storing them in map CameraRequestDescriptor.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-20 05:59:08 +03:00
Hirokazu Honda
0b661d70ec android: CameraDevice: Add stop()
This adds CameraDevice::stop(), which cleans up the member
variables of CameraDevice. It is called in CameraDevice::close()
and CameraDevice::configureStreams().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-20 05:55:50 +03:00
Naushir Patuck
796109c8dc pipeline: raspberrypi: Fix typo in a comment
s/embedded/bayer/

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-20 03:35:49 +03:00
Kieran Bingham
a8fb12877a ipa: ipu3: Move the IPA to the ipa::ipu3 namespace
Simplify name-spacing of the IPU3 components by placing it in the
ipa::ipu3 namespace directly.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-17 21:47:24 +01:00
Kieran Bingham
9b5478e725 libcamera: pipeline: ipu3: Check for failures when loading IPA
The ipa_->init() method can fail if the IPA can't load correctly.
This should be caught by the pipeline handler to prevent continuing
with an invalid IPA.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-17 20:45:02 +01:00
Laurent Pinchart
5a76290b5d libcamera: bound_method: Please the gcc undefined behaviour sanitizer
Enabling the gcc undefined behaviour sanitizer (with the meson configure
-Db_sanitize=undefined option) causes many tests to fail, with errors
such as the following (for test/object-invoke):

------------------------------------------------------------------------
../../include/libcamera/bound_method.h:198:27: runtime error: member access within address 0x55fcd7bfbd38 which does not point to an object of type 'BoundMethodBase'
0x55fcd7bfbd38: note: object has invalid vptr
 fc 55 00 00  2a 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  31 00 00 00 00 00 00 00  4b c6 72 88
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
../../include/libcamera/bound_method.h:198:41: runtime error: member call on null pointer of type 'struct InvokedObject'
../../include/libcamera/bound_method.h:198:41: runtime error: member access within null pointer of type 'struct InvokedObject'
Segmentation fault
------------------------------------------------------------------------

or

------------------------------------------------------------------------
../../include/libcamera/bound_method.h:198:27: runtime error: member access within address 0x603000006628 which does not point to an object of type 'BoundMethodBase'
0x603000006628: note: object has invalid vptr
 70 55 00 00  2a 00 00 00 be be be be  03 02 00 00 18 00 00 00  01 00 00 60 00 00 00 00  05 00 80 07
              ^~~~~~~~~~~~~~~~~~~~~~~
              invalid vptr
=================================================================
==941==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000006630 at pc 0x55704e461371 bp 0x7fff539b9040 sp 0x7fff539b9030
READ of size 8 at 0x603000006630 thread T0
    #0 0x55704e461370 in libcamera::BoundMethodMember<InvokedObject, void, int>::invoke(int) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x47370)
    #1 0x55704e4622ca in void libcamera::BoundMethodArgs<void, int>::invokePack<0ul>(libcamera::BoundMethodPackBase*, std::integer_sequence<unsigned long, 0ul>) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x482ca)
    #2 0x55704e460a93 in libcamera::BoundMethodArgs<void, int>::invokePack(libcamera::BoundMethodPackBase*) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x46a93)
    #3 0x7fdc38a5fec4 in libcamera::InvokeMessage::invoke() ../../src/libcamera/message.cpp:154
    #4 0x7fdc38a62faf in libcamera::Object::message(libcamera::Message*) ../../src/libcamera/object.cpp:183
    #5 0x7fdc38ad3742 in libcamera::Thread::dispatchMessages(libcamera::Message::Type) ../../src/libcamera/thread.cpp:575
    #6 0x7fdc38972d8d in libcamera::EventDispatcherPoll::processEvents() ../../src/libcamera/event_dispatcher_poll.cpp:148
    #7 0x55704e44bc15 in ObjectInvokeTest::run() (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x31c15)
    #8 0x55704e4630ab in Test::execute() ../../test/libtest/test.cpp:28
    #9 0x55704e44965b in main ../../test/object-invoke.cpp:204
    #10 0x7fdc36090eba in __libc_start_main ../csu/libc-start.c:314
    #11 0x55704e449359 in _start (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x2f359)

0x603000006630 is located 0 bytes to the right of 32-byte region [0x603000006610,0x603000006630)
allocated by thread T0 here:
    #0 0x7fdc3ad757c7 in operator new(unsigned long) /var/tmp/portage/sys-devel/gcc-11.0.1_pre9999/work/gcc-11.0.1_pre9999/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x55704e45afea in __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x40fea)
    #2 0x55704e45a45d in std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x4045d)
    #3 0x55704e458339 in std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, (__gnu_cxx::_Lock_policy)2> >&) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x3e339)
    #4 0x55704e4574ad in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, int&>(libcamera::BoundMethodPack<void, int>*&, std::_Sp_alloc_shared_tag<std::allocator<libcamera::BoundMethodPack<void, int> > >, int&) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x3d4ad)
    #5 0x55704e4569c7 in std::__shared_ptr<libcamera::BoundMethodPack<void, int>, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<libcamera::BoundMethodPack<void, int> >, int&>(std::_Sp_alloc_shared_tag<std::allocator<libcamera::BoundMethodPack<void, int> > >, int&) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x3c9c7)
    #6 0x55704e455f9d in std::shared_ptr<libcamera::BoundMethodPack<void, int> >::shared_ptr<std::allocator<libcamera::BoundMethodPack<void, int> >, int&>(std::_Sp_alloc_shared_tag<std::allocator<libcamera::BoundMethodPack<void, int> > >, int&) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x3bf9d)
    #7 0x55704e454eb5 in std::shared_ptr<libcamera::BoundMethodPack<void, int> > std::allocate_shared<libcamera::BoundMethodPack<void, int>, std::allocator<libcamera::BoundMethodPack<void, int> >, int&>(std::allocator<libcamera::BoundMethodPack<void, int> > const&, int&) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x3aeb5)
    #8 0x55704e454220 in std::shared_ptr<libcamera::BoundMethodPack<void, int> > std::make_shared<libcamera::BoundMethodPack<void, int>, int&>(int&) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x3a220)
    #9 0x55704e450e60 in libcamera::BoundMethodMember<InvokedObject, void, int>::activate(int, bool) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x36e60)
    #10 0x55704e44efb2 in void libcamera::Object::invokeMethod<InvokedObject, void, int, int, (void*)0>(void (InvokedObject::*)(int), libcamera::ConnectionType, int) (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x34fb2)
    #11 0x55704e44b7cc in ObjectInvokeTest::run() (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x317cc)
    #12 0x55704e4630ab in Test::execute() ../../test/libtest/test.cpp:28
    #13 0x55704e44965b in main ../../test/object-invoke.cpp:204
    #14 0x7fdc36090eba in __libc_start_main ../csu/libc-start.c:314

SUMMARY: AddressSanitizer: heap-buffer-overflow (libcamera/build/x86-gcc-11.0.1/test/object-invoke+0x47370) in libcamera::BoundMethodMember<InvokedObject, void, int>::invoke(int)
Shadow bytes around the buggy address:
  0x0c067fff8c70: 00 fa fa fa 00 00 06 fa fa fa fd fd fd fd fa fa
  0x0c067fff8c80: 00 00 06 fa fa fa 00 00 03 fa fa fa 00 00 00 05
  0x0c067fff8c90: fa fa 00 00 04 fa fa fa 00 00 00 00 fa fa fd fd
  0x0c067fff8ca0: fd fd fa fa fd fd fd fd fa fa fd fd fd fd fa fa
  0x0c067fff8cb0: fd fd fd fd fa fa 00 00 00 00 fa fa 00 00 00 00
=>0x0c067fff8cc0: fa fa 00 00 00 00[fa]fa fd fd fd fa fa fa fa fa
  0x0c067fff8cd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8ce0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8cf0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8d00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8d10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==941==ABORTING
------------------------------------------------------------------------

The root cause isn't clear, but this change fixes the issue. It may be a
bug in gcc.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-17 00:53:01 +03:00
Laurent Pinchart
ab8db44efb libcamera: signal: Fix return value template type of BoundMethodMember
The BoundMethodMember instance created in Signal::connect() for
receivers inheriting from the Object class incorrectly sets the return
type to void instead of R. This doesn't cause any functional issue as
the return type is ignored anyway for signals, but should be fixed
nonetheless.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-17 00:52:57 +03:00
Laurent Pinchart
1ad214dd1b libcamera: span: Fix reverse iterators
std::reverse_iterator<iterator> is constructed from an instance of
iterator, and automatically subtracts 1 when dereferencing. rbegin() and
rend() should thus be constructed from end() and begin() respectively.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-15 22:23:02 +03:00
Laurent Pinchart
c244d07286 test: span: Add tests for begin() and rbegin()
Verify that the begin() and rbegin() iterators (and their const version)
reference the correct values. The end() and rend() iterators can't be
tested the same way as they're not dereferenceable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-15 22:23:02 +03:00
Jacopo Mondi
c3269524e4 libcamera: camera_sensor: Demote error message
The CameraSensor class is noisy enough in reporting the missing
sensor driver features.

Demote an error message about defaulting the active sensor area when
retrieving the camera sensor info to a warning.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-15 15:52:53 +02:00
Sebastian Fricke
47a159234f ipa: raspberrypi: cam_helper: Remove duplicate words
Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-15 01:52:54 +03:00
Laurent Pinchart
df1d955d24 libcamera: log: Use compiler builtins to retrieve file and line number
Replace the __FILE__ and __LINE__ values passed to the _log() function
with default parameters, taking their values from the __builtin_FILE()
and __builtin_LINE() functions. This moves handling of the file and line
from the preprocessor to the compiler, which is generally preferred as
it increases type safety.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-15 00:04:54 +03:00
Laurent Pinchart
93be96431a libcamera: log: De-duplicate _log() functions and LogMessage constructor
The _log() functions, as well as the LogMessage constructor, exist in
two versions, one that takes a log category, and one that doesn't. The
latter uses the default log category. This can be simplified by passing
a LogCategory pointer to _log(), which can then be null for the default
category, and moving the retrieval of the default log category from the
LogMessage constructor to the _log() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-15 00:04:54 +03:00
Laurent Pinchart
304ea65551 libcamera: pipeline_handler: Fix typo in documentation
There's no CameraConfiguration::valid(), the correct function is
CameraConfiguration::validate().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Sebastian Fricke <sebastian.fricke@posteo.net>
2021-04-15 00:04:54 +03:00
Nícolas F. R. A. Prado
e51926f07b libcamera: pipeline: rkisp1: Allow requests to be cancelled
Previously when a frame got cancelled, the frameInfo flags
metadataProcessed and paramDequeued wouldn't get set, meaning that the
request wasn't able to be completed and cancelled.

Make sure that these flags are set when the frame gets cancelled so that
the request can be cancelled.

This issue happened while running lc-compliance.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-04-14 16:33:11 +02:00
Nícolas F. R. A. Prado
63dd6a8327 libcamera: pipeline: rkisp1: Assert empty queuedRequests before clearing frameInfo
Assert that there are no queued requests before clearing the frameInfo,
otherwise a SEGFAULT can occur.

This issue happened while running lc-compliance.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-04-14 16:33:09 +02:00
Nícolas F. R. A. Prado
330ea9d946 libcamera: pipeline: rkisp1: Stop IPA before streams
The IPA should be stopped before stopping the streams in order to avoid
a "No BufferCache available to queue" issue.

This issue happened while running lc-compliance.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-04-14 16:32:54 +02:00
Niklas Söderlund
58f558fdda lc-compliance: Drop return value from SimpleCapture::stop()
The return value is never checked and serves to real usage, drop it.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-14 16:13:18 +02:00
Niklas Söderlund
6c96861ea3 lc-compliance: Initialize the event loop pointer
The event loop pointer loop_ was not initialized. This has no effect on
the current code flow but could in the future lead to hard debug
problems.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-14 16:13:18 +02:00
Phi-Bang Nguyen
0373490ef6 pipeline: simple: Fix an issue in breadth-first search
When seting up the pipeline, the latest entity in the queue is
taken but the oldest one is poped. This is a mistake. Fix it.

Fixes: 4671911df0 ("pipeline: simple: Use breadth-first search to setup media pipeline")
Signed-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-14 02:14:41 +03:00
Kieran Bingham
c8cfa6650d libcamera: pipeline_handler: Document requestSequence_
The documentation for requestSequence_ was not added when the sequence
number was implemented.

Provide it.

Fixes: d874b3e341 ("libcamera: request: Provide a sequence number")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-13 20:55:40 +01:00
Kieran Bingham
1c9f2d7889 libcamera: ipa_proxy: Document ProxyState
The documentation for the ProxyState and tracking variable was not added
when the IPA was extended with a state machine.

Add it.

Fixes: 70238ceca5 ("utils: ipc: proxy: Track IPA with a state machine")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-13 20:55:40 +01:00
Kieran Bingham
296a903fe3 libcamera: ipa_proxy: Scope ProxyState to IPAProxy
The ProxyState is only used by the IPAProxy, so it should remain inside
that scope.  This helps clarify the usage, and improves the
documentation by bringing the (future) ProxyState documentation into the
class.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-13 20:52:19 +01:00
Laurent Pinchart
05b8022601 test: threads: Fix memory leak
The last instance of Thread allocated in the test is never deleted, nor
are other instances deleted in error paths. Use a std::unique_ptr<> to
ensure deletion.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Sebastian Fricke <sebastian.fricke@posteo.net>
2021-04-12 22:16:56 +03:00