Age | Commit message (Collapse) | Author |
|
The CameraHalManager starts a thread that is never stopped. This leads
to the thread being destroyed while running, which causes a crash. Fix
this by stopping the thread and waiting for it to finish in the
destructor of the CameraHalManager.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The CameraProxy is constructed with a Camera instance passed through a
shared pointer. It forwards it to the CameraDevice constructor, which
takes a reference used for the sole purpose of making an internal copy
of the shared pointer. Both constructors can thus take a const reference
instead of a value or a mutable reference. This optimises the
constructors slightly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Pass the CameraManager instance from the main() function to the
MainWindow class instead of accessing it through
CameraManager::instance(). This prepares for the removal of the
CameraManager::instance() method.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The camera manager is stopped both in the destructor of the MainWindow
class and in the main() function. This double stop isn't needed, remove
the former and keep the latter as the manager is started in the main()
function.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Get the event dispatcher from the current thread instead of the camera
manager. This prepares for the removal of CameraManager::instance().
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The device enumerator logs an error message when a media device is
removed while still in use. Add the device name to the message to help
debugging.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Replace the manual implementation of asynchronous method invocation
through a custom message with Object::invokeMethod(). This simplifies
the thread RPC implementation.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Now that the Object class implements parent-child relationships, make it
possible to create EventNotifier and Timer instances with a parent by
adding a parent argument to their constructors.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Add a parent Object to Object instances, and track the parent-children
relationships. Children are bound to the same thread as their parent,
and moving an Object to a thread automatically moves all its children.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The Timer instances are registered with the event dispatcher instance of
the CameraManager. This makes it impossible to use timers in other
threads.
Fix this by inheriting from Object, which allows binding instances to a
thread, and register them with the event dispatcher for the thread they
are bound to.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The EventNotifier instances are registered with the event dispatcher
instance of the CameraManager. This makes it impossible to use event
notifiers in other threads.
Fix this by inheriting from Object, which allows binding instances to a
thread, and register them with the event dispatcher for the thread they
are bound to.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The CameraManager class uses the event dispatcher of the current thread.
This makes the CameraManager::eventDispatcher() and
CameraManager::setEventDispatcher() methods inconsistent, as they access
different event dispatcher instances depending on the calling thread.
Fix this by inheriting from the Object class, which binds the
CameraManager to a thread, and use the event dispatcher of the bound
thread.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Send a synchronous message to objects just before they get moved to a
new thread. This allows the object to perform any required processing.
EventNotifier and Timer objects will use this mechanism to move
themselves to the new thread's event disaptcher.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Add a helper invokeMethod() to the Object class that allows asynchrnous
invocation of any method of an Object instance. Asynchronous invocation
occurs when control returns to the event dispatcher of the target
object's thread, in the context of that thread.
To support this, generalise the SignalMessage implementation to support
automatic deletion of the associated BoundMethod, and rename the message
to InvokeMessage to reflect the more generic purpose.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
To make the BoundMethod classes more generic, replace direct access to
private member from Signal classes with accessors or helper functions.
This allows removal of friend statements from the BoundMethod classes.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Move the Slot* classes to bound_method.{h,cpp} and rename them to
Bound*Method*. They will be reused to implement asynchronous method
invocation similar to cross-thread signal delivery.
This is only a move and rename, no functional changes are included.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Threads contain message queues and dispatch queued messages in their
event loop, in Thread::exec(). This mechanism prevents the main thread
from dispatching messages as it doesn't run Thread::exec().
Fix this by moving message dispatching from Thread::exec() to
EventDispatcher::processEvents().
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
When moving an object to a different thread, messages posted for the
object are moved to the message queue of the new thread. Wake up the new
thread to ensure it processes the moved messages.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The CameraHalManager::getCameraInfo() validates the camera id it
receives from the camera service, and in doing so generates a compiler
error with gcc as the id is an unsigned integer and can never be
negative:
../src/android/camera_hal_manager.cpp: In member function ‘CameraProxy* CameraHalManager::open(unsigned int, const hw_module_t*)’:
../src/android/camera_hal_manager.cpp:89:9: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
if (id < 0 || id >= numCameras()) {
Fix it by removing the unneeded comparison.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
V4L2 M2M devices represent a V4L2Device with two queues: One output, and
one capture on a single device node.
Represent this by instantiating a V4L2VideoDevice for each queue type,
and preparing each device for its queue.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The "Opened device" statement occurs before the buffertype_ is set.
This causes all devices to report that they are [out] devices at open()
regardless of their type.
As the message operates in the past-tense, move the statement to the end
of the function when all work has been completed.
Fixes: 04d5be7f76fe ("libcamera: v4l2_device: Inherit from Loggable to print device node name")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Provide a means for V4L2 device instances to set the fd_ explicitly.
This allows for V4L2Devices to operate when they must use an external
open() call.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The CameraHalManager::getCameraInfo() validates the camera id it
receives from the camera service, and in doing so compares it with an
unsigned integer, generating a compiler error:
src/android/camera_hal_manager.cpp:121:9: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
if (id >= numCameras() || id < 0) {
~~ ^ ~~~~~~~~~~~~
Fix this by turning the id into an unsigned int, as camera ids can't be
negative. If a negative id is received from the camera service it will
be converted to a large unsigned integer that will fail the comparison
with numCameras().
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add libcamera Android Camera HALv3 implementation.
The initial camera HAL implementation supports the LIMITED hardware
level and uses statically defined metadata and camera characteristics.
Add a build option named 'android' and adjust the build system to
selectively compile the Android camera HAL and link it against the
required Android libraries.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add SPDX tag to the android metadata library files licensed under
Apache-2.0.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|