summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2023-10-18ipa: workaround libcxx duration limitationjmondi/android/vndkNicholas Roth
A bug in libcxx [0] used by clang version 11.0.2 is prevalent when building libcamera for Android SDK30. This has been fixed and integrated upstream with [1]. As a workaround, directly cast libcamera::utils::Duration objects to std::chrono::duration when dividing. Alternatives evaluated: Considered: Enable public inheritance of std::chrono::duration and override operator/ in the class. Outcome: Does not fix the original compiler error. Considered: Enable public inheritance of std::chrono::duration and override operator/ in the libcamera namespace. Outcome: new compiler error: ld.lld: error: duplicate symbol: libcamera::operator/ (libcamera::utils::Duration const&, libcamera::utils::Duration const&) Considered: Use private inheritance of std::chrono::duration and re-implement a pass-through version of each std::chrono::duration operator within libcamera::utils::Duration and use template metaprogramming to fix the division operator. Outcome: Testing shows that this would introduce substantial limitations, i.e. requring the Duration object to be on the LHS of any arithmetic operation with other numeric types. This also substantially increases implementation complexity. Considered: Extract double values from libcamera::utils::Duration objects and use those to divide. Outcome: This creates substantial readability and unit-safety issues. [0] https://github.com/llvm/llvm-project/issues/40475 [1] https://github.com/llvm/llvm-project/commit/efa6d803c624f9251d0ab7881122501bb9d27368 Bug: https://bugs.libcamera.org/show_bug.cgi?id=156 Signed-off-by: Nicholas Roth <nicholas@rothemail.net>
2023-10-13WIP: add vndk_libyuv for compile testingMattijs Korpershoek
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-10-13android: mm: generic: Use GraphicBufferAllocator instead of gralloc.hMattijs Korpershoek
gralloc.h is a very old API that has been deprecated at least since Android P (9). Switch over to a higher level abstraction of gralloc from libui, which is compatible with Android 11 and up. Libui: * is provided in the VNDK (so it's available to vendors). * is also used in the camera vts test named VtsAidlHalCameraProvider_TargetTest. Notes: * GraphicsBufferAllocator being a Singleton, buffer lifecycle management is easier. * The imported headers from Android generate the -Wextra-semi warning. To avoid patching the files, a pragma has been added before inclusion. * libdl was used for dlclosing() the legacy hal, so the dep has been dropped Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-10-13Revert "android: mm: Stub libhardware for build tests"Mattijs Korpershoek
The VNDK, which is included as a subproject can provide libhardware. Remove the stub and use the VNDK instead. This reverts commit b9ecd85ed1fee2e9d715368b24592ad3009131d8. Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-09-21android: camera_device: Fix requestedStream handlingHarvey Yang
The Android CameraDevice class adds a sourceStream for each Mapped stream requested by the framework. When mapping multiple framework streams to the same sourceStream, the implementation of CameraDevice::processCaptureRequest wrongly erases the just added sourceStream from the list of streams to request to libcamera. Fix this by adding the stream instead of erasing it. Fixes: 7ea83eba0df6 ("android: camera_device: Postpone mapped streams handling") Signed-off-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-16ipa: rpi: Fix segfault when parsing invalid json fileNaushir Patuck
If the json file parsing failed due to a malformed file, the root pointer would be null. This was not tested and caused a segfault when trying to use the pointer to retrieve the version key. Fix this by bailing out early if the parser returns a null pointer. 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: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-16ipa: rpi: agc: Use channel constraints in the AGC algorithmDavid Plowman
Whenever we run Agc::process(), we store the most recent total exposure requested for each channel. With these values we can apply the channel constraints after time-filtering the requested total exposure, but before working out how much digital gain is needed. 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: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-16ipa: rpi: agc: Add AgcChannelConstraint classDavid Plowman
A channel constraint is somewhat similar to the upper/lower bound constraints that we use elsewhere, but these constraints apply between multiple AGC channels. For example, it lets you say things like "don't let the channel 1 total exposure be more than 8x that of channel 0", and so on. By using both an upper and lower bound constraint, you could fix one AGC channel always to be a fixed ratio of another. Also read a vector of them (if present) when loading the tuning file. 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: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-16ipa: rpi: agc: Implementation of multi-channel AGCDavid Plowman
The switchMode, prepare and process methods are updated to implement multi-channel AGC correctly: * switchMode now invokes switchMode on all the channels (whether active or not). * prepare must find what channel the current frame is, and run on behalf of that channel. * process updates the most recent DeviceStatus and statistics for the channel of the frame that has just arrived, but generates updated values working through the active channels in round-robin fashion. One minor detail in process is that we don't want to change the DeviceStatus metadata of the current frame, so we now pass this to the AgcChannel's process method, rather than letting it find the DeviceStatus in the metadata. 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: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-16ipa: rpi: agc: Reorganise code for multi-channel AGCDavid Plowman
This commit does the basic reorganisation of the code in order to implement multi-channel AGC. The main changes are: * The previous Agc class (in agc.cpp) has become the AgcChannel class in (agc_channel.cpp). * A new Agc class is introduced which is a wrapper round a number of AgcChannels. * The basic plumbing from ipa_base.cpp to Agc is updated to include a channel number. All the existing controls are hardwired to talk directly to channel 0. There are a couple of limitations which we expect to apply to multi-channel AGC. We're not allowing different frame durations to be applied to the channels, nor are we allowing separate metering modes. To be fair, supporting these things is not impossible, but there are reasons why it may be tricky so they remain "TBD" for now. This patch only includes the basic reorganisation and plumbing. It does not yet update the important methods (switchMode, prepare and process) to implement multi-channel AGC properly. This will appear in a subsequent commit. For now, these functions are hard-coded just to use channel 0, thereby preserving the existing behaviour. 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: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-16ipa: rpi: histogram: Add interBinMean()Naushir Patuck
Add a new helper function Histogram::interBinMean() that essentially replaces the existing Histogram::interQuantileMean() logic but working on bins instead. Rework the interQuantileMean() to call into interBinMean() with the appropriate convertion from quatiles to bins. 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: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-04ipa: rpi: vc4: Make the StatisticsPtr construction clearerDavid Plowman
StatisticsPtr is a shared pointer, so the use of std::make_unique to create it was a bit confusing. Use std::make_shared instead. 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>
2023-09-04ipa: rpi: agc: Split AgcStatus into AgcStatus and AgcPrepareStatusDavid Plowman
The Agc::process() function returns an AgcStatus object in the metadata as before, but Agc::prepare() is changed to return the values it computes in a separate AgcPrepareStatus object (under the new tag "agc.prepare_status"). The "digitalGain" and "locked" fields are moved from AgcStatus to AgcPrepareStatus. This will be useful going forward as we can be more flexible about the order in which prepare() and process() are called, without them trampling on each other's results. 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-04ipa: rpi: agc: Filter exposures before dealing with digital gainDavid Plowman
We now time-filter the exposure before sorting out how much digital gain is required. This is actually a little more natural and simplifies the code. It also prepares us for some future work where this arrangement will be helpful. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrpyi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-04ipa: rpi: agc: Fetch AWB status in process method, not prepareDavid Plowman
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-04pipeline: rpi: Simplify buffer id generationNaushir Patuck
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-04pipeline: rpi: Rename RPi::Stream::setExternalBuffer()Naushir Patuck
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-04pipeline: rpi: Remove additional external dma buf handling logicNaushir Patuck
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-04pipeline: rpi: Increase buffer import count to 32Naushir Patuck
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-08-29libcamera: stream: Document stride will be 0 for compressed formatsUmang Jain
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-29ipa: rpi: imx290: Hide one frame on startupNaushir Patuck
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-07-31pipeline: rpi: Don't call toV4L2DeviceFormat() from validate()Naushir Patuck
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-28libcamera: yaml: Increase the YAML parser limitNaushir Patuck
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-28ipa: rpi: Fix the reporting of Focus FoMsDavid Plowman
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: ac7511dc4c59 ("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-28ipa: rpi: vc4: data: Updated color matrices for RPi CamerasBen Benson
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-25ipa: rpi: common: Handle AEC/AGC flicker controlsDavid Plowman
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-25libcamera: controls: Add controls for AEC/AGC flicker avoidanceDavid Plowman
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-24libcamera: rpi: pipeline_base: Cache sensor formatJacopo Mondi
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-24libcamera: rpi: pipeline_base: Move findBestFormat to CameraDataJacopo Mondi
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-24libcamera: rpi: pipeline_base: Remove populateSensorFormats()Jacopo Mondi
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-11libcamera: CameraManager: Remove ::get(dev_t)Kieran Bingham
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-11v4l2: Use SystemDevices properties to identify camerasKieran Bingham
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-11v4l2: v4l2_camera_proxy: Prevent ioctl sign-extensionsKieran Bingham
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-10ipa: rpi: imx296_mono: Disable all colour shadingNaushir Patuck
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-10ipa: rpi: imx708: Fix mode switch drop frame countNaushir Patuck
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-07pipeline: rpi: Account for Bayer packing when validating formatNaushir Patuck
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: 6c71ee1f1530 ("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-07libcamera: pipeline: simple: Support TI CSI-RXJai Luthra
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: https://github.com/jailuthra/linux/commits/6ff226ca13f34 [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-07libcamera: Add option to configure udev supportLaurent Pinchart
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-07meson: Fix space around colon issuesLaurent Pinchart
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-05apps: Add ipa-verify applicationLaurent Pinchart
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-04libcamera: Remove `StreamRoles` aliasBarnabás Pőcze
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-04libcamera: camera: Take span of StreamRole instead of vectorBarnabás Pőcze
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-06-28gstreamer: Drop libcamera_private dependencyUmang Jain
Drop libcamera_private dependency entirely as to avoid libcamerasrc getting more dependent on it. In order to achieve that, one of the mutex locks in GstLibcameraSrcState needs to be replaced with GMutex. However doing so, this won't let us to use the clang's thread annotation macros in libcamera (which should be fine as libcamerasrc would move out of libcamera repo once matured). Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
2023-06-19libcamera: meson: Allow PH to change libcamera_depsNaushir Patuck
Pipeline handlers can have custom dependencies. Allow each pipeline handler subdir to add them to libcamera_deps[]. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-06-19pipeline: rpi: Do not return an error from pipeline config file handlingNaushir Patuck
If a user provided pipeline config file is not present, or if the version reported in the file is invalid, do not return with an error when creating the pipeline handler. Instead, log a warning message and return success with default pipeline config values used. This now matches the behaviour when the pipeline config file could not be parsed correctly, and we revert to default values. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2023-06-19ipa: rpi: agc: Do not switch to a default if a mode is unavailableNaushir Patuck
In commit 0ee9339331c6, a default metering/exposure/constraint mode is used if a control sets a mode that is not listed in the camera tuning file. Setting a default mode may be undesirable in these cases, so instead keep the agc mode unchanged. This also matches the behaviour for other IPA controls where no changes are made in error conditions. Fixes: 0ee9339331c6 ("ipa: rpi: agc: Gracefully handle missing agc modes") Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2023-06-19libcamera: camera_sensor: Adjust properties::RotationJacopo Mondi
As the CameraSensor::validateTransform() function compensate for the sensor's mounting rotation, the properties::Rotation value should be adjusted to make sure application that receive already "corrected" images do not get confused by Rotation still reporting a value. Howerver, as an image sensor can only compensate rotations by applying H/V flips, only correct Rotation when the mounting rotation is 180 degrees. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-06-18gstreamer: Add enable_auto_focus option to the GStreamer pluginCedric Nugteren
Cameras such as the PiCam 3 support auto-focus, but the GStreamer plugin for libcamera does not enable auto-focus. With this patch auto-focus can be enabled for cameras that support it. By default it is disabled, which means default behaviour remains unchanged. For cameras that do not support auto-focus, an error message shows up if auto-focus is enabled. This was tested on cameras that do not support auto-focus (e.g. PiCam2) and was tested on a camera that does support auto-focus (PiCam3). The test involved setting the focus to AfModeContinous and observing it. However, by not setting "auto-focus-mode" or using AfModeManual as the "auto-focus-mode" both resulting in auto-focus being disabled. Bug: https://bugs.libcamera.org/show_bug.cgi?id=188 Signed-off-by: Cedric Nugteren <cedric@plumerai.com> Reviewed-by: Maarten Lankhorst <dev@lankhorst.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Tested-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2023-06-17libcamera: pipeline: Register device numbers with cameraKieran Bingham
Register the identified device numbers with each camera as the SystemDevices property. This facilitates camera daemons or other systems to identify which devices are being managed by libcamera, and can prevent duplication of camera resources. As the SystemDevices property now provides this list of devices, use it directly from within the CameraManager when adding a Camera rather than passing it through the internal API. Tested-by: Ashok Sidipotu <ashok.sidipotu@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-06-17libcamera: properties: Provide a Devices camera propertyKieran Bingham
Provide a new Camera property that allows pipeline handlers to list any kernel device used to operate the camera. This allows other frameworks and daemons such as PipeWire to better understand the resources consumed by a Camera and consider ignoring those resources when enumerating camera devices on a system. Tested-by: Ashok Sidipotu <ashok.sidipotu@collabora.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>