Commit graph

65 commits

Author SHA1 Message Date
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
Niklas Söderlund
53b549b631 tests: call the derived Test class cleanup() function
Calling the cleanup() function in the base class Test destructor only
calls the base class empty cleanup() function, not the overloaded one.
This results in tests not cleaning up after themself. Solve this by
explicitly calling the cleanup() function from execute().

This was discovered while running valgrind on tests where objects where
allocated in init() and freed in cleanup().

Signed-off-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>
2018-12-21 06:47:27 +02:00
Laurent Pinchart
4114a93dff tests: Add a base Test class
The base Test class is meant to provide infrastructure common to all
tests. It is very limited for now, and should be extended with at least
logging and assertion handling.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2018-12-21 06:44:55 +02:00
Laurent Pinchart
907602eab5 libcamera: log: Add a debug log level
Many of the message logged by the library will be debug messages, we
thus need a debug log level.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-19 14:11:25 +02:00
Laurent Pinchart
3c8886d698 utils: checkstyle.py: Strip trailing white spaces
As astyle doesn't strip trailing white spaces, strip them manually.
Organize the code to allow for new additional formatting steps if
needed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-19 14:11:16 +02:00
Laurent Pinchart
cf04a496a6 utils: checkstyle.py: Highlight trailing white space at end of line
In order to facilitate interpretation of diffs, highlight trailing white
space at end of lines with a red background.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-19 14:11:16 +02:00
Laurent Pinchart
2887934ca0 utils: checkstyle.py: Support execution from non-root directories
The git diff command is invoked with relative paths, which causes git to
fail to locate files when the checkstyle.py script is run from
subdirectories of the git tree. Fix this by prepending the absolute path
to the git tree root directory to the file names.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-19 14:11:16 +02:00
Jacopo Mondi
7dc517ca6b build: Define library private include path
Separate declaration of library internal inclusion path.
This will be used by tests, developed outside of library code, that need to
include parts of the library internal APIs and can re-use the here defined
variable.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-19 10:30:44 +01:00
Jacopo Mondi
c81bc473fd libcamera: include: Import media.h from Linux v4.19
In order to avoid depending on system headers that may be outdated compared
to the kernel version available at runtime, import the Linux kernel headers
related to the APIs that libcamera requires a recent version of. This allows
libcamera to use the latest kernel APIs even when compiled on older systems.
The library must of course test at runtime whether those APIs are available
and fallback to older APIs in order to support older kernels.

Import media.h for the recent media controller APIs. The file is extracted
verbatim from kernel v4.19.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-19 10:30:28 +01:00
Laurent Pinchart
d416f42cce Documentation: Remove | on the left side of diagrams
There's no need to add a character on the left side of the ascii art
diagrams, provided that we indent them properly. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-14 15:34:00 +02:00
Jacopo Mondi
17fab5dfc8 Documentation: Document the style check script
Add a section to the coding style documentation to explain usage of the
checkstyle.py script.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-14 15:34:00 +02:00
Laurent Pinchart
8b30bb3185 utils: Add Python-based commit style checker script
checkstyle.py is a reimplementation of checkstyle.sh in Python, that
should be easier to extend with additional features.

Three additional features and enhancements are already implemented:

- While retaining the default behaviour of operating on the HEAD commit,
  a list of commits can also be specified on the command line.

- Correct line numbers are printed in the diff output.

- The index and working tree are not touched, they can be dirty.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-14 15:34:00 +02:00
Kieran Bingham
cebe684c19 git: Add .gitignore file
Provide an initial starting point for our ignore file.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-14 13:23:07 +00:00
Laurent Pinchart
8274fed13d Documentation: contributing: Mark command line as shell code-block
The git clone command line is a (single line) block of shell code, mark
it appropriately.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-14 10:43:01 +02:00
Laurent Pinchart
6f739290ec Documentation: coding-style: Fix list indentation
The various lists in the document are not quoted blocks. Don't indent
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-14 10:43:00 +02:00
Laurent Pinchart
58a31afc0c Documentation: Add architecture documentation
The documentation is copied mostly verbatim from the website, with small
modifications to the ascii art diagrams to make them compile.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-14 10:42:58 +02:00
Laurent Pinchart
73fec989ae Documentation: contributing: Add links to libcamera git and linuxtv.org
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-14 10:42:56 +02:00
Laurent Pinchart
24038c2c44 Documentation: Remove _static and _templates directory
sphinx only requires those directories to be present because they're
referenced in the configuration file. Remove the references and the
directories.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-14 10:42:33 +02:00
Jacopo Mondi
ee56622401 Documentation: Add coding style document
Add document to summarize the coding style adopted by libcamera.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-13 09:00:07 +01:00
Jacopo Mondi
3b56ddaa96 build: Add 'std=c++11' cpp compiler flag
Building the current master branch with g++ 5.4.0-6 fails with:
./src/libcamera/include/log.h:25:34:
   error: defaulted and deleted functions only available with -std=c++11 \
   or -std=gnu++11 [-Werror]
   LogMessage(const LogMessage&) = delete;

Fix this by adding the 'std=c++11' compiler argument for to the list of
cpp build flags.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-13 08:51:05 +01:00
Laurent Pinchart
6ab3ff4501 libcamera: log: Document the LogMessage class
Fix Doxygen build warnings by adding the missing documentation for the
LogMessage class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-12 20:45:39 +02:00
Laurent Pinchart
b4351e1a6b libcamera: log: Fix Doxygen documentation
Now that the documentation can be compiled, Doxygen throws a few
warnings due to incorrect enum field naming. Fix it.

The \file block needs to be named after the header file in order for
Doxygen to document any global function, variable, typedef or enum
defined in the header (as documented in the Doxygen manual under the
\file command). We thus need to use log.h as the file name. No \file
block is needed for the .cpp file, as we don't want to generate
documentation for internal private globals.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-12 20:45:39 +02:00
Laurent Pinchart
53c4d4c34f Documentation: Generate source code documentation using Doxygen
Extend the documentation build system to automatically generate
documentation from source code using Doxygen. This is currently separate
from the sphinx documentation, and should be integrated using the
breathe (and possibly exhale) extensions.

As the Documentation/meson.build file needs to reference the variables
holding the source files, move the Documentation directory to the end of
the subdirs() in the top-level meson.build.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-12 20:45:24 +02:00
Laurent Pinchart
652b1c8679 Documentation: Don't hardcode install directory
Use the datadir option to select the directory in which to install
documentation. This defaults to $prefix/share so this doesn't introduce
any change in the default case.

While at it use join_paths() to join patch components instead of
hardcoding the / separator.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-12 20:18:41 +02:00
Laurent Pinchart
66bb4d388d Documentation: Set install_dir in custom_target()
The custom_target() function accepts an install_dir parameter. Along
with setting install to true, this can be used to replace the
install_subdir() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-11 20:28:34 +02:00
Laurent Pinchart
830031892b build: Clean up file names variables
The build system defines two variables, public_api and sources, that
store the names of the public headers and the source files respectively.
These files will need to be referenced when generating documentation
from source code, so let's make the variable names more descriptive:

- Rename public_api to libcamera_api and use the files() function
- Rename sources to libcamera_sources
- Add a libcamera_headers variable to hold the internal headers

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-11 20:28:34 +02:00
Laurent Pinchart
0763b8a80e utils: ipu3: process: Configure formats on ImgU subdev pads
Set format and selection rectangles on the ImgU subdev as required by
the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-11 15:58:19 +02:00
Laurent Pinchart
1ebd2c09f5 utils: ipu3: process: Fix typo in output files path
A typo in the output files path causes the script to attempt to write
all captured frames to /. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-11 15:48:26 +02:00
Laurent Pinchart
0d96f3e232 utils: ipu3: Abort when sensor or media device isn't found
Calling exit from a function only exits from the function, it doesn't
abort the whole script. Propagate the errors to stop operation when the
sensor or media device can't be found.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-11 00:31:24 +02:00
Laurent Pinchart
ad8934db5b libcamera: log: Fix miscellaneous coding style issues
Those issues were pointed out during review.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-11 00:02:04 +02:00
Laurent Pinchart
cc7d204b2c libcamera: Use the logger instead of cout
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-06 16:43:45 +02:00
Laurent Pinchart
edbd2059d8 libcamera: Add initial logger
The logger is based on the ostream API, allowing code to log messages in
a native way. It automatically logs the time stamp, severity level, file
name and line number.

Many important features are missing, such as logging to file, logging
classes, and log filtering based on the severity level, file name and
class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-06 16:43:04 +02:00
Laurent Pinchart
913b3ee817 Overhaul the directory structure
In order to match the directory structure of traditional projects,
rename the top-level lib/ directory to src/libcamera/. Other libraries
developed as part of the project will later find a home in src/.

Split the libcamera header files in three categories: public headers
describing the public API in include/libcamera/, internal headers
describing the internal API in src/libcamera/include/, and private
headers local to one or a small number of compilation units along the
corresponding .cpp files. As no internal header exists yet the
src/libcamera/include/ directory is created empty as the build system
would fail otherwise.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-06 16:34:01 +02:00
Laurent Pinchart
0713202dc0 Add boilerplate headers comments and include guards
The initial main.cpp and libcamera.h files are missing boilerplate
header comments. libcamera.h is further missing include guards. Add
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-06 16:33:36 +02:00