Commit graph

5008 commits

Author SHA1 Message Date
Kieran Bingham
44b49af7a0 utils: abi-compat: sort meson options
Sort the options passed to meson setup alphabetically when performing a
slimline libcamera build.

Signed-off-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-09-25 10:36:40 +01:00
Kieran Bingham
9155d79f4d utils: abi-compat: Disable python build
While building the core libcamera library for ABI compatibility checks,
the pycamera python bindings may get built if the required dependencies
are found.

The ABI compatibility checks do not validate or verify the Python API -
so remove this from the intermediate build steps.

Signed-off-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-09-25 10:36:37 +01:00
Kieran Bingham
8bcec68734 libcamera v0.3.2
abi-compliance-checker reports 100% binary and source compatibility,
so this release does not change the SONAME.

  Binary compatibility: 100%
  Source compatibility: 100%
  Total binary compatibility problems: 0, warnings: 0
  Total source compatibility problems: 0, warnings: 0

bugs:

The following commits in this release relate to either a bug fix or
improvement to existing commit.

 - meson: Enable simple pipeline handler on all platforms by default
   - Fixes: 06e0d8508e ("libcamera: pipeline: simple: Enable intel-ipu6 with Soft ISP")
 - libcamera: udev: Catch udev notification errors
   - Bug: https://bugs.libcamera.org/show_bug.cgi?id=230
 - libcamera: Drop remaining file names from header comment blocks
   - Fixes: 829acb3ab0 ("libcamera: Drop file name from header comment blocks in templates")
 - Documentation: Fix link to introduction on mainpage.dox
   - Fixes: 860a3e3031 ("Documentation: Rework docs.rst into introduction.rst")
 - Documentation: Fix links from API references to guides
   - Fixes: e938861781 ("Documentation: Improve doxygen main page")
 - pipeline: uvcvideo: Implement acquireDevice() + releaseDevice()
   - Bug: https://bugs.libcamera.org/show_bug.cgi?id=168

And the following updates have been made in this release, grouped by
category:

core:
 - libcamera: Avoid variable-length arrays
 - meson: Enable simple pipeline handler on all platforms by default
 - libcamera: base: Add MemFd helper class
 - libcamera: base: memfd: Handle uClibc compatibility with function wrapper
 - libcamera: shared_mem_object: Prevent memfd from shrinking or growing
 - libcamera: simple: Log a missing sensor in a better way
 - libcamera: ipa_proxy: Unify configurationFile argument name
 - libcamera: ipa_proxy: Report a missing configuration as a warning
 - libcamera: Remove spaces at end of lines
 - meson: Drop gcc 8 support
 - utils: checkstyle.py: Warn when no valid Signed-off-by line is found
 - libcamera: Drop path prefix from Doxygen file directive
 - libcamera: Make all internal headers visible to Doxygen
 - libcamera: Unify Doxygen file directive prefix for formats.h
 - libcamera: Mark internal parts of public classes with \internal
 - libcamera: Hide *::Private classes with __DOXYGEN_PUBLIC__
 - libcamera: Split public and internal source arrays
 - libcamera: Add version.h to public headers
 - libcamera: Drop libcamera_generated_ipa_headers from sources
 - libcamera: Move IPA headers to the libcamera_private dependency
 - libcamera: Consolidate all IPA headers in libcamera_ipa_headers
 - libcamera: Add missing headers to libcamera_internal_headers
 - libcamera: Consolidate tracepoint header in libcamera_internal_headers
 - libcamera: Don't add libcamera_public_headers to libcamera_public_sources
 - utils: checkstyle.py: Add author property to Commit class
 - utils: checkstyle.py: Validate SoB trailer against author
 - utils: checkstyle.py: Fix trailer parsing for commits with changelogs
 - libcamera: ipa_manager: Remove singleton requirement
 - libcamera: udev: Catch udev notification errors
 - libcamera: Add missing <stdint.h> include to base/file.h
 - libcamera: Add missing <stdint.h> include to internal/yaml_parser.h
 - libcamera: Fix header grouping
 - libcamera: formats: Adding Support for Y12P
 - utils: checkstyle.py: Rework commit message parsing
 - utils: checkstyle.py: Skip title and trailers checkers for pre-commit
 - utils: checkstyle.py: Add __repr__ method to Commit class
 - libcamera: simple: Fix a typo in a doc string
 - libcamera: camera: Hide Camera::create() from the public API
 - meson: Store controls and properties YAML files in variables
 - meson: Fix mismatch in controls and properties generated file names
 - libcamera: Drop remaining file names from header comment blocks
 - meson: Move all code generation scripts to utils/codegen/
 - meson: utils: Provide environment for Python scripts
 - utils: codegen: gen-header.sh: Generate libcamera.h based on meson.build
 - utils: codegen: gen-controls.py: Convert to jinja2 templates
 - utils: codegen: gen-controls.py: Move helper classes to separate file
 - libcamera: controls: Improve formatting of control descriptions in YAML
 - libcamera: pipeline_handler: Fix unlocking media devices too early
 - libcamera: pipeline_handler: Call releaseDevice() before unlocking media devices
 - libcamera: controls: Fix example for ExposureValue
 - utils: update-kernel-headers: Support relative path to kernel git tree
 - include: linux: Update headers for rkisp1 extensible parameters
 - libcamera: camera: Use invokeMethod() for pipe_->acquire() and pipe_->release()
 - libcamera: uvcvideo: Fix includes
 - libcamera: v4l2: Remove unused includes
 - libcamera: v4l2: Fix an include placement
 - libcamera: v4l2: Fix indirect include
 - libcamera: libcamera: Remove unused includes
 - libcamera: libcamera: Add missing includes
 - libcamera: libcamera: Formatting improvements
 - libcamera: includes: Add missing includes
 - libcamera: includes: Remove unused includes
 - libcamera: includes: Formatting improvements
 - utils: checkstyle: Add a python formatter
 - utils: checkstyle: Remove style checker for python pep8
 - libcamera: utils: Add ScopeExitActions class
 - libcamera: v4l2_videodevice: Improve readability
 - libcamera: media_object: Add MediaPad string representations
 - libcamera: media_object: Add MediaLink string representations
 - libcamera: media_device: Use MediaLink string helper
 - libcamera: yaml-parser: Add additional tests
 - libcamera: yaml-parser: Add failing test for unexpected behavior
 - libcamera: yaml-parser: Differentiate between empty and empty string
 - Document additional environmental variables

pipeline:
 - libcamera: software_isp: Remove file seal TODO item
 - libcamera: software_isp: Replace malloc() with std::vector<>
 - pipeline: rkisp1: Use the extensible parameters format
 - pipeline_handler: Add acquireDevice() function to mirror releaseDevice()
 - pipeline: uvcvideo: Implement acquireDevice() + releaseDevice()
 - libcamera: ipu3: Remove unused includes
 - libcamera: ipu3: Replace wrong include
 - libcamera: ipu3: Formatting improvements
 - libcamera: rkisp1: Remove unused includes
 - libcamera: rkisp1: Formatting improvements
 - pipeline: rkisp1: Use ScopeExitActions to simplify error handling in start
 - libcamera: pipeline: simple: Fix typos in match routing comment
 - pipeline: simple: Remove media member variable
 - libcamera: pipeline: simple: Use MediaLink string helper
 - libcamera: debayer_cpu: Sync DMABUFs

ipa:
 - ipa: libipa: camera_sensor_helper: Reference blackLevel() in documentation
 - ipa: libipa: Add missing CameraSensorHelper fn label in docs
 - ipa: rkisp1: Pass parameters buffer format to IPA module
 - ipa: rkisp1: Pass parameters buffer size to pipeline handler
 - ipa: rkisp1: Add ISP parameters abstraction class
 - ipa: rkisp1: Use the new ISP parameters abstraction
 - ipa: rkisp1: params: Add companding blocks
 - ipa: rkisp1: Add compand feature flag to ipa context
 - ipa: rkisp1: blc: Add support for BLS in compand
 - libcamera: libipa: Remove unused includes
 - libcamera: ipa: Remove unused includes
 - utils: ipc: Include <string> in generated headers where needed
 - libcamera: ipa: Drop unneded includes from ipa_interface.h
 - ipa: rpi: agc: Ignore stable region when exposure/gain set manually
 - ipa: rpi: Adding IMX283 support
 - libcamera: libipa: camera_sensor: Add IMX283 black level
 - ipa: libipa: Add generic Interpolator class
 - ipa: rkisp1: Use generic Interpolator class
 - ipa: rkisp1: Remove MatrixInterpolator
 - ipa: rkisp1: Use interpolator in lsc
 - ipa: rkisp1: Move loader functions into helper class
 - ipa: libipa: Add lsc polynomial class
 - ipa: rkisp1: Add sensor info to context
 - ipa: rkisp1: Add polynomial LSC loader
 - libcamera: libipa: camera_sensor: Add Sony IMX214 sensor properties

apps:
 - gstreamer: Fix width and height range handling
 - apps: qcam: Disable -Wextra-semi
 - gstreamer: Fix missing "greater than" symbol in author string
 - py: cam: Convert to PyQt6
 - py: gen-py-controls: Use Control class
 - py: gen-py-controls: Convert to jinja2 templates
 - v4l2: Support setting frame rate in the V4L2 Adaptation layer
 - qcam: Decrease minimum width of selector dialog
 - qcam: Drop Qt version checks
 - qcam: viewfinder_qt: Draw the letterbox background black
 - qcam: viewfinder_gl: Fix binding of vertex buffer and shader program
 - qcam: viewfinder_gl: Drop duplicate glClearColor()
 - qcam: viewfinder_gl: Render image centered in letterbox

documentation:
 - Documentation: Add Thread safety page
 - Documentation: Split doxygen_input in public and internal inputs
 - Documentation: Split public/private documentation
 - Documentation: Improve doxygen main page
 - Documentation: Add documentation-contents.rst
 - Documentation: Alphabetise the Documentation toctree
 - Documentation: Synchronise camera stack details
 - Documentation: Breakout docs.rst
 - Documentation: Remove libcamera architecture from introduction.rst
 - Documentation: Rework docs.rst into introduction.rst
 - Documentation: Rework index.rst
 - Documentation: Add internal-api-html placeholder
 - Documentation: Reformat documentation_contents.rst
 - Documentation: Rename "API" section to "API Reference"
 - Documentation: Drop local table of contents from introduction
 - Documentation: Rename "Documentation" section to "Introduction"
 - Documentation: Fix link to introduction on mainpage.dox
 - Documentation: Fix links from API references to guides

tuning:
 - utils: tuning: rkisp1: Clean up tuner construction
 - utils: tuning: Change Tuner.add() to accept a list of modules

test:
 - tests: Add a missing iostream include
 - test: ipa: libipa: Add tets for Interpolator

Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-24 14:30:57 +01:00
André Apitzsch
642dbafe64 libcamera: libipa: camera_sensor: Add Sony IMX214 sensor properties
Provide the Sony IMX214 camera sensor properties and registration with
libipa for the gain code helpers.

Signed-off-by: André Apitzsch <git@apitzsch.eu>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-23 15:51:24 +01:00
Stefan Klug
0c72c6b4cf ipa: rkisp1: Add polynomial LSC loader
Add a loader that is capable of loading polynomial coefficients from the
tuning files. The polynomial is sampled at load time to reduce the
computational overhead at runtime.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
830340615a ipa: rkisp1: Add sensor info to context
For the LSC algorithm to dynamically calculate the LSC tables based on
the sensor size and the crop rectangle it needs access to that data.
Provide access to it by adding the sensorInfo object to the context.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
eb6edfb69e ipa: libipa: Add lsc polynomial class
Add a basic class to represent polynomials as specified in the DNG spec
for vignetting correction.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
b9d4fc82d9 ipa: rkisp1: Move loader functions into helper class
In preparation for supporting polynomial LSC data, move the current
loader into its own helper class.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
a6adaa7283 ipa: rkisp1: Use interpolator in lsc
Now, that the generic interpolator is available, use it to do the
interpolation of the lens shading tables. This makes the algorithm
easier to read and remove some duplicate code.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
79aa7ecd1a ipa: rkisp1: Remove MatrixInterpolator
The MatrixInterpolator is no longer used. Remove it.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
91e6491fa0 ipa: rkisp1: Use generic Interpolator class
Replace all occurrences of the MatrixInterpolator with the generic one.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
8ccb04a168 test: ipa: libipa: Add tets for Interpolator
Add tests for the Interpolator class.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
2e936455ae ipa: libipa: Add generic Interpolator class
The MatrixInterpolator is great for interpolation of matrices for
different color temperatures. It has however one limitation - it can
only handle matrices. For LSC it would be great to interpolate the LSC
tables (or even polynomials) using the same approach. Add a generic
Interpolator class based on the existing MatrixInterpolator. This class
can be adapted to any other type using partial template specialization.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 16:42:45 +02:00
Stefan Klug
6b67094cd2 libcamera: yaml-parser: Differentiate between empty and empty string
When accessing a nonexistent key on a dict the YamlObject returns an
empty element. This element can happily be cast to a string which is
unexpected. For example the following statement:

yamlDict["nonexistent"].get<string>("default")

is expected to return "default" but actually returns "". Fix this by
introducing an empty type to distinguish between an empty YamlObject and
a YamlObject of type value containing an empty string. For completeness
add an isEmpty() function and an explicit cast to bool to be able to
test for that type.

Extend the tests accordingly.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 13:03:35 +02:00
Stefan Klug
f623f3ed64 libcamera: yaml-parser: Add failing test for unexpected behavior
When accessing a nonexistent key on a dict the YamlObject returns an
empty element. This element can happily be cast to a string. This is
unexpected. For example the following statement:

yamlDict["nonexistent"].get<string>("default")

is expected to return "default" but actually returns "". Add a (failing)
testcase for that behavior.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 13:03:35 +02:00
Stefan Klug
f2842258d1 libcamera: yaml-parser: Add additional tests
Add additional tests in preparation for upcoming modifications on the
yaml parser. These tests handle the case where the yaml file contains
empty items in dictionaries or lists. E.g.:

dict:
  key_with_value: value
  key_without_value:

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23 13:03:35 +02:00
Robert Mader
cbfe04f77c libcamera: debayer_cpu: Sync DMABUFs
Using `DMA_BUF_IOCTL_SYNC` is required for DMABUFs in order to ensure
correct output. Not doing so currently results in occasional tearing
and/or backlashes in GL/VK clients that use the buffers directly for
rendering.

An alternative approach to have the sync code in `MappedFrameBuffer` was
considered but rejected for now, in order to allow clients more
flexibility.

While the new helper is added to an annoymous namespace, add
timeDiff to the same namespace and remove the static definition as a
drive by.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
Tested-by: Milan Zamazal <mzamazal@redhat.com> # Debix
Tested-by: Hans de Goede <hdegoede@redhat.com> # IPU6 + ov2740
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> # Lenovo X13s + OV5675
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-20 21:09:26 +01:00
Kieran Bingham
66c9b157e9 libcamera: pipeline: simple: Use MediaLink string helper
Replace the open-coded implementation of a link representation
with the operator<< overload string representation to simplify
the code and unify appearance of reporting MediaLinks.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 12:01:29 +02:00
Kieran Bingham
4035f5754e libcamera: media_device: Use MediaLink string helper
Replace the two open-coded implementations of a link representation
with the operator<< overload string representation to simplify
the code and unify appearance of reporting MediaLinks.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 12:01:29 +02:00
Kieran Bingham
a783562a34 libcamera: media_object: Add MediaLink string representations
Various parts of libcamera print the representation of a MediaLink by
inline joining the parts to make a string representation.

This repeated use case can be supported with a common helper to print
the MediaLink in a common manner using the existing toString() and
operator<< overload style to make it easier to report on MediaLink
types.

This implementation will report in the following style:

  'imx283 1-001a'[0] -> 'video-mux'[0]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 12:01:29 +02:00
Kieran Bingham
6837607ca3 libcamera: media_object: Add MediaPad string representations
Facilitate easy representations of a MediaPad object by preparing
it as a string and supporting output streams.

A MediaPad will be report in the following style:

  'imx283 1-001a'[0]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 12:01:29 +02:00
Paul Elder
d900ec990d pipeline: simple: Remove media member variable
There is no need for the simple pipeline handler to save the media
device. Remove it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 11:12:28 +02:00
Stefan Klug
33a49ce4a2 libcamera: v4l2_videodevice: Improve readability
The handling for the sequence number validation within
V4L2VideoDevice::dequeueBuffer makes use of a std::optional, which can
be used as a boolean in conditional statements. This has the impact in
this use case that it can be mis-read to be interpretting the value for
firstFrame_ which is assigned as the buf.sequence.

Remove this potential for confusion by making it clear that the first
frame handling is only performed when firstFrame_ does not have a value
assigned.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Kieran: Rework commit message]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 11:12:28 +02:00
Kieran Bingham
75fc944738 libcamera: pipeline: simple: Fix typos in match routing comment
Fix a small typo in the comment regarding the default routing
table configuration.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 11:12:28 +02:00
Kieran Bingham
935f6ff267 libcamera: libipa: camera_sensor: Add IMX283 black level
Report the default sensor black level reported by the datasheet.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 11:12:28 +02:00
will whang
69b702d183 ipa: rpi: Adding IMX283 support
Add support for the IMX283 sensor for the VC4 target.

Signed-off-by: will whang <will@willwhang.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12 11:12:28 +02:00
Laurent Pinchart
e6441ec4f4 qcam: viewfinder_gl: Render image centered in letterbox
Mimic the letterbox behaviour of the Qt viewfinder by rendering the
image centered. This is done by adding a projection matrix to the vertex
shader to scale the rendered rectangle.

Another option would have been to keep using glViewport() (which would
have needed to be moved to paintGL(), as Qt resets the viewport to span
the full widget before calling). Hidpi displays would then need special
handling of the device pixel ratio, which is done automatically by Qt
when it sets the default viewport. Using a projection matrix avoids this
complication.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-11 18:24:51 +03:00
Laurent Pinchart
583901a714 qcam: viewfinder_gl: Drop duplicate glClearColor()
There's no need to call glClearColor() twice before drawing any GL
content. Drop the first call. This doesn't introduce any functional
change.

While at it, pass floats instead of doubles to glClearColor(), as
required by the function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-11 18:24:51 +03:00
Laurent Pinchart
33a0b14e0a qcam: viewfinder_gl: Fix binding of vertex buffer and shader program
Starting in Qt 6.7.0, vertex buffers and shader programs are unbound
just before calling QOpenGLWidget::paintGL(). This breaks rendering in
the GL viewfinder in two ways.

First, we bind the vertex buffer only once at initialization time. There
is therefore no vertex buffer mapped at rendering time, preventing both
the vertex shader from having access to the vertex and texture
coordinates.

Then, we bind the shader program only when rendering the first frame.
There is thus no shader program bound for all subsequent frames,
breaking rendering.

Fix this by binding the vertex buffer where needed, when setting
attribute buffers for the shader program, and binding the shader program
for every frame.

As we use a single vertex buffer, we could bind it at the beginning of
paintGL() and keep it bound indefinitely. That would however fail to
clearly indicate in the source code where the vertex buffer is needed,
making the code more difficult to understand as it would rely on
implicit assumptions. Release the vertex buffer explicitly when we don't
need it anymore to avoid this.

While at it, fix a coding style violation by adding missing curly
brackets.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-11 18:24:51 +03:00
Laurent Pinchart
2e2aa40799 qcam: viewfinder_qt: Draw the letterbox background black
When the widget's aspect ratio doesn't match the camera aspect ratio,
the viewfinder is rendered letter-boxed. The side rectangles are not
painted by the viewfinder, and Qt thus renders the parent widget
background to fill that space.

To make it black, we have two options:

- The simplest option is to set the widget's autoFillBackground property
  to true. This causes Qt to paint the whole widget with its background
  colour before calling paintEvent(). As the camera image typically
  covers most (if not all) of the viewfinder widget, this is less
  efficient.

- The more complicated option is to paint the letterbox rectangles
  manually. We can additionally set the widget's WA_OpaquePaintEvent
  attribute to instruct Qt to skip painting the parent widget. This
  reduces CPU usage by about 1% (and may reduce GPU usage as well).

Note that the WA_OpaquePaintEvent attribute has to be disabled when we
render the stopped icon, as the icon has a transparent background.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-11 18:24:50 +03:00
Laurent Pinchart
e5fd3bea77 qcam: Drop Qt version checks
The Qt version checks to support different minor Qt5 versions are not
needed anymore, now that we switched to Qt6. Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Neal Gompa <neal@gompa.dev>
2024-09-11 18:24:01 +03:00
Luca Weiss
13645ab0ab qcam: Decrease minimum width of selector dialog
On phone screens the default width is too wide, so the OK button cannot
be clicked.

Fix this by decreasing the minimum size of the dialog so it fits nicely.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-11 18:23:59 +03:00
Nejc Galof
5456e02d3f v4l2: Support setting frame rate in the V4L2 Adaptation layer
The V4L2 adaptation layer can already support streaming with components
such as OpenCV, however it is not accepting, or handling any requests to
configure the frame rate.

In V4L2 the frame rate is set by configuring the timeperframe component
of the v4l2_streamparm structure through the VIDIOC_S_PARM ioctl.

Extend the V4L2 compatibility layer to accept the VIDIOC_S_PARM ioctls
and provide an interface for setting controls on the V4L2Camera class to
set the requested rate when starting the camera.

Signed-off-by: Nejc Galof <galof.nejc@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-10 22:17:28 +02:00
David Plowman
5c5bc85082 ipa: rpi: agc: Ignore stable region when exposure/gain set manually
When a user is taking control of exposure and gain, setting them
manually, we set the AGC "stable region" to zero. This means that any
user changes, however small, will be applied, and they won't be
regarded as "too small to bother with".

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-09 15:13:43 +01:00
Laurent Pinchart
f75b8dd26f pipeline: rkisp1: Use ScopeExitActions to simplify error handling in start
Error handling in the PipelineHandlerRkISP1::start() function is
cumbersome. Simplify it using the utils::ScopeExitActions class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2024-09-05 16:12:41 +03:00
Laurent Pinchart
481fc69e7c libcamera: utils: Add ScopeExitActions class
The ScopeExitActions class is a simple object that performs
user-provided actions upon destruction. It is meant to simplify cleanup
tasks in error handling paths.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2024-09-05 16:12:35 +03:00
Stefan Klug
8161018b9b utils: checkstyle: Remove style checker for python pep8
The issues detected and fixed by autopep8 are the same as the ones
detected by pycodestyle. As the formatter runs unconditionally we can
remove the checker.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-04 17:22:59 +02:00
Stefan Klug
8ffaf376bb utils: checkstyle: Add a python formatter
Reporting style issues on python files is great, automatically fixing
them is even better. Add a call to autopep8 for python files. This fixes
the same issues as the ones reported by pycodestyle.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-04 17:22:36 +02:00
Laurent Pinchart
b318101ada libcamera: ipa: Drop unneded includes from ipa_interface.h
The ipa_interface.h file includes a number of headers that are not
directly used. Remove them, and add them to the source files that
include ipa_interface.h as required.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-09-03 15:25:55 +03:00
Laurent Pinchart
0e333755ff utils: ipc: Include <string> in generated headers where needed
Depending on the types used in the IPA interface, generated headers may
use the std::string class. Include <string> when needed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-09-03 15:25:45 +03:00
Milan Zamazal
ac1c57fcf5 libcamera: includes: Formatting improvements
The LSP autoformatter doesn't like some of the current formatting, let's
make it happier.  Note that not all of its suggestions were accepted
because readability is preferred and adjusting .clang-format may not be
easy or possible.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 22:46:32 +03:00
Milan Zamazal
e2cace52d5 libcamera: includes: Remove unused includes
The includes that are not used can be removed.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 22:44:38 +03:00
Milan Zamazal
308f0ccf04 libcamera: includes: Add missing includes
Let's add direct includes for classes currently included indirectly,
through other header files.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 22:37:55 +03:00
Milan Zamazal
6d0bf44c32 libcamera: libcamera: Formatting improvements
The LSP autoformatter doesn't like some of the current formatting, let's
make it happier.  Note that not all of its suggestions were accepted
because readability is preferred and adjusting .clang-format may not be
easy or possible.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 22:34:37 +03:00
Milan Zamazal
61a1d1694c libcamera: libcamera: Add missing includes
Let's add direct includes for classes currently included indirectly,
through other header files.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 22:31:50 +03:00
Milan Zamazal
d3aa432305 libcamera: libcamera: Remove unused includes
The includes that are not used can be removed.  Additionally, add some
directly used includes not listed.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 22:01:40 +03:00
Milan Zamazal
fd7fc9cca5 libcamera: ipa: Remove unused includes
The includes that are not used can be removed.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 21:55:41 +03:00
Milan Zamazal
132ba5ea8a libcamera: v4l2: Fix indirect include
Use the direct include of V4L2PixelFormat.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 21:54:50 +03:00
Milan Zamazal
89da2f4736 libcamera: v4l2: Fix an include placement
Put the inclusion of geometry.h to the right place.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 21:54:33 +03:00
Milan Zamazal
802073e79f libcamera: v4l2: Remove unused includes
The includes that are not used can be removed.  Also, some directly used
includes not listed are added.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02 21:54:18 +03:00