Commit graph

2612 commits

Author SHA1 Message Date
Paul Elder
77c6ac0ae7 android: CameraDevice: Report proper min and max frame durations
The HAL layer was getting the min and max frame durations from the
camera, then rounding it to fps to report as available fps ranges. The
same min and max frame durations were then being reported as min and max
frame durations. Since the fps are integer values while the frame
durations are in ns, this caused a rounding error making it seem like we
were reporting an available max fps that was higher than what was
allowed by the minimum frame duration.

An example is if the minimum frame duration is reported as 33366700ns.
The HAL layer would then convert it to fps, which is 29.97, but it would
be rounded and reported as 30 fps. When 30 fps is converted to a frame
duration it is 33333333ns, which is less than the minimum frame duration
that we report. Thus the minimum frame duration that we report
contradicts the fps range that we report.

Fix this by recalculating the frame durations based on the rounded fps
values.

This allows the following CTS test to pass:
- android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreviewFpsRange

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-25 18:20:55 +09:00
Jean-Michel Hautbois
63c3c54592 libcamera: add OV5693 sensor properties
The new sensor database has introduced several sensors, but ov5693 is
missing.
It is used on most MS Surface tablets, add it to the database.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-05-25 11:19:16 +02:00
Laurent Pinchart
67a83e126b Revert "libcamera: V4L2Device: Remove the controls order assumption in updateControls()"
This reverts commit 34bee5e84e.

The commit introduced a breakage in the master branch, reported by
linux-surface users already. Let's revert it while discussing the
propert fix.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Tested-by: Umang Jain <umang.jain@ideasonboard.com>
2021-05-25 12:11:14 +03:00
Phi-Bang Nguyen
a25a611bb3 pipeline: simple: Rework the supportedDevices list
The supportedDevices may contain entries which have the same driver
but different converters. For example, if we add these two entries:

{ "mtk-seninf", "mtk-mdp", 3 },
{ "mtk-seninf", "mtk-mdp3", 3 },

the simple pipeline handler will always take the first one where it
can acquire the driver and skip the rest.

So, make the changes to support this usecase.

Signed-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-25 04:56:32 +03:00
Hirokazu Honda
34bee5e84e libcamera: V4L2Device: Remove the controls order assumption in updateControls()
The original updateControls() has the assumption that ctrls and
v4l2Ctrls lists are in the same order. It is dependent on the
caller implementation though. This changes updateControls()
implementation so that it works without the assumption.

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-05-25 02:54:16 +03:00
Laurent Pinchart
7de2daf653 android: camera_worker: Process all queued requests when stopping
When stopping the camera worker, queuedRequest() calls may have queued
asynchronous function invocation messages to the worker thread, and some
of those messages may not have been processed yet. The messages will
stay in the thread's queue until the camera worker is restarted (when
the camera service will start a new capture session). At that point,
they will be dispatched, which will cause a crash due to the
CaptureRequest passed to processRequest() having been deleted by
CameraDevice::stop() calling descriptors_.clear().

Fix this by forcing dispatching of all function invocation messages when
stopping the camera worker thread. Note that this is inherently racy, as
more queueRequest() calls may arrive from the camera service while we're
stopping. This race condition will be addressed by a subsequent patch
series.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-24 15:06:05 +03:00
Umang Jain
e8924f30f7 meson: Add a configuration option to build IPAs
There can be multiple IPAs per pipeline-handler or platform.
They can live in-tree or externally linked. It is up to the vendor
whether to use in-tree IPA for a platform or provide it externally.
In the case of IPAs being external, building in-tree IPAs might be
futile hence, provide a clear and explicit mechanism to choose whether
to build the in-tree IPA for the platform or not.

By default, all in-tree IPAs are built when a matching Pipeline handler
is also enabled.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 14:27:29 +03:00
Umang Jain
c76ca01323 ipa: ipu3: Introduce IPAConfigInfo in IPC
IPAConfigInfo is a consolidated data structure passed from IPU3
pipeline-handler to IPU3 IPA. The structure can be extended with
additional parameters to accommodate the requirements of multiple
IPU3 IPA modules.

Adapt the in-tree IPU3 IPA to use IPAConfigInfo as well.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 14:13:37 +03:00
Umang Jain
231d93557d ipa: meson: Install mojom generated headers to include paths
Generated IPA headers from mojom files need to be installed to
$INCLUDE_PATH in order to be available system-wide. Without this,
out-of-tree IPAs won't be able to link and build themselves.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 14:13:35 +03:00
Umang Jain
378f572e7f ipa: ipc: Rename CameraSensorInfo to IPACameraSensorInfo
This matches the naming convention for IPA IPC.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.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-24 14:13:32 +03:00
Umang Jain
6449590b63 ipa: mojom: Move CameraSensorInfo struct exclusively to IPA IPC
CameraSensorInfo structure is designed to pass in camera sensor related
information from pipeline-handler to IPA. Since the pipeline-handler
and IPA are connected via mojom IPC IPA interface, the interface
itself provides a more suitable placement of CameraSensorInfo,
instead of camera_sensor.h (which is a libcamera internal header
ultimately, at this point).

As CameraSensorInfo is already defined in core.mojom, it is just
a matter of removing [skipHeader] tag to allow code-generation
of CameraSensorInfo.

Finally, update header paths to include CameraSensorInfo definition
from IPA interfaces instead of "libcamera/internal/camera_sensor.h".

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.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-24 14:13:28 +03:00
Umang Jain
ff9276cc62 ipa: Move core IPA interface documentation to a .cpp file
Moving the core.mojom documentation to its corresponding .cpp file
(core_ipa_interface.cpp). This will allow Doxygen to generate the
documentation for IPABuffer, IPASettings and IPAStream structures.
Since the .mojom files are placed in include/ directory, the .cpp file
will live in $sourcedir/src/libcamera/ipa/ - which can also contain
documentation for other mojom generated IPA interfaces in subsequent
commit.

Also hide the constructors in generated IPA interface from doxygen,
via  #ifndef __DOXYGEN__. These constructors provide no major value in
documenting them, instead will spew out doxygen warnings during the
build.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 14:13:01 +03:00
Laurent Pinchart
b9d55fe69e libcamera: thread: Document race condition at stop time
When a thread stops, messages may be left in its message queue. Document
this in details, with a way to force processing of pending messages when
the thread is stopped.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-24 13:33:48 +03:00
Laurent Pinchart
cccb748000 libcamera: thread: Drop doc of asynchronous signals delivery to applications
The asynchronous signal delivery mechanism can't be used by application,
as it requires libcamera to be aware of the application event loop,
which has been dropped a long time ago. Drop the corresponding
documentation paragraph.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-05-24 12:27:17 +03:00
Laurent Pinchart
6551bd39f0 libcamera: thread: Enforce dispatchMessages() call context with assert
The Thread::dispatchMessages() function is meant to be called from
within the thread only. Catch incorrect usage with an ASSERT().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-05-24 12:27:07 +03:00
Laurent Pinchart
95cda2905c libcamera: thread: Document dispatchMessages() thread-safety requirements
The Thread class is incorrectly documented as thread-safe, as the
dispatchMessages() function isn't thread-safe. Fix the documentation by
tagging individual functions as thread-safe as appropriate.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-05-24 12:26:40 +03:00
Hirokazu Honda
a5f8ab82df libcamera: V4L2Control: remove V4L2Control classes
V4L2ControlId and V4L2ControlInfo are just convenience classes to
create ControlId and ControlInfo from v4l2_query_ext_control.
Therefore, there is no need of being a class. It is used only
from V4L2Device. This removes the classes and put the equivalent
functions of creating ControlId and ControlInfo in
v4l2_device.cpp.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 07:21:02 +03:00
Hirokazu Honda
afb503fa34 libcamera: pipeline: Remove unnecessary v4l2_controls.h includes
v4l2_controls.h is included in some places in pipeline codes.
But V4l2Control classes are not used there. This removes the
redundant v4l2_controls.h includes.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 06:51:53 +03:00
Hirokazu Honda
5a9d19210f libcamera: pipeline: ipu3: Try queuing pending requests if a buffer is available
IPU3CameraData stores requests that have been failed due to a
buffer shortage. The requests should be retried once enough
buffers are available. This sets the retry function as signal to
CIO2Device and IPU3Frame, and invokes it from
CIO2Device::tryReturnBuffer() and IPU3Frame::remove().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 05:55:56 +03:00
Hirokazu Honda
89dae58449 libcamera: pipeline: ipu3: Store requests in the case a buffer shortage
PipelineHandlerIPU3 returns -ENOBUFS and -ENOMEM on queueing a
request when there are not sufficient buffers for the request.
Since the request will be successful if it is queued later when
enough buffers are available. The requests failed due to a buffer
shortage should be stored and retried later in the FIFO order.
This introduces the queue in IPU3CameraData to do that.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 05:55:42 +03:00
Laurent Pinchart
fd1cbe8447 libcamera: log: Hide value of the ASSERT() macro
ASSERT() is a function-like macro that expands to internal code. Hide
the expansion from the generated documentation, as it would only confuse
the reader.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-05-22 14:08:25 +03:00
Laurent Pinchart
cc2139ec63 libcamera: log: Document LOG() restrictions
The LOG() macro uses the global Logger and LogCategory objects
internally. This can result in crashes or other undefined behaviour when
logging from destructors of global objects, as the Logger and/or the
LogCategory instances may have been destroyed.

This isn't ideal and should eventually be fixed. For the time being,
document the restriction, and add a todo list item to fix the problem.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-22 02:56:25 +03:00
Jacopo Mondi
e56f1f4935 libcamera: ipu3: imgu: Bump script version
Update the revision of the ImgU Python configuration tool the
libcamera implementation is based on to commit 243d134
("Fix some bug for some resolutions").

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org
2021-05-20 10:58:52 +02:00
Jacopo Mondi
5b015e96cc libcamera: ipu3: imgu: Add pipe calculation debug
Add pipe calculation debug with a new associated log category.

This helps compare the pipe calculation with the one performed by the
python script.

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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-05-20 10:58:52 +02:00
Jacopo Mondi
5be6313d32 libcamera: ipu3: imgu: Fix BSD height size comparison
Fix a size comparison when iterating on the BDS sizes to accepts
values that are equal to the minimum accepted height.

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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-05-20 10:58:52 +02:00
Jacopo Mondi
8f888a8e84 libcamera: ipu3: imgu: Fix IF height selection
Apply to calculateBDSHeight() function the first hunk of commit 243d134
("Fix some bug for some resolutions") from
https://github.com/intel/intel-ipu3-pipecfg.git.

The condition for the computed IF rectangle height to be matched
against the desired alignment now makes sure that it is included
in the minimum and maximum acceptable values.

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:58:52 +02:00
Jacopo Mondi
630c83f82a libcamera: ipu3: imgu: Fix BDS height calculation
The IF rectangle height is iteratively computed by first subtracting
the scaling factor to the estimated height, then in a successive loop
by adding the same scaling factor until the maximum IF size is not
reached.

As the computed IF height is not cached in any variable, the second
loop over-writes the result of the first one, even if the BDS alignment
condition is not satisfied.

Fix this by caching the result of the two iterations, and use the one
that produced any result, with a preference for the one produced by the
second loop, as implemented in the reference python script.

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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-05-20 10:58:52 +02:00
Jacopo Mondi
c1b0e931a6 libcamera: ipu3: imgu: Filter BDS by height
Apply to calculateBDS() function the content of commit 243d134 ("Fix
some bug for some resolutions") from
https://github.com/intel/intel-ipu3-pipecfg.git.

The calculated BDS sizes are filtered by height and not only by width
anymore.

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:58:52 +02:00
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