Commit graph

5599 commits

Author SHA1 Message Date
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
Kieran Bingham
b99da21657 lib: Fix class and namespace usage
The (dummy) init_lib function was linking correctly only due to a
namespace 'collision' adding the init_lib to libcamera namespace, which
is 'shared' by class libcamera.

The init function was designed to be a class member function of the
libcamera object - and is used as such in the existing test function.

Instead of relying on the namespace collision - update the lib/main.cpp
example file to correctly utilise the class header - and specify the
function declaration, so that further implementations do not fall into
the same bad habits.

Reported-by: Jacopo Mondi <jacopo@mondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-03 09:21:23 +00:00
Laurent Pinchart
b4935e9a4d utils: ipu3: Add test process script
The script processes raw frames through the Intel IPU3 IMGU.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-02 19:23:07 +02:00
Kieran Bingham
b15e378851 meson: Describe minimum meson version requirements
We utilise 'add_project_arguments' which is only available in version
0.36 and 'build_by_default' which is only available in version 0.40 of
meson.

Add this dependancy to the project requirements.

Reported-by: Jacopo Mondi <jacopo@mondi.org>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-11-30 11:28:14 +00:00
Laurent Pinchart
9cb17c2743 utils: ipu3: Add test capture script
The script captures raw frames from cameras based on the Intel IPU3. It
takes the sensor name as an argument and isn't meant to depend on a
particular platform.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-11-29 14:45:12 +02:00
Kieran Bingham
c60069241f Documentation: Introduce sphinx documentation
Utilise sphinx-build to generate documentation in HTML form, and
populate with some initial content.

An initial conf.py is generated from sphinx-quickstart and answering
initial questions.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-11-28 11:10:11 +00:00
Kieran Bingham
ce1c86c10c licenses: Add licenses subdirectory
Code licensing will be specified with SPDX license headers.
Documentation will be licensed under CC-by-SA.

Include the common license text files to reference with the headers.

Licenses are extracted from the following locations:
  https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
  https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
  https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-11-28 11:10:11 +00:00
Kieran Bingham
df77f99386 meson: Replace tabs for spaces
Tabs are disliked within the meson build system.
Replace indentation by spaces, in all existing locations.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-11-28 11:08:35 +00:00
Kieran Bingham
a66fe04c19 build: Add project arguments
Add language specific project arguments and ensure that -Werror is
enabled, enforcing code to be as clean as possible.

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>
2018-11-27 12:11:48 +00:00
Kieran Bingham
66051636c5 include: Install include files
The include directory was defined but not installed.

Add it to the meson build structure to incorporate it as part of the
library install.

To facilitate the same include paths in our internal includes, update
the structure for headers to match the install structure.

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>
2018-11-27 12:10:57 +00:00
Kieran Bingham
88c35c9084 lib: Include library in the install target
The shared library build target does not install the library when 'ninja
install' is executed.

Flag it as an installable item.

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>
2018-11-27 12:10:26 +00:00
Kieran Bingham
72ca485dd4 README: Update build instructions
README is currently a bit too sparse, and there is no guidance on how to
use our build system.

Add some initial instructions.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-11-26 15:52:21 +00:00
Kieran Bingham
cc4de52524 test: Register the initialisation test with meson
Register the test so that it can integrate with the meson test
framework.

To execute the test suite, use 'ninja test'.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-11-22 15:24:56 +00:00
Laurent Pinchart
23ac77dc4a utils: ipu3: Add IPU3 raw capture unpack utility
The IPU3 captures Bayer data in a 25-pixels-in-32-bytes packed format,
which no standard tool can process. Add a quick implementation of data
unpacking to turn raw binary files into 16 bits per pixel unpacked Bayer
data.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2018-11-20 03:06:41 +02:00
Kieran Bingham
708d3c9fc0 build: Provide initial meson infrastructure
Define the starting points for the libcamera build using
meson and ninja build components.

An initial 'dummy' library class is created, and a test binary links
against the shared library calling it's init_lib() function.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-10-24 12:22:19 +01:00
Kieran Bingham
87ba17ba41 libcamera: Supporting complex camera pipelines
Cameras are complex devices that need heavy hardware image processing
operations. Control of the processing is based on advanced algorithms
that must run on a programmable processor. This has traditionally been
implemented in a dedicated MCU in the camera, but in embedded devices
algorithms have been moved to the main CPU to save cost. Blurring the
boundary between camera devices and Linux often left the user with no
other option than a vendor-specific closed-source solution.

To address this problem the Linux media community has very recently
started collaboration with the industry to develop a camera stack that
will be open-source-friendly while still protecting vendor core IP.
libcamera was born out of that collaboration and will offer modern
camera support to Linux-based systems, including traditional Linux
distributions, ChromeOS and Android.
2018-10-24 12:00:06 +01:00