Commit graph

2275 commits

Author SHA1 Message Date
Paul Elder
7832e19a59 utils: ipc: add templates for code generation for IPC mechanism
Add templates to mojo to generate code for the IPC mechanism. These
templates generate:
- module header
- module serializer
- IPA proxy cpp, header, and worker

Given an input data definition mojom file for a pipeline.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16 19:21:00 +09:00
Paul Elder
892c0f4c19 libcamera: control_serializer: Save serialized ControlInfoMap in a cache
The ControlSerializer saves all ControlInfoMaps that it has already
(de)serialized, in order to (de)serialize ControlLists that contain the
ControlInfoMaps. Leverage this to cache ControlInfoMaps, such that the
ControlSerializer will not re-(de)serialize a ControlInfoMap that it has
previously (de)serialized.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16 19:20:57 +09:00
Dafna Hirschfeld
a119d75530 libcamera: pipeline: rkisp1: configure IPA from configure method instead of start method
Currently the call to the configure method of rkisp1 IPA
is called upon the 'start' of the pipeline. This should be done
in the 'configure' method instead.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-02-16 19:20:52 +09:00
Kieran Bingham
f9c0cf2a3a libcamera: MappedBuffer: Disable copy and assignment
MappedBuffers have a custom move constructor and assignment operator to
ensure that memory is not unmapped during object manipulation.

Because of the user-defined move constructor, the implicitly-declared
copy-constructor will already be deleted, however delete it explicitly
to help readability of the code, and make it clear that the object can
not be copied.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:21 +00:00
Kieran Bingham
640f48d603 libcamera: Utilise LIBCAMERA_DISABLE_COPY
Replace existing use cases where the copy constructor and copy
assignment operator are deleted with the LIBCAMERA_DISABLE_COPY
statement

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:20 +00:00
Kieran Bingham
83c5a2a7aa libcamera: controls: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE
The ControlId and Control classes disable the copy constructor and
assignment operator, but they should also prevent move construction and
assignment.

Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE to fully disable these
functions.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:17 +00:00
Kieran Bingham
234ee71517 libcamera: media_object: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE
Convert MediaLink, MediaPad, and MediaEntity to declare
LIBCAMERA_DISABLE_COPY_AND_MOVE. These classes already deleted their
copy constructor but not the assignment operator.

They should also not be movable, so expand to fully disable both copying
and moving.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:12 +00:00
Kieran Bingham
74f103486c libcamera: buffer: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE
Convert the existing copy, move and assignment operators to use the new
macros.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:34:18 +00:00
Kieran Bingham
41b6d83e6a libcamera: class: Provide move and copy disablers
It can be difficult to correctly parse the syntax for copy/move and the
associated assignment operators.

Provide helpers as syntactic sugar to facilitate disabling either the
copy constructor, and copy assignment operator, and the move constructor
and move assignment operator in a way which is explicit and clear.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:34:04 +00:00
Kieran Bingham
1473add188 libcamera: Move extensible to class
The Extensible concept is a generic Class helper. To prepare for
further class helper additions, move the specific extensible
implementation and header to a more generic class header and source.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 11:56:00 +00:00
David Plowman
db55e09b42 ipa: raspberrypi: AWB: Fix race condition setting manual gains
Applying the manual_r_ and manual_b_ values is entirely removed from
the asynchronous thread where their use constituted a race hazard. The
main thread now deals with them entirely, involving the following
changes.

1. SetManualGains() applies the new values directly to the
"sync_results", meaning that Prepare() will jump to the new values
immediately (which is a better behaviour).

2. Process() does not restart the asynchronous thread when manual
gains are in force.

3. The asynchronous thread might be running when manual gains are set,
so we ignore the results produced in this case.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-11 19:14:39 +02:00
Laurent Pinchart
e36a6f4043 libcamera: Drop unneeded depend_files from meson custom targets
The meson custom_target() function accepts a 'depend_files' argument to
list additional dependency files. Files already listed in the 'command'
argument are handled automatically, and don't need to be added manually.
Drop them.

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-02-11 18:20:49 +02:00
Laurent Pinchart
db27029ce4 meson: Fix coding style when declaring arrays
The meson.build files mix array declarations with and without a space
after the opening and before the closing square bracket. The vast
majority of cases don't use spaces, so standardize on that.

While it it, fix indentation in a few places.

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-02-11 18:20:22 +02:00
David Plowman
9e369da993 ipa: raspberrypi: AWB: Remove unecessary frame count variable
The variable frame_count2_ is not needed as Prepare() and Process()
always run in lock step one after the other.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-10 19:23:18 +02:00
Naushir Patuck
8a05d35ba5 ipa: raspberrypi: Handle control::NoiseReductionMode in the controller
The application provided noise reduction mode gets passed into the
denoise controller. The denoise controller in turn returns the mode to
the IPA which now sets up the colour denoise processing appropriately.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-09 13:23:40 +02:00
Naushir Patuck
c9e1ef7bd2 ipa: raspberrypi: Add a DenoiseAlgorithm class to the Controller
This denoise algorithm class will be used to pass in the user requested
denoise operating mode to the controller. The existing Denoise
controller will derive from this new DenoiseAlgorithm class.

Add a denoise mode field in the denoise status metadata object for the
IPA to use when configuring the ISP.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-09 13:23:39 +02:00
Naushir Patuck
44ea5b65c8 ipa: raspberrypi: Rename SdnStatus to DenoiseStatus
This change is in anticipation of the addition of a DenoiseAlgorithm
base class which the SDN class will derive from. We want to match the
metadata object name with the base class algorithm name.

This renames:
- SdnStatus metadata object to DenoiseStatus
- "sdn.status" metadata string key to "denoise.status"
- sdn_status.h header file to denoise_status.h

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-09 13:23:39 +02:00
Naushir Patuck
1c362b7855 uapi: raspberrypi: Update the bcm2835-isp header definition
Update the bcm2835-isp.h file with the latest version available in the
downstream Raspberry Pi linux repo at commit:
68878170d8a98afd6d519a3a2c909080c19de4ce

This change adds support for colour denoise processing, and the
following downstream kernel changes must be available:
https://github.com/raspberrypi/linux/pull/4069
https://github.com/raspberrypi/linux/pull/4083

The Raspberry Pi image must also be running the latest firmware,
obtained by running rpi-update.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Acked-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-02-09 13:23:39 +02:00
Naushir Patuck
68b992e72e pipeline: raspberrypi: Set the ISP Output1 to 1/4 resolution if unused
In preparation for fast colour denoise, set the low resolution ISP
output stream (Output1) to a 1/4 resolution of the application requested
stream (Output0). This only happens if the application has not requested
an additional YUV or RGB stream.

We also constrain this 1/4 resolution to at most 1200 pixels in the
largest dimension to avoid being too taxing on memory usage and system
bandwidth.

Also switch the default StreamRole::VideoRecording to YUV420 to allow
fast colour denoise to run.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-09 13:23:39 +02:00
Naushir Patuck
64e3aa23ff pipeline: raspberrypi: Refactor stream configuration routine
Refactor the high/low resolution stream format and output selection
routine. This change is in preparation of adding 1/4 resolution output
for fast colour denoise.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-09 13:23:39 +02:00
Niklas Söderlund
03def6e947 libcamera: ipu3: Get request from information structure instead of buffer
Buffers dequeued from the ImgU may not be associated with a Request as
they are internal (statistics, parameters and some RAW buffers). Fetch
the request they are used for from the frame information instead.

Fixes: 9708f49fec ("libcamera: ipu3: Share parameter and statistic buffers with IPA")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-08 20:13:57 +01:00
David Plowman
4625132b90 ipa: raspberrypi: Remove atomic variable from Algorithm class
Pause() and Resume() are only called synchronously so paused_ does not
need to be atomic.

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-02-08 19:30:12 +02:00
Jacopo Mondi
756fcbaaf2 android: camera_device: Calculate MAX_JPEG_SIZE
Calculate the JPEG maximum size using the maximum preview format size
multiplied by a 1.5 factor.

The same multiplication factor is used in the existing HAL
implementations in ChromeOS.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-08 11:04:21 +01:00
David Plowman
7fab304719 ipa: raspberrypi: lux: Supply missing method and remove atomic variable
Supply the missing SetCurrentAperture() method (even though no one is
calling it). If we did call it, it would be called synchronously so
the atomic variable is not required.

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-02-07 16:09:02 +02:00
David Plowman
ef3ce74b26 ipa: raspberrypi: noise: Remove unnecessary atomic variable
mode_factor_ does not need to be atomic - it is set by SwitchMode()
which runs synchronously.

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-02-07 16:08:06 +02:00
David Plowman
7a8150c5b9 ipa: rasberrypi: contrast: Remove unnecessary atomic variables
SetBrightness() and SetContrast() are only called synchronously so
there is no need for brightness_ and contrast_ to be atomic.

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-02-07 16:06:51 +02:00
David Plowman
df3a86ace3 ipa: raspberrypi: ccm: Remove unnecessary atomic variable
SetSaturation() gets called synchronously so there is no need for
saturation_ to be atomic.

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-02-07 16:05:46 +02:00
David Plowman
a03cd6af11 ipa: raspberrypi: AWB: Improve locking
Fix a couple of places where notify_one() was called with the lock
held. Also restartAsync doesn't need the lock for its entire duration.

This change exactly matches commit db552b0b92 ("libcamera: ipa:
raspberrypi: ALSC: Improve locking in a few places") where we do the
same for ALSC (the asynchronous thread arrangement there is identical).

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-02-07 16:01:49 +02:00
David Plowman
3a1b50876c ipa: raspberrypi: AWB: Remove unnecessary locking for AWB settings
AWB settings get updated synchronously with the main thread, so the
settings_mutex_ and associated locking can be removed.

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-02-07 16:01:29 +02:00
Jacopo Mondi
b2839ed68a libcamera: ipu3: Fix RAW sizes selection
Commit 7208e70211 ("libcamera: ipu3: Always use sensor full frame size")
changed the CIO2 configuration procedure to always select the full
sensor resolution to work around an ImgU configuration issue, as
reported in the todo item introduced in said commit.

When capturing a RAW stream only and the ImgU is not involved, the CIO2
has to be configured with the requested stream size to avoid adjusting
the stream to the sensor resolution.

As an example, capturing a raw frame smaller than the sensor resolution
with this patch applied results in the stream configuration to be
correctly assigned.

$ cam -c1 -swidth=1056,height=784,role=raw
ipu3.cpp:207 CIO2 configuration: 1056x784-SGRBG10_IPU3
ipu3.cpp:222 Validating stream: 1056x784-SGRBG10_IPU3
ipu3.cpp:233 Assigned 1056x784-SGRBG10_IPU3 to the raw stream

Without this patch the same operation results in the stream resolution
to be adjusted to the sensor resolution.

$ cam -c1 -swidth=1056,height=784,role=raw
ipu3.cpp:201 CIO2 configuration: 4224x3136-SGRBG10_IPU3
ipu3.cpp:216 Validating stream: 1056x784-SGRBG10_IPU3
ipu3.cpp:227 Assigned 4224x3136-SGRBG10_IPU3 to the raw stream
ipu3.cpp:297 Stream 0 configuration adjusted to 4224x3136-SGRBG10_IPU3
Camera configuration adjusted

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-02-05 14:22:15 +01:00
Jacopo Mondi
f29601efc4 android: camera_device: Report HOT_PIXEL_MAP_MODE as OFF
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE result
metadata.

Report ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF as the Camera HAL
does not support the generation of an hot pixel correction map.

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-02-05 13:25:30 +01:00
Jacopo Mondi
5360d807b4 android: camera_device: Report sensor test pattern mode
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_SENSOR_TEST_PATTERN_MODE result metadata.

Report the only supported value of ANDROID_SENSOR_TEST_PATTERN_MODE_OFF.

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-02-05 13:24:22 +01:00
Jacopo Mondi
d77233be82 libcamera: ipu3: Always report crop region
Report the crop region for every completed request.

The crop region is initialized as the sensor's analogue crop
rectangle and updated when a Request with a new region completes.

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-02-05 13:22:51 +01:00
Jacopo Mondi
9690d082ec android: camera_device: Report AF_MODE_OFF in template
The CaptureResultTest#testCameraCaptureResultAllKeys CTS test
enforces the presence of the auto focus mode in the preview
request template.

Add the only supported mode AF_MODE_OFF in the generated template.

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-02-05 13:08:01 +01:00
Jacopo Mondi
f266c0eb9c android: camera_device: Use AF_MODE_OFF in scene override
The camera HAL does currently list AF_MODE_OFF as the only supported
auto-focus mode in the ANDROID_CONTROL_AF_AVAILABLE_MODES static
metadata. For this reason reporting AF_MODE_AUTO as scene override
is wrong.

At the moment scene override is disabled in the Camera HAL, but this
is worth a fix nonetheless.

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-02-05 13:07:05 +01:00
Jacopo Mondi
e9c2875aea android: camera_device: Report AE_EXPOSURE_COMPENSATION
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION result
metadata.

Report 0 as the current value for
ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION in the result metadata
pack.

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-02-05 13:06:45 +01:00
Jacopo Mondi
520c3664bc android: camera_device: Report COLOR_CORRECTION_ABERRATION_MODE
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_COLOR_CORRECTION_ABERRATION_MODE result
metadata.

Report the only supported value of
ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF.

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-02-05 13:03:36 +01:00
Niklas Söderlund
a3c75bba84 cam: Only queue the exact number of requests asked for
The cam option --capture=N is suppose to only capture N requests. But if
the processing done for each request is large (such as writing it to a
slow disk) the current implementation could queue more than N requests
before the exit condition is detected and capturing stopped.

Solve this by only queueing N requests while still waiting for N
requests to complete before exiting.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 11:10:29 +01:00
Niklas Söderlund
5b60b689c1 cam: event_loop: Execute events in the libevent loop
Cam uses libevent to deal with threads and idle loop while still
implementing its own event queue. This creates issues when the event
loop is terminated as it might get stuck in the idle loop if exit() is
called while the thread is busy with dispatchCalls().

Solve this by removing the custom event execution and instead injecting
the calls as events to the base event loop.

Reported-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 11:10:29 +01:00
Niklas Söderlund
297c9c3fa0 cam: event_loop: Rename event_ to base_
The 'event' variable name is usually used for events added to the base
event loop, not the loop itself. Rename the struct event_base member to
base_ as a preparation for future work adding events to the loop.

There is no functional change.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 11:10:29 +01:00
Niklas Söderlund
9708f49fec libcamera: ipu3: Share parameter and statistic buffers with IPA
Use the IPU3Frames helper to share parameters and statistics buffers
with the IPA. Track which parameter and statistic buffer is used for
which request and make sure the parameter buffers is filled in by the
IPA before it's needed and that the statistic buffer is consumed and
meta data generated before completing the request.

With this change the IPU3 pipeline is prepared to fully operate with an
IPA component.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
d2bc3eb7b6 libcamera: ipu3: Add helper for parameter and statistic buffers
Add a helper class to aid in associating a parameter and statistic
buffer with each request queued to the pipeline. The helper helps with
tracking the state of the extra buffers and in completing the request
once all extra processing is done.

This change only adds the helper more work is needed to integrate it
with the pipeline and an IPA.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
82549ae253 libcamera: ipu3: Map buffers in IPA
Map and unmap the parameters and statistic buffers in the IPA when the
pipeline handler allocates and frees the buffers.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
60b5f3b8b9 libcamera: ipu3: imgu: Allocate buffers for stats and param
Instead of preparing for buffer importing allocate buffers that can be
used by an IPA.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
9cdad8461e libcamera: ipu3: Attach to an IPA and allow it to set sensor controls
Attach to the IPA and allow it to push V4L2 controls that apply to the
camera sensor. The IPA is not fully integrated in the pipeline as
statistics and parameters buffers are not yet allocated, processed by
the IPA nor queued to the hardware.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
0a7000cc96 libcamera: ipa: ipu3: Add an IPA skeleton for the IPU3 pipeline
Add an empty IPA skeleton for the IPU3 pipeline. The skeleton IPA
handles the flow of parameter and statistic buffers but does not read or
write anything in the buffers. It also allows the IPA to set sensor
controls but does not implement any logic to set optimal values and
instead sets the V4L2 exposure and gain controls to max and keeps them
at that setting.

This IPA is meant as a base to allow the pipeline handler to be wired up
to an IPA. The image algorithms can then later be added to the IPA
independently from also having to add plumbing to the pipeline handler.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
ef80137671 libcamera: ipu3: cio2: Generate start of frame event
Propagate the frameStart event whenever the CSI-2 receiver in the CIO2
pipeline generates one.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
354f1fb933 libcamera: ipu3: cio2: Return the FrameBuffer pointer used
When adding IPA plumbing to the IPU3 pipeline handler it will be needed
to track which raw buffer was queued to the CIO2 for a specific request.
Currently if using an internally allocated raw buffer the FrameBuffer is
not exposed outside the CIO2Device as it was not needed. Prepare for the
IPA by exposing which internal raw buffer is picked for each request,
later changes will associate this with a Request.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
d4225a23ae libcamera: ipu3: imgu: Add parameters video device
Add the parameters video device to the data structure of the ImgUDevice.
Even if the video device is configured, prepared to import buffers and
started no buffers are ever queued to it so it does not yet effect the
capture. Nor is does this change hinder the current capture mode to
function.

This is done in preparation to attach an IPA to the IPU3 pipeline.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05 01:20:32 +01:00
Niklas Söderlund
c5fe5f572c libcamera: ipu3: imgu: Configure the stat video device as part of configure()
There is no reason to expose and call a separate configureStat() when
the statistics video device can be configured with the exact same
parameters as part of configure(). Move the configuration internally to
the ImgUDevice simplifying the interface, there is no functional change.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05 01:20:32 +01:00