Commit graph

3766 commits

Author SHA1 Message Date
Laurent Pinchart
2d5a78f664 Documentation: application-developer: Add camera detection check
The simple-cam application has a check to ensure that at least one
camera is present before attempting to access the first camera, to avoid
a crash. Update the application developer's guide to match this
behaviour.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-27 23:41:18 +03:00
Laurent Pinchart
348df7bc4b Documentation: application-developer: Use correct type to store size
The return type of std::vector::size() is size_t. Use the same type,
instead of unsigned int, to store its return value when retrieving the
number of allocated buffers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-27 23:41:18 +03:00
Laurent Pinchart
1ec7072827 Documentation: application-developer: Make global variable static
The global "camera" variable isn't accessed outside of its compilation
unit. Make it static.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-27 23:41:18 +03:00
Umang Jain
957c5d534b android: Fix generation of thumbnail for EXIF data
Generation of thumbnail is not occuring currently because
ANDROID_JPEG_THUMBNAIL_SIZE is not set for request metadata passed
to PostProcessorJpeg::process(). The commit 1264628d3c92("android:
jpeg: Configure thumbnailer based on request metadata") introduced
the mechanism to retrieve the thumbanil size from request metadata,
however it didn't add the counterpart i.e. inserting the size in
the request metadata in request metadata template, at the first place.

The patch fixes this issue by setting ANDROID_JPEG_THUMBNAIL_SIZE in
the request metadata template populated by
CameraCapabilities::requestTemplatePreview(). The value for
ANDROID_JPEG_THUMBNAIL_SIZE is set to be the first non-zero size
reported by static metadata ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES.

Fixes: 1264628d3c92("android: jpeg: Configure thumbnailer based on request metadata")
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-09-27 22:25:05 +05:30
Umang Jain
67adaf5ebf android: camera_capabilities: Clarify CameraMetadata allocation
CameraMetadata's constructor take in number of entries and number of
bytes to be allocated for those entries. However, CameraMetadata is
already capable of resizing its container on the fly, in case more
entries are added to it. Hence, the numbers passed in during the
construction acts as hint values for initialization.

Clarify this in CameraCapabilities::requestTemplatePreview() and
remove the \todo, as the arguments and the \todo gives the perspective
that we need to be quite accurate with the numbers of entries / bytes,
which is not the case.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-09-27 22:24:58 +05:30
Jacopo Mondi
11e9d19288 libcamera: control_serializer: Separate the handles space
Two independent instances of the ControlSerializer class are in use at
the IPC boundaries, one in the Proxy class that serializes data from the
pipeline handler to the IPA, and one in the ProxyWorker which serializes
data in the opposite direction.

Each instance operates autonomously, without any centralized point of
control, and each one assigns a numerical handle to each ControlInfoMap
it serializes. This creates a risk of potential collision on the handle
values, as both instances will use the same numerical space and
are not aware of what handles has been already used by the instance "on
the other side".

To fix that, partition the handles numerical space by initializing the
control serializer with a seed according to the role of the component
that creates the serializer and increment the handle number by 2, to
avoid any collision risk.

While this is temporary and rather hacky solution, it solves an issue
with isolated IPA modules without too much complexity added.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-09-27 14:39:15 +02:00
Jacopo Mondi
23c2b8a9ca libcamera: control_serializer: Serialize info::def()
The ControlInfo class was originally designed to only transport
the control's minimum and maximum values which represent the control's
valid limits.

Later the default value of the control has been added to the ControlInfo
class, but the control serializer implementation has not been updated
accordingly.

This causes issues in IPA modules making use of ControlInfo::def() as,
when running in isolation, they would receive 0.

Fix that by serializing and deserializing the additional ControlValue
and update the protocol description accordingly.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-09-27 14:37:45 +02:00
Jacopo Mondi
b516ffb3bd libcamera: control_serializer: Use the right idmap
When a ControlList is deserialized, the code searches for a valid
ControlInfoMap in the local cache and use its id map to initialize the
list. If no valid ControlInfoMap is found, as it's usually the case
for lists transporting libcamera controls and properties, the globally
defined controls::controls id map is used unconditionally.

This breaks the deserialization of libcamera properties, for which a
wrong idmap is used at construction time.

As the serialization header now transports an id_map_type field, store
the idmap type at serialization time, and re-use it at
deserialization time to identify the correct id map.

Also make the validation stricter by imposing to list of V4L2 controls to
have an associated ControlInfoMap available, as there is no globally
defined idmap for such controls.

To be able to retrieve the idmap associated with a ControlList, add an
accessor function to the ControlList class.

It might be worth in future using a ControlInfoMap to initialize the
deserialized ControlList to implement controls validation against their
limit. As such validation is not implemented at the moment, maintain the
current behaviour and initialize the control list with an idmap.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-09-27 14:37:39 +02:00
Jacopo Mondi
7fde7c7aeb ipa: proxy_worker: Reset ControlSerializer on worker
When running the IPA in isolated mode, each side of the IPC boundary
has an instance of the ControlSerializer class which is used to
serializer/deserialize controls before transmitting them on the wire.

The IPAProxyWorker, which creates and manages the process the IPA runs in,
does not reset its ControlSerializer upon an IPA::configure() call, while
the IPAProxy does, effectively creating a misalignment between the
two sides of the fence.

This obviously creates issues as one side of the IPC runs with a
populated and possibly stale cache of ControlInfoMap references, while the
other side gets reset every time a new configuration is applied to the
Camera.

Fix that by resetting the IPAProxyWorker ControlSerializer on an
IPA configure() call.

This change fixes an issue which is easily triggered by running two
consecutive capture sessions with the IPA running in isolated mode:
ERROR Serializer control_serializer.cpp:520 Can't deserialize ControlList: unknown ControlInfoMap

Fixes: 7832e19a59 ("utils: ipc: add templates for code generation for IPC mechanism")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-27 14:35:51 +02:00
Jacopo Mondi
4c1fc33d8a libcamera: ipu3: Drop entityControls map
The IPA::configure() function has an IPAConfigInfo parameters which
contains a map of numerical indexes to ControlInfoMap instances.

This is a leftover of the old IPA protocol, where it was not possible to
specify a rich interface as it is possible today and each entity
ControlInfoMap was indexed by a numerical id and stored in a map.

Now that the IPA interface allows to specify parameters by name, drop the
map and send the sensor's control info map only.

If we'll need more ControlInfoMap to be shared with the IPA, a new parameter
can be added to IPAConfigInfo.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-27 14:35:51 +02:00
Laurent Pinchart
72e8e03719 libcamera: camera_manager: Fix utils.h #include location
The utils.h header #include is separate from the rest of the group for
no reason. Move it to where it should be.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-09-26 15:59:09 +03:00
Laurent Pinchart
40f5fddca7 libcamera: Standardize URLs to git repositories
When the libcamera project was started, we had no public git tree hosted
on git.libcamera.org. The problem has been addressed a while ago, and
the git.linuxtv.org libcamera repository is now a mirror of the main git
tree. The mirror is useful to benefit from the linuxtv.org automated
compile tests, but it can also confuse users who don't know where the
official version is. To try and clarify this, use the git.libcamera.org
URL consistently through the project.

This doesn't void the validatity of the linuxtv.org repository which
will continue to mirror the libcamera.org repository.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-24 13:25:33 +03:00
Laurent Pinchart
9b8f4c870f android: camera_device: Return unique_ptr from createFrameBuffer
Returning a non-managed pointer can cause leaks. Use a unique_ptr<>
instead to avoid possible future issues.

The std::move() for the planes argument to the FrameBuffer constructor
is dropped as it's misleading. FrameBuffer has no constructor that takes
an rvalue reference to planes, so the vector was copied despite the
move. This only clarifies the intent, no functional change is
introduced.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-24 13:25:33 +03:00
Laurent Pinchart
d4e15331cb libcamera: v4l2_videodevice: Don't move planes to construct FrameBuffer
The FrameBuffer class has no constructor that takes an rvalue reference
to planes. The std::move() is thus misleading as a copy will still take
place. Drop it to clarify the code, no functional change is introduced.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-24 13:25:33 +03:00
Vedant Paranjape
d1713de60a test: gstreamer: Add a test for gstreamer multi stream
This patch adds a test to test if multi stream using libcamera's
gstreamer element works.

Test will run only on devices that support multistream capture, eg.,
devices that use IPU3 and raspberrypi pipeline. This was tested on
a Raspberry Pi 4B+.

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-24 18:01:15 +09:00
Paul Elder
2cc4303b17 test: v4l2_compat: Skip vimc as a test candidate
As the vimc scaler prevents us from passing v4l2-compliance, skip it
until the fix has been merged. Instead of removing it from the
supported_pipelines list, add an extra check, since we will have the
same construct later when we check for the kernel version.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-23 16:04:57 +09:00
Vedant Paranjape
c7daf645d4 test: gstreamer: Simplify elements' ownerships
In gstreamer, when elements are created, usually a floating [1]
reference is returned which simply means, there is no ownership
transfer (yet). Once can simply check for NULL and return through
an error path, without bothering to clean up. Hence, g_autoptr is
not much of help here.

If the NULL checks have been passed successfully, elements are ready
to use. However, we must claim ownership/reference it before using
them via g_object_ref_sink().

This patch build upon this principle and removes the g_autoptr
from gstreamer test base class (gstreamer_test.cpp) whereever
necessary to tide up the code.

[1] https://gstreamer.freedesktop.org/documentation/additional/design/MT-refcounting.html?gi-language=c#refcounting1

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-23 16:03:15 +09:00
Vedant Paranjape
fa9a9d7f6b test: gstreamer: Simplify single stream test using functions from GstUtils
Simplify memory handling and complexity of the test by using
gst_parse_bin_from_description_full [1].

[1]: https://gstreamer.freedesktop.org/documentation/gstreamer/gstutils.html?gi-language=c#gst_parse_bin_from_description_full

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-23 16:03:08 +09:00
Vedant Paranjape
ca9ea1f9ce test: gstreamer_single_stream_test: Fix memory leak
The test hold a valid reference to convert0_ and sink0_ but
not released. This results in a memory leak and can be checked
via valgrind. Drop the references with test cleanup() virtual
function.

Valgrind log (glib and gst suppression files were used):
==345380== LEAK SUMMARY:
==345380==    definitely lost: 1,688 bytes in 2 blocks
==345380==    indirectly lost: 7,069 bytes in 42 blocks

The patch fixes the leaks reported by valgrind above to:
==348870== LEAK SUMMARY:
==348870==    definitely lost: 0 bytes in 0 blocks
==348870==    indirectly lost: 0 bytes in 0 blocks

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-23 16:03:01 +09:00
Vedant Paranjape
8d3d92ea81 gstreamer: Convert cm_singleton_ptr to static variable
The global pointer pointing to libcamera's CameraManager isn't used
outside of the gstlibcamera-utils.cpp compilation unit. Make it static.

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-22 21:33:10 +01:00
Kieran Bingham
f9ca897c7f gstreamer: Support planar formats
Existing pipeline handlers already support planar YUV formats.
Extend the gstreamer format map to incorporate them.

While here, split the formats into distinct groups.

Signed-off-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>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
2021-09-22 16:41:04 +01:00
Laurent Pinchart
a3b1539869 qcam: viewfinder_gl: Support configurable stride in shaders
The RGB and YUV conversion doesn't take the stride into account, neither
when creating the textures, nor when sampling them. Fix it by using the
stride as the texture width, and multiplying the x coordinate in the
vertex shaders by a factor to only sample the active portion of the
image.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-22 11:21:49 +03:00
Laurent Pinchart
5e1b7a0f68 qcam: format_converter: Add fully-planar YUV formats support
Add support for the YUV420, YVU420 and YUV422 formats supported by
libcamera. YUV420 can be produced by the Raspberry Pi pipeline handler,
being able to display it is useful for testing.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-22 10:58:38 +03:00
Laurent Pinchart
3a4e251122 qcam: format_converter: Rename YUV and NV to YUVPacked and YUVSemiPlanar
To prepare for fully-planar YUV support, rename the existing format
families YUV and NV to YUVPacked and YUVSemiPlanar respectively.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-22 10:58:38 +03:00
Laurent Pinchart
4abbd832fe qcam: format_converter: Add configurable stride support
Make the stride configurable to support conversion of images with
padding at the end of lines.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-22 10:58:38 +03:00
Laurent Pinchart
f3671b33d9 qcam: viewfinder: Pass stride value to viewfinder
qcam currently assumes that no padding is used at end of lines, and uses
the image width as the stride. This leads to rendering failures with
some formats on some platforms. To prepare for stride support, add a
stride parameter to the ViewFinder::setFormat() function to pass the
stride from the stream configuration to the viewfinder.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-22 10:58:37 +03:00
Hirokazu Honda
d165f7da34 android: camera_device: Configure one stream for identical stream requests
An Android HAL client may request multiple identical streams. It is
redundant that a native camera device produces a separate stream for
each of the identical requests. Configure the camera with a single
stream in that case. The other identical HAL streams will be produced by
the YUV post-processor.

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-09-22 10:58:37 +03:00
Hirokazu Honda
13b76d6209 android: camera_stream: Support PostProcessorYuv in CameraStream
CameraStream creates PostProcessorYuv if the destination format
is NV12.

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-09-22 10:58:37 +03:00
Hirokazu Honda
76819971b9 android: camera_stream: Create post processor in configure()
CameraStream creates PostProcessor and FrameBufferAllocator in
the constructor. CameraStream assumes that a used post processor
is JPEG post processor. Since we need to support various post
processors, we would rather move the creation to configure() so
as to return an error code if no proper post processor is found.
This also moves FrameBufferAllocator and Mutex creation for
consistency.

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-09-22 10:58:37 +03:00
Umang Jain
3e335b69b6 android: jpeg: Rectify variable naming style.
Rectify variable renaming style for YPlaneSize, UVPlaneSize.
libcamera uses camelCase where first letter should be in lower case.

Fixes: e355ca0087cd9("android: jpeg: Split and pass the thumbnail planes to encoder")
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-09-21 11:51:56 +05:30
Umang Jain
e7c52de5e5 android: yuv: Remove CameraDevice forward-declare
YUV post-processor doesn't need any instance reference from CameraDevice
class. Remove it.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-09-21 11:51:24 +05:30
Fabrice Fontaine
c52e8429cc libcamera: base: Add libatomic dependency
Add libatomic dependency which is needed since the addition of the base
support library in commit 27aff949fb ("libcamera/base: Move extended
base functionality") to avoid the following build failure:

/tmp/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: src/libcamera/base/libcamera-base.so.p/message.cpp.o: in function `libcamera::Message::registerMessageType()':
message.cpp:(.text+0x290): undefined reference to `__atomic_fetch_add_4'

Fixes: 27aff949fb ("libcamera/base: Move extended base functionality")
Fixes: http://autobuild.buildroot.org/results/6e3471df8e9312a1789ca05ae70cc2283bfeec23
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-09-19 20:48:57 +03:00
Laurent Pinchart
556e2de509 test: v4l2_compat: Report test as skipped if no compatible driver found
The V4L2 compatibility layer test includes a list of supported devices,
as V4L2 compatibility isn't officially supported with all devices yet.
If no supported device is present, the test reports success, while it
actually hasn't run. Report it being skipped in that case.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-19 20:45:36 +03:00
Kieran Bingham
a881b90b5d test: serialization: Prevent parallelisation
The ipa_data_serializer_test is configured to be able to run in parallel
with other tests.

If the test tries to acquire the VIMC sensor B while it is in use, it
would skip require skipping the test.

Instead, inform meson that it can not be run in parallel to ensure that
the test is able to obtain the resources it requires for execution.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-15 16:35:25 +01:00
Kieran Bingham
4cf7a8fc0b libcamera: v4l2_videodevice: Handle unexpected buffers
A kernel bug can lead to unexpected buffers being dequeued where we
haven't entered the buffer in our queuedBuffers_ list.

This causes invalid accesses if not handled correctly within libcamera,
and while it is a kernel issue, we can protect against unpatched
kernels to provide a more suitable error message.

This is fixed in the kernel by commit c592b46907ad ("media:
videobuf2-core: dequeue if start_streaming fails") [0]

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c592b46907ad

Handle unexpected buffers by returning a nullptr, and move cache
management after the validation of the buffer.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-14 12:54:45 +01:00
Kieran Bingham
3bcb7a90c1 ipa: ipu3: Clear incoming parameter use flags
The incoming params buffer may contain uninitialised data, or the
parameters of previously queued frames. Clearing the entire buffer
may be an expensive operation, and the kernel will only read from
structures which have their associated use-flag set.

It is the responsibility of the algorithms to set the use flags
accordingly for any data structure they update during prepare().

Clear the use flags of the parameter buffer before passing the buffer
to the algorithms during their prepare() operations.

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-14 12:47:53 +01:00
Kieran Bingham
84acaac8b7 README: Fix android dependencies
While the distribution is unspecified, The README.rst gives
debian/ubuntu named dependencies for all except the android
requirements.

Update the android dependencies to match the others, by showing that the
-dev package is required.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-14 12:46:32 +01:00
Paul Elder
b0175735aa utils: ipc: proxy worker: Fix indentation in call deserialization
The indentation of the deserialization call on the proxy worker side
inside the case statement was one level too shallow. Fix it.

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>
2021-09-10 15:06:47 +09:00
Paul Elder
df58fc1f4b test: v4l2_compat_test: Fix v4l2-compliance version parsing
v4l2-compliance changed their version string:

v4l2-compliance 1.21.0-4618
v4l2-compliance SHA: cc211b76476aca2c072ffa83a9b003957d5f3909, 64 bits, 64-bit time_t

v4l2-compliance 1.21.0-4838, 64 bits, 64-bit time_t

The current parsing takes the last result of split, which works for the
former, but not the latter. Take the second result of split instead, and
strip away any commas.

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>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-09-10 10:32:57 +09:00
Paul Elder
4e3d152d1e v4l2: v4l2_camera_proxy: Set the compressed flag in enum_fmt
Set the compressed flag in ENUM_FMT if the format is MJPEG. As the only
compressed format that libcamera currently supports is MJPEG, this
should be sufficient.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-09-10 10:32:57 +09:00
Paul Elder
69cffe7012 v4l2: v4l2_camera_proxy: Report the proper format name in enum_fmt
Now that libcamera has the V4L2 format names, retrieve and report those
names in ENUM_FMT. While at it, refactor the code slightly with
PixelFormatInfo.

This fixes the test failures on v4l2-compliance with the v4l2
compatilibity layer that were observed in version v4l2-compliance
version 1.21.0-4838.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-09-10 10:32:57 +09:00
Paul Elder
9f9c224c7b libcamera: v4l2_pixelformat: Add helper function to get the description
Add a helper function to V4L2PixelFormat for retrieving the V4L2
description string.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-09-10 10:32:57 +09:00
Paul Elder
ba155eadb9 libcamera: v4l2_pixelformat: Add entries for NV24 and NV42
The entries for NV24 and NV42 were missing from the V4L2PixelFormat map.
Add them.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-09-10 10:26:55 +09:00
Paul Elder
67f0def9ba libcamera: v4l2_pixelformat: Add V4L2 description strings
Add V4L2 description strings to the map of V4L2 formats. To achieve
this, create an Info struct to wrap them. Update the one current user of
the old map.

This will be used later in the V4L2 compatibility layer to report the
V4L2 format description.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-09-10 10:26:39 +09:00
Paul Elder
a20d52a35b v4l2: v4l2_compat_manager: Don't print "camera not found" on openat()
Some applications (like Firefox) run open() many times on video device
nodes. This may lead to user confusion when they see "INFO V4L2Compat
v4l2_compat_manager.cpp:146 No camera found for /dev/videoX" over and
over again.

Lower the log level to debug so that we can still get this information
on debug, and so users won't see it all the time.

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>
2021-09-10 10:26:31 +09:00
Umang Jain
e355ca0087 android: jpeg: Split and pass the thumbnail planes to encoder
After multi-planar support was introduced for jpeg encoding as well,
EncoderLibJpeg::encode() expects a vector of planes as the source of
framebuffer to be encoded. Currently, we are passing a contiguous buffer
which is treated as only one plane (instead of two, as thumbnail is NV12).

Hence, split the thumbnail data into respective planes according to NV12.
This fixes a crash in encoding of thumbnails.

Fixes: 894ca69f6043("android: jpeg: Support multi-planar buffers")
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-09-09 22:31:53 +05:30
Kieran Bingham
3d297f7ac8 libcamera: controls: Use a const ControlValidator
The ControlValidator passed to a ControlList constructor
is used, but not modified.

Make it const.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-09 15:58:23 +01:00
Vedant Paranjape
0eea207b04 test: gstreamer: Fix the destructor of GstreamerTest base class
The destructor tried to check if pipeline_ is a parent of libcameraSrc_.
This was needed to be checked as if it is, cleanup of libcameraSrc_
would be handled by pipeline itself.

Since, the destructor can be called anytime, even when pipeline_ hasn't
been created, the use of pipeline_ to check if libcameraSrc_ has an
ancestor as pipeline_ caused a segmentation fault.

Fixes: f58768092277 ("test: gstreamer: Fix the destructor of GstreamerTest base class")
Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-09 15:47:38 +01:00
Umang Jain
68fe3b058a android: mm: cros_camera_buffer: Log failure error on cleanup
Failure can still happen by CameraBufferManager during Unlock() and/or
Deregister() of camera3Buffer handles. We should be logging those
errors as well.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-09 11:44:30 +05:30
Vedant Paranjape
39c2d5dc95 test: gstreamer: Factor out code into a base class
A lot of code used in the single stream test is boiler plate and common
across every gstreamer test. Factor out this code into a base class
called GstreamerTest.

Also update the gstreamer_single_stream_test to use the GstreamerTest
base class.

Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-08 17:40:53 +09:00