Commit graph

652 commits

Author SHA1 Message Date
Laurent Pinchart
28535ea1a2 libcamera: v4l2_controls: Use the ControlRange class for control info
Use the ControlRange class to express the range of a V4L2 control,
replacing the open-coded minimum and maximum fields in the
V4L2ControlInfo class.

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-10-05 20:02:51 +03:00
Laurent Pinchart
186ae04c0c libcamera: v4l2_controls: Use the ControlValue class for data storage
Use the ControlValue class to replace the manually crafted data storage
in V4L2Control. This will help sharing code when more data types will be
supported.

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-10-05 20:02:51 +03:00
Laurent Pinchart
ace50f75a4 libcamera: controls: Rename ControlInfo to ControlRange
The ControlInfo class stores a range of valid values for a control. Its
name is vague, as "info" has multiple meanings. Rename it to
ControlRange.

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-10-05 20:02:51 +03:00
Laurent Pinchart
f1ab117e81 libcamera: controls: Remove ControlInfo::id
The ControlInfo id member is only used in the toString() method of the
class, and nowhere else externally. The same way that ControlValue
doesn't store a ControlId, ControlInfo shouldn't. Remove it.

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-10-05 20:02:51 +03:00
Laurent Pinchart
5a952df386 libcamera: controls: Remove the unused ControlList::update() method
The ControlList::update() method is unused. While it is meant to fulfil
a need of applications, having no user means that it is most probably
not correctly designed. Remove the method, we will add it back later if
needed.

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-10-05 20:02:51 +03:00
Laurent Pinchart
8ea6912c96 libcamera: controls: Auto-generate control_ids.h and control_ids.cpp
Bring back auto-generation of control ids. In this version, both the
header and the source files are generated from a single YAML file that
stores all control definitions. This allows centralising controls in a
single file, while the previous version required keeping both
declarations (in a header) and documentation (in a the source) in sync
manually.

Using YAML as a format to store control definitions is a trade-off
between ease of use (there are many YAML parsers available) and
simplicity (XML was considered, but would have lead to more complex
processing). A new build time dependency is added on python3-yaml, which
should be available as a package in all distributions and build
environments.

The YAML format is likely to change over time as we improve
documentation of controls, the first version simply copies the
information currently available. Future improvements should also include
a YAML schema to validate the YAML source file.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-05 20:02:51 +03:00
Laurent Pinchart
a8c40942b9 libcamera: controls: Improve the API towards applications
Rework the control-related classes to improve the API towards
applications. The goal is to enable writing code similar to

	Request *req = ...;
	ControlList &controls = req->controls();
	controls->set(controls::AwbEnable, false);
	controls->set(controls::ManualExposure, 1000);

	...

	int32_t exposure = controls->get(controls::ManualExposure);

with the get and set operations ensuring type safety for the control
values. This is achieved by creating the following classes:

- Control defines controls and is the main way to reference a control.
  It is a template class to allow methods using it to refer to the
  control type.

- ControlId is the base class of Control. It stores the control ID, name
  and type, and can be used in contexts where a control needs to be
  referenced regardless of its type (for instance in lists of controls).
  This class replaces ControlIdentifier.

- ControlValue is kept as-is.

The ControlList class now exposes two template get() and set() methods
that replace the operator[]. They ensure type safety by infering the
value type from the Control reference that they receive.

The main way to refer to a control is now through the Control class, and
optionally through its base ControlId class. The ControlId enumeration
is removed, replaced by a list of global Control instances. Numerical
control IDs are turned into macros, and are still exposed as they are
required to communicate with IPAs (especially to deserialise control
lists). They should however not be used by applications.

Auto-generation of header and source files is removed for now to keep
the change simple. It will be added back in the future in a more
elaborate form.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-04 19:33:08 +03:00
Laurent Pinchart
dd37ef784e libcamera: controls: Use explicit 32-bit integer types
Make the control API more explicit when dealing with integer controls by
specifying the size. We already do so for 64-bit integers, using int64_t
and ControlTypeInteger64, do the same for 32-bit integers.

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-10-04 19:33:08 +03:00
Laurent Pinchart
224ef9776a libcamera: controls: Make ControlValue get/set accessors template methods
The ControlValue get accessors are implemented with functions of
different names, whlie the set accessors use polymorphism to support
different control types. This isn't very consistent and intuitive. Make
the API clearer by using template methods. This will also have the added
advantage that support for the new types will only require adding
template specialisations, without adding new methods.

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-10-04 19:33:08 +03:00
Laurent Pinchart
c5dfd9d57e libcamera: controls: Rename ControlValueType to ControlType
The type of a control value is also the type of the control. Shorten the
ControlValueType enumeration to ControlType, and rename ControlValue* to
ControlType* for better clarity.

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-10-04 19:33:08 +03:00
Jacopo Mondi
594de3aed3 ipa: ipa_manager: Print the loaded IPA modules path
Add debug message to report which IPA modules have been loaded and in
which order.

The loading order is particularly relevant for the test VIMC IPA, as the
same IPA is compiled with an open source license tag and a proprietary
one and they both match() against the VIMC pipeline handler. Being
informed about their loading order is helpful to understand which one of
the two is actually in use.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-10-04 19:02:05 +03:00
Laurent Pinchart
200bb4c60f libcamera: ipa_manager: Sort IPA modules by name
Sort IPA modules by name when enumerating modules in a directory in
order to guarantee a stable ordering. This eases debugging by making
issues more reproducible.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-10-04 19:01:21 +03:00
Laurent Pinchart
f102ea69cc libcamera: camera_manager: Fix typo in the documentation
Fix a typo in the CameraManager documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-10-04 18:25:36 +03:00
Niklas Söderlund
5d8ae4f488 qcam: Fix timers not emitting timeout signal
The timer signal was never emitted in QtEventDispatcher::timerEvent(),
this results in timers not working as designed running under the Qt
event loop. Fix this by emitting the signal on timeout.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-10-01 15:26:22 +02:00
Niklas Söderlund
82bf40e1f0 qcam: Stop timer on timeout
Stopping the timer will reset the Timer::deadline_ field to 0 fixing
potential bugs and call QtEventDispatcher::unregisterTimer() which will
take care of the cleanup.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-10-01 15:24:59 +02:00
Niklas Söderlund
b13b134616 qcam: Fix unregister of not registered timer
If an unregistered timer is given to QtEventDispatcher::unregisterTimer()
an error is printed and Qt gets confused and locks up. Fix this by
following the libcamera documentation that passing a unregistered timer
is a no-op.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-27 21:30:37 +02:00
Kieran Bingham
f0b2582c49 qcam: Fix ViewFinder memory leak
When setting the format on the ViewFinder, a new image_ is allocated.
Any change in format deletes the existing allocation, but it is not
cleaned up on shutdown:

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f0bf8a7e17f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10e17f)
    #1 0x564c7205f7b0 in ViewFinder::setFormat(unsigned int, unsigned int, unsigned int) ../src/qcam/viewfinder.cpp:43
    #2 0x564c71fec467 in MainWindow::startCapture() ../src/qcam/main_window.cpp:152
    #3 0x564c71fe6c1a in MainWindow::MainWindow(libcamera::CameraManager*, OptionsParser::Options const&) ../src/qcam/main_window.cpp:40
    #4 0x564c71fdf133 in main ../src/qcam/main.cpp:76
    #5 0x7f0bf5944b6a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26b6a)

Provide a ViewFinder destructor, and delete the allocation as
appropriate.

Fixes: 97e8b3a2eb ("qcam: Add Qt-based GUI application")
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-09-24 17:35:23 +01:00
Laurent Pinchart
ad0a61e32c libcamera: ipa_manager: Rework error messages when enumerating IPAs
When enumerating IPAs, the system IPA directory and all the directories
listed in the LIBCAMERA_IPA_MODULE_PATH environment variable are listed
in turn. Failing to list any of those directories results in an error
message being printed for every failure. This is particularly common
when developing libcamera, as IPAs may not have been installed locally.

To avoid unnecessarily worrying error messages, rework the enumeration
procedure to only print a message when no IPA can be found at all.
Individual missing directories are not considered as an issue anymore.
The message is also downgraded from an error to a warning as the
situation may still be normal.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-23 09:50:50 +03:00
Laurent Pinchart
448393f77e libcamera: proxy: linux: Initialise pointer members at construction time
If the IPAProxyLinux constructor fails to locate the proxy worker, the
socket_ and proc_ member pointers will be left uninitialised, leading
the a crash in the destructor. Initialise them both to nullptr.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-15 17:26:45 +03:00
Laurent Pinchart
4ec807192d ipa: Generate the two dummy IPA modules from the same source
The ipa_dummy.cpp and ipa_dummy_isolate.cpp only differ in the license
reported in the IPAModuleInfo structure. Drop the second file and
generate the two .so from ipa_dummy.cpp, with the license defined
through the command line.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-15 13:58:21 +03:00
Laurent Pinchart
ba44276dd1 libcamera: Move list of private headers to src/libcamera/include/meson.build
The libcamera private headers are listed in src/libcamera/meson.build,
while they are located in src/libcamera/include/. The lack of a
meson.build in src/libcamera/include/ increases the risk of forgetting
to add new headers to the libcamera_headers array. Fix it by moving it
to src/libcamera/include/meson.build, and add the missing
v4l2_controls.h entry.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-15 13:58:18 +03:00
Laurent Pinchart
1e704c84a9 libcamera: Move ipa includes to the same level as libcamera
The ipa includes are located in include/libcamera/ipa/. This gives an
incorrect impression that they are a sub-part of the rest of the
libcamera API, while they are the API towards the IPA the same way that
include/libcamera/ contains the API towards applications. To clarify
this, move them to include/ipa/.

The IPA headers are however still part of libcamera, so installing them
to ${prefix}/include/ipa/ would make little sense. To fix this, move the
application facing API to ${prefix}/include/libcamera/libcamera/ when
installed, and the IPA to ${prefix}/include/libcamera/ipa/. When major
versions of libcamera will be released, they could then be installed
side by side in ${prefix}/include/libcamera-${version}/.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-15 13:57:08 +03:00
Laurent Pinchart
cecfeed61e libcamera: Switch to the std::chrono API
Replace the clock_gettime()-based API with durations expressed as
integers with the std::chrono API.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-09-14 15:05:45 +03:00
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
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
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
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