Commit graph

1526 commits

Author SHA1 Message Date
Laurent Pinchart
39fa976b46 libcamera: Summarize licensing terms in COPYING.rst
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>
2020-06-26 15:18:25 +03:00
Niklas Söderlund
40148cfcaf libcamera: ipu3: Allow zero-copy RAW stream capture
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
a96eb0cc8f libcamera: ipu3: cio2: Hide buffer allocation and freeing from users
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
bb82835bc5 libcamera: ipu3: cio2: Make the V4L2 devices private
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
d2c94456d9 libcamera: ipu3: cio2: Add function to generate configuration
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
906ff25ef8 libcamera: ipu3: cio2: Consolidate information about formats
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
6bd3d7259f libcamera: ipu3: cio2: Move the CIO2Device class to separate files
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
2cd9556021 libcamera: ipu3: Calculate number of buffers for ImgU
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
e00b7b7c1a libcamera: ipu3: Breakout stream assignment to new function
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>
2020-06-26 13:32:29 +02:00
Niklas Söderlund
82ddb680a8 libcamera: ipu3: Fold mediaBusToFormat() into only caller
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>
2020-06-26 13:32:29 +02:00
Chris Chinchilla
cbf0a92185 libcamera: pipeline_handler: Correct small typo in acquireMediaDevice description
Correct a small typo in the method description.

Fixes: d6a8860747 ("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>
2020-06-26 11:22:01 +01:00
Chris Chinchilla
e284261cf0 libcamera: pipeline_handler: Fix incorrect method in CameraData docs
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: b581b9576a ("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>
2020-06-26 11:12:11 +01:00
Naushir Patuck
0396380614 libcamera: pipeline: raspberrypi: Add StreamFormats to StreamConfiguration
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>
2020-06-25 17:47:51 +03:00
David Plowman
23e15e72f9 ipa: rpi: Add "focus" algorithm
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>
2020-06-25 17:47:51 +03:00
Paul Elder
0952f2014d v4l2: v4l2_camera_proxy: Serialize accesses to the proxy
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>
2020-06-25 23:47:13 +09:00
Paul Elder
12fa2fe020 v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing
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>
2020-06-25 23:47:13 +09:00
Paul Elder
3f01ccf24b v4l2: v4l2_camera_proxy: Don't allow buffers to be freed if still mmaped
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>
2020-06-25 23:47:13 +09:00
Paul Elder
4d150c7faf v4l2: v4l2_camera_proxy: Don't allow streamon if no buffers have been requested
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>
2020-06-25 23:47:13 +09:00
Paul Elder
609036a9e6 v4l2: v4l2_camera_proxy: Check arg->index bounds for querybuf, qbuf, dqbuf
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>
2020-06-25 23:47:13 +09:00
Paul Elder
9909ce33f9 v4l2: v4l2_camera: Clear pending requests on freeBuffers and streamOff
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>
2020-06-25 23:47:13 +09:00
Paul Elder
566ccd75ca v4l2: v4l2_camera: Don't use libcamera::Semaphore for available buffers
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>
2020-06-25 23:47:13 +09:00
Paul Elder
f155e63816 v4l2: v4l2_camera_proxy: Clear internal buffer vector on reqbufs 0
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>
2020-06-25 23:47:13 +09:00
Paul Elder
6a5d416b37 v4l2: v4l2_camera_proxy: noop if streamon when stream is already on
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>
2020-06-25 23:47:13 +09:00
Paul Elder
b3dc3d7cf2 v4l2: v4l2_camera_proxy: Disallow dqbuf when not streaming
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>
2020-06-25 23:47:13 +09:00
Paul Elder
d45d53cde0 v4l2: v4l2_camera: Add isRunning()
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>
2020-06-25 23:47:13 +09:00
Paul Elder
c857ae3c89 v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUM_FRAMESIZES
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>
2020-06-25 23:47:13 +09:00
Paul Elder
e0e10d2b53 v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUMINPUT, VIDIOC_G/S_INPUT
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>
2020-06-25 23:47:13 +09:00
Paul Elder
25b52e35a6 v4l2: v4l2_camera_proxy: Implement VIDIOC_G/S_PRIORITY
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>
2020-06-25 23:47:13 +09:00
Paul Elder
012cfab9b1 v4l2: v4l2_camera_proxy: Fix v4l2-compliance support for extended formats
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>
2020-06-25 23:47:13 +09:00
Paul Elder
b5d61c86ab v4l2: v4l2_camera_proxy: Check for null arg values in main ioctl handler
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>
2020-06-25 23:47:13 +09:00
Paul Elder
02802aa11f v4l2: v4l2_camera_proxy: Set timestamp monotonic buffer flag on reqbufs
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>
2020-06-25 23:46:56 +09:00
Paul Elder
d73ea3a252 v4l2: v4l2_camera_proxy: Clear reserved field in reqbufs
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>
2020-06-25 23:41:36 +09:00
Paul Elder
0eea47a956 v4l2: v4l2_camera_proxy: Free old buffers on reqbufs > 0
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>
2020-06-25 23:41:33 +09:00
Paul Elder
9076e88fc3 v4l2: v4l2_compat: Support multiple open
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>
2020-06-25 23:41:29 +09:00
Paul Elder
edacd07c5e v4l2: V4L2CameraProxy: Take V4L2CameraFile as argument for intercepted calls
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>
2020-06-25 23:41:19 +09:00
Paul Elder
d37ec82515 v4l2: v4l2_camera_file: Add V4L2CameraFile to model the opened camera file
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>
2020-06-25 23:41:15 +09:00
David Plowman
58732e4b49 libcamera: ipa: raspberrypi: Plumb in the libcamera sharpness control
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>
2020-06-25 06:47:53 +03:00
David Plowman
0dbc6a507c libcamera: ipa: raspberrypi: Add sharpness strength control
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>
2020-06-25 06:47:53 +03:00
David Plowman
58e63a6e7e libcamera: ipa: raspberrypi: Make sharpening mode_factor an ordinary double
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>
2020-06-25 06:47:53 +03:00
David Plowman
f68c6eb17b libcamera: Add a sharpness strength control
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>
2020-06-25 06:47:53 +03:00
Kaaira Gupta
2129117df9 libcamera: pixel_format: Replace hex with format names
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>
2020-06-25 06:47:48 +03:00
Niklas Söderlund
c2bfe003e7 libcamera: formats: Add formats for IPU3
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: 56c99424ed ("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>
2020-06-24 19:07:36 +02:00
Niklas Söderlund
fc520719a9 meson: options: Add an option to control compilation of qcam
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>
2020-06-24 19:06:16 +02:00
David Plowman
c3ed943c99 libcamera: Add support for planar YUV422 and YUV420 formats
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>
2020-06-23 01:39:28 +03:00
Niklas Söderlund
405ba5fd4a libcamera: ipu3: Remove id from camera names
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>
2020-06-22 17:00:46 +02:00
Niklas Söderlund
72b9b7d3f3 libcamera: stream: Initialize stride and bufferCount
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>
2020-06-22 17:00:41 +02:00
David Plowman
846e7d999a libcamera: ipa: raspberrypi: Recalculate camera exposure/gain when camera 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>
2020-06-22 07:03:31 +03:00
David Plowman
ff291b3c15 libcamera: ipa: raspberrypi: Allow SwitchMode method to return camera settings
This commit adds a Metadata parameter to the SwitchMode method
enabling it to return camera and other settings to the caller
(usually the configure method, just after the camera mode has been
selected).

In future this will allow the Raspberry Pi IPAs to take those settings
(such as exposure and analogue gain) and program them directly into
the camera or ISP before the camera is even started.

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>
2020-06-22 07:03:25 +03:00
Paul Elder
1023107b64 v4l2: v4l2_compat: Intercept open64, openat64, and mmap64
Some applications (eg. Firefox, Google Chrome, Skype) use open64,
openat64, and mmap64 instead of their non-64 versions that we currently
intercept. Intercept these calls as well. _LARGEFILE64_SOURCE needs to
be set so that the 64-bit symbols are available and not synonymous to
the non-64-bit versions on 64-bit systems.

Also, since we set _FILE_OFFSET_BITS to 32 to force the various open and
mmap symbols that we export to not be the 64-bit versions, our dlsym to
get the original open and mmap calls will not automatically be converted
to their 64-bit versions. Since we intercept both 32-bit and 64-bit
versions of open and mmap, we should be using the 64-bit version to
service both. Fetch the 64-bit versions of openat and mmap directly.

musl defines the 64-bit symbols as macros that are equivalent to the
non-64-bit symbols, so we put compile guards that check if the 64-bit
symbols are defined.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> # Compile with musl
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-19 20:21:00 +09:00
Laurent Pinchart
ee5dc92dc1 include: linux: Remove drm.h and drm_mode.h
The drm.h and drm_mode.h headers are not used anymore, as drm_fourcc.h
isn't included but only parsed by gen-formats.py. Remove them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-06-18 13:26:59 +03:00