Commit graph

2984 commits

Author SHA1 Message Date
Jacopo Mondi
1da35058ec libcamera: ipu3: imgu: Filter resolutions < IF_CROP_MAX
As reported in https://bugs.libcamera.org/show_bug.cgi?id=32
allowing resolutions < IF_CROP_MAX leads to a not manageable number
configurations to be tested, slowing down the ImgU pipe configuration
to a point which is not acceptable for production devices.

Filter all resolutions < IF_CROP_MAX to maintain the run-time complexity
acceptable and remove the safety check that was meant to avoid overflows
when computing the IF rectangle sizes.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=32
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-05-20 10:58:36 +02:00
Jacopo Mondi
92411679b1 libcamera: ipu3: imgu: Update BDS calculation process
Apply the last three hunks of commit 243d134 ("Fix some bug for some
resolutions") from https://github.com/intel/intel-ipu3-pipecfg.git
to the BDS calculation procedure.

The BDS calculation is now perfomed by scaling both width and height,
and repeated by scaling width first.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-05-20 10:44:28 +02:00
Laurent Pinchart
2a103ba17e android: camera_metadata: Add type sanity check to updateEntry()
The CameraMetadata::updateEntry() functions cast the data pointer to a
void pointer, which is then used internally to call
update_camera_metadata_entry(). If the caller passes a pointer to an
incorrect data type, the behaviour is undefined, with possible crashes
if the incorrect data type is smaller than expected by the Android
metadata library.

To avoid crashes, make all public updateEntry() functions take typed
pointers, and pass the element size to the internal function. The
element size is then checked against the expected size, and an error
message logged if they don't match. This won't catch incorrect data
types that have the same size as the correct type, but will at least
avoid potential crashes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-18 14:45:29 +03:00
Laurent Pinchart
d189248302 android: camera_metadata: Make internal functions private
The resize() function and the addEntry() override that takes a void
pointer are not meant to be called by the user of the CameraMetadata
class. Make them private.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-18 14:45:29 +03:00
Laurent Pinchart
6dcfba2e9d android: camera_metadata: Constify argument to addEntry() and updateEntry()
The addEntry() and updateEntry() overrides that take a reference to a
container don't need to modify the container. Make it const.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-18 14:45:29 +03:00
Laurent Pinchart
64586e7d6e android: camera_metadata: Rename sizeofT argument to elementSize
The sizeofT argument to CameraMetadata::addEntry() stores the size of
one element. Its name is a bit cryptic as the function isn't a template
function with a typename T. Rename it to elementSize.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-18 14:45:29 +03:00
Laurent Pinchart
6aee488bfc v4l2: Replace manual loop counters with utils::enumerate()
Use the newly introduced utils::enumerate() to replace manual loop
counters. A local variable is needed, as utils::enumerate() requires an
lvalue reference.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-18 14:45:29 +03:00
Laurent Pinchart
ad38d9151b libcamera: utils: Add enumerate view for range-based for loops
Range-based for loops are handy and widely preferred in C++, but are
limited in their ability to replace for loops that require access to a
loop counter.  The enumerate() function solves this problem by wrapping
the iterable in an adapter that, when used as a range-expression, will
provide iterators whose value_type is a pair of index and value
reference.

The iterable must support std::begin() and std::end(). This includes all
containers provided by the standard C++ library, as well as C-style
arrays.

A typical usage pattern would use structured binding to store the index
and value in two separate variables:

std::vector<int> values = ...;

for (auto [index, value] : utils::enumerate(values)) {
     ...
}

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-05-18 14:45:28 +03:00
Naushir Patuck
d832e9622e pipeline raspberrypi: Move adding of ScalerCrop to the Request metadata
With the recent change to merge existing Request metadata with the
ControlList provided by the IPA in commit fcfb1dc02a ("libcamera:
raspberry: Report sensor timestamp"), we can now write the
controls::ScalerCrop value at the start of the pipeline instead of at
the end.

This change simplifies the logic slightly, and allows us to write all
metadata items to the Request in one place.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-18 11:45:32 +01:00
Naushir Patuck
f1b7b68d20 pipeline: raspberrypi: Store timestamp in the correct Request metadata
Write the controls::SensorTimestamp value in the Request metadata when
the request is popped from the queue ready to run the pipeline. This
ensures that the timestamp is written to the correct Request item,
which may not be at the top of the queue when the Unicam buffer dequeue
occurs.

Fixes: fcfb1dc02a ("libcamera: raspberry: Report sensor timestamp")
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-18 11:45:31 +01:00
Paul Elder
193ca8c353 android: jpeg: post_processor: Use the new metadata functions
Now that CameraMetadata supports more convenient functions, use those
instead.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-14 17:59:18 +09:00
Paul Elder
0bc6ce8f67 android: camera_device: Use the new CameraMetadata functions
Now that CameraMetadata supports more convenient functions, use those
instead.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-14 17:56:14 +09:00
Paul Elder
1ff6887d6b android: camera_metadata: Auto-resize CameraMetadata
Previously we had to manually declare the size of CameraMetadata on
allocation, and its count could not be changed after construction.
Change CameraMetadata's behavior so that the user can simply add or
update entries, and the CameraMetadata will auto-resize (double the
size) as necessary. Also remove everything involved with calculating
the initial size for any CameraMetadata instances.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-14 17:55:58 +09:00
Hirokazu Honda
0445a2dc02 Documentation: Fix too short title underline in ipa.rst
Sphinx build is broken from the commit (0906ddb2) because a
title underline is too short. This fixed the breakage.

Fixes: 0906ddb268 ("Documentation: Add IPA writers guide")
Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-13 17:24:02 +09:00
Paul Elder
0906ddb268 Documentation: Add IPA writers guide
Add a guide about writing IPAs.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Fricke <sebastian.fricke@posteo.net>
2021-05-13 13:20:42 +09:00
Paul Elder
2cd13cd58e android: camera_device: Fix typo in result metadata allocation error
Fix an error message typo s/static/result/.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-12 19:14:17 +09:00
Umang Jain
697e038e54 libcamera: Use get_option('includedir') instead of raw 'include'
In most cases, file paths in meson files start with get_option().
To maintain a consistent theme, use meson's get_option('includedir')
universal option over raw 'include'. This option is defaulted to
'include' string value, hence this commit does not introduce any
functional changes.

Signed-off-by: Umang Jain <umang.jain@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>
2021-05-11 11:57:11 +01:00
Umang Jain
17bf7df227 meson: Replace obselete join_paths() with '/' operator
Since meson v0.49.0, join_paths() is equivalent to '/' hence,
drop and replace it with '/' short-hand in meson files.

This commit does not introduce any functional changes.

Signed-off-by: Umang Jain <umang.jain@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>
2021-05-11 11:50:45 +01:00
Naushir Patuck
99feb66df0 ipa: raspberrypi: Rate-limit the controller algorithms
The controller algorithms currently run on every frame provided to the
IPA by the pipeline handler. This may be undesirable for very fast fps
operating modes where it could significantly increase the computation
cycles (per unit time) without providing any significant changes to the
IQ parameters. The added latencies could also cause dropped frames.

Pass the FrameBuffer timestamp to the IPA through the controls. This
timestamp will be used to rate-limit the controller algorithms to run
with a minimum inter-frame time given by a compile time constant,
currently set to 16.66ms. On startup, we don't rate-limit the algorithms
until after the number of frames required for convergence.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11 03:14:42 +03:00
Naushir Patuck
a80db5a723 ipa: raspberrypi: Add a Merge method to RPiController::Metadata
Add a new Merge method to the Metadata class. This will merge all unique
key/value pairs from a source metadata map to the destination map.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11 03:14:27 +03:00
Naushir Patuck
2bbd1e4766 ipa: raspberrypi: Add move/copy ctors and operators to Metadata class
Add a default, move and copy constructor as well as a move operator
implementation RPiController::Metadata class.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11 03:14:22 +03:00
Naushir Patuck
7de2bbed9b ipa: raspberrypi: Switch to std::scoped_lock in the Metadata class
Replace std::lock_guard with std::scoped_lock. When locking a single
mutex, both are functionally the same. When locking two mutexes in the
operator= overload, the scoped_lock uses a deadlock avoidance algorithm
to avoid deadlock.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11 03:13:45 +03:00
Naushir Patuck
340477f987 ipa: raspberrypi: Reformat RPiController::Metadata class header
Rearrange header includes to be in alphabetical order.
Add whitespace to class definition to match libcamera coding guidelines.
Fix a typo in the comment showing an example of scoped locks.

There are no functional changes in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11 03:13:39 +03:00
Naushir Patuck
3099e91c7b ipa: raspberrypi: Store dropped frame count in a member variable
Store the number of dropped frames on startup in a member variable. This
will be used in a subsequent change for rate limiting the controller
algorithms.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11 03:13:26 +03:00
David Plowman
82e4a98026 libcamera: pipeline: raspberrypi: Update ControlInfoMap after sensor format change
The Raspberry Pi pipeline handler does not update the sensor format
using CameraSensor::setFormat(), so it must manually force the update of
the associated ControlInfoMap.

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>
2021-05-11 02:31:19 +03:00
David Plowman
91122dea97 libcamera: camera_sensor: Fix frame lengths calculated by sensorInfo()
The minimum and maximum vblanking can change when a new format is
applied to the sensor subdevice, so be sure to retrieve up-to-date
values.

The V4L2Device acquires the new updateControlInfo() method to perform
this function, and which the CameraSensor calls automatically if its
setFormat method is used to update the sensor.

However, not all pipeline handlers invoke the setFormat method
directly, so the new method must be made publicly available for
pipeline handlers to call if they need to.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.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>
2021-05-11 02:31:08 +03:00
Jacopo Mondi
45c6a7e6e8 android: camera_device: Report sensor physical size
Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property
multiplying the number of sensor's readable pixels with the pixel unit
cell size if provided by the Camera.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-10 15:08:51 +02:00
Jacopo Mondi
cdfcb05bed libcamera: camera_sensor: Register static properties
Register static properties in the CameraSensor class by inspecting the
camera sensor properties database.

Static properties are overridden by properties retrieved from
the kernel interface at run-time if any overlap between the two
sets occurs.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-10 15:08:26 +02:00
Jacopo Mondi
a58a94e4c2 libcamera: Introduce camera sensor properties
Introduce a database of camera sensor properties, which contains
information on the camera sensor which are not possible, or desirable,
to retrieve from the device at run time.

The camera sensor database is accessed through a static function and
is indexed using the camera sensor model as reported by
properties::Model.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-10 15:07:59 +02:00
David Plowman
5fda81e1f4 ipa: raspberrypi: Use CamHelpers to generalise sensor embedded data parsing
CamHelpers get virtual Prepare() and Process() methods, running just
before and just after the ISP, just like Raspberry Pi Algorithms.

The Prepare() method is able to parse the register dumps in embedded
data buffers, and can be specialised to perform custom processing when
necessary.

The IPA itself only needs to call the new Prepare() and Process()
methods. It must fill in the DeviceStatus from the controls first, in
case the Prepare() method does not supply its own values.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-08 02:49:13 +03:00
David Plowman
df36fb4abb ipa: raspberrypi: Make sensor embedded data parser use Span class
Improve MdParser::Parse() by taking a Span, pointing to const data
that it should not change, as its input buffer.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-08 02:49:03 +03:00
Kieran Bingham
414babb60b libcamera: controls: Remove merge assertion
The ControlList merge operation is protected with an ASSERT to guarantee
that the two lists are compatible.

Unfortunately this assertion fails when we run IPAs in an isolated case
as while the lists are compatible, the isolated IPA has a unique
instance of the id map. This breaks the pointer comparison, and the
assertion fails with a false positive.

Remove the assertion, leaving only a todo in it's place as this breaks
active users of the library.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=31
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-07 17:21:11 +01:00
Jacopo Mondi
d66fd818ec android: camera_device: Use controls::SensorTimestamp
Use the controls::SensorTimestamp value to populate
ANDROID_SENSOR_TIMESTAMP result metadata.

The Camera is assumed to provide the control in the Request metadata.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:42 +02:00
Jacopo Mondi
b3a504e965 cam: Implement OptMetadata
Implement support for the new '--metadata' option by printing the
value of each metadata entry associated with a completed Request.

As sample of the output, running on raspberry pi, looks like the
following:

3050.205672 (30.01 fps) stream0 seq: 000033 bytesused: 720000
	ScalerCrop = (0x2)/3280x2460
	ExposureTime = 13969
	AeLocked = true
	DigitalGain = 1.000721
	Lux = 771.204224
	ColourGains = [ 1.561101, 1.629698 ]
	ColourTemperature = 4289
	SensorBlackLevels = [ 4096, 4096, 4096, 4096 ]
	ColourCorrectionMatrix = [ 1.691066, -0.599756, -0.091317, -0.437452, 1.983766, -0.546314, -0.083429, -0.722407, 1.805836 ]
	AnalogueGain = 2.000000
	SensorTimestamp = 3050205672000

3050.238999 (30.01 fps) stream0 seq: 000034 bytesused: 720000
	ScalerCrop = (0x2)/3280x2460
	ExposureTime = 13969
	AeLocked = true
	DigitalGain = 1.000709
	Lux = 771.232422
	ColourGains = [ 1.560868, 1.630029 ]
	ColourTemperature = 4289
	SensorBlackLevels = [ 4096, 4096, 4096, 4096 ]
	ColourCorrectionMatrix = [ 1.691081, -0.599726, -0.091362, -0.437497, 1.983627, -0.546130, -0.083420, -0.722523, 1.805943 ]
	AnalogueGain = 2.000000
	SensorTimestamp = 3050238999000

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:42 +02:00
Jacopo Mondi
7df772f559 cam: Add option to print the Request metadata
Add the "--metadata" option to the cam tool, which will be used to
print the metadata associated with a completed capture request.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:42 +02:00
Jacopo Mondi
fcfb1dc02a libcamera: raspberry: Report sensor timestamp
Report the sensor's timestamp in the Request metadata by using the
Unicam::Image buffer timestamp as an initial approximation.

The buffer's timestamp is recorded at DMA-transfer time, and it does not
theoretically matches the 'start of exposure' definition, but when used
to compare two consecutive frames it gives an acceptable estimation of
the sensor frame period duration.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:42 +02:00
Jacopo Mondi
131b209693 libcamera: raspberrypi: Do not over-write metadata
When a Request is completed upon receiving the IPA produced metadata,
the metadata associated with the Request are over-written, deleting
the information set at output buffer completion, such as the
SensorTimestamp.

This commit applies to the RaspberryPi pipeline handler the same change
applied to IPU3 in commit 2ee3dd57e2fc ("libcamera: ipu3: Merge IPA
metadata controls").

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:30 +02:00
Jacopo Mondi
99de822436 libcamera: buffer: Re-work setRequest() documentation
I got fooled by the documentation of setRequest() implying that the
function is meant to be called by pipeline handlers only, which it is
used in the Request class at Request::addBuffer() and Request::reuse()
time.

Rework the documentation to report that.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:18 +02:00
Jacopo Mondi
787c90027c libcamera: vimc: Report sensor timestamp
Report the sensor's timestamp in the Request metadata using the
completed buffer timestamp.

The buffer's timestamp reports the video capture buffer processing time,
and it does not theoretically matches the 'start of exposure'
definition.

VIMC being a testing platform and the test driver completes the buffers
for each media entity connected in the pipeline one after the other, the
current solution is acceptable for the pipeline.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:18 +02:00
Jacopo Mondi
922833f774 libcamera: simple: Report sensor timestamp
Report the sensor's timestamp in the Request metadata using the
completed buffer timestamp.

The buffer's timestamp is recorded at DMA-transfer time, and it does not
theoretically matches the 'start of exposure' definition. Record this with
a \todo entry.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:18 +02:00
Jacopo Mondi
62f53a0f22 libcamera: rkisp1: Report sensor timestamp
Report the sensor's timestamp in the Request metadata using the
completed buffer timestamp.

The buffer's timestamp is recorded at DMA-transfer time, and it does not
theoretically matches the 'start of exposure' definition. Record this with
a \todo entry.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:09:17 +02:00
Jacopo Mondi
210c59b6bb libcamera: rkisp1: Do not over-write metadata
When a Request is completed upon receiving the IPA produced metadata,
the metadata associated with the Request are over-written, deleting
the information set at output buffer completion, such as the
SensorTimestamp.

This commit applies to the RkISP1 pipeline handler the same change
applied to IPU3 in commit 2ee3dd57e2fc ("libcamera: ipu3: Merge IPA
metadata controls").

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:08:56 +02:00
Jacopo Mondi
ae342991dc libcamera: uvc: Report sensor timestamp
Report the sensor's timestamp in the Request metadata using the
completed buffer timestamp.

The UVC driver reports timestamps of SOE event through metadata, for
which there is no support in the current pipeline implementation.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:08:56 +02:00
Jacopo Mondi
d9a68af06d libcamera: ipu3: Merge IPA metadata controls
When a Request is completed upon receiving the IPA produced metadata,
they should be merged with the metadata set by the pipeline handler
before reporting them to applications.

Use ControlList::merge() to collect the IPA produced controls to the
request's metadata.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:08:34 +02:00
Jacopo Mondi
cb43c18040 libcamera: ipu3: Report sensor timestamp
Report the sensor's timestamp in the Request metadata by using the
CIO2 buffer timestamp as an initial approximation.

The buffer's timestamp is recorded at DMA-transfer time, and it does not
theoretically matches the 'start of exposure' definition, but when used
to compare two consecutive frames it gives an acceptable estimation of
the sensor frame period duration.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:08:34 +02:00
Jacopo Mondi
4f26020e66 libcamera: controls: Destage 'SensorTimestamp'
Destage the 'SensorTimestamp' control, which is used by pipeline
handlers to report the time when the first active line of the sensor's
pixel array is exposed.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:08:34 +02:00
Jacopo Mondi
b3a603a489 test: control_list: Test ControlList::merge()
Test the ControlList::merge() method by creating a new list and
merging it with the existing one.

Test that the merged list contains all the controls, the existing values
do not get overwritten and the ones copied are not changed.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:08:34 +02:00
Jacopo Mondi
f348188625 test: control_list: Check for Brightness presence
The current test verifies that after adding a new control to a list
already populated with one control the new one is present.

However the test wrongly tests for its presence twice instead of
making sure the existing control is still there.

Fix this by checking for the presence of both controls after the
update, and fix the error message accordingly.

Fixes: a8c40942b9 ("libcamera: controls: Improve the API towards applications")
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:08:34 +02:00
Laurent Pinchart
a5c881645a libcamera: controls: Add a function to merge two control lists
Add a new ControlList::merge() function to merge two control lists by
copying in the values in the list passed as parameters.

This can be used by pipeline handlers to merge metadata they populate
with metadata received from an IPA.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[reimplement the function by not using std::unordered_map::merge()]
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-06 15:07:52 +02:00
Umang Jain
332870ea2b test: bayer-format: Rectify internal header's #include path
libcamera internal headers are not available system-wide. Hence,
directive `#include <libcamera/internal/header.h>` is wrong. Fix it
by using "" for the #include directive.

Fixes: e09c487b97 ("test: Add unit tests for the BayerFormat class")
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-05 10:32:33 +02:00