Commit graph

5598 commits

Author SHA1 Message Date
Laurent Pinchart
ce24c052de libcamera: log: Add an ASSERT macro
The ASSERT() macro is similar to the assert() macro defined by the C
standard, but uses the libcamera logging infrastructure.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-08 16:23:16 +02:00
Laurent Pinchart
99a3e7bcfb libcamera: log: Add a LogFatal log level
The LogFatal log level is similar to the LogError level, but
additionally abort program execution. This is useful to implement
assertion handlers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-08 16:23:16 +02:00
Kieran Bingham
e256a58bf0 Documentation: Suppress normal doxygen output
Enable the QUIET mode of Doxygen so that warnings and errors from
Doxygen are more prominent in the build logs.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-08 14:13:11 +00:00
Kieran Bingham
eda3cfa1e3 libcamera: media_object: Rename major/minor functions
The system libraries define macro's for major/minor through
<sys/types.h> on some versions of GCC/GLibc.

To prevent namespace collisions with these macros, rename our major and
minor device node accessors.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-08 13:14:29 +00:00
Laurent Pinchart
5af15d1931 libcamera: pipeline_handler: Improve documentation
Miscellaneous documentation improvements for the PipelineHandler and
related 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>
2019-01-04 00:23:33 +02:00
Laurent Pinchart
2d73fd9eca libcamera: pipeline_handler: Remove unneeded forward declaration
There's no need to forward-declare the PipelineManagerFactory class.
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-01-04 00:23:32 +02:00
Laurent Pinchart
1e04362d6e libcamera: device_enumerator: Improve documentation
Miscellaneous documentation improvements for the DeviceEnumerator and
related 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>
2019-01-04 00:23:30 +02:00
Laurent Pinchart
a87cb586e2 libcamera: device_enumerator: Constify argument to search function
The DeviceEnumerator::search() function doesn't need to modify its
DeviceMatch argument, make it const.

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-01-04 00:23:29 +02:00
Laurent Pinchart
079c5fe63d libcamera: device_enumerator: Fix wording of log message
The log message still refers to the DeviceInfo class that has been
removed. Replace it with a reference to MediaDevice.

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-01-04 00:23:27 +02:00
Laurent Pinchart
b63209a793 libcamera: device_enumerator: Downgrade skipped device errors to warnings
When a device is skipped by the udev-based enumerator a message is
logged. Downgrade its severity to warning as the error isn't fatal.

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-01-04 00:23:26 +02:00
Laurent Pinchart
9f5d6ee69f libcamera: device_enumerator: Fix indentation
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-01-04 00:23:24 +02:00
Laurent Pinchart
6b0c2f027a libcamera: camera_manager: Sort includes alphabetically
Alphabetically sorted includes help finding where to insert new include
statements, and avoiding duplicates.

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-01-04 00:23:23 +02:00
Laurent Pinchart
6ddbf354d5 libcamera: camera_manager: Remove put() method
The method is declared but not implemented. 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-01-04 00:23:12 +02:00
Jacopo Mondi
171f4c0a0d libcamera: Use 'struct' for structure types
Add back the 'struct' keyword for structure types.
C++ allows omitting the 'struct' keywork. Add it back to make clear
we're dealing with structures and not class types.

While at there re-sort fields of media_v2_* type in populate() function
to reflect the declaration order in the kernel headers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-03 09:16:31 +01:00
Jacopo Mondi
4e5a93da83 libcamera: media_device: Minor cleanup in findInterface()
Do not compare an usigned int with -1 to avoid going through cast.
Also align function parameters and long assignement lines while at there.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-03 09:10:50 +01:00
Kieran Bingham
4863d44104 licenses: Add the Developer CoO
Provide a reference copy of the Developers Certificate of Origin.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 21:59:46 +02:00
Laurent Pinchart
c59272f417 libcamera: media_device: Zero media graph arrays when querying topology
This silences valgrind that otherwise warns about usage of uninitialized
values. While not strictly required as the kernel should fill the whole
arrays in MEDIA_IOC_G_TOPOLOGY, the extra cost, in a non-critical path,
is negligible compared to the ability to run without valgrind warnings.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 13:29:45 +02:00
Jacopo Mondi
1b80471805 libcamera: media_device: Make getEntityByName() const
The function does not modify the instance state. Mark it as const.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-02 12:21:45 +01:00
Jacopo Mondi
ea3fa2680c libcamera: media_device: Tiny valid() documentation improvement
Mention in the valid() method documentation, that a media graph has to
be populated to be valid.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-02 12:21:15 +01:00
Jacopo Mondi
d83269aae0 libcamera: device_enumerator: Use MediaDevice
Replace usage of the DeviceInfo class with MediaDevice in the
DeviceEnumerator and remove the DeviceInfo class.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 12:59:04 +02:00
Jacopo Mondi
d4af90d729 libcamera: media_device: Create entities with major and minor numbers
Extend the MediaEntity object with device node major and minor numbers,
and retrieve them from the media graph using interfaces. They will be
used by the DeviceEnumerator to retrieve the devnode path.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 12:53:55 +02:00
Jacopo Mondi
14291e50b7 libcamera: media_device: Add DeviceInfo features
Add the features of the DeviceInfo class needed to replace it with
MediaDevice.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 12:35:18 +02:00
Kieran Bingham
b403cb4550 test: Move include definitions to libtest
With the libtest functionality moved to its own library folder, the
definitions for test includes should reasonably live there too.

The libtest subdir should always remain the first entry in the
test/meson.build file.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 11:08:20 +02:00
Kieran Bingham
5802259b3c test: Use foreach iterators to simplify definitions
Create two arrays, to contain public and internal test targets, and use
the foreach iterators to automatically generate test output targets for
each entry in each array.

The public tests array is linked only against public libcamera headers,
while tests declared in the internal_tests will have access to
non-public API headers from within the libcamera sources.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 11:07:27 +02:00
Kieran Bingham
a9fe3adc4f test: media_device: Move test definition
The test definition for the media_device_test executable should be
located with the exectuable definition.

Move it to the meson.build of that test suite subdir.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 11:05:26 +02:00
Laurent Pinchart
7e9e508093 libcamera: Remove libcamera class
The class was just a placeholder, now that we have other objects
defined, remove it along with the associated test.

The libcamera/libcamera.h header is kept as a shortcut to include the
whole libcamera public API.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 03:28:19 +02:00
Laurent Pinchart
a591cc8655 libcamera: mediadevice: Improve documentation
Improve the documentation of the media device operation, including how
it handles the lifetime of media objects.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-02 02:38:10 +02:00
Laurent Pinchart
dc647a6707 libcamera: mediadevice: Reorder functions in declaration order
In order to simplify navigation in the .cpp file, order functions in the
declaration order in the .h file.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-02 02:36:29 +02:00
Laurent Pinchart
492019745d libcamera: mediadevice: Make getEntityByName() public
The function is useful as a public API, make it public.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-02 02:35:36 +02:00
Laurent Pinchart
67dce611e5 libcamera: mediadevice: Fix graph parsing error handling
Most errors recorded during graph parsing are logged but not propagated
to the caller. Fix this and delete objects that are created but not
successfully added to the graph to avoid memory leaks. As the error code
returned from the addObject() and populate*() functions doesn't matter
much, turn them into bool functions.

Additionally, add a way to query whether the media graph was valid, and
clear objects before populating the graph to avoid leaking them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-02 02:35:25 +02:00
Kieran Bingham
26d9f28c1b meson: Shorten project description
The project description is really the project name. The extraneosly long
string gets printed at the test runner prefixed to the suite. As such it
should really be the shortened simple project name.

Remove the 'description' from the project naming field.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-01 18:24:22 +02:00
Kieran Bingham
e3694a3ae8 test: libtest: Return all non-zero init values
A skipped test is currently defined as returning 77. If this is returned
by the init stage, currently the execute call will continue on to the
run stage.

Correct this such that any non-zero return code from the init phase will
abort the test.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-01 18:24:22 +02:00
Kieran Bingham
e3bb826e66 test: libtest: Add test return codes
The meson test infrastructure uses return codes to determine test
results. Define these values for use in tests.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Use an enum instead of macros for test return codes.]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-01 18:24:22 +02:00
Kieran Bingham
3900b0771e test: Move test objects to libtest
Create a subdirectory to contain the libtest helper library.

Define two variables to clarify when tests are aimed at public or
internal components.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-01 18:24:22 +02:00
Jacopo Mondi
b43f56c46d test: Add media device test
Add media device test infrastructure and an intial test that
print out the media devices available in the system.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 19:01:35 +01:00
Jacopo Mondi
363824662f libcamera: Add MediaDevice class
The MediaDevice object implements handling and configuration of the media
graph associated with a media device.

The class allows enumeration of all pads, links and entities registered in
the media graph.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 19:00:57 +01:00
Jacopo Mondi
f0e16f0389 libcamera: Add MediaObject class hierarchy
Add a class hierarcy to represent all media objects a media graph represents.
Add a base MediaObject class, which retains the global unique object id,
and define the derived MediaEntity, MediaLink and MediaPad classes.

This hierarchy will be used by the MediaDevice objects which represents and
handles the media graph.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 18:56:41 +01:00
Niklas Söderlund
20d15d9dc4 tests: add test to list all cameras in the system
Add simple test which lists all cameras detected in the system. The test
fails if no camera can be found.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2018-12-31 00:58:32 +01:00
Niklas Söderlund
167f751701 libcamera: pipeline: vimc: add pipeline handler for vimc
Provide a pipeline handler for the virtual vimc driver.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-31 00:58:31 +01:00
Niklas Söderlund
1c4f156332 libcamera: camera_manager: add CameraManager class
Provide a CameraManager class which will handle listing, instancing,
destruction and lifetime management of cameras.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-31 00:58:30 +01:00
Niklas Söderlund
7f8ef1bb99 libcamera: pipeline_handler: add PipelineHandler class
Provide a PipelineHandler which represents a handler for one or more
media devices and provides one or more cameras.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 00:58:29 +01:00
Niklas Söderlund
01107c2490 libcamera: device_enumerator: add documentation
Document the intended use-case of the different elements of the device
enumerator.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2018-12-31 00:58:27 +01:00
Niklas Söderlund
06e2ac2e2f libcamera: device_enumerator: add factory for DeviceEnumerators
Provide a factory for DeviceEnumerator objects. Depending on which
libraries are available there will be different ways to enumerate
information in the system. This factory hides this from the rest of the
library.

Currently udev enumeration is the only supported implementation, a sysfs
implementation is another method that surely will be added in the
future.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 00:58:23 +01:00
Niklas Söderlund
4db38e82a3 libcamera: device_enumerator: add DeviceEnumeratorUdev class
Provide a DeviceEnumeratorUdev class which is a specialization
of DeviceEnumerator which uses udev to enumerate information in the
system.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-31 00:58:19 +01:00
Niklas Söderlund
af8c212600 libcamera: device_enumerator: add DeviceEnumerator class
Provide a DeviceEnumerator base class which enumerates all media devices
in the system and information about them, resolving Media Controller
data structures to paths and a method to search in all the enumerated
information.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-31 00:58:15 +01:00
Niklas Söderlund
c0d39bab5b libcamera: device_enumerator: add DeviceMatch class
Provide a DeviceMatch class which represents all properties of a media
device a pipeline hander can specify when searching for a device to use
in its pipeline.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-31 00:58:11 +01:00
Niklas Söderlund
0eab433d05 libcamera: device_enumerator: add DeviceInfo class
Provide a DeviceInfo class which holds all information from the initial
enumeration of a media device. Not all information available at a media
device is stored, only the information needed for a pipeline handler to
find a specific device.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 00:58:06 +01:00
Niklas Söderlund
723a6356c8 libcamera: add dependency on libudev
The device enumeration will depend on libudev, add the dependency to the
build system. This should be turned into a optional dependency once a
device enumerator not using udev is supported.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-31 00:58:03 +01:00
Niklas Söderlund
8c10082a9e libcamera: Add Camera class
Provide a Camera class which represents our main interface to handling
camera devices. This is a rework of Kieran's initial proposal and
Laurent's documentation of the file changed to fit the device
enumerators needs.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 00:57:58 +01:00
Kieran Bingham
df7bd278a6 utils: checkstyle: add keep-one-line-blocks
Enable --keep-one-line-blocks to prevent astyle from wanting to move
single inlined blocks to cover 4 lines such as:

-       virtual int init() { return 0; }
+       virtual int init()
+       {
+               return 0;
+       }

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-21 15:18:32 +00:00