Age | Commit message (Collapse) | Author |
|
When the IPU3 pipeline was first developed sinks of the ImgU that where
not active still needed to have buffers allocated to allow streaming to
start. This is no longer true, it's enough that the sinks have imported
buffers to allow streaming to start. As we already need to import
buffers for stream that are active we can align the two cases and always
import buffers.
With this there is no longer a reason to store the allocated
FrameBuffers to keep them alive and the vector tracking them can be
removed.
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>
|
|
Statistics buffers are not yet used by the IPU3 pipeline, they are never
queued to the statistics video device or in any other way consumed. The
kernel driver will however not allow video streaming to start if buffers
are not either allocated or imported on the statistics video device.
Instead of allocating the buffers wasting memory that is never used,
import buffers.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The field is never used, remove it.
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>
|
|
Storing detailed licensing information in SPDX headers and in the DEP5
file gives precise information to handle license compliance, but lacks a
high-level overview. Summmarize the licensing terms in a COPYING.rst
file to facilitate understanding of the libcamera project licenses, and
to clarify that closed-source third-party IPA modules are permitted.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
|
|
With the refactored CIO2 interface it's now easy to add zero-copy for
buffers in the RAW stream. Use the internally allocated buffers inside
the CIO2Device if no buffer for the RAW stream is provided by the
application, or use the application-provided buffer if any.
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>
|
|
The allocation and freeing of buffers for the CIO2 is handled in the
IPU3 pipeline handlers start() and stop() functions. These functions
also call CIO2Device start() and stop() at the appropriate times so
move the CIO2 buffer allocation/freeing inside the CIO2Device and reduce
the complexity of the exposed interface.
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>
|
|
In order to make the CIO2 easier to extend with new features make the
V4L2 devices (sensor, CIO2 and video device) private members. This
requires a few helper functions to be added to allow for the IPU3 driver
to still be able to interact with all parts of the CIO2. These helper
functions will later be extended to add new features to the IPU3
pipeline.
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>
|
|
Collect the code used to generate configurations for the CIO2 block in
the CIO2Device class. This allows simplifying the code and allow further
changes to only happen at one code location.
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>
|
|
Instead of spreading the mapping between media bus codes and V4L2 FourCC
all over the CIO2 code collect it in a single map and extract the data
from it. This is done in preparation of adding PixelFormat information
to the mix.
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>
|
|
In preparation of refactoring the IPU3 pipeline handler breakout the
CIO2Device into its own .cpp and .h file, no functional change.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Decouple the number of buffers to allocate for the ImgU from the number
of buffers allocated for the CIO2. Instead of blindly following the CIO2
pick the maximum number of buffers requested for any stream facing
applications.
This is potentially wasteful, as each stream could allocate just as many
buffers as requested by the application instead of the maximum from the
set. But this is not more wasteful than what is already used by the
pipeline and should be fixed on top after the decoupling of the two
processing units.
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>
|
|
Selecting which stream is the most suitable for the requested
configuration is mixed with adjusting the requested format when
validating configurations. This is hard to read and got worse when
support for Bayer formats was added. Break it out to a separate
function.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Make the code easier to read and refactor.
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>
|
|
description
Correct a small typo in the method description.
Fixes: d6a88607479 ("libcamera: pipeline_handler: Keep track of MediaDevice")
Signed-off-by: Chris Chinchilla <chris@gregariousmammal.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>
|
|
The pipeline handler documentation incorrectly references an old API
usage of setCameraData, which should have been updated to
registerCamera() while updating pipeline handlers to ensure they all
have a pipeline-specific "CameraData" allocation.
Update the remaining documentation reference.
Fixes: b581b9576abd ("libcamera: pipeline_handler: Make pipeline-specific data mandatory")
Signed-off-by: Chris Chinchilla <chris@gregariousmammal.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
In generateConfiguration(), add the device node specific formats to the
StreamConfiguration for each StreamRole requested.
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
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>
|
|
Adds FocusStatus to the image metadata, containing contrast measurements
across the image. Optionally also prints a contrast measure to the
console, to aid in manual adjustment of the lens. Note that it is not an
actual auto-focus algorithm that can drive a lens!
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Make the V4L2 compatibility layer thread-safe by serializing accesses to
the V4L2CameraProxy with a lock. Release the lock when blocking for
dqbuf.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Fix buffer flags related to queueing and dequeueing:
- don't allow a buffer with the same index that is already in the queue
to be enqueued again
- don't clear the done flag upon qbuf
- do clear the done flag upon dqbuf
- set the flags in V4L2CameraProxy's internal buffers, and not just in
the buffers returned from qbuf
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
In VIDIOC_REQBUFS with count = 0, if the buffers are still mmaped, they
should not be allowed to be freed. Add a check for this.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Make VIDIOC_STREAMON return -EINVAL if no buffers have been allocated
with reqbufs.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
There were no bounds checks for the index argument for VIDIOC_QUERYBUF,
VIDIOC_QBUF, and VIDIOC_DQBUF. Add them.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
V4L2 allows buffer queueing before streamon while libcamera does not.
The compatibility layer thus saves these buffers in a pending queue
until streamon, and then automatically queues them. However, this
pending queue is not cleared when the buffers are freed, so the
following sequence of actions will cause a use-after-free:
1. queue buffers
2. free buffers
- buffers from 1. stay in pending queue but have been freed
3. queue buffers
4. streamon
- buffers from 1. are enqueued, then the buffers from 3. are
enqueued. Use-after-free segfault when libcamera tries to handle
the enqueued buffers from 1.
Fix this by clearing the pending request queue upon buffers being freed.
Also clear the pending request queue on streamOff, for correctness.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
In V4L2, a blocked dqbuf should not not also block a streamoff. This
means that on streamoff, the blocked dqbuf must return (with error). We
cannot do this with the libcamera semaphore, so pull out the necessary
components of a semaphore, and put them into V4L2Camera, so that dqbuf
from V4L2CameraProxy can wait on a disjunct condition of the
availability of the semaphore or the stopping of the stream.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
If VIDIOC_REQBUFS with count = 0 is called when the stream is not on,
clear the proxy's internal vector of buffer. If the stream is on when
reqbufs 0 is called, return -EBUSY.
Note that this is contrary to what the V4L2 docs say (reqbufs 0 when
streaming should also streamoff), but it is how the V4L2 implementation
works. v4l2-compliance doesn't seem to care either way, however, so we
cater to the implementation, and no longer call streamoff on reqbufs 0.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
If VIDIOC_STREMAON is called when the stream is already on, do a noop.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Make VIDIOC_DQBUF return -EINVAL if the stream is not turned on.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add a method isRunning() to V4L2Camera so that V4L2CameraProxy can use
it for checks.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Implement VIDIOC_ENUM_FRAMESIZES in the V4L2 compatibility layer.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Implement VIDIOC_ENUMINPUT, VIDIOC_G_INPUT, and VIDIOC_S_INPUT. Only the
zeroth input device is supported, and the info returned by enuminput is
hardcoded and basic. This is sufficient to pass v4l2-compliance.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Implement VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY. The behaviour
documented in the V4L2 specification doesn't match the implementation in
the Linux kernel, implement the latter.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Fix the following v4l2-compliance error:
fail: v4l2-compliance.cpp(652): !(caps & V4L2_CAP_EXT_PIX_FORMAT)
Simply add V4L2_CAP_EXT_PIX_FORMAT to capabilities in querycap.
In addition, populate the necessary fields in struct v4l2_pix_format to
support extended pixel formats in try_fmt and g/s_fmt, and clear the
reserved field for enum_fmt.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The ioctl handlers currently don't check if arg is null, so if it ever
is, it will cause a segfault. Check that arg is null and return -EFAULT
in the main vidioc ioctl handler.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Set buffer flag V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC at VIDIOC_REQBUFS
after the buffers have been allocated.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Clear the reserved field in arg struct v4l2_reqbuffers of
VIDIOC_REQBUFS.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Free buffers, if any were previously allocated, at VIDIOC_REQBUFS with
count > 0.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Previously, since we acquired the libcamera camera upon open(), it was
impossible to support multiple open, as any subsequent opens would
return error because the camera would already be acquired.
To fix this, we first initialize the camera in the first call to
V4L2CameraProxy::open(), just to heat up the stream format cache. We
then add ownership by a V4L2CameraFile of a V4L2Camera via the
V4L2CameraProxy. All vidioc ioctls prior to reqbufs > 0 (except for
s_fmt) are able to access the camera without ownership. A call to
reqbufs > 0 (and s_fmt) will take ownership, and the ownership will be
released at reqbufs = 0. While ownership is assigned, the eventfd that
should be signaled (and cleared) by V4L2Camera and V4L2CameraProxy is
set to the V4L2CameraFile that has ownership, and is cleared when the
ownership is released. In case close() is called without a
reqbufs = 0 first, the ownership is also released on close().
We also use the V4L2CameraFile to contain all the information specific
to an open instance of the file. This removes the need to keep track of
such information within V4L2CameraProxy via multiple maps from int fd to
info.
Since V4L2 does not expect reqbufs 0 to ever return error, make
V4L2CameraProxy::freeBuffers() return void.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Prepare for using the V4L2CameraFile as a container for file-specific
information in the V4L2 compatibility layer by making it a required
argument for all V4L2CameraProxy calls that are directed from
V4L2CompatManager, which are intercepted via LD_PRELOAD. Change
V4L2CameraFile accordingly.
Also change V4L2CompatManager accordingly. Instead of keeping a map of
file descriptors to V4L2CameraProxy instances, we keep a map of
V4L2CameraFile instances to V4L2CameraProxy instances. When the
proxy methods are called, feed the file as a parameter.
The dup function is also modified, in that it is removed from
V4L2CameraProxy, and is handled completely in V4L2CompatManager, as a
map from file descriptors to V4L2CameraFile instances.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
With relation to opening files, the kernel has three objects related to
files:
- inodes, that represent files on disk
- file objects, that are allocated at open() time and store all data
related to the open file
- file descriptors, that are integers that map to a file
In the V4L2 compatibility layer, V4L2CameraProxy, which wraps a single
libcamera camera via V4L2Camera, is more or less equivalent to the
inode. We also already have file descriptors (that are really eventfds)
that mirror the file descriptors. Here we create a V4L2CameraFile to
model the file objects, to contain information related to the open file,
namely if the file has been opened as non-blocking, and the V4L2
priority (to support VIDIOC_G/S_PRIORITY later on). This new class
allows us to more cleanly support multiple open later on, since we can
move out of V4L2CameraProxy the handling of mapping the fd to the open
file information.
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
This simply wires up the libcamera sharpness control in the Raspberry
Pi IPAs so that it controls the strength of the Raspberry Pi sharpness
control algorithm.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The sharpness control is, loosely speaking, a gain applied to
the amount of sharpening added to an image. We also report the
sharpness setting used back to the caller in metadata.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
No need for it to be std::atomic as SwitchMode runs synchronously with
Prepare.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The control is a single float value with minimum, default and maximum
values. Please read the description for more details.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Print format names defined in formats namespace instead of the hex
values in toString() as they are easier to comprehend. For this add
a property of 'name' in PixelFormatInfo' so as to map the formats
with their names. Print fourcc for formats which are not used in
libcamera.
Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
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>
|
|
When replacing DRM FourCCs with libcamera formats IPU3 format
descriptors where missing resulting in RAW capture not being possible.
Fix this by adding the missing descriptors.
Fixes: 56c99424edd64c5a ("libcamera: pipeline: Replace explicit DRM FourCCs with libcamera formats")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add an option to control compilation of the qcam test application. The
default behavior is to compile qcam, no change in behavior without user
intervention.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
These formats can be helpful when downstream applications or libraries
support them natively (avoiding a costly conversion).
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.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>
|
|
The id in the camera name is confusing and is of little use for users.
Camera names are not (yet) required to be unique and appending which
numerical CIO2 unit the sensor is attached to is just as good as
depending on the i2c bus information already present in the entity name.
Before this change,
$ cam -l
Available cameras:
1: ov13858 2-0010 0
2: ov5670 4-0036 1
After this change,
$ cam -l
Available cameras:
1: ov13858 2-0010
2: ov5670 4-0036
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>
|
|
The two public unsigned integer fields of StreamConfiguration, stride
and bufferCount where not initialized, fix this to match other members
being initialized to their 'zero' state.
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>
|
|
mode changes
This commit causes the AGC to recalculate its camera exposure/gain
values when the camera mode changes. For example it's possible
that the exposure profile could be changed by the application so
the division between exposure time and analogue gain may be
different.
The other underlying reason (and which this commit accomplishes too)
is that the sensor's line timing may change in a new mode, and because
V4L2 drivers store a number of exposure _lines_, the resulting _time_
will "change under our feet". So we have to go through the process of
recalculating the correct number of lines and writing this back to the
sensor with every mode switch, regardless of anything else.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|