Age | Commit message (Collapse) | Author |
|
Import the Android camera metadata library from the ChromiumOS build
system.
The camera metadata library has been copied from
https://chromium.googlesource.com/chromiumos/platform2
at revision 9e65ddd2c496e712f005ada9715decd2ff8e4a03
The original path in the Cros platform2/ repository is:
camera/android/libcamera_metadata/src
Create a new build target for the camera metadata library to
create a static library to link against libcamera.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add SPDX indentifier to Apache-2.0 licensed android headers.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Copy the Android Camera3 HAL headers from the ChromiumOS build system
and define a new inclusion directive in the meson build system for them.
The header files have been copied from:
https://chromium.googlesource.com/chromiumos/platform2
at revision 9e65ddd2c496e712f005ada9715decd2ff8e4a03
and provide:
1) Android CameraHAL3 HAL headers in include/android/hardware/
2) The Android system headers in include/android/system/
3) The Android camera metadata headers in include/android/metadata/
The original path in the Cros platform2/ repository is, respectively:
camera/android/header_files/include/hardware
camera/android/header_files/include/system
camera/android/libcamera_metadata/include/
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
All the Android camera stack code used by the libcamera camera HAL
adaptation layer is licensed under the Apache-2.0 license.
Add the Apache-2.0 license text to the licenses directory.
The associated SPDX header is "Apache-2.0" and the license text is
copied from:
https://www.apache.org/licenses/LICENSE-2.0.txt
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Linux commit b6c61a6c37317efd ("media: vimc: propagate pixel format in
the stream") changes the sensor in the vimc media graph to accept all
media bus format currently described in Linux. This prevents the
camera-sensor test case to verify that a supported media bus format is
selected from a list of defined formats, fix this by using an invalid
media bus format in the test case.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Most of the video device tests are based on vimc and Linux commit
85ab1aa1fac17bcd ("media: vimc: deb: fix default sink bayer format")
changes the default media bus format for the debayer subdevices. This
leads to a -EPIPE error when trying to use the raw capture video device
nodes.
Fix this by explicitly setting media bus and pixel formats to known good
values which works before and after the upstream change.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Linux commit 85ab1aa1fac17bcd ("media: vimc: deb: fix default sink bayer
format") which is part of v5.2 changes the default media bus format for
the debayer subdevices. This leads to a -EPIPE error when trying to use
the raw capture video device nodes.
Fix this by moving the vimc pipeline to use the RGB/YUV Capture capture
video node. As a consequence of this change the scaler in the vimc
pipeline is used and a hard coded upscale of 3 is present in the video
pipeline. This limits the sizes exposed and accepted by libcamera to
multiples of 3.
Update the buffer import test case to match this new format constraint
by setting the resolution to 1920x1080, a resolution which works with
both vimc and vivid. With this new resolution the buffer import test
takes a bit more time to complete 60 buffers and it's runtime also needs
to be increased.
The raw capture video node still needs to be handled by the pipeline as
its format needs to be updated to allow the pipeline format validation
to pass.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
As the device pointers are deleted in the pipelines destructor it's not
a good idea to have them uninitialized.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
ISP output pad should be set to YUYV8_2X8 for non-bayer output format.
Bayer formats are not listed in RkISP1CameraConfiguration::validate(),
only non-bayer are listed, so we can set YUYV8_2X8 directly.
This will need to be changed if we add support for bayer output with
libcamera.
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The IPAModule::loadIPAModuleInfo() function includes a *data pointer
which is used as a null-pointer comparison in the error path with a
conditional statement of "if (ret || !data)".
The data variable is not initialised, and a single error path evaluates
this as "if (true || uninitialised)".
Whilst this error path does not incorrectly utilise the uninitialised
data, as the ret evaluates to true already, it does leave a statement
which includes an uninitialised variable.
Help the static analysers by initialising the data variable when it is
defined.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The FrameSink::cleanup() call checks if video_ is set before cleaning up
and then deleting the object.
If the cleanup() call is called twice for any reason, this will
encounter a use-after-free as the video_ pointer is not cleared after
deletion.
Whilst cleanup() is not currently called twice consecutively, to prevent
errors in the future, make it explicit that the object has been deleted
by clearing the stale pointer.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add an error debug message when disassociating part of a process
execution context using unshare fails.
As this is currently used to isolate a child process which is
immediately terminated silently if unshare fails, add a debug printout
and propagate up the error code to make the failure more visible.
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Fix an argument name mismatch between method declaration and
definition.
Reported-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Since there are two logging tests now, move them to their own
subdirectory. Update meson as necessary.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add a test to test that logging works in isolated child processes.
Only logSetFile is tested, because stdout and stderr are closed for
isolated child processes, and syslog and the none logging destinations
are expected to be the same as non-isolated processes.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Test the new logSetStream logging API call. Reorganize the logging API
tests at the same time.
logSetTarget for the syslog logging destination is not tested.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Allow logging to syslog, or any given ostream, or to nowhere. The
logging API is updated to accomodate these new logging destinations.
LogMessage is modified to allow this.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
When a video device is stopped all the buffers there queued are released
and their state is set to BufferCancelled.
Currently, on buffer completion, cancelled buffers are blindly re-queued
to the ImgU input or CIO2 output devices, preventing them to be
re-started succesfully in future capture sessions.
Fix that by inspecting the buffers status and skip re-queueing if
they're reported as cancelled. For the ImgU output buffer this is not
required, as cancelled request should be reported to applications in
order to report them failure of the capture operations.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
With the current IPU3 kernel driver implementation, a linked pipe shall be
used (buffers should be queued on it) in order not to block all other pipes.
Currently all links on the ImgU device are only disabled at match() time,
implying that once an ImgU pipe gets linked, it should be used until the
whole pipeline is not re-matched and links disabled again. This is a severe
limitation for applications that wants to switch between cameras using
different pipes going through a full library tear-down and reload.
Perform link disabling at configure() time as well, so that a camera
configuration operation always unlock the usage of the assigned pipe,
regardless of the previously linked ones.
Unfortunately this requires a camera start/stop sequence to always go
through a configure step, a requirement that is not enforced by the
Camera state machine.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add a '-s|--size' option to qcam to allow selecting the stream
resolution using a command line option.
If the sizes are not supported by the camera, they get automatically
adjusted and the user notified via an output message.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Reserve identifiers for user-defined message types and add an operation
to the Message class to register the type identifiers.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The SignalMessage type is undocumented. Fix it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
To avoid depending on unitialised values, set the pixelFormat field of
the StreamConfiguration class to 0 in the constructor.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The internal buffers between the CIO2 and ImgU are freed by the
CIO2Device::stop() method, which is called first when stopping
streaming. The ImgUDevice::stop() method is then called, and attempts to
report completion for all queued buffers, which we have just freed. The
use-after-free corrupts memory, leading to crashes.
Fix this by moving the vector of internal buffers to the IPU3CameraData
where it belongs, and free the buffers after stopping both devices.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
To avoid printing debugging messages related to stream configuration
adjustement when generating a new configuration, set the pixel format
explicitly instead of relying on the internal validate() call to do so.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Fix a number of spelling errors and word duplications throughout the comments
within libcamera.
These were picked up with spellintian.
Also one capitalisation of the first word of a \return statement picked
up by checkstyle.py while creating this patch.
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Test buffer importing and mapping by streaming the VIMC camera to VIVID
video output device performing zero-copy memory sharing using dmabuf
file descriptors.
The test cycle 20 buffers between the camera and the output with a 1:1
buffer index to dmabuf fd mapping, then randomises the mapping with the
same number of buffers on each side for 20 more frames, to finally
increase the number of buffers on the output side for the 20 last
frames. No remapping of dmabuf fd to buffer index should occur for the
first 40 frames.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Add support for importing external buffers in all pipeline handlers.
Use the stream memory type in the pipeline handlers during buffer
allocation to import buffers to or export buffers from the video device.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Add and use an operation to assign to Buffer representing external
memory locations an index at queueRequest() time. The index is used to
identify the memory buffer to be queued to the video device once the
buffer will be queued in a Request.
In order to minimize relocations in the V4L2 backend, this method
provides a best-effort caching mechanisms that attempts to reuse
BufferMemory previously mapped to the buffer's dmabuf file descriptors,
if any.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Buffer instances reference memory, which is modelled internally by a
BufferMemory instance. Store a pointer to the BufferMemory in the Buffer
class, and populate it when the buffer is queued to the camera through a
request. This is useful for applications to access the buffer memory in
the buffer or request completion handler.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
In addition to referencing buffer memory by index, add support to
referencing it using dmabuf file descriptors. This will be used to
reference buffer memory allocated outside of libcamera and import it.
The dmabuf file descriptors are stored in an array in the Buffer class,
and a new Stream::createBuffer() overload is added to construct a buffer
from dmabuf file descriptor.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Define the memory type a Stream uses and allow application to set it
through the associated StreamConfiguration.
A Stream can use either internal or external memory allocation methods,
depending on where the data produced by the stream is actually saved.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
All interactions with the Stream's buffers currently go through the
BufferPool. In order to shorten accessing the buffers array, and eventually
restrict access to the Stream's internal buffer pool, provide operations to
access, create and destroy buffers.
It is still possible to access the pool for pipeline handlers to
populate it by exporting buffers from a video device to Stream's pool.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The cam and qcam applications, as well as the camera capture test case,
access the Stream::bufferPool in order to know how many requests to
initially queue. As part of an effort to remove access to the buffer
pool from applications, use the buffer count from the stream
configuration instead.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Access the number of allocated buffer for the streams through the stream
configuration instead of the stream's buffers pool.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
When stopping the stream buffers have been queued, in which case their
completion is never be notified to the user. This can lead to memory
leaks. Fix it by notifying completion of all queued buffers with the
status set to error.
As a result the base PipelineHandler implementation can be simplified,
as all requests complete as the result of stopping the stream. The
stop() method that manually completes all queued requests isn't needed
anymore.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The Buffer class is a large beast the stores information about the
buffer memory, dynamic metadata related to the frame stored in the
buffer, and buffer reference data (in the index). In order to implement
buffer import we will need to extend this with dmabuf file descriptors,
making usage of the class even more complex.
Refactor the Buffer class by splitting the buffer memory information to
a BufferMemory class, and repurposing the Buffer class to reference a
buffer and to store dynamic metadata. The BufferMemory class becomes a
long term storage, valid and stable from the time buffer memory is
allocated to the time it is freed. The Buffer class, on the other hand,
becomes transient, is created on demand when an application requires a
buffer, is given to a request, and is deleted when the request
completes.
Buffer and BufferMemory don't need to be copied, so their copy
constructor and assignment operators are deleted.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
When starting the stream on a capture video device it is often needed to
queue all the allocated buffers. Add a helper method to do so, and
refactor the existing queueBuffer() method to make it clearer.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Applications often have to map requests queued to a camera to external
resources. To make this easy, add a 64-bit integer cookie to the Request
class that is set when the request is created and can be retrieved at
any time, especially in the request completion handler. The cookie is
completely transparent for libcamera and is never modified.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
libcamera guarantees that requests complete in sequence. This
requirement is currently pushed down to pipeline handlers. Three out of
four of our pipeline handlers implement that requirement based on the
sole assumption that buffers will always complete in sequeuence, while
the IPU3 pipeline handler implements a more complex logic.
It turns out that the logic can be moved to the base PipelineHandler
class with support from the Request class. Do so to simplify the
pipeline handlers.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
There's no need to check if buffers have been allocated before freeing
them as the BufferPool::destroyBuffers() method is a no-op when no
buffers have been allocated. Document this fact explicitly, and remove
the buffer count check.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
For a historical reason that isn't fully understood, the request
completion handler in the Camera class moves all buffers away from the
request's buffer map to a local variable before emitting the request
completion signal. There's no reason to do so, and it makes it
impossible for requests to access buffers in their destructor. Fix it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
C++11 does not support std::clamp(), add a custom implementation in
utils.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Lower the resolution to the smallest vivid supports, 320x180, in order
to speed up the test. This isn't enough in itself as the frame rate also
has to be configured, but the V4L2VideoDevice class doesn't support
frame rate control yet. In the meantime the frame rate can be set
manually with yavta or v4l2-ctl.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
|
|
processing
An event notifier may be unregistered from its activated signal. This
can cause the notifiers set entry in notifiers_ to be deleted while
processNotifiers() is looping over the notifiers_ map, leading to
problems.
To fix this, add a flag to the EventNotifierPoll class to indicate that
event processing is in progress. If the flag is set, the notifiers_
entry is not deleted during notifier unregistration, but will be deleted
by the event processing loop.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The second argument to std::array is the size of the array, not of the
elements it contains. Fix this by turning the std::array into a simple
array of const char pointers.
Fixes: 099815b85377ac68 ("libcamera: ipa_module: add isOpenSource")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
|
|
The return value of a read() call is mistakenly checked for nonzero
rather than less than zero. Fix this.
Fixes: df23ab95f3d7 ("libcamera: process: fix compilation on Chromium OS")
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
|
|
Commit a25c937f8afe ("test: add logging API test") causes the build to
fail in the Chromium OS build environment, because the return value of a
function call marked with the __warn_unused_result__ attribute is ignored.
Fix this.
Fixes: a25c937f8afe ("test: add logging API test")
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Commit 3d20beca6616 ("libcamera: Add Process and ProcessManager
classes") causes the build to fail in the Chromium OS build environment,
because the return values of some function calls marked with the
__warn_unused_result__ attribute are ignored. Fix this.
Fixes: 3d20beca6616 ("libcamera: Add Process and ProcessManager classes")
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add the dummy IPA that needs isolation to meson. At the same time, clean
up the IPA meson to facilitate adding more IPAs.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|