Commit graph

2606 commits

Author SHA1 Message Date
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
Umang Jain
08f7469617 src: android: Rectify internal header's #include path
libcamera internal headers are not installed system-wide. Hence, any
inclusion of internal headers should follow the #include directive
form:
	#include "libcamera/internal/header.h"

This was not the case for a few of the class in android HAL. Fix them.

Signed-off-by: Umang Jain <umang.jain@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-05 10:30:32 +02:00
Sebastian Fricke
093b71b24a pipeline: rkisp1: Add check for non-existent frame info
Add a check, that makes sure that the given FrameBuffer is associated
to a RkISP1FrameInfo instance. The current code tries to access the
frame info without checking if it actually exists.

Fixes: 0eb65e14e ("libcamera: pipeline: rkisp1: Attach to an IPA")

Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-03 13:31:25 +01:00
Kieran Bingham
3a1f67a803 src: meson: Define system paths
Define libcamera specific system paths for use within the library code
base. These can be used to identify system configuration files and
shared data.

Also, make use of the new system path variables and map the ipa paths
upon the libcamera system path, making use of the new shorter syntax for
join_paths().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-30 11:53:09 +01:00
Kieran Bingham
7065ad84f0 libcamera: internal: log: Report function on asserts
Report the function which fails an assertion as well as the actual
assertion.

This now reports as:

[30:08:53.218816270] [226567] FATAL default request.cpp:150 assertion "d" failed in reuse()
rather than:
[30:11:05.271888926] [228531] FATAL default request.cpp:150 assertion "d" failed

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-27 22:50:23 +01:00
Paul Elder
0f2189ba30 ipa: mojom: Put core.mojom in the libcamera namespace
Put core.mojom in the libcamera namespace, as all structs that are
defined in core.mojom are meant to be in that namespace. Fix the structs
that are used in the other mojom files accordingly.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 17:34:58 +09:00
Paul Elder
078fbff8f4 utils: ipc: Use the proper namespace for mojom structs
Structs defined in mojom previously used the namespace of the mojom file
that was being used as the source. This is obviously not the correct
namespace for structs that are defined in core.mojom. Fix the jinja
function for getting the element type including namespace, and use it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 17:34:58 +09:00
Paul Elder
17e8f6f71c utils: ipc: Include instead of forward-declare CameraSensorInfo
For structs defined in core.mojom that have the skipHeader tag, if
they're only used in function parameters (in a mojom file) then a
forward-declaration is sufficient. However, if the struct is used in
another struct in a mojom file, then the forward-declaration is
insufficient, and the definition needs to be included. Do so for
CameraSensorInfo, which is the only forward-declared struct in
ipa_interface.h, and update the documentation comment.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 17:34:55 +09:00
Sebastian Fricke
446cb01d14 ipa: cam_helper: Correct a wrong choice of term
Sensors provide embedded data buffers and not metadata buffers,
replace the incorrect term with the correct one.

Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
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-04-27 09:54:25 +03:00
Sebastian Fricke
2d95f773ab ipa: cam_helper_imx219: Rework comment
Fix two typos and improve the sentence.

Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 09:54:13 +03:00
Hirokazu Honda
c3ab0fa0ce libcamera: V4L2Device: Use Span in updateControls()
V4L2Device::updateControls() takes two arguments, raw array and
its size, for the v4l2_ext_control values. This replaces it with
libcamera::Span.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26 16:40:13 +03:00
Hirokazu Honda
3c0e99e034 libcamera: V4L2Device: Replace VLA with std::vector in setControls()
The original code uses Variable-Length-Array, which is not
officially supported in C++. This replaces the array with
std::vector.

Signed-off-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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26 16:40:10 +03:00
Hirokazu Honda
3252631fbd libcamera: V4L2Device: Replace VLA with std::vector in getControls()
The original code uses Variable-Length-Array, which is not officially
supported in C++. This replaces the array with std::vector.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26 16:39:54 +03:00
Jean-Michel Hautbois
8a2fb73337 ipa: rkisp1: Move the IPA to the ipa::rkisp1 namespace
Simplify name-spacing of the RKISP1 components by placing it in the
ipa::rkisp1 namespace directly.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-26 10:24:11 +02:00
Kieran Bingham
883334135b libcamera: pipeline: ipu3: Cancel unused buffers
When the CIO2 returns a cancelled buffer, we will not queue buffers
to the IMGU.

These buffers should be explicitly marked as cancelled to ensure
the application knows there is no valid metadata or frame data
provided in the buffer.

Provide a cancel() method on the FrameBuffer to allow explicitly
cancelling a buffer.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Kieran Bingham
0abed64843 libcamera: pipeline: rkisp1: Fail RkISP1FrameInfo can't be found
The RkISP1FrameInfo structure associated data sent to the IPA and is
essential for handling events.

If it can not be found, this is a fatal error which must be fixed.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Kieran Bingham
47c12e2635 libcamera: pipeline: ipu3: frames: Fail if the FrameInfo can't be found
The FrameInfo structure associates the data sent to the IPA
and is essential for handling events.

If it can not be found, this is a fatal error which must be fixed.

While we're changing the line, also correct a spelling error for
'Information'.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Kieran Bingham
ec5d4acfca libcamera: camera: Assert pipelines complete all requests
When the camera manager calls stop on a pipeline, it is expected that
the pipeline handler guarantees all requests are returned back to the
application before the camera has stopped.

Ensure that this guarantee is met by providing an accessor on the
pipeline handler to validate that all pending requests are removed.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:07 +01:00
Jean-Michel Hautbois
7e0da7c349 ipa: ipu3: fix coverity issues in AWB
The BNR configuration structure has inconsistent initialisation of two
members.

This was picked up by Coverity, after merge.
While this code is still functional, fix them to be consistent with the
other initialisations within the struct.

Reported-by: Coverity CID=320056
Reported-by: Coverity CID=320058
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 16:56:06 +01:00
Jean-Michel Hautbois
9e1bd62de3 ipa: ipu3: Add support for IPU3 AEC/AGC algorithm
Implement basic auto-exposure (AE) and auto-gain (AG) correction functions.
The functions computeTargetExposure() and computeGain() are adapted from
the Raspberry Pi AGC implementation to suit the IPU3 structures, and
filtering is added to reduce visible stepsize when there are large
exposure changes.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:13:03 +01:00
Jean-Michel Hautbois
b2ddc9b118 ipa: ipu3: Add support for IPU3 AWB algorithm
The IPA will locally modify the parameters before they are passed down
to the ImgU. Use a local parameter object to give a reference to those
algorithms.

Inherit from the Algorithm class to implement basic AWB functions.

The configure() call will set exposure and gain to their minimum value,
so while AGC is not there, the frames will be dark.

Once AWB is done, a color temperature is estimated and a default CCM matrix
will be used (yet to be tuned).
Implement a basic "grey-world" AWB algorithm just for demonstration purpose.

The BDS output size is passed by the pipeline handler to the IPA.
The best grid is then calculated to maximize the number of pixels taken
into account in each cells.

As commented in the source code, it can be improved, as it has (at least)
one limitation: if a cell is big (say 128 pixels wide) and indicated as
saturated, it won't be taken into account at all.
Maybe is it possible to have a smaller one, at the cost of a few pixels
to lose, in which case we can center the grid using the x_start and
y_start parameters.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:12:53 +01:00
Jean-Michel Hautbois
3ebb692f32 ipa: ipu3: Add a histogram class
This class will be used at least by AGC algorithm when quantiles are
needed for example. It stores a cumulative frequency histogram. Going from
cumulative frequency back to per-bin values is a single subtraction, while
going the other way is a loop.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:12:40 +01:00
Jean-Michel Hautbois
d5168b503a ipa: Add a common interface for algorithm objects
In order to instantiate and use algorithms (AWB, AGC, etc.)
there is a need for a common class to define mandatory methods.

Instead of reinventing the wheel, reuse what Raspberry Pi has done and
adapt to the minimum requirements expected.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-22 10:12:23 +01:00
Niklas Söderlund
b2cc8a2f57 lc-compliance: simple_capture: Handle unsupported roles
It's valid for a camera to return a nullptr if the requested set of
roles can not be satisfied. This is not correctly handled by
lc-compliance which instead crashes, fix this.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
2021-04-21 20:05:21 +02:00
Jacopo Mondi
e58b5fa39f libcamera: class: Drop 'klass' argument from documentation
The LIBCAMERA_D_PTR() and LIBCAMERA_O_PTR() macros do not require an
argument, but the version of the macro consumed by Doxygen does.

Fix this by removing the klass parameter from both macros in their
documentation version.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-21 09:53:08 +02:00
Jacopo Mondi
1fca6228fe libcamera: Drop argument from LIBCAMERA_DECLARE_PRIVATE
The LIBCAMERA_DECLARE_PRIVATE() macro, used by the library classes
that inherit from libcamera::Extensible in order to implement the
PIMPL pattern, expands to:

public:									\
	class Private;							\
	friend class Private;

The 'klass' argument is not used and it might confuse developers as
it might hint that the class that defines the pattern's implementation
can be freely named, while it is actually hardcoded to 'Private'.

Drop the argument from the macro definition.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hanlin Chen <hanlinchen@google.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-21 09:52:34 +02:00
Hirokazu Honda
d40430116b android: CameraDevice: Fix Camera3RequestDescriptor leakage
CameraDevice creates Camera3RequestDescriptor in
processCaptureRequest() and disallocates in requestComplete().
Camera3RequestDescriptor can never be destroyed if
requestComplete() is never called. This avoid the memory
leakage by storing them in map CameraRequestDescriptor.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-20 05:59:08 +03:00
Hirokazu Honda
0b661d70ec android: CameraDevice: Add stop()
This adds CameraDevice::stop(), which cleans up the member
variables of CameraDevice. It is called in CameraDevice::close()
and CameraDevice::configureStreams().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-20 05:55:50 +03:00
Naushir Patuck
796109c8dc pipeline: raspberrypi: Fix typo in a comment
s/embedded/bayer/

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-20 03:35:49 +03:00