Commit graph

4397 commits

Author SHA1 Message Date
Laurent Pinchart
436b38fd89 libcamera: Open files with O_CLOEXEC
Files opened internally in libcamera without the O_CLOEXEC file will
remain open upon a call to one of the exec(3) functions. As exec()
doesn't destroy local or global objects, this can lead to various side
effects. Avoid this by opening file descriptors with O_CLOEXEC for all
internal files.

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-04-05 07:18:30 +03:00
Laurent Pinchart
4cd9cb4a90 meson: Really fix git version parsing
The previous attempt to fix git version parsing in commit d34cefad17
("meson: Fix git version parsing") was too naive, and didn't take into
account cases where the libcamera git version contains no or multiple
'+' signs.

Fixing this is more complex than a one-liner change, as meson doesn't
support Python-style slicing of arrays or a length method on strings.
The simplest and most versatile option is to patch the version string in
the gen-version.sh script. Do so, and clarify the comments related to
version handling in meson.build.

Fixes: d34cefad17 ("meson: Fix git version parsing")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-04-05 07:16:07 +03:00
Naushir Patuck
ac7511dc4c ipa: raspberrypi: Generalise the focus reporting code
Use the generalised focus statistics structure to compute the centre
window focus FoM value. This avoids needed to hard-code a specific
grid size.

Remove the focus reporting algorithm as the functionality is duplicated
by this bit of IPA code. Remove focus_status.h as it is no longer needed.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31 13:29:18 +01:00
Nick Hollinghurst
43f57f26b4 ipa: raspberrypi: Generalise the autofocus algorithm
Remove any hard-coded assumptions about the target hardware platform
from the autofocus algorithm. Instead, use the "target" string provided
by the camera tuning config and generalised statistics structures to
determing parameters such as grid and region sizes.

Additionally, PDAF statistics are represented by a generalised region
statistics structure to be device agnostic.

These changes also require the autofocus algorithm to initialise
region weights on the first frame's prepare()/process() call rather
than during initialisation.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: Naushir Patuck <naush@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-03-31 13:29:18 +01:00
Naushir Patuck
e51a9f7b94 ipa: raspberrypi: Generalise the agc algorithm
Remove any hard-coded assumptions about the target hardware platform
from the AGC algorithm. Instead, use the "target" string provided by
the camera tuning config and generalised statistics structures to
determing parameters such as grid and region sizes.

This change replaces all hard-coded arrays with equivalent std::vector
types.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31 13:29:18 +01:00
Naushir Patuck
e145decf36 ipa: raspberrypi: Make RegionStats::get() always return a Region struct
Update the overloaded RegionStats::get() and RegionStats::getFloating()
member functions to return a Region struct for consistency.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31 13:29:18 +01:00
Naushir Patuck
d8685a579c ipa: raspberrypi: Generalise the contrast algorithm
Generalise the contrast algorithm code by removing any hard-coded
assumptions about the target hardware platform. Instead, the algorithm
code creates a generic Pwl that gets returned to the IPA, where it gets
converted to the bcm2835 hardware specific lookup table.

As a drive-by, remove an unused mutex.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31 13:29:18 +01:00
David Plowman
a82d08973f ipa: raspberrypi: alsc: Use a better type name for sparse arrays
The algorithm uses the data type std::vector<std::array<double, 4>> to
represent the large sparse matrices that are XY (X, Y being the ALSC
grid size) high but with only 4 non-zero elements on each row.

Replace this slightly long type name by SparseArray<double>.

No functional changes.

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-03-31 13:29:18 +01:00
David Plowman
c557de126e ipa: raspberrypi: alsc: Replace std::vectors by Array2D class
The Array2D class is a very thin wrapper round std::vector that can be
used almost identically in the code, but it carries its 2D size with
it so that we aren't passing it around all the time.

All the std::vectors that were X * Y in size (X and Y being the ALSC
grid size) have been replaced. The sparse matrices that are XY * 4 in
size have not been as they are somewhat different, are used
differently, require more code changes, and actually make things more
confusing if everything looks like an Array2D but are not the same.

There should be no change in algorithm behaviour at all.

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-03-31 13:29:18 +01:00
Naushir Patuck
af946958da ipa: raspberrypi: Generalise the ALSC algorithm
Remove any hard-coded assumptions about the target hardware platform
from the ALSC algorithm. Instead, use the "target" string provided by
the camera tuning config and generalised statistics structures to
determing parameters such as grid and region sizes.

The ALSC calculations use run-time allocated arrays/vectors on every
frame. Allocating these might add a non-trivial run-time penalty.
Replace these dynamic allocations with a set of reusable pre-allocated
vectors during the init phase.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31 13:29:18 +01:00
Naushir Patuck
f6cc78b446 ipa: raspberrypi: Add hardware configuration to the controller
Add a new Controller::HardwareConfig structure that captures the
hardware statistics grid/histogram sizes and pipeline widths. This
ensures there is a single centralised places for these parameters.

Add a getHardwareConfig() helper function to retrieve these values for a
given hardware target.

Update the statistics populating routine in the IPA to use the values
from this structure instead of the hardcoded numbers.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31 13:29:18 +01:00
Naushir Patuck
cf6df17958 ipa: raspberrypi Store the target string in the controller
The target string may be used by algorithms to determine the running
hardware target.

Store the target string provided by the camera tuning files in the
controller state. Add a getTarget() member function to retrieve this
string.

Validate the correct hardware target ("bcm2835") during the IPA
initialisation phase.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-31 13:29:17 +01:00
Naushir Patuck
f7bf0be653 ipa: raspberrypi: Fix default frame durations calculation
Fix a bug in the default frame durations calculation where the min/max
values are swapped round. This is a rarely travelled code path, so has
not actually caused a reported failure.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-28 14:12:20 +01:00
Naushir Patuck
6e88911338 ipa: raspberrypi: Ensure shutter speed and gain are clipped in the AGC
Make a copy of the CameraMode structure on a switch mode call. This
replaces the existing lastSensitivity_ field.

Limit the AGC gain calculations to the minimum value given by the
CameraMode structure. The maximum value remains unclipped as any gain
over the sensor maximum will be made up by digital gain.

Rename clipShutter to limitShutter for consistency, and have the latter
limit the shutter speed to both upper and lower bounds.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-28 14:12:18 +01:00
Naushir Patuck
f0b9eaeaa8 ipa: raspberrypi: Use the new sensor limits fields in CameraMode
Use the new analogue gain and shutter speed limit fields in the ipa
code when reporting back the control value limits and calculating the
analogue gain code to use. This also replaces the now unused (and
removed) maxSensorGainCode_ field.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-28 14:11:56 +01:00
Naushir Patuck
d6e85bdfe9 ipa: raspberrypi: Add sensor mode limits to CameraMode
Add fields in the CameraMode structure to capture the mode specific
limits for analogue gain and shutter speed. For convenience, also add
fields for minimum and maximum frame durations.

Populate these new fields when setting up the CameraMode structure.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-28 14:11:41 +01:00
Elias Naur
d942bdc913 libcamera: v4l2_device: openat(2) with O_CLOEXEC to cleanup after exec(3)
When an executable using libcamera calls exec(3) while a camera is in
use, file descriptors corresponding to the V4L2 video devices are kept
open has they have been created without O_CLOEXEC. This results in the
video devices staying busy, preventing the new executable from using
them:

[91] ERROR V4L2 v4l2_videodevice.cpp:1047 /dev/video0[149:cap]: Unableto set format: Resource busy

Fix this by opening video devices with O_CLOEXEC, which is generally a
good idea in libraries.

Signed-off-by: Elias Naur <mail@eliasnaur.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-03-26 11:48:18 +03:00
Kieran Bingham
e39f046f66 libcamera: camera: Ensure queued requests are invalid
Invalid, or not correctly reset requests can cause undefined behaviour
in the pipeline handlers due to unexpected request state.

If the status has not been reset to Request::RequestPending, it is
either not new, or has not been correctly procesed through
Request::reuse().

This can be caught early by validating the status of the request when it
is queued to a camera.

Reject invalid requests before processing them in the pipeline handlers.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-21 23:47:59 +00:00
Kieran Bingham
d9371444c4 meson: libcamera: Report IPA signature method
Use the Configuration section to report which dependency is used to
handle IPA module signatures.

In the event that it is not found, report directly in the configuration
that modules are Isolated.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-21 23:45:35 +00:00
Kieran Bingham
ffa3afdd61 ipa: libipa: Add OV2685 Camera Sensor Helper
Provide a CameraSensorHelper for the OV2685, along with the
corresponding camera sensor properties.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-21 23:40:41 +00:00
Kieran Bingham
8c0ae95865 ipa: libipa: Add OV5647 Camera Sensor Helper
Provide a CameraSensorHelper for the OV5647 as used in the Raspberry Pi
Camera Module v1.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Christopher Obbard <chris.obbard@collabora.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-21 23:34:28 +00:00
Tomi Valkeinen
b3cefd4c0e py: cam: Fix demosaic overflow issue
The demosaic code first expands the buffer datatype to uint16, and then
shifts the data left so that the 8, 10 and 12 bitspp formats all become
16 bitspp.

It then, eventually, uses np.einsum to calculate averages, but this
averaging sums multiple uint16 values together, and stores them in
uint16 storage. As in the first step we shifted the values left,
possibly getting values close to the maximum of uint16 range, we, of
course, overflow when summing them together. This leads to rather bad
looking images.

Fix this by dropping the original shift. It serves no purpose, and is
probably a remnant of some early testing code. This way the largest
numbers we are summing together are 12 bit values, and as we use a 3x3
window from which we fetch values, for a single rgb plane, the max
number of 12 bit values is 5 (for green). Sum of 5 12 bit values is well
below the 16 bit maximum.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@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>
2023-03-21 23:33:43 +00:00
Dave Jones
afc5ea57b4 ipa: raspberrypi: Fix crash under LTO
When compiled with LTO (the default on Ubuntu), the global static
objects camHelpers and algorithms cause a crash in raspberrypi_ipa_proxy
at runtime as they're not allocated by the time the registration
routines execute.

This is a fairly crude fix which just converts the global static objects
into local static objects inside an equivalently named function.

Signed-off-by: Dave Jones <dave.jones@canonical.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-21 23:32:10 +00:00
Laurent Pinchart
d34cefad17 meson: Fix git version parsing
When extracting the build metadata from the git version, we use the
string strip() method to remove the version prefix. This is incorrect,
as the strip() method takes a set of characters to be removed, not a
literal string. Fix it by splitting the git version string on the '+'
character and keeping the suffix.

Fixes: 02518e598e ("meson: Rewrite .replace usage")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-21 23:30:58 +00:00
Nicolas Dufresne
2ccca099d3 libcamera: base: Make the registration of log categories atomic
Logger::create() is not currently thread safe and causes crashes
noticeable on RaspberryPi 4. This adds a mutex around the creation
of categories.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.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-03-21 23:30:22 +00:00
Michael Riesch
f852b7fbc4 meson: Align handling of build metadata
The build metadata is split off correctly from the version string
obtained with utils/gen-version.sh, but for the meson project version
this step is not carried out. However, since libcamera uses Semantic
Versioning, it should be possible to add build metadata to the meson
project version. Align the handling of the build metadata to resolve
this mismatch.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
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-03-09 18:41:16 +02:00
Suhrid Subramaniam
16546269aa libcamera: converter: Check converter validity
The ConverterFactoryBase::create() function returns a nullptr when no
converter is found. The only caller, SimpleCameraData::init(), checks if
the converter is valid with isValid(), but doesn't check if the pointer
is null, which can lead to a crash.

We could check both pointer validity and converter validity in the
caller, but to limit the complexity in callers, it is better to check
the converter validity in the create() function and return a null
pointer when no valid converter is found.

Signed-off-by: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-03-09 18:40:40 +02:00
David Plowman
1957219d7e ipa: raspberrypi: imx296: Minor tuning updates
Some updates to the tuning for the imx296 sensors.

For the colour variant:

* Minor change to the AWB curve, making things a little less green.
* Updated CCMs that reduce colour saturation to a more accurate level.
  Thanks to Dr. Rolf Henkel for these measurements and calculations.
* Sharpening has been toned down quite a lot.
* rpi.focus algorithm added so that the focus measure can be accessed.

The sharpening and focus changes are applied to the mono version of
the sensor too as we expect similar characteristics.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-07 21:55:05 +00:00
David Plowman
85541db7bb ipa: raspberrypi: agc: Fix overflow in Y value calculation
The maxVal variable in the computeInitialY function needs to be a
uint64_t, otherwise the subsequent multiplications in the function
can overflow on relatively high resolution images (when the counts in
the regions go over 16 bits).

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-07 21:55:05 +00:00
Naushir Patuck
2a261d911f pipeline: raspberrypi: Iterate over all Unicam instances in match()
On Raspberry Pi Compute Module platforms, it is possible to attach a
single camera device only to the secondary Unicam port. The current
logic of PipelineHandlerRPi::match() will return a failure during
enumeration of the first Unicam media device (due to no sensor attached,
or sensor failure) and thus the second Unicam media device will never be
enumerated.

Fix this by looping over all Unicam instances in PipelineHandlerRPi::match()
until a camera is correctly registered, or return a failure otherwise.

Reported-on: https://github.com/raspberrypi/libcamera/issues/44
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-07 21:55:05 +00:00
Naushir Patuck
471cbc0ef7 pipeline: raspberrypi: Add a Unicam timeout override config options
Add a new parameter to the pipeline handler config file named
"unicam_timeout_value_ms" to allow users to override the automatically
computed Unicam timeout value.

This value is given in milliseconds, and setting a value of 0 (the
default value) disables the override.

An example use of this parameter would be if an application configured a
RAW stream, and provides buffers for the stream on every request. If the
application holds off on sending requests for a particular reason (e.g.
a timelapse use case), then we will possibly hit the watchdog timeout as
it is only a small multiple of the frame length. This override allows an
application to select a larger value with the knowledge that it may
space requests longer than the calculated timeout value.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-07 21:55:05 +00:00
Naushir Patuck
9648e85994 ipa: raspberrypi: Better heuristics for calculating Unicam timeout
The existing mechanism of setting a timeout value simply uses the
maximum possible frame length advertised by the sensor mode. This can be
problematic when, for example, the IMX477 sensor can use a frame length
of over 600 seconds. However, for typical usage the frame length will
never go over several 100s of milliseconds, making the timeout very
impractical.

Store a list of the last 10 frame length values requested by the AGC. On
startup, and at the end of every frame, take the maximum frame length
value from this list and return that to the pipeline handler through the
setCameraTimeoutValue() signal. This allows the timeout value to better
track the actual sensor usage.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-03-07 21:55:05 +00:00
Naushir Patuck
b6d84ed456 pipeline: ipa: raspberrypi: Change Unicam timeout handling
Add an explicit helper function setCameraTimeout() in the pipeline
handler to set the Unicam timeout value. This function is signalled from
the IPA to set up an appropriate timeout. This replaces the
maxSensorFrameLengthMs value parameter returned back from
IPARPi::start().

Adjust the timeout to be 5x the maximum frame duration reported by the
IPA.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.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>
2023-03-07 21:55:05 +00:00
Jacopo Mondi
cde9293cf9 ipa: rkisp1: lsc: Fix integer division error
The RkISP1 implementation of the LensShadingCorrection algorithm has been
made adaptive to the scene color temperature in commit 14c869c00f ("ipa:
rkisp1: Take into account color temperature during LSC algorithm").

The LSC algorithm interpolates the correction factors using the
table's reference color temperatures. When calculating the interpolation
coefficients, an unintended integer division makes both coefficient
zeros resulting in a completely black image.

Fix this by type casting to double one of the division operands.

Fixes: 14c869c00f ("ipa: rkisp1: Take into account color temperature during LSC algorithm")
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2023-03-06 18:12:10 +01:00
Sophie Friedrich
a146e05125 libcamera: camera_manager: Stop exponential explosive calls to createPipelineHandlers
Currently the function `createPipelineHandlers` connects itself to the
`devicesAdded` signal at the end of each call. As the Signal object
supports multiple non-unique listeners connected to it, the former
function would be called exponentially often with each new emitted event
on `devicesAdded` (i.e. with udev plugging in a new camera)

Fix it by connecting the createPipelineHandlers() slot to `devicesAdded`
signal in CameraManager::Private::init() instead. This will prevent the
slot getting connected multiple times to the `devicesAdded` signal.

Signed-off-by: Sophie Friedrich <dev@flowerpot.me>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-03-06 14:35:17 +02:00
Advait Dhamorikar
cee03cd183 Documentation: guides: pipeline-handler: Fix spelling error
The pipeline handler writers guide incorrectly references the
VividCameradata::init() impelementation with a spelling error.

Fix spelling of "impelementation" in the pipeline handler development
guide.

Signed-off-by: Advait Dhamorikar <advaitdhamorikar@gmail.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-03-06 13:10:54 +02:00
Matthias Fend
dbe96a2a6b libcamera: Keep using syslog for isolated IPA modules
Currently it is not possible to display debug output from an isolated IPA
module. The standard  descriptors are all closed and any specified log
file is explicitly deactivated for the IPA module. Since libcamera and the
isolated IPA module are separate processes, they cannot write to the same
file. However, if syslog is used, then this would be possible.

If syslog is specified as a log file, then this is left as it is for the
isolated IPA module.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-03-01 16:46:08 +01:00
Paul Elder
51396ab512 utils: checkstyle.py: Don't run commit title checker on staged commits
When creating a new commit, there is no title, so the title checker
complains that the title isn't compliant and the commit cannot be
created if checkstyle is run as a pre-commit hook. Fix this by skipping
the title checker when run on staged changes.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-03-01 17:20:05 +09:00
Barnabás Pőcze
58e0b6e18c apps: Return std::optional<> from StreamKeyValueParser::parseRole()
Instead of having bool return type and an out parameter, use
std::optional<libcamera::StreamRole> to return from
StreamKeyValueParser::parseRole().

Meanwhile at it, re-word an existing comment to make it lucid.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-15 01:32:05 +05:30
David Plowman
02f0492c55 pipeline: raspberrypi: Always use ColorSpace::Raw for raw streams
Commit 613d540267 ("pipeline: raspberrypi: Fix handling of colour
spaces") adjusts the colorspace to ColorSpace::Raw for raw streams.
However, if the colorspace is not requested for raw streams(nullopt),
we should still set the colorspace to ColorSpace::Raw, for raw streams.

Fixes: 613d540267 ("pipeline: raspberrypi: Fix handling of colour spaces")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-15 01:32:03 +05:30
Pavel Machek
3f8bcc1a36 Documentation: Small typo fix
Out should really be output.

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-12 20:01:25 +02:00
Harvey Yang
2403f5141f android: jpeg: Add JEA implementation
This patch adds JEA implementation to replace libjpeg in CrOS platform,
where hardware accelerator is available.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:42 +02:00
Harvey Yang
8702b9dac7 android: jpeg: Pass StreamBuffer to Encoder::encoder
To prepare for support of the JEA encoder in a following commit, which
will need to access the buffer_handle_t of the destination buffer, pass
the StreamBuffer to the Encoder::encoder() function. As the StreamBuffer
contains the source FrameBuffer and the destination Span, drop them from
the function arguments and access them directly from the StreamBuffer.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:42 +02:00
Harvey Yang
7a44534c4f android: jpeg: Add meson.build in src/android/jpeg
To further control sources in jpeg to build based on the platform, this
patch adds meson.build in src/android/jpeg directory.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:42 +02:00
Harvey Yang
b64fa1363c android: framebuffer: Add HALFrameBuffer and replace FrameBuffer
HALFrameBuffer is derived from FrameBuffer with access to
buffer_handle_t, which is needed for JEA usage.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:41 +02:00
Harvey Yang
4843bfa66d libcamera: framebuffer: Allow inheritance of FrameBuffer
To add buffer_handle_t access in android, this patch allows inheritance
of FrameBuffer to add a derived class in android.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:41 +02:00
Jacopo Mondi
85befa816e libcamera: Remove transform from V4L2SubdeviceFormat
Commit 6f6e1bf704 ("libcamera: camera_sensor: Apply flips at
setFormat()") extended the CameraSensor::setFormat() function
to apply vertical/horizontal flips on the sensor based on the
supplied Transform. To pass the Transform to the function the
V4L2SubdeviceFormat structure has been augmented with a Transform
member.

However as the newly added Transform is not used at all in the
V4L2Subdevice class, it should not be part of V4L2SubdeviceFormat.

Fix that by removing the transform field from V4L2SubdeviceFormat
and pass it as an explicit parameter to CameraSensor::setFormat().

Fixes: 6f6e1bf704 ("libcamera: camera_sensor: Apply flips at setFormat())
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-09 23:40:15 +01:00
Laurent Pinchart
3aa42f36c0 pipeline: raspberrypi: Drop unused code
Commit 1a614866a2 ("libcamera: camera_sensor: Validate Transform") has
removed usage of the RPiCameraData::supportsFlips_ but hasn't removed
the field itself, nor its initialization. Drop those as they're unused.

Fixes: 1a614866a2 ("libcamera: camera_sensor: Validate Transform")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-09 21:40:48 +02:00
Laurent Pinchart
9cc5cbadc2 pipeline: ipu3: Drop unused code
Commit 1a614866a2 ("libcamera: camera_sensor: Validate Transform") has
removed usage of the IPU3CameraData::rotationTransform_ but hasn't
removed the field itself, nor its initialization. Drop those as they're
unused.

Fixes: 1a614866a2 ("libcamera: camera_sensor: Validate Transform")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-09 21:40:47 +02:00
Laurent Pinchart
ec392360f6 libcamera: camera_sensor: Fix typo in comment
Fix a typo introduced in a comment when refactoring transformation
handling in the CameraSensor class.

Fixes: 1a614866a2 ("libcamera: camera_sensor: Validate Transform")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-09 21:40:45 +02:00