Age | Commit message (Collapse) | Author |
|
Add an entry for MJPEG in V4L2CameraProxy's PixelFormatInfo list to
allow proper calculation of sizeimage for MJPEG, such that the
parameters to mmap can align properly instead of failing. This allows
MJPEG to be used in the V4L2 compatibility layer.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The V4L2 compatibility layer uses devnum to match video device nodes to
libcamera Cameras. Some pipeline handlers don't report a devnum for
their camera, which prevents the V4L2 compatibility layer from matching
video device nodes to these cameras. To fix this, we first allow the
camera manager to map multiple devnums to a camera. Next, we walk the
media device and entity list and tell the camera manager to map every
one of these devnums that is a video capture node to the camera.
Since we decided that all video capture nodes that belong to a camera
can be opened via the V4L2 compatibility layer to map to that camera, it
would cause confusion for users if some pipeline handlers decided that
only specific device nodes would map to the camera. To prevent this
confusion, remove the ability for pipeline handlers to declare their own
devnum-to-camera mapping. The only pipeline handler that declares the
devnum mapping is the UVC pipeline handler, so remove the devnum there.
We considered walking the media entity list and taking the devnum from
just the one with the default flag set, but we found that some drivers
(eg. vimc) don't set this flag for any entity. Instead, we take all the
video capture nodes (entities with the sink pad flag set).
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Translate the Android format code to the libcamera format code
at stream configuration time, using the translation map built at
camera device initialization time.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Replace the hardcoded stream configuration map with the information
collected at CameraDevice initialization time.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
As we move to have more and more dynamically generated static metadata
entries, the size of the metadata buffer has to be calculated
dynamically inspecting the information collected from the camera.
Provide a method to perform metadata buffers size calculation and
use it when generating camera static metadata.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Initialize the stream configuration map by applying the Android Camera3
requested resolutions and formats to the libcamera Camera device.
For each required format test a list of required and optional
resolutions, construct a map to translate from Android format to the
libcamera formats and store the available stream configuration to
be provided to the Android framework through static metadata.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The NV24 pixelFormatInfo table entry defines an incorrect horizontal
sub-sampling.
Update to the correct value.
Fixes: 29c5508075c1 ("v4l2: camera_proxy: Create format info array")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The hex stream output helper was introduced in f391048a7b98 ("libcamera: utils:
Add hex stream output helper"). It simplifies writing hexadecimal values to an
ostream which can be used in this test too. As the helper doesn't modify the
stream configuration (refer to utils::hex() documentation), this eliminates the
need of restoring the stream's format state as pointed out by the coverity scan.
Reported-by: Coverity CID=279058
Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The V4L2 compatibility layer keeps track of the index of the next buffer
to be dequeued, to handle VIDIOC_DQBUF. This index is set to 0 on
startup and incremented (modulo #frames), and is otherwise never reset.
This means that if the last handled frame index is not #frames-1, and
the stream is restarted without restarting libcamera and the V4L2
compatilibity layer, the buffer index number won't match with the
libcamera buffer index number, causing a segfault. Fix this by resetting
the current buffer index to zero on VIDIOC_STREAMON.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
To support polling, we need to be able to signal when data is
available to be read (POLLIN), as well as events (POLLPRI). Add the
necessary calls to eventfd to allow signaling POLLIN. We signal POLLIN
by writing writing to the eventfd, and clear it by reading from the
eventfd, upon VIDIOC_DQBUF.
Note that eventfd does not support signaling POLLPRI, so we don't yet
support V4L2 events.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
If VIDIOC_REQBUFS returns -EINVAL, it signals to the application that
the requested buffer or memory type is not supported. If we return
-EINVAL due to a zero sizeimage, then the application will think that we
don't support a memory type that we actually do. We cannot error on a
zero sizeimage, because reqbufs could be called merely to probe what IO
methods we support; qv4l2, for example, called reqbufs once with userptr
and once more with mmap, both times with count=1.
On the other hand, sizeimage will be zero for formats whose size we
don't know how to calculate, such as MJPEG. If we try to stream such
formats anyway, we will get a floating point exception and crash. Issue
a warning for now, and don't return -EINVAL, so that we can continue
operation.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
We use a semaphore to atomically keep track of how many buffers are
available for dequeueing. The check for how to acquire the semaphore was
incorrect, leading to a double acquire upon a successful nonblocking
acquire. Fix this.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
VIDIOC_ENUM_FMT is meant to return -EINVAL if the requested index is out
of bounds. This bounds is obtained from the libcamera Camera's list of
formats. The bounds check for this list was incorrect; fix it.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
As the only usage of IPAManager::instance() is by the pipeline handlers
to call IPAManager::createIPA(), remove the former and make the latter
static. Update the pipeline handlers and tests accordingly.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
If any ipa_context instances are destroyed after the IPAManager is
destroyed, then a segfault will occur, since the modules have been
unloaded by the IPAManager and the context function pointers have been
freed.
Fix this by making the lifetime of the IPAManager explicit, and make the
CameraManager construct and deconstruct (automatically, via a unique
pointer) the IPAManager.
Also update the IPA interface test to do the construction and
deconstruction of the IPAManager, as it does not use the CameraManager.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Given how the elfSection() function uses the sub-expression
(idx * eHdr->e_shentsize)
it has effectively two (16 bits, unsigned) operands.
The sub-expression is promoted to type int (32 bits, signed) for
multiplication and then added to eHdr->e_shoff, which is uint32_t on
32-bit platforms and uint64_t on 64-bit platforms. Since eHdr->e_shoff
is unsigned, the integer conversion rules dictate that the other signed
operand (i.e. the result of aforementioned sub-expression) will be
converted to unsigned type too. This causes sign-extension for both of
the above operands to match eHdr->e_shoff's type and should be avoided.
The solution is to explicitly cast one of the operands of the
sub-expression with unsigned int type. Hence, the other operand will be
integer promoted and the resultant will also be of unsigned int type,
not requiring to bother about a sign-extension.
Reported-by: Coverity CID=280008
Reported-by: Coverity CID=280009
Reported-by: Coverity CID=280010
Signed-off-by: Umang Jain <email@uajain.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>
|
|
Refactor the code to find section into a common helper function.
This commit introduces no functional changes.
Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The PixelFormat class is a lightweight wrapper around a 32-bit FourCC
and a 64-bit modifier. Make is usable as a constexpr.
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>
|
|
With the internal headers now in include/libcamera/internal/, we may
have identically named headers in include/libcamera/. Their header
guards would clash. Rename the header guards of internal headers to
prevent any issue.
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>
|
|
The control_ids.h.in and property_ids.h.in headers use C++-style
comments, when the coding style mandates C-style comments. Fix them.
While at it, adjust three minor typos in comments.
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>
|
|
The libcamera source files are named after class names, using
snake_case. pixelformats.h and pixelformats.cpp don't comply with that
rule. Fix them.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The preprocessor directive '#pragma once' is non-standard, replace it
with the include guard used elsewhere in libcamera.
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>
|
|
Virtual functions overriden in derived classes should be marked with the
override keyword. Do so for the logPrefix() implementations inheriting
from the Loggable class.
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>
|
|
Fix a typo in a comment in ipa_context_wrapper.cpp.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
LD_PRELOAD is an environment variable, use code markup to reflect that
semantic
Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The DRM(BGRA8888)/V4L2(ARGB8888) format is not supportable by the current
configurations of VIMC.
Remove it from the list of supported configurations.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Older kernels do not support all 'reported' formats. Skip them on those
kernels.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Fail and return the Camera::configure() operation if any
of the stream turns out to be a nullptr even after the
PipelineHandler handler seems to have configured the config
successfully. This prevents a null-dereference below in the
loop.
Reported-by: Coverity CID=279069
Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Reported-by: Coverity CID=279091
Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Reported-by: Coverity CID=279097
Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The reset function in staggered write was using the wrong index when
looking for the last updated camera parameters. This would cause
possibly stale exposure values to be written to the camera on a
mode switch for captures.
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Pick the correct media bus format based on the video pixel format on the
capture node.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
We don't use full stops at the end of \return directives in Doxygen
documentation. Drop it.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The CameraHalManager::getCameraInfo() method hardcodes the camera facing
side and orientation (which corresponds, confusingly, to libcamera's
location and rotation properties).
Instead of hard-coding the values based on the camera id, inspect the
libcamera properties that report the camera location and rotation in a
new initialize() method, and use them to report the android camera info
and to populate the static metadata buffer.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Report the supported API version in the camera_info structure provided
to the framework.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Make the CameraDevice a Loggable subclass and provide a logPrefix()
method to identify which camera the log output refers to.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The return value of write() function is ignored, causing the following
compiler error|warning with gcc version 5.4
error: ignoring return value of 'ssize_t write(int, const void*, size_t)'
Fix this by storing the return value of write() and return a test error in
case of failure.
Reported-by: Coverity CID=284605
Signed-off-by: Madhavan Krishnan <madhavan.krishnan@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The preferred coding style in libcamera is to declare private functions
before private variables in class definitions. This rule isn't followed
by some of the internal classes. Update them accordingly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
|
|
When the native pixel formats supported by QT were introduced, the
RGB/BGR formats were inverted.
Swap the BGR888 and RGB888 mappings accordingly.
Fixes: f890a57b7a06 ("qcam: viewfinder: Add support for more native formats")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The V4L2 compatibility layer is licensed under the GPL. It is compiled
as a binary separate from libcamera.so, and is loaded into the address
space of processes through LD_PRELOAD to intercept calls to the C
library.
It is our understanding and intent that the GPL license doesn't
propagate to the binaries whose calls are intercepted, considering those
binaries are not derivative work of the V4L2 compatibility layer and are
not designed to be linked to the V4L2 compatibility layer. There is
however a possibly grey area if binaries are packaged with a shell
script wrapper that loads the V4L2 compatibility layer. This could lead
to license-related issues if such packaging is performed by Linux
distributions or system integrators.
To clarify the intent and lift the doubts, relicense the V4L2
compatibility layer under the LGPL. The V4L2 compatibility layer code
itself still benefits from the license protection, while its usage with
third-party binaries is clearly allowed as intended.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
|
Use the converter to implement scaling.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Extend the SimpleConverter to support scaling, with reporting of the
minimum and maximum output sizes supported for a given input size.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Report the stride when configuring the camera. The stride is retrieved
from the capture device first, and overridden by the converter if used.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The default SizeRange constructor initializes the min and max members,
but leaves the hStep and vStep members uninitialized. Fix it.
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>
|
|
The RPiCameraData class destructor tries to stop its ipa_ instance
without making sure it has been initialized.
If the RPiCameraData gets destroyed before its ipa_ member is
initialized, for example if the sensor initialization fails during the
match() function, a nullptr dereference segfault is triggered preventing
a graceful library teardown.
Fix this by checking for ipa_ to be initialized before stopping it.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|