Commit graph

248 commits

Author SHA1 Message Date
Laurent Pinchart
b8b24c5b5e utils: checkstyle.py: Refactor IncludeChecker
The IncludeCheck warns when code uses C++ standard library headers where
corresponding C compatibility headers are preferred. We have an
exception to that rule for math.h, where cmath is prefered. In order to
prepare for extending checkstyle.py to enforce that rule, refactor the
way the IncludeChecker identifies headers. No functional change is
intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-05-31 20:04:53 +03:00
Laurent Pinchart
3cb20bc230 libcamera: Drop remaining file name from header comment blocks
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment blocks in all
remaining locations that were not caught by the automated script as they
are out of sync with the file name.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-09 23:31:15 +03:00
Laurent Pinchart
829acb3ab0 libcamera: Drop file name from header comment blocks in templates
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment blocks in
template files and templates embedded in generator scripts.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-09 23:31:14 +03:00
Laurent Pinchart
626172a16b libcamera: Drop file name from header comment blocks
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment block.

The change was generated with the following script:

----------------------------------------

dirs="include/libcamera src test utils"

declare -rA patterns=(
	['c']=' \* '
	['cpp']=' \* '
	['h']=' \* '
	['py']='# '
	['sh']='# '
)

for ext in ${!patterns[@]} ; do
	files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done)
	pattern=${patterns[${ext}]}

	for file in $files ; do
		name=$(basename ${file})
		sed -i "s/^\(${pattern}\)${name} - /\1/" "$file"
	done
done
----------------------------------------

This misses several files that are out of sync with the comment block
header. Those will be addressed separately and manually.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-08 22:39:50 +03:00
Daniel Scally
6728160b11 libcamera: controls: Generate enum value-name maps
Generate maps for each control enum which associate strings that
represent the enum values with the values themselves. This change
will allow us to refer to enumerated control values using the
string. For example if we want to pass variables to an algorithm
for use when a control has a particular value we can embed within
tuning files a dictionary that uses the control values as keys.

Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-05-08 09:47:07 +01:00
Umang Jain
503c3a838a libcamera: Fix output spelling error
There are two places where "output" is spelled as "ouput".
Fix it.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-04-20 01:18:07 +01:00
Laurent Pinchart
7d79e9425e utils: checkstyle.py: Drop period at end of Doxygen one liners
The libcamera documentation style calls for no period at the end of the
Doxygen one-liner commands (\brief, \param and \return). Extend the
DoxygenFormatter class to drop the period.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-04-19 12:35:03 +03:00
Laurent Pinchart
fef732d4dc utils: checkstyle.py: Use r'' strings for regular expressions
It's a good practice to use r'' strings for regular expressions in
Python, to avoid unexpected interaction with string escape sequences.
Use them globally. This allows simplifying escaping in one of the
regular expression strings.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-04-19 12:34:57 +03:00
Khem Raj
f4d416db91 ipu3: Use posix basename
musl does not implement GNU basename extention and with latest musl
the prototype from string.h is also removed [1] which now results in
compile errors e.g.

../git/utils/ipu3/ipu3-pack.c:21:47: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

These utilities are using this function in usage() which is used just
before program exit. Always use the basename APIs from libgen.h which is
posix implementation

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-04-17 10:56:03 +01:00
Paul Elder
1c5830a9a4 utils: ipc: Fix async main interface functions with no parameters
If an async main interface function is defined with no parameters, there
would be a compilation error complaining about an extra comma. Fix this.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-04-13 19:25:01 +03:00
Paul Elder
9dc601cf7a utils: ipc: Fix event functions with no parameters
If an event function is defined with no parameters, there would be a
compilation error complaining about unused parameters in the generated
code for the data and dataSize parameters that would normally correspond
to serialized data. Fix this by simply marking the parameters as
maybe_unused.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-04-10 16:40:34 +09:00
Paul Elder
8106b6671f utils: tuning: readme: Improve names of dependency packages
Change the names of python packages in the list of dependencies to the
exact names that should be used in the pip install command.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-03-19 19:57:29 +09:00
Stefan Klug
62c31a352c checkstyle: Work around bug in difflib
If a file misses the newline at the end it gets detected by checkstyle,
but the resulting patch is incorrect and does not apply. It took me a
while to understand that it wasn't me using checkstyle incorrectly, but
that the patch was faulty. The bug itself is in difflib and dates back to
2008.

To reproduce:
- Remove trailing newline from a file
- git add the file
- run ./utils/checkstyle.py -s | patch -p0

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-03-15 14:14:59 +01:00
Hans de Goede
cdb07a0217 utils: checkstyle.py: Fix known_trailers sort order
An unruly libcamera maintainer merged the wrong patch adding the
Co-developed-by: tag to the known_trailers.

Fix the sort order alphabetically to match the version which should have
been merged.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-11 14:24:14 +00:00
Hans de Goede
60f6e71cc4 utils: checkstyle.py: Add Co-developed-by to known_trailers
Add Co-developed-by to known_trailers to silence false positive
"Invalid commit trailer key 'Co-developed-by'" warnings.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-11 13:04:01 +00:00
Kieran Bingham
bdd85fa01c utils: ipu3: Fix return value check on file output
The data parsed by ipu3-unpack is written out using the write() c
library call, but the error code is incorrectly checked which misses the
single erroroneous return value returned by the function.

Fix it to explicitly check against the error code.

Fixes: 23ac77dc4a ("utils: ipu3: Add IPU3 raw capture unpack utility")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-02-28 11:09:11 +00:00
Laurent Pinchart
26d9e36d3e utils: rkisp1: gen-csc-table.py: Don't presume python3 location
The python3 binary may be present in a location other than /usr/bin/.
Use /usr/bin/env to locate it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-02-27 15:53:46 +02:00
Milan Zamazal
51054cef60 utils: checkstyle.py: Update LogCategoryChecker regexp
The regexp uses obsolete form, update it to mute the warning emitted by Python
3.12:

  SyntaxWarning: invalid escape sequence '\('

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-02-27 15:39:33 +02:00
Milan Zamazal
08556380b8 utils: checkstyle.py: Don't presume python3 location
python3 binary may be present in a location other than /usr/bin/.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-02-27 15:39:33 +02:00
Naushir Patuck
5e4dc46a0c utils: mojom: Fix build error caused by the mojom tool update
The update to the mojom tool in commit d17de86904 causes build errors
with gcc 12.2 release builds. One such error is:

In file included from src/libcamera/proxy/worker/raspberrypi_ipa_proxy_worker.cpp:18:
In static member function ‘static libcamera::ipa::RPi::ProcessParams libcamera::IPADataSerializer<libcamera::ipa::RPi::ProcessParams>::deserialize(std::vector<unsigned char>::const_iterator, std::vector<unsigned char>::const_iterator, libcamera::ControlSerializer*)’,
    inlined from ‘void IPAProxyRPiWorker::readyRead()’ at src/libcamera/proxy/worker/raspberrypi_ipa_proxy_worker.cpp:302:70:
include/libcamera/ipa/raspberrypi_ipa_serializer.h:1172:32: error: ‘*(uint32_t*)((char*)&ret + offsetof(libcamera::ipa::RPi::ProcessParams, libcamera::ipa::RPi::ProcessParams::buffers.libcamera::ipa::RPi::BufferIds::bayer))’ may be used uninitialized [-Werror=maybe-uninitialized]
 1172 |                         return ret;

The failure is caused by the new auto-generated IPA interface not
initialising POD types to a default value. This is because the updated
mojom library uses a new mojom.ValueKind class to represent POD types,
whereas the interface generator script uses the mojom.Kind class, which
is correct for the older mojom library.

Fix this breakage by switching the interface generator script to use
mojom.ValueKind to test for POD types.

Fixes: d17de86904 ("utils: ipc: Update mojo")
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-02-15 11:38:25 +00:00
Laurent Pinchart
d5c9b726bd libcamera: signal: Replace object.h inclusion with forward declatation
The signal.h header doesn't need to include object.h. Replace it with a
forward declaration, and instead include object.h in source files that
require it. It can speed up compilation a little bit, but more
importantly avoids unintended dependencies from the Signal class to the
Object class to be added later as the compiler will catch them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:38:59 +02:00
Paul Elder
81791d2cac utils: ipc: extract-docs: Fix escape characters in regex
Newer versions of python now generate a SyntaxWarning (SyntaxError in
the future [1]) for invalid escape sequences. Fix this, as there were
invalid escape sequences in the regexes:

"libcamera/utils/ipc/./extract-docs.py:13: SyntaxWarning: invalid escape
sequence '\/'"

[1] https://docs.python.org/3.12/library/re.html

Reported-by: Nicolas Dufresne <nicolas@ndufresne.ca>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-01-23 02:21:30 +02:00
Laurent Pinchart
d17de86904 utils: ipc: Update mojo
Update mojo from commit

9be4263648d7d1a04bb78be75df53f56449a5e3a "Updating trunk VERSION from 6225.0 to 6226.0"

from the Chromium repository.

The update-mojo.sh script was used for this update.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=206
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:05 +00:00
Laurent Pinchart
8ac367fe0c utils: ipc: generate.py: Disable attributes checker
The attributes checker ensures that .mojom files don't contain unknown
attributes. These check fail with the custom 'skipSerdes' and 'async'
libcamera attributes. Ideally the list of supported attributes should be
extended, but that can't easily be done without modifying the mojo
sources that we try to keep identical to the upstream version to make
updates easier. Disable the attributes checker completely for now to fix
this issue.

While at it, fix an indentation issue reported by checkstyle.py.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:05 +00:00
Laurent Pinchart
3e4a211ff4 utils: ipc: generate.py: Add bindings directory to Python path
Newer mojo versions import a 'checks' module located in the bindings
directory. In preparation for a mojo update, add the directory to the
Python path make the import work.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:05 +00:00
Laurent Pinchart
3a74a36316 utils: update-mojo.sh: Commit the mojo update
Commit the mojo update with a standardized commit message. As mojo is
imported as-is without local modifications, this simplifies usage of the
update script.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:05 +00:00
Laurent Pinchart
a9adb798e1 utils: update-mojo.sh: Reject a dirty libcamera tree
If the libcamera tree is dirty committing the result of the mojo update
will be messy. Bail out in that case.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
Laurent Pinchart
0e9585ff5b utils: update-mojo.sh: Change to the libcamera source directory
Instead of prefixing all paths to IPC files with ${ipc_dir}, change to
the libcamera sources root directory and use relative file paths. This
simplifies the update script.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
Laurent Pinchart
09af551b93 utils: update-mojo.sh: Exit immediately on error
If an error occurs there's no point in ignoring it silently and
continuing. Exit immediately.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
Laurent Pinchart
cb69c6e843 utils: update-mojo.sh: Properly remove old sources
The update-mojo.sh script starts by removing all sources before copying
the new files from chromium. A bug in the 'rm' command makes the removal
a no-op: the glob pattern is quoted, which attempts to remove a file
name '*' in the tools directory, not all files in the directory. Fix it
by removing the whole utils/ipc/mojo/ directory.

While at it, also remove the utils/ipc/tools/ directory that contains
imported sources.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
Kieran Bingham
ffcd1b2804 hooks: pre-push: Disable interpretation of escape sequences
The pre-push hook validates the commit messages utilising 'echo' to send
the captured data from the git commit through grep.

Commit messages may occasionally contain strings that could appear to be
escape sequences such as doxygen style references to \struct.

The '\' 'c' escape sequence can be interpreted to supress all further
output [0] which then breaks the processing and string matching.

Unfortunatley for us, doxygen's class reference constructed in the same
form as \struct can be interpreted as the escape sequence to supress
further output.

[0] https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins

Update the pre-push hook to explicitly disable escape sequence
interpretation using the '-E' flag. This is not available on the
posix-compliant shell 'dash', so also switch to bash explicitly to
prevent potential failures.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
Milan Zamazal
3d45b9ad9a utils: ipc: mojom_libcamera_generator.py: Fix Python warning
Python 3.12 starts emitting the following warning when building libcamera:

  .../utils/ipc/generators/mojom_libcamera_generator.py:372:
  SyntaxWarning: invalid escape sequence '\.'
    if not re.match('^ipa\.[0-9A-Za-z_]+', namespace):

`r' prefix is now required before the regexp.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
Paul Elder
1d0d2cf67c utils: ipc: Fix deserialization of multiple fd parameters
The IPADataSerializer::deserializer attempts to optimise code paths and
remove potentially unused code where multiple File Descriptors were not
expected to be utilised.

The addition of multiple SharedFD entries in the IPC highlights this as
a bug.

Clean up the conditionals to ensure that all File Descriptors are
correctly deserialized.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=205
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
David Plowman
66479605ba utils: raspberrypi: ctt: Improve the Macbeth Chart search reliability
Previously the code would brighten up images in case the Macbeth Chart
is slightly dark, and also zoom in on sections of it to look for
charts occupying less of the field of view. But it would not do both
together.

This change makes the search for smaller charts also repeat that
search for the brightened up images that it made earlier, thereby
increasing the chances of success for non-optimal tuning images.

There are also a couple of very small drive-by typo fixes.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:02 +00:00
Naushir Patuck
e18a007b9d libcamera: controls: Use vendor tags for draft controls and properties
Label draft controls and properties through the "draft" vendor tag
and deprecate the existing "draft: true" mechanism. This uses the new
vendor tags mechanism to place draft controls in the same
libcamera::controls::draft namespace and provide a defined control id
range for these controls. This requires moving all draft controls from
control_ids.yaml to control_ids_draft.yaml.

One breaking change in this commit is that draft control ids also move
to the libcamera::controls::draft namespace from the existing
libcamera::controls namespace. This is desirable to avoid API breakages
when adding new libcamera controls. So, for example, the use of
controls::NOISE_REDUCTION_MODE will need to be replaced with
controls::draft::NOISE_REDUCTION_MODE.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-11-30 13:59:27 +00:00
Naushir Patuck
d3365b358f libcamera: control: Add vendor control id range reservation
Add a new control_ranges.yaml file that is used to reserve control id
ranges/offsets for libcamera and vendor specific controls. This file is
used by the gen-controls.py script to generate control id values for
each control.

Draft controls now have a separate range from core libcamera controls,
breaking the existing numbering behaviour.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-11-29 09:05:39 +00:00
Naushir Patuck
0455bbbf51 build: controls: Rework how controls and properties are generated
Add support for using separate YAML files for controls and properties
generation. The mapping of vendor/pipeline handler to control file is
done through the controls_map variable in include/libcamera/meson.build.

This simplifies management of vendor control definitions and avoids
possible merge conflicts when changing the control_ids.yaml file for
core and draft controls. With this change, libcamera and draft controls
and properties files are designated the 'libcamera' vendor tag.

In this change, we also rename control_ids.yaml -> control_ids_core.yaml
and property_ids.yaml -> property_ids_core.yaml to designate these as
core libcamera controls.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-11-29 09:05:38 +00:00
Naushir Patuck
bba4ec63c4 controls: Update argument handling for controls generation scripts
The template file to the gen-controls.py and gen-py-controls.py is now
passed in through the '-t' or '--template' command line argument instead
of being a positional argument.  This will allow multiple input files to
be provided to the scripts in a future commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-11-29 09:05:38 +00:00
Naushir Patuck
bd6658943a controls: Add vendor control/property support to generation scripts
Add support for vendor-specific controls and properties to libcamera.
The controls/properties are defined by a "vendor" tag in the YAML
control description file, for example:

vendor: rpi
controls:
  - MyExampleControl:
      type: string
      description: |
        Test for libcamera vendor-specific controls.

This will now generate a control id in the libcamera::controls::rpi
namespace, ensuring no id conflict between different vendors, core or
draft libcamera controls. Similarly, a ControlIdMap control is generated
in the libcamera::controls::rpi namespace.

A #define LIBCAMERA_HAS_RPI_VENDOR_CONTROLS is also generated to allow
applications to conditionally compile code if the specific vendor
controls are present. For the python bindings, the control is available
with libcamera.controls.rpi.MyExampleControl. The above controls
example applies similarly to properties.

Existing libcamera controls defined in control_ids.yaml are given the
"libcamera" vendor tag.

A new --mode flag is added to gen-controls.py to specify the mode of
operation, either 'controls' or 'properties' to allow the code generator
to correctly set the #define string.

As a drive-by, sort and redefine the output command line argument in
gen-controls.py and gen-py-controls.py to ('--output', '-o') for
consistency.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-11-29 09:05:37 +00:00
Laurent Pinchart
d2094a0185 utils: update-kernel-headers: Support git worktrees
When operating on a git worktree, the Linux kernel directory contains a
.git file, not a .git directory. Relax the git tree check to support
both.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 16:17:18 +03:00
Laurent Pinchart
4694e441c3 utils: checkstyle.py: Extract title and trailers with one command
The Amendment class calls `git show` twice, once to extract the commit
title, and a second time to extract the trailers. This can be combined
in a single command, which is more efficient. Do so.

While at it, centralize initialization of self._trailers in the
Commit.__init__() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-28 19:11:56 +03:00
Ben Benson
09dd65442b utils: raspberrypi: ctt: Code tidying
Altered the way that some lines are laid out, made functions
more attractive to look at, and tidied up messy areas.

Signed-off-by: Ben Benson <ben.benson@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-28 08:32:40 +01:00
Ben Benson
f8dd17a8f4 utils: raspberrypi: ctt: Improved color matrix fitting
Added code which optimises the color matrices based off
delta E values for the calibration images. Working in LAB
color space.

Signed-off-by: Ben Benson <ben.benson@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-28 08:31:38 +01:00
Kieran Bingham
baaad1bf9e utils: checkstyle.py: Check trailers for Amendment commits
The commit trailers are checked as part of processing the commit message
with the newly introduced TrailersChecker.

This relies on the trailers property being correctly exposed by the
Commit object, and is implemented for the base Commit but not processed
for Amendment commits.

Refactor the trailer property handling to a helper function in the base
Commit class and make use of it with a newly added call to obtain the
existing Trailers from the most recent commit when using Amendment.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-18 09:26:31 +01:00
Kieran Bingham
e2f0ad27b1 utils: checkstyle.py: Derive Amendment from Commit
The Amendment commit class is derived from the StagedChanges class
(which in turn derives from the Commit base class), however there is no
code sharing between Amendment and StagedChanges other than the call to
initalise through the base Commit class.

Refactor the inheritance to make an Amendment derive directly from
Commit.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-18 09:26:24 +01:00
Kieran Bingham
37106ba02a utils: checkstyle.py: Initialise staged trailers
There are no possible Trailers for staged changes as the commit message
has not yet been written.

Initialise the empty trailers when the commit object is initialised.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-18 09:26:12 +01:00
Kieran Bingham
b14d2cab12 utils: checkstyle.py: Treat Malformed trailers as a CommitIssue
If a Malformed trailer is identified the checkstyle script triggers a
RuntimeError and stops processing the rest of the commit.

A malformed trailer can be regarded as an issue in the commit and
reported as such using the same method as other faults identified by the
tool.

Convert the RuntimeError into a CommitIssue and continue processing
other trailers.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-18 09:25:13 +01:00
Laurent Pinchart
d06ed87d49 utils: checkstyle: Add trailers checker
The libcamera git history contains numerous examples of incorrect commit
message trailers due to invalid trailer types (e.g. Change-Id), typos
and other small issues. Those went unnoticed through reviews, which
shows that an automated checker is required.

Add a trailers checker to checkstyle.py to catch invalid or malformed
trailers, with a set of supported trailers that match libcamera's commit
message practices. New trailer keys can easily be added later as new
needs arise.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-05 17:11:26 +03:00
Laurent Pinchart
925ee0ac8e utils: checkstyle: Don't include commit ID in commit title
The commit title and commit ID are two different pieces of information.
Don't include the latter in the former, to simplify code that only needs
the commit title. Constructing a string from the ID and title is easier
than splitting the combined string back into its elements.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-05 15:39:02 +03:00
Laurent Pinchart
69e3983acf utils: checkstyle: Support running checkers selectively
During development of the checkstyle.py script, it can be useful to run
only a subset of the checker. Add the ability to do so with a
'--checkers' command line argument.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-05 15:39:00 +03:00