Commit graph

972 commits

Author SHA1 Message Date
Laurent Pinchart
98dff063f2 libcamera: utils: Add clock helpers
In preparation for standardisation of the std::chrono::steady_clock as
the libcamera default clock, define aliases for the clock, duration and
time point, and add helper functions to convert a duration to a timespec
and a time point to a string. More helpers will be added later as
needed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-09-14 15:05:29 +03:00
Laurent Pinchart
304574420d qcam: Fix compilation errors with gcc-9 and Qt < 5.13
gcc-9 has introduced a deprecated-copy warning that is triggered by Qt
header files. The issue has been fixed in Qt 5.13. Fix compilation with
earlier Qt versions by disabling the warning. In order to still benefit
from the warning when possible, only disable it for gcc-9 and Qt < 5.13.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-09-13 22:12:07 +03:00
Laurent Pinchart
04b20723d4 libcamera: device_enumerator_udev: Support entities sharing device nodes
Some media devices, such as V4L2 M2M devices, share the same device node
for multiple entities. The udev enumerator used to support this, but
commit 6e62034900 ("libcamera: device_enumerator: fix udev media graph
loading dependency") broke this.

To fix the problem, rework the media device to V4L2 devices matching
code. A new MediaDeviceDeps internal struct stores unmet device number
dependencies for a media device, and is stored in a list of pending
media devices. To avoid linear lookups, the dependencies are cached in a
reverse map of device number to media device dependencies.

Fixes: 6e62034900 ("libcamera: device_enumerator: fix udev media graph loading dependency")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-13 20:13:26 +03:00
Laurent Pinchart
e832a00bab libcamera: device_enumerator_udev: Avoid double list lookup
DeviceEnumeratorUdev::populateMediaDevice() searches for orphan devices
in an std::list, and if found removes them using std::list::remove().
This ends up looking up the entry twice. Replace the remove() call with
erase() to fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-13 20:13:24 +03:00
Laurent Pinchart
7516d41080 libcamera: device_enumerator_udev: Delay device node lookup
When populating media devices, we look up device nodes for every entity
in the media device, regardless of if the entity is present in the
orphans list. This causes unnecessary lookups (that may also fail as the
device node may not be ready yet at that time). Move the lookup at a
later time, when the device node is actually needed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-13 20:13:22 +03:00
Laurent Pinchart
b3cdccbff9 libcamera: device_enumerator: Move lookupDeviceNode() to child classes
The lookupDeviceNode() method is declared as pure virtual in the base
DeviceEnumerator class, but is only called by derived classes. Move it
to the DeviceEnumeratorSysfs and DeviceEnumeratorUdev. This allows
changing the udev version to take a dev_t instead of separate
major/minor, as that's what both the caller and the callee end up using.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-13 20:13:16 +03:00
Laurent Pinchart
edd60994e8 Documentation: Exclude bound_method.{h,cpp}
The bound method classes are not part of the public API, even though
they need to be exposed to applications due to the Object and Signal
template methods that use them. They are excluded from documentation
generation through EXCLUDE_SYMBOLS, but the corresponding .h file is
still listed in the generated documentation. Fix this by excluding the
bound_method.{h,cpp} files themselves.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-09-13 12:17:48 +03:00
Kieran Bingham
ff09b6d378 test: process: Extend timeout duration
The process test runs for just 100mS. The spawned process runs for at
least 50mS. Ordinarily this should allow plenty of time for both the
process to be spawned and run, but when adding extra debug
instrumentation, the processes can be slowed down, leading to a false
negative test failure.

Extend the timeout to 2 seconds to allow the short process to be run
correctly - but use the now initialised exitStatus_ to exit the event
loop as soon as the process has completed.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-09-13 09:21:40 +01:00
Kieran Bingham
122892d1bc test: process: Initialise member variables
The ProcessTest() declares member variables but leaves them unitialised.
Set them appropriately from the constructor.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-09-13 09:21:40 +01:00
Kieran Bingham
ee35abb7c7 test: process: Connect signal before launching process
The procFinished event handler is registered after the process is
started. This doesn't actually create any race, as the finished signal
is emitted after a SIGCHLD is caught and handled through the
ProcessManager and processed by the event loop.

However, to follow the best practice that resources should be acquired
before performing an action, connect the finished signal before starting
the process.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-09-13 09:21:37 +01:00
Fabrice Fontaine
5d05418d9b src/libcamera/meson.build: link with atomic when needed
On some architectures, atomic binutils are provided by the libatomic
library from gcc. Linking with libatomic is therefore necessary,
otherwise the build fails with:

src/libcamera/4ab8042@@camera@sha/message.cpp.o: In function `libcamera::Message::registerMessageType()':
message.cpp:(.text+0x178): undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status

This is often for example the case on sparc v8 32 bits.

Fixes:
 - http://autobuild.buildroot.org/results/1f0b8338f5f39aa86b9d432598dae2f53c5f7c84

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Kieran: Updated commit message to refer to build failure on current
master, rather than the old code currently built by buildroot]
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-09 11:44:49 +01:00
Paul Elder
6e62034900 libcamera: device_enumerator: fix udev media graph loading dependency
When a MediaDevice is enumerated and populated by the
DeviceEnumeratorUdev, there is a possibility that the member device
nodes of the media graph would not be ready (either not created, or
without proper permissions set by udev yet). The MediaDevice is still
passed up to the pipeline handler, where an attempt to access the device
nodes will fail in EPERM. This whole issue is especially likely to
happen when libcamera is run at system init time.

To fix this, we first split DeviceEnumerator::addDevice() into three
methods:
- createDevice() to simply create the MediaDevice
- populateMediaDevice() to populate the MediaDevice
- addDevice() to pass the MediaDevice up to the pipeline handler

DeviceEnumeratorSysfs calls these methods in succession, similar to what
it did before when they were all together as addDevice().

DeviceEnumeratorUdev additionally keeps a map of MediaDevices to a list
of pending device nodes (plus some other auxillary maps), and a simple
list of orphan device nodes. If a v4l device node is ready and there
does not exist any MediaDevice node for it, then it goes to the orphan
list, otherwise it is initialized and removed from the pending list of
the corresponding MediaDevice in the dependency map. When a MediaDevice
is populated via DeviceEnumeratorUdev::populateMediaDevice(), it first
checks the orphan list to see if the device nodes it needs are there,
otherwise it tries to initialize the device nodes and if it fails, then
it adds the device nodes it wants to its list in the dependency map.

This allows MediaDevice instances to be created and initialized properly
with udev when v4l device nodes in the media graph may not be ready when
the MediaDevice is populated.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-08 19:50:11 -04:00
Jacopo Mondi
19f85f43ff android: camera_device: Report available keys
Report the list of available static metadata tags (characteristicKeys),
of supported controls (requestKeys) and produced metadata (resultKeys)
in the static metadata pack.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-05 23:29:22 +02:00
Jacopo Mondi
fcd5a4f335 android: camera_device: Fix handling of request template
According to the Android camera HALv3 documentation, the request
template metadata pack should not be modified after it is returned to
the camera stack from the HAL.

Currently, the same metadata pack is used for all types of template
request, without updating the capture intent there contained to match
the requested template type, as correctly reported by the
cros_camera_test test application.

In order to avoid modifying the single request template already returned
to the camera stack in order to update the capture intent it contains,
create a map that associates a dedicated template to each supported
capture type.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-05 23:27:36 +02:00
Laurent Pinchart
3986009cf1 android: camera_device: Use the new CameraMetadata helper class
Simplify the implementation of metadata handling in the CameraDevice
class by using the new CameraMetadata helper class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-05 23:27:34 +02:00
Laurent Pinchart
9214e2b493 android: Add CameraMetadata helper class
The new CameraMetadata helper class wraps the Android camera_metadata_t
to simplify its usage.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-05 23:07:53 +02:00
Jacopo Mondi
637034742f android: camera_device: Use precise sizes for request template
Use more opportune sizes, manually calculated, for the generated request
template.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-05 23:07:53 +02:00
Jacopo Mondi
9b361dc4bc android: camera_device: Add missing tags in request template
Add two missing tags from the request template generated by the HAL.
The tags are reported as missing by the cros_camera_test tool.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-05 23:07:53 +02:00
Jacopo Mondi
31f784c47b android: camera_device: Remove tags from request template
Remove metadata tags wrongly added to the request template constructed
by the libcamera HAL.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-05 23:07:53 +02:00
Jacopo Mondi
48504ba143 android: camera_device: Use correct sizes for static metadata
Use more opportune sizes for the static metadata pack, and for the
dynamic metadata sizes which where wrongly set to use the ones defined
for the static pack.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-05 23:07:53 +02:00
Jacopo Mondi
b4893fce68 android: camera_device: Add missing static metadata
Add all the static metadata keys part of the BC (backward compatible)
metadata group, which represent the minimum requirement for devices
supporting the LIMITED hardware level.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-05 23:07:53 +02:00
Niklas Söderlund
808a7fc04e libcamera: v4l2_device: Fix error messages in setControls()
The error messages are copied from getControls() without being updated
for the set controls case, fix this.

Fixes: eb068f4e67 ("libcamera: v4l2_device: Implement get and set controls")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-08-29 16:46:15 +02:00
Laurent Pinchart
8a92e6fc72 meson: Rename 'tests' option to 'test'
The 'tests' option enables compilation of tests. On Gentoo and Chrome
OS, the corresponding package USE flag is named 'test'. Rename the
option to 'test' to bring it in line.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-22 19:35:54 +03:00
Laurent Pinchart
965c5bf7fb meson: Define _FORTIFY_SOURCE for optimised builds
_FORTIFY_SOURCE adds useful checks during compilation. The option is
enabled by default by gcc on all non-optimised builds (as it requires
-O1 or higher). Enable it explicitly for clang.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-08-22 11:10:43 +03:00
Laurent Pinchart
af4304e497 libcamera: process: Properly ignore unused result with gcc
Casting the return value of a function to (void) doesn't ignore the
unused result warning with gcc. Use a #pragma to fix this properly, to
fix compilation with _FORTIFY_SOURCE.

Fixes: df23ab95f3 ("libcamera: process: fix compilation on Chromium OS")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-08-22 11:09:05 +03:00
Kieran Bingham
d209b2d4b4 libcamera: v4l2_videodevice: Support MPLANE M2M devices
M2M devices using MPLANE API will set the V4L2_CAP_VIDEO_M2M_MPLANE
capability flag.

Ensure that this is matched when checking for Multiplanar capabilities.

Fixes: 4f7625cca7 ("libcamera: v4l2_videodevice: Support M2M devices")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-21 12:48:03 +01:00
Laurent Pinchart
82bdcc91fc android: camera_device: Store static metadata in cache
The CameraDevice class has a mechanism to cache static metadata, but
doesn't use it. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:08:08 +03:00
Laurent Pinchart
53704ac3f4 libcamera: camera_manager: Construct CameraManager instances manually
The CameraManager class is not supposed to be instantiated multiple
times, which led to a singleton implementation. This requires a global
instance of the CameraManager, which is destroyed when the global
destructors are executed.

Relying on global instances causes issues with cleanup, as the order in
which the global destructors are run can't be controlled. In particular,
the Android camera HAL implementation ends up destroying the
CameraHalManager after the CameraManager, which leads to use-after-free
problems.

To solve this, remove the CameraManager::instance() method and make the
CameraManager class instantiable directly. Multiple instances are still
not allowed, and this is enforced by storing the instance pointer
internally to be checked when an instance is created.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:07:45 +03:00
Laurent Pinchart
3e4672f159 android: camera_hal_manager: Clean up resources when terminating
The CameraHalManager starts the libcamera CameraManager and creates
CameraProxy instances for each camera in the system. Clean up those
resources when the CameraHalManager terminates.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:07:41 +03:00
Laurent Pinchart
dadd1fd8fe android: camera_hal_manager: Remove unused close() method
The CameraHalManager::close() method isn't used, remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:07:33 +03:00
Laurent Pinchart
06166a331c android: camera_hal_manager: Stop thread when destroying
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>
2019-08-19 19:07:33 +03:00
Laurent Pinchart
0ed40d2cd4 android: Pass Camera shared pointer to CameraProxy by const reference
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>
2019-08-19 19:07:33 +03:00
Laurent Pinchart
5ce4bb62e7 test: camera: Use the CameraManager from the CameraTest base class
Make the camera manager a protected field of the CameraTest class, and
use it instead of CameraManager::instance() in the camera tests. This
prepares for the removal of CameraManager::instance().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:06:50 +03:00
Laurent Pinchart
fd0087b5d8 test: Get event dispatcher from current thread
For all tests that don't otherwise require access to the camera manager,
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>
2019-08-19 19:06:37 +03:00
Laurent Pinchart
8c9deeb30f test: unixsocket: Fix typo in error message
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:06:37 +03:00
Laurent Pinchart
57baad97b9 test: event-thread: Fix compilation on Chromium OS
Commit 92b4af98cd ("test: Add EventNotifier thread move test") causes
the build to fail in the Chromium OS build environment, because the
return values of the pipe() function marked with the
__warn_unused_result__ attribute is ignored. Fix this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:06:37 +03:00
Laurent Pinchart
af49b18c81 qcam: Pass camera manager to MainWindow class
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>
2019-08-19 19:06:23 +03:00
Laurent Pinchart
749dbd576f qcam: Remove double stop of the camera manager
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>
2019-08-19 18:07:40 +03:00
Laurent Pinchart
4403a66789 libcamera: proxy: Get event dispatcher from current thread
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>
2019-08-19 18:07:30 +03:00
Laurent Pinchart
d0cf816569 libcamera: device_enumerator: Print media device name in error message
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>
2019-08-19 18:07:29 +03:00
Laurent Pinchart
0c32433d8c android: Simplify thread RPC with Object::invokeMethod()
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>
2019-08-19 18:07:28 +03:00
Laurent Pinchart
778f6b1d70 test: Simplify tests with parent-child relationships
Create object instances with a parent to avoid the need for reparenting
objects manually.

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>
2019-08-17 18:47:17 +03:00
Laurent Pinchart
d7aded92d3 test: object: Extend object test to verify parent-child relationships
The test verifies correct behaviour of parent-child relationships in
relation to thread affinity.

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>
2019-08-17 18:47:17 +03:00
Laurent Pinchart
1554d0b6e6 libcamera: Add parent argument to constructors of Object-derived classes
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>
2019-08-17 18:47:17 +03:00
Laurent Pinchart
2b25819ec0 libcamera: object: Create parent-child relationships
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>
2019-08-17 18:47:17 +03:00
Laurent Pinchart
4d9f1a0efc test: Add Timer thread move test
The test verifies correct behaviour of a running timer moved to a
different 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>
2019-08-17 18:47:17 +03:00
Laurent Pinchart
92b4af98cd test: Add EventNotifier thread move test
The test verifies correct behaviour of an enabled event notifier moved
to a different 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>
2019-08-17 18:46:54 +03:00
Laurent Pinchart
6ecf99a708 libcamera: timer: Bind timers to threads
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>
2019-08-17 18:32:42 +03:00
Laurent Pinchart
0c3fd6eb14 libcamera: event_notifier: Bind event notifiers to threads
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>
2019-08-17 18:32:38 +03:00
Laurent Pinchart
b566e97aac libcamera: camera_manager: Bind CameraManager to threads
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>
2019-08-17 18:32:38 +03:00