Commit graph

4380 commits

Author SHA1 Message Date
David Plowman
2ea57d0b77 ipa: rpi: agc: Fetch AWB status in process method, not prepare
prepare() doesn't use the AWB status, so fetching it in process() is
probably better. This change is preparatory to other changes, where we
may find ourselves calling process() without having called prepare()
previously.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-04 17:47:35 +01:00
Naushir Patuck
ad64716ce9 pipeline: rpi: Simplify buffer id generation
Replace the buffer id generation in RPi::Stream with a simple integer
counter since ids don't get recycled any more.

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-09-04 11:13:27 +01:00
Naushir Patuck
74af791304 pipeline: rpi: Rename RPi::Stream::setExternalBuffer()
Since we don't distinguish between externally and internally allocated
dma bufs, rename this function to setExportedBuffer() to clearer on its
function.

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-09-04 10:45:22 +01:00
Naushir Patuck
e8582ee42e pipeline: rpi: Remove additional external dma buf handling logic
There is no need to distinguish between dma bufs allocated outside of
libcamera and internally allocated buffers. As such, remove all the
special case handling of such buffers.

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-09-04 10:45:22 +01:00
Naushir Patuck
1107999f71 pipeline: rpi: Increase buffer import count to 32
Hardcode the maximum number of buffers imported to the V4L2 video device
to 32. This only has a minor disadvantage of over-allocating cache slots
and V4L2 buffer indexes, but does allow more headroom for using dma
buffers allocated from outside of libcamera.

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-09-04 10:45:10 +01:00
Umang Jain
ae9bcb2155 libcamera: stream: Document stride will be 0 for compressed formats
For compressed formats, v4l2_pix_format.bytesperline value will be zero
and is documented similarly in the kernel. Since we set the stride to
v4l2_pix_format.bytesperline, document the case where it is expected
to be zero (i.e. if the format is compressed).

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-08-29 10:40:25 +03:00
Naushir Patuck
26ac1a8e3f ipa: rpi: imx290: Hide one frame on startup
The imx290 produces a single unusable frame on startup and mode switch.
This is signalled to the IPA in the mode switch case, but not the
startup case. Fix this.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-08-29 10:39:13 +03:00
Harvey Yang
960d0c1e19 libcamera: Remove duplicated SortIncludes in .clang-format
`SortIncludes: true` was added in both commit ae05b9f9d0
("clang-format: Enable sorted includes") and commit 0e1ff86e78
("clang-format: Regroup sort orders"), which caused issues to run
clang-format.

Fixes: 0e1ff86e78 ("clang-format: Regroup sort orders")
Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-08-02 00:50:31 +03:00
Laurent Pinchart
6cb92b523b Documentation: theme: Fix compilation with Sphinx >= 7.0.0
Sphinx 7.0.0 has dropped support for the deprecated 'style' variable
(https://github.com/sphinx-doc/sphinx/pull/11381). This breaks
compilation of the documentation:

  /usr/bin/sphinx-build -D release=v0.1.0+16-eed6a079 -q -W -b html Documentation Documentation/html

  Theme error:
  An error happened in rendering the page api-html/index.
  Reason: UndefinedError("'style' is undefined")

The recommended replacement is 'styles[-1]'. However, this resolves to
'_static/css/theme.css', which is part of the 'css_styles' variable, and
results in the stylesheet being included twice. To avoid that and fix
the compilation error, simply drop the first reference.

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>
2023-07-31 22:58:58 +03:00
Naushir Patuck
fe73f05475 pipeline: rpi: Don't call toV4L2DeviceFormat() from validate()
Don't make an unnecessary call to toV4L2DeviceFormat() from validate()
to get a V4L2DeviceFormat. Instead, the conversion can happen directly
from the RAW stream PixelFormat.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-07-31 12:09:41 +02:00
Laurent Pinchart
eed6a079d2 meson: Correctly locate libc++
The meson find_library() function takes a library name without the "lib"
prefix. Its usage to find lic++ is thus not correct, and meson warns
about it:

WARNING: find_library('libc++') starting in "lib" only works by accident and is not portable

Fix it by dropping the "lib" prefix.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-28 19:45:04 +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
Naushir Patuck
5322b7ba61 libcamera: yaml: Increase the YAML parser limit
Increase the maximum list size to 2000 elements. This allows, for
example, larger lens shading config structures to be parsed correctly
without throwing any errors.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-07-28 18:34:02 +03:00
David Plowman
baab00721c ipa: rpi: Fix the reporting of Focus FoMs
The FocusFom metadata was no longer being reported back because the
"focus.status" metadata was never being created.

Additionally, the scaling of the focus FoMs was over-zealous, rounding
just about everything down to zero.

Fixes: ac7511dc4c ("ipa: raspberrypi: Generalise the focus reporting code")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-07-28 18:34:02 +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
6213ecb859 ipa: rpi: vc4: data: Updated color matrices for RPi Cameras
Altered the color matrices for the tuning files for various
cameras in order to make them more color accurate.

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:23 +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
David Plowman
a2eadc40a7 ipa: rpi: common: Handle AEC/AGC flicker controls
We handle the flicker modes by passing the correct period to the
AEC/AGC algorithm which already contains the necessary code.

The "Auto" mode, as well as reporting the detected flicker period via
the "AeFlickerDetected" metadata, are unsupported for now.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-25 10:21:11 +01:00
David Plowman
6fdbf3f38c libcamera: controls: Add controls for AEC/AGC flicker avoidance
Flicker is the term used to describe brightness banding or oscillation
of images caused typically by artificial lighting driven by a 50 or
60Hz mains supply. We add three controls intended to be used by
AEC/AGC algorithms:

AeFlickerMode to enable flicker avoidance.

AeFlickerPeriod to set the flicker period "manually".

AeFlickerDetected to report any flicker that is currently detected.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-25 10:21:01 +01:00
Jacopo Mondi
cd7d917a04 libcamera: rpi: pipeline_base: Cache sensor format
The format to be applied on the sensor is selected by two criteria: the
desired output size and the bit depth. As the selection depends on the
presence of a RAW stream and the streams configuration is handled in
validate() there is no need to re-compute the format in configure().

Centralize the computation of the sensor format in validate() and remove
it from configure().

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-24 11:38:15 +02:00
Jacopo Mondi
4edc162e3d libcamera: rpi: pipeline_base: Move findBestFormat to CameraData
The findBestFormat() helper operates on the list of sensor formats,
which is owned by the CameraData class. Move the function to that class
as well to:

1) Avoid passing the list of formats to the function
2) Remove a static helper in favour of a class function
3) Allow subclasses with access to CameraData to call the function

Move to the CameraData class the scoreFormat helper as well.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2023-07-24 11:32:10 +02:00
Jacopo Mondi
81fa10d87f libcamera: rpi: pipeline_base: Remove populateSensorFormats()
populateSensorFormats() is a static helper that is called from a single
place and performs a simple loop over the sensor camera formats.

Remove it and in-line it in the caller to remove one static helper from
the pipeline_base.cpp file.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-24 11:21:00 +02: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
Kieran Bingham
668a5e674a libcamera v0.1.0
ABI Compliance:

abi-compliance-checker reports 99% binary compatibility and 81.4% source
compatibilty between version 0.0.5 and 0.1.

 - Binary compatibility: 99%
 - Source compatibility: 81.4%
 - Total binary compatibility problems: 4, warnings: 2
 - Total source compatibility problems: 165, warnings: 7

Now that we have funtional ABI validation, the soname has been updated from
libcamera.so.0.0.5 to libcamera.so.0.1.

Future releases will now maintain the same soname until an ABI breakage is
detected to reduce the repackaging and rebuilding of other components that may
use libcamera. The abi-compatibility report can now be generated with the new
utility './utils/abi-compat.sh'.

Key differences here are due to preventing the installation of internal and
private headers in the packaging process, and most of this API compatibility
should not be visible to applications with the exception of:

- Camera::generateConfiguration ( StreamRoles const& roles )

  The StreamRoles type definition has been removed. This is now handled as a
  Span<StreamRole> to prevent unnecessary allocations and copies.

- CameraManager::addCamera ( std::shared_ptr<struct Camera> camera, std::vector<unsigned long>const& devnums )
- CameraManager::get ( dev_t devnum )
- CameraManager::removeCamera ( std::shared_ptr<struct Camera> camera )

  These functions of the CameraManager were for use exclusively by the V4L2
  adaptation layer, and not intended for use by applications. This has now been
  reworked to use the new SystemDevices and the redundant functions removed.

The ABI/API breakages have been introduced by:

  5ca0c9276f ("libcamera: CameraManager: Remove ::get(dev_t)")
  26a4b83d1b ("libcamera: Remove `StreamRoles` alias")
  63966ae587 ("libcamera: base: Do not install private headers")

Core:
 - libcamera: v4l2_videodevice: Use O_CLOEXEC when exporting DMA buffers
 - libcamera: ipa_manager: Allow IPA loading in nested subdirs
 - meson: Fix usage of overwritten pipeline variable
 - subprojects: Drop leftovers of pybind11
 - camera_sensor: ipa: core: Add CFA pattern to IPACameraSensorInfo
 - libcamera: controls: Define a default lens position behaviour
 - libcamera: internal: request: convert to pragma once
 - libcamera: camera_manager: Move private implementation to internal
 - libcamera: camera_manager: Move {add,remove}Camera to internal
 - libcamera: properties: Provide a Devices camera property
 - libcamera: pipeline: Register device numbers with camera
 - libcamera: camera_sensor: Adjust properties::Rotation
 - libcamera: meson: Allow PH to change libcamera_deps
 - libcamera: base: Move thread_annotations to private
 - libcamera: base: Do not install private headers
 - utils: ABI Compatibility checker
 - meson: Use x.y soname versioning
 - libcamera: camera: Take span of StreamRole instead of vector
 - libcamera: Remove `StreamRoles` alias
 - utils: ipu3-capture.sh: Fix the script to work with recent media-ctl versions
 - Documentation: Add predefined macros from config.h to Doxyfile
 - utils: checkstyle: Add __repr__ method to CommitFile class
 - utils: checkstyle: Support running checkers selectively
 - utils: checkstyle: Don't include commit ID in commit title
 - utils: checkstyle: Add trailers checker
 - tests: gstreamer: Test cameras' enumeration from GstDeviceProvider
 - meson: Fix space around colon issues
 - libcamera: Add option to configure udev support
 - libcamera: CameraManager: Remove ::get(dev_t)
 - tests: gstreamer: Fix compiler error with gcc 8.4.0

ipa:
 - meson: ipa: Add mapping for pipeline handler to mojom interface file
 - libcamera: ipa: Remove character restriction on the IPA name
 - ipa: meson: Allow nested IPA directory structures
 - ipa: raspberrypi: Introduce IpaBase class
 - ipa: raspberrypi: agc: Move weights out of AGC
 - ipa: rkisp1: agc: drop hard-coded analogue gain range
 - libipa: camera_sensor_helper: Add IMX327 helper
 - pipeline: rpi: ipa_base: Parse config files after platformRegister()
 - libcamera: camera_sensor: Add Sony IMX327 sensor properties
 - ipa: rpi: imx296: Small refinements to the IMX296 mono sensor tuning
 - ipa: rpi: Handle controls for mono variant sensors
 - libcamera: controls: Drop reference to IPA in controls documentation
 - libipa: camera_sensor_helper: Restore alphabetical order
 - ipa: ipu3: agc: Drop hard-codec analogue gain max
 - ipa: rkisp1: agc: Restore minimum analogue gain limit
 - pipeline: ipa: rpi: Return lens controls from ipa->configure()
 - ipa: rpi: Set lens position to hyperfocal on startup
 - ipa: rpi: tunings: Add missing short and long exposure profiles
 - ipa: rpi: agc: Use std::string instead of char arrays
 - ipa: rpi: agc: Gracefully handle missing agc modes
 - ipa: rpi: agc: Do not switch to a default if a mode is unavailable
 - ipa: rpi: imx708: Fix mode switch drop frame count
 - ipa: rpi: imx296_mono: Disable all colour shading

pipeline:
 - libcamera: pipeline: simple: Add support for ST's DCMIPP
 - pipeline: meson: Allow nested pipeline handler directory structures
 - pipeline: ipa: raspberrypi: Refactor and move the Raspberry Pi code
 - pipeline: raspberrypi: rpi_stream: Set invalid buffer to id == 0
 - pipeline: ipa: raspberrypi: Restructure the IPA mojom interface
 - pipeline: raspberrypi: Make RPi::Stream::name() return const std::string &
 - pipeline: raspberrypi: Introduce PipelineHandlerBase class
 - pipeline: raspberrypi: Add stream flags to RPi::Stream
 - libcamera: rkisp1: Generate config using main path
 - libcamera: rkisp1: Crop on ISP before downscaling
 - libcamera: rkisp1: Assign sizes to roles
 - libcamera: rkisp1: Fix enumeration of RAW formats
 - pipeline: rpi: Do not return an error from pipeline config file handling
 - libcamera: pipeline: simple: Support TI CSI-RX
 - pipeline: rpi: Account for Bayer packing when validating format

apps:
 - apps: qcam: Remove redundant check
 - v4l2: Move the v4l2 compat layer to libexec/libcamera
 - android: mm: generic: use GRALLOC_HARDWARE_MODULE_ID
 - android: mm: Stub libhardware for build tests
 - py: Fix CameraManager.version property
 - py: Move ColorSpace and Transform classes to separate files
 - py: Use exceptions instead of returning error codes
 - py: unittests.py: Add weakref helpers and use del
 - py: Move to mainline pybind11 version
 - py: Fix code formatting
 - py: unittests.py: Fix type checker warnings
 - gstreamer: Add enable_auto_focus option to the GStreamer plugin
 - gstreamer: Drop libcamera_private dependency
 - apps: Add ipa-verify application
 - v4l2: v4l2_camera_proxy: Prevent ioctl sign-extensions
 - v4l2: Use SystemDevices properties to identify cameras

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-16 12:46:01 +01:00
Laurent Pinchart
03526e58d1 tests: gstreamer: Fix compiler error with gcc 8.4.0
The provider g_autoptr variable introduced by commit adb1bbb748
("tests: gstreamer: Test cameras' enumeration from GstDeviceProvider")
is left uninitialized when declared. The cleanup function could thus get
called on an unitialized variable if the scope was exited before the
variable gets initialized. This can't occur here, but gcc 8.4.0 still
complains about it:

/usr/include/glib-2.0/glib/gmacros.h: In member function ‘virtual int GstreamerDeviceProviderTest::run()’:
/usr/include/glib-2.0/glib/gmacros.h:1049:27: error: ‘provider’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     { if (_ptr) (cleanup) ((ParentName *) _ptr); }                                                              \
                           ^
../test/gstreamer/gstreamer_device_provider_test.cpp:37:32: note: ‘provider’ was declared here
   g_autoptr(GstDeviceProvider) provider;

Silence the error by initializing the variable to NULL at declaration
time. This is a good practice in any case, as later refactoring could
otherwise introduce a scope exit before initialization.

Fixes: adb1bbb748 ("tests: gstreamer: Test cameras' enumeration from GstDeviceProvider")
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>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-11 15:58:06 +01:00
Kieran Bingham
5ca0c9276f libcamera: CameraManager: Remove ::get(dev_t)
The CameraManager::get(dev_t) implementation was provided only for the
V4L2 Adaptation layer. This has now been replaced with the use of the
public SystemDevices property.

Remove the deprecated function entirely, along with the camerasByDevnum_
map which was only used to support this functionality.

This is a clear (and intentional) breakage in both the API and ABI.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-11 15:19:13 +01:00
Kieran Bingham
bff6d95281 v4l2: Use SystemDevices properties to identify cameras
The CameraManager->get(dev_t) helper was implemented only to support the
V4L2 Adaptation layer, and has been deprecated now that a new camera
property - SystemDevices has been introduced.

Rework the implementation of getCameraIndex() to use the SystemDevices
property and remove reliance on the now deprecated call.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-11 15:19:13 +01:00
Kieran Bingham
f7a9f14156 v4l2: v4l2_camera_proxy: Prevent ioctl sign-extensions
Handling ioctl's within applications is often wrapped with a helper such
as xioctl. Unfortunately, there are many instances of xioctl which
incorrectly handle the correct size of the ioctl request.

This leads to incorrect sign-extension of ioctl's which have bit-31 set,
and can cause values to be passed into the libcamera's v4l2 adaptation
layer which no longer represent the true IOCTL code.

Match the implementation of the Linux kernel and ensure that only 32
bits of the ioctl request are used by assigning to an unsigned int.

Link: https://github.com/Motion-Project/motion/discussions/1636
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-11 15:19:13 +01:00
Naushir Patuck
22cc8bc25d ipa: rpi: imx296_mono: Disable all colour shading
Colour shading should be turned off for the mono variant of the IMX296
sensor. To do this, set all the colour gain coefficients to 1.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <daivd.plowman@raspberrypi.com>
Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-10 14:20:22 +01:00
Naushir Patuck
f516141574 ipa: rpi: imx708: Fix mode switch drop frame count
The imx708 must drop a single frame on startup - but only when in HDR
mode. Non-HDR modes do not need to drop frames. Fix the logic in
hideFramesModeSwitch() which currently unconditionally advertises to
drop one frame.

Unfortunately there is no clear way to tell if the sensor is in the HDR
mode. So for now, look the resolution and framerate to deduce this.

Additionally ensure we override hideFramesStartup() and return the same
number as hideFramesModeSwitch().

Bug: https://github.com/raspberrypi/libcamera-apps/issues/524
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.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>
2023-07-10 14:20:15 +01:00
Naushir Patuck
7802471a3b pipeline: rpi: Account for Bayer packing when validating format
RPiCameraConfiguration::validate() did not account for user supplied
Bayer packing when validating the RAW stream configuration. Fix this
by seeing what packing (if any) has been specified selecting the output
RAW stream format.

Fixes: 6c71ee1f15 ("pipeline: raspberrypi: Introduce PipelineHandlerBase class")
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-07-07 11:39:34 +03:00
Jai Luthra
954ba8a803 libcamera: pipeline: simple: Support TI CSI-RX
New TI SoCs from J7 and AM62 family have a camera pipeline that receives
data using Cadence's DPHY-RX and CSI-RX bridge. A pixel-grabbing "shim"
IP routes this incoming stream of data to the DMA subsystem, to finally
store the frame data in memory.

The driver for this is not merged in mainline yet, but v7 was posted [1]
on linux-media list a few months ago.

With some minor fixes, the work-in-progress v8 series [2] works with the
simple pipeline handler, so we enable support for this device.

Link: https://lore.kernel.org/all/20230314115516.667-1-vaishnav.a@ti.com/ [1]
Link: 6ff226ca13 [2]
Signed-off-by: Jai Luthra <j-luthra@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-07-07 11:39:34 +03:00
Laurent Pinchart
d314d3b98b libcamera: Add option to configure udev support
libcamera uses udev to support hotplug (and unplug) detection. This is
an optional feature, which gets selected automatically if udev is
available. Users may however want to build libcamera without hotplug
detection, even if udev is available on the system. Add a new feature
option to control udev support. The default value is auto, which retains
the existing behaviour.

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>
2023-07-07 11:39:32 +03:00
Laurent Pinchart
ca437b4a0c meson: Fix space around colon issues
The meson style, which libcamera follows, recommends a space before
colons in function parameters. Fix the style violations through the
project.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-07-07 11:39:19 +03:00
Umang Jain
adb1bbb748 tests: gstreamer: Test cameras' enumeration from GstDeviceProvider
Test the enumeration of the cameras through GstDeviceProvider against
the libcamera camera manager.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
2023-07-06 10:05:27 +02: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
Laurent Pinchart
c9b2f62edd utils: checkstyle: Add __repr__ method to CommitFile class
Add a custom representation to the CommitFile class in order to
facilitate debugging.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-05 15:39:00 +03:00
Laurent Pinchart
52579639ce apps: Add ipa-verify application
When packaging libcamera, distributions may break IPA module signatures
if the packaging process strips binaries. This can be fixed by resigning
the modules, but the process is error-prone.

Add a command line ipa-verify utility that tests the signature on an IPA
module to help packagers. The tool takes a single argument, the path to
an IPA module shared object, and expects the signature file (.sign) to
be in the same directory.

In order to access the public key needed for signature verification, add
a static function to the IPAManager class. As the class is internal to
libcamera, this doesn't affect the public API.

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>
Tested-by: Javier Martinez Canillas <javierm@redhat.com>
2023-07-05 15:38:59 +03:00
Laurent Pinchart
1d5a072c5e Documentation: Add predefined macros from config.h to Doxyfile
libcamera creates a config.h file with predefined macros, and instructs
the compiler to include it implicitly with the -include argument.
Doxygen has no support for implicit inclusion of headers, but has a
PREDEFINED configuration option for its preprocessor that lists
predefined macros. Populate it with the values from the config_h
configuration data object that is used for generate the config.h file,
to ensure that documentation matches the configuration options libcamera
has been built with.

Bump the minimum meson version to 0.57 to use cfg_data.keys().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-05 15:38:55 +03:00
Hans de Goede
c49958d0b4 utils: ipu3-capture.sh: Fix the script to work with recent media-ctl versions
Recent media-ctl versions include the framerate in the fmt property output:

- entity 37: ov5693 4-0036 (1 pad, 1 link)
             type V4L2 subdev subtype Sensor flags 0
             device node name /dev/v4l-subdev6
	pad0: Source
		[fmt:SBGGR10_1X10/2592x1944@1/30
		 crop.bounds:(16,6)/2592x1944
		 crop:(16,6)/2592x1944]
		-> "ipu3-csi2 1":0 [ENABLED]

This resulted in $sensor_size getting set to: "2592x1944@1 30", which
causes the script to fail.

Fix this by:

1. Replacing the gsub() to remove the '/' between e.g. SBGGR10_1X10
and 2592x1944 with a sub() so that only that first '/' gets replaced
(resulting in a $sensor_size of "2592x1944@1/30" instead).

2. Adding a new sub() to remove the @1/30 suffix.

Signed-off-by: Hans de Goede <hdegoede@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>
2023-07-05 00:51:34 +01:00
Barnabás Pőcze
26a4b83d1b libcamera: Remove StreamRoles alias
Now that `Camera::generateConfiguration()` takes a `libcamera::Span`
of `StreamRole`, remove the `StreamRoles` type, which was an alias
to `std::vector<libcamera::StreamRole>`.

The removal has two reasons:
 - it is no longer strictly necessary,
 - its presence may suggest that that is the preferred (or correct)
   way to build/pass a list of `StreamRole`.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
[Kieran: Fix small checkstyle report on roles initialiser]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-04 22:56:38 +01:00
Barnabás Pőcze
86fa7300fa libcamera: camera: Take span of StreamRole instead of vector
Change the parameter type of `generateConfiguration()` from `const std::vector&`
to `libcamera::Span`. A span is almost always preferable to a const vector ref
because it does not force dynamic allocation when none are needed, and it allows
any contiguous container to be used.

A new overload is added that accepts an initializer list so that

  cam->generateConfiguration({ ... })

keeps working.

There is no API break since a span can be constructed from a vector
and the initializer list overload takes care of the initializer lists,
but this change causes an ABI break.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Kieran: Apply checkstyle fixups]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-04 22:48:30 +01:00
Kieran Bingham
8da938b007 meson: Use x.y soname versioning
Now that we identify ABI breakages, provide incremental releases which
can support backwards compatible linkage across release points that have
a compatible ABI.

Introduction of this commit does not convey that libcamera now has a
stable API, but that patch releases with a common minor number
(0.minor.patch) may potentially be used by applications without
recompilation and linkage against new releases.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-04 20:25:10 +01:00
Kieran Bingham
bbb77cc59b utils: ABI Compatibility checker
Provide support to compare ABI compatibility between any two git commits
or by a commit and the most recent ancestral tag of that commit.

Tested-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-04 20:25:10 +01:00
Kieran Bingham
63966ae587 libcamera: base: Do not install private headers
Split the public and private headers from the base library and stop installing
private headers as part of the install process.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-04 20:22:05 +01:00