Commit graph

2025 commits

Author SHA1 Message Date
Niklas Söderlund
f65e6b124b libcamera: pipeline: rkisp1: Prepare buffer ready handlers for multiple streams
The buffer ready handlers are designed for a single application facing
stream from the main path. To prepare for multiple application facing
streams from main and/or self path the handlers need to be prepared.

The data keeping track of the frame number and advancing the timeline
can be moved from the application facing buffer ready handler to the
statistics handler. For each request processed there will always be a
statistic buffer and as the ISP is inline and is the source of both
main, self and statistic paths there is no change in behavior.

The application facing handler no longer needs a special case for
cancelled frames and can be made simpler. With this change the handlers
are ready to deal with any combinations of application facing streams.

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>
2020-09-28 23:53:45 +02:00
Niklas Söderlund
fedc77842e libcamera: pipeline: rkisp1: Setup links as part of configuration
In preparation of supporting both the main and self path configure all
the media graph links as a part of the configuration step. Before this
change the link between ISP and DMA engine was setup at match time as
the only supported path was the main path and only the link between
sensor and ISP was updated at part of the configuration step.

The main path is still the only path between ISP and DMA engine that is
possible to enable.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-28 23:53:45 +02:00
Niklas Söderlund
e260513f52 libcamera: pipeline: rkisp1: Breakout mainpath size and format constraints
Breakout the mainpath size and format constrains as it will be used in
more places then just validate(). While at it use the new helpers to
validate Size.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-28 23:53:45 +02:00
Niklas Söderlund
0862959184 libcamera: pipeline: rkisp1: Remove redundant check of buffer in Request
There is no need to check if Request contains a buffer belonging the
RkISP1 Camera as this is already done in Camera::queueRequest(), remove
the redundant check.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-28 23:53:45 +02:00
Niklas Söderlund
afe0ad41db libcamera: pipeline: rkisp1: Set number of planes based on format
The RkISP1 pipeline originally only supported NV formats which have 2
planes. When support for YUV formats was added the plane count on the
output format was not made to reflect this. Instead of hard coding the
plane count to 2 fetch the number of planes from the format information.

Reported-by: Jacopo Mondi <jacopo@jmondi.org>
Fixes: 2b1a908b52 ("libcamera: camera: Add a validation API to the CameraConfiguration class")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-28 23:53:45 +02:00
Ezequiel Garcia
aac96e34ba meson: Define python3 and python3-yaml required dependencies
With this change, meson will complain specifically about missing
python3 and missing python3-yaml. As specified by meson
documentation: https://mesonbuild.com/Python-module.html,
this change requires meson v0.51.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:40 +03:00
Ricardo Ribalda
da81e368e7 meson: Bump meson version to 0.51
Version 0.51 allows, among others, checking for python modules, which is
a required feature.

It is also now easily accessible: it is in stable distros such as Debian
testing, or in pip:

https://tracker.debian.org/pkg/meson
https://pypi.org/project/meson/

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:34 +03:00
Ricardo Ribalda
aba567338b Documentation: Move all dependencies into features
This way if the user enables the documentation and the dependencies are
missing the configure fails.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:30 +03:00
Ricardo Ribalda
4e998cea15 Documentation: Search for dot binary
Doxygen depends on dot to generate the documentation. Make this
dependency explicit on the meson file.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:27 +03:00
Ricardo Ribalda
f08b720acc README: Add missing dependency for documentation
Doxygen fails to create the documentation with this message:

[145/276] Generating doxygen with a custom command
sh: 1: dot: not found
error: Problems running dot: exit code=127, command='dot', arguments='"/home/user/libcamera/build/Documentation/api-html/inline_dotgraph_1.dot" -Tpng -o "/home/user/libcamera/build/Documentation/api-html/dot_inline_dotgraph_1.png"'
sh: 1: dot: not found
error: Problems running dot: exit code=127, command='dot', arguments='"/home/user/libcamera/build/Documentation/api-html/inline_dotgraph_1.dot" -Tcmapx -o "/home/user/libcamera/build/Documentation/api-html/dot_inline_dotgraph_1.map"'
[276/276] Linking target test/utils

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:25 +03:00
Ricardo Ribalda
507a94d904 README: Add missing libtiff-dev package for qcam
Without it:

Run-time dependency libtiff-4 found: NO (tried pkgconfig and cmake)

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:23 +03:00
Ricardo Ribalda
dff416a84b README: Add missing package for Qt5 tools
Without it:

Program /usr/lib/x86_64-linux-gnu/qt5/bin/lrelease found: NO
Program lrelease-qt5 found: NO
Program lrelease found: NO found  but need: '== 5.14.2'

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:11 +03:00
Ricardo Ribalda
20177249c0 README: Move pkg-config to Meson section
pkg-config it is not only used to detect libudev-dev, it is used for
detecting gstreamer and others. So it is more correct to place it on the
Meson Build system section.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:06 +03:00
Ricardo Ribalda
ad55da5713 README: Add libboost to list of dependencies
Raspberry Pi IPA, which is enabled by default, requires libboost to
compile.
Specify in the documentation its dependencies and how to disable the
IPA.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:03 +03:00
Ricardo Ribalda
c84d64e305 README: Move the required dependencies to the top
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:07:59 +03:00
Ricardo Ribalda
b30c8b5848 README: Unify dependency names
All the dependencies are for libcamera, so we should move all the
packages under this paragraph, or make a paragraph for Meson, and a
second one for python3-yaml. I think the later is more clear.

Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:07:53 +03:00
Kieran Bingham
4af45819d0 libcamera: ipa: Move key generation to utils
Move the GPLv2 utilities used for generating public and private keys to
the utilities subtree.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2020-09-24 10:56:22 +01:00
Kieran Bingham
131629d3a2 src: meson: Rename ipa_gen_priv_key to gen_ipa_priv_key
Refactor the naming of the custom command variable to match the style
used in the other custom target generators, and the name of the script.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2020-09-24 10:55:54 +01:00
Kieran Bingham
c09626cd63 libcamera: Move Header generation utilities to utils
Move the GPL2 utilities which handle generation of controls, formats and
the top level libcamera header to the utils subtree.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2020-09-24 10:55:49 +01:00
Kieran Bingham
d6b6ad950d meson: Process utils first
The utils directory can contain helpers and support tools which are used
throughout other components of the build.

Ensure that the utils subdir is parsed first allowing helpers to be
defined there.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2020-09-24 10:55:39 +01:00
Niklas Söderlund
f999ee85fa libcamera: buffer: Remove copyFrom()
There are no user left of the copyFrom() operation, remove it.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-09-22 12:06:09 +02:00
Naushir Patuck
39798e8777 pipeline: ipa: raspberrypi: Handle any externally allocated FrameBuffer
Handle the case where a FrameBuffer that has been externally allocated
(i.e. not through the v4l2 video device) is passed into a Request.

We must store the buffer pointer in the stream internal buffer list to
identify when used.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:49 +02:00
Naushir Patuck
dd0df6d739 pipeline: raspberrypi: Use an unordered_set to store IPA buffer ids
By using a set container, we can easily insert/remove buffer ids that have
been mmaped by the IPA. This will be required to track buffers allocated
externally and passed to the pipeline handler through a Request.

Move the IPA buffer mapping code into a function to remove duplicated
code.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
e1784ca883 pipeline: raspberrypi: Use an unordered_map for the stream buffer list
By using a map container, we can easily insert/remove buffers from the
buffer list. This will be required to track buffers allocated externally
and passed to the pipeline handler through a Request.

Replace the buffer index tracking with an id generated internally by the
stream object.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
f22ffc0ebe libcamera: pipeline: ipa: raspberrypi: Remove use of FrameBuffer cookie
The FrameBuffer cookie may be set by the application, so this cannot
be set by the pipeline handler as well. Revert to using a simple index
into the buffer list to identify buffers passing to and from the IPA.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
b752c57c33 libcamera: pipeline: raspberrypi: Add more robust stream buffer logic
Add further queueing into the RPiStream object to ensure that we always
follow the buffer ordering (be it internal or external) given by
incoming Requests.

This is essential, otherwise we risk dropping frames that are meant to
be part of a Request, and can cause the pipeline to stall indefinitely.
This also prevents any possibility of mismatched frame buffers going
through the pipeline and out to the application.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
45430e12ee libcamera: pipeline: raspberrypi: Fix bug in passing configuration to IPA
The counter was not incremented, so multiple streams would only pass the
last stream config to the IPA.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
2df7bf1681 libcamera: pipeline: raspberrypi: Rework stream buffer logic for zero-copy
Stop using v4l2_videodevice::allocateBuffer() for internal buffers and
instead export/import all buffers. This allows the pipeline to return
any stream buffer requested by the application as zero-copy.

Advertise the Unicam Image stream as the RAW capture stream now.

The RPiStream object now maintains a new list of buffers that are
available to queue into a device. This is needed to distinguish between
FrameBuffers allocated for internal use vs externally provided buffers.
When a Request comes in, if a buffer is not provided for an exported
stream, we re-use a buffer from this list.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
3e7ee080d6 libcamera: pipeline: raspberrypi: Remove const qualifier from RPiStream
For the zero-copy RAW capture feature, the RPiStream will have to be
modified. Remove the const qualifier in anticipation of the future
commits for this feature.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
addd343b96 libcamera: pipeline: raspberrypi: Increase the number of RAW buffers
Increase the number of expected RAW buffers in the stream configuration
to 2. This will avoid dropping Unicam frames when exporting RAW streams.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
dd0a9cf2b1 libcamera: pipeline: raspberrypi: Add some debug logging
No functional changes, only added some more trace points.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
8404d02d75 libcamera: pipeline: ipa: raspberrypi: Rework drop frame signalling
The IPA now signals up front how many frames it wants the pipeline
handler to drop. This makes it easier to handle up-coming changes to the
buffer handling for import/export buffers.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Naushir Patuck
6bca768a0b libcamera: pipeline: raspberrypi: Move RPiStream into a separate file
Put RPiStream into the RPi namespace and add a new log category (RPISTREAM).
Reorder methods into logical groups for readability.

There are no functional changes in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:10:48 +02:00
Laurent Pinchart
e390f9f618 Documentation: Adjust guidelines regarding math.h header
While libcamera prefers usage of the C standard library headers (xxx.h)
over the C++ version (cxxx), we make an exception for cmath as the
overloaded versions of the math functions are convenient. Document this,
and adjust checkstyle.py accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:55:02 +03:00
Laurent Pinchart
beed258a5a test: Include specific headers instead of libcamera.h
Let's only pull required headers, to avoid slowing compilation down.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-21 13:50:42 +03:00
Laurent Pinchart
2fa4ba01ff libcamera: Don't unnecessarily include event_notifier.h
The ipc_unixsocket.h and process.h internal headers don't need to
include event_notifier.h, the former because a forward declaration
suffices, and the latter because it doesn't use event notifiers. Remove
the unnecessary include, and include signal.h instead which is required
and was included indirectly through event_notifier.h.

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>
2020-09-21 13:50:30 +03:00
Laurent Pinchart
54557e25f2 libcamera: camera: Optimize camera deletion
In most cases the last reference to a Camera instance will be the one
held by the CameraManager. That reference gets released when the
CameraManager thread cleans up, just before it stops. There's no need to
delete the camera with deleteLater() in that case.

To optimize this case, use deleteLater() only when the camera gets
deleted from a different thread, and delete is synchronously otherwise.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
2020-09-20 15:09:53 +03:00
Laurent Pinchart
7720c4aefa android: jpeg: exif: Use reentrant localtime_r()
The std::localtime() function isn't thread-safe, and we have no
guarantee whether other threads in the camera service may or may not
call it. Replace it with localtime_r(). This requires switching from
ctime to time.h, as there is no std::localtime_r() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-20 15:02:35 +03:00
Jacopo Mondi
7208e70211 libcamera: ipu3: Always use sensor full frame size
When calculating the pipeline configuration for the IPU3 platform,
libcamera tries to be smart and select the smallest sensor frame
resolution large enough to accommodate the stream sizes
requested by the application.

While this makes a lot of sense, in practice optimizing the
selected sensor resolution makes the pipeline configuration calculation
process fail in multiple occasions, or results in stalls during capture.

As a trivial example, capturing with cam with the following command
line results in a stall:
$ cam -swidth=1280,height=720 -swidth=640,height=480 -c1 -C

Likewise, the Android HAL supported format enumeration fails in
reporting smaller resolutions as supported when used with the OV5670
sensor.

320x240:
DEBUG IPU3 ipu3.cpp:192 CIO2 configuration: 648x486-SGRBG10_IPU3
ERROR IPU3 imgu.cpp:408 Failed to calculate pipe configuration
ERROR IPU3 ipu3.cpp:299 Failed to calculate pipe configuration: unsupported resolutions.

640x480:
DEBUG IPU3 ipu3.cpp:192 CIO2 configuration: 320x240-SGRBG10_IPU3
ERROR IPU3 imgu.cpp:408 Failed to calculate pipe configuration
ERROR IPU3 ipu3.cpp:299 Failed to calculate pipe configuration: unsupported resolutions.

Furthermore the reference xml files used for the IPU3 camera
configuration on the ChromeOS platform restricts the number of sensor
resolution to be used for the OV5670 sensor to 2 from the 6 supported by
the driver [1].

The selection criteria of the correct CIO2 mode are not specified, and
for the time being, as a workaround, always use the sensor maximum
resolution at the expense of frame rate and bus bandwidth to allow the
pipeline to successfully support smaller modes for the OV5670 sensor and
solve pipeline stalls when capturing with both sensors.

[1] See the <sensor_modes> enumeration in:
https://chromium.googlesource.com/chromiumos/overlays/board-overlays/+/master/baseboard-poppy/media-libs/cros-camera-hal-configs-poppy/files/gcss/graph_settings_ov5670.xml

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
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>
2020-09-18 14:59:58 +02:00
Jacopo Mondi
45fe8e99c8 android: camera_device: Make CameraStream a class
Complete the transformation of CameraStream into a class and provide
a read-only interface that allows to access its parameters but not
modify them at run-time.

No functional changes intended but this change aims to make the code
more robust by enforcing a stricter interface in the CameraStream class.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
facadb188e android: camera_device: Set Encoder at construction
Make the CameraStream encoder a private unique pointer and require its
initialization at construction time. This ties the encoder lifetime to
the CameraStream it has been created with, allowing to remove the
CameraStream destructor.

This change dis-allow creating a CameraStream and set the Encoder later,
which shall not happen now that we create CameraStream once we have all
the required information in place.

No functional changes intended but this change aims to make the code
more robust enforcing a stricter CameraStream interface.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
c82f944399 android: camera_device: Rework CameraStream handling
The CameraDevice::streams_ vector of CameraStream instances is
currently mostly accessed by index. The current implementation
creates all the CameraStream during the first loop that inspects the
camera3_stream instances and then update the index of the
StreamConfiguration associated with the CameraStream during a second
loop that inspects MJPEG streams. A third loop creates the JPEG encoder
associated with camera streams that produce MJPEG format.

As the index-based association is hard to follow and rather fragile,
rework the creation and handling of CameraStream:

1) Make the StreamConfiguration index a constructor parameter and a
   private struct member. This disallows the creation of CameraStream
   without a StreamConfiguration index assigned.

2) Create CameraStream only after the associated StreamConfiguration
   has been identified. The first loop creates CameraStream for non-JPEG
   streams, the second for the JPEG ones after having identified the
   associated StreamConfiguration. Since we have just created the
   CameraStream, create the JPEG encoder at the same time instead of
   deferring it.

This change removes all accesses by index to the CameraDevice::streams_
vector.

No functional changes intended, but this change aims to make the code
easier to follow and more robust.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
f868f08c21 android: camera_device: Use Android format
When iterating the camera3_stream_t received from the Android camera
framework to identify the MJPEG streams, the format check was performed
on the CameraStream created when iterating the non-MJPEG streams and not
on the format actually requested by Android. As the next patches will
remove the creation of CameraStream instances for MJPEG streams, use the
camera3_stream format to prepare for that.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
5b64f64745 android: camera_device: Get rid of stream counter
Use the size() method of the CameraConfiguration class to retrieve the
index of the StreamConfiguration associated with a CameraStream and get
rid of the custom counter.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
4961033ac9 android: camera_device: Generate RAW resolutions
The resolutions supported for the RAW formats cannot be tested from
a list of known sizes like the processed ones. This is mainly due to the
fact RAW streams are produced by capturing frames at the CSI-2 receiver
output and their size corresponds to the sensor's native sizes.

In order to obtain the RAW frame size generate a temporary
CameraConfiguration for the Role::StillCaptureRAW role and inspect the
map of StreamFormats returned by the pipeline handler.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
bfee6316fc android: camera_device: Break out size calculation
As the RAW stream sizes needs to be calculated differently from the
processed one, break out the procedure to calculate the processed
(RGB/YUV) resolutions from initializeStreamConfigurations() in order to
prepare for RAW sizes calculation.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
af264ec750 android: camera_device: Add debug to stream initialization
Add debug printouts to the CameraDevice::initializeStreamConfigurations()
function that help to follow the process of building the stream
configurations map.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
843565c6ec android: camera_device: Generate JPEG sizes
When producing the list of image resolutions to claim as supported by the
camera HAL, the JPEG stream was assumed to be 'always valid' as, at the
time, there was no JPEG support in place at all.

With the introduction of support for JPEG compression, reporting
non-valid sizes as supported obviously causes troubles.

In order to avoid reporting non-supported resolutions as supported,
produce the list of available JPEG sizes by using the ones supported
by the YCbCr_420_888 format, from which the JPEG stream is encoded.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
3533fd4271 android: camera_device: Refuse unsupported formats
The current implementation of CameraDevice::initializeStreamConfigurations()
fails if an image format marked as mandatory is not supported by the
libcamera::Camera device, but erroneously accepts non-mandatory
non-supported formats in the list of accepted ones.

Fix this by ignoring non supported image formats which are not marked as
mandatory.

Reviewed-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: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Laurent Pinchart
d5ce2679c6 libcamera: Turn the android option into a feature
Allow disabling compilation of the Android HAL adaptation layer
automatically when a dependency is missing by turning the android option
into a feature. The default value is set to 'disabled' to match the
current behaviour.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-16 18:15:28 +03:00