Commit graph

709 commits

Author SHA1 Message Date
Florian Sylvestre
02e387e7b6 libcamera: yaml_parser: Add getList() function
Allow to retrieve a YAML list of any already supported types in a
std::vector.

Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-28 13:48:54 +03:00
Laurent Pinchart
38987e165c libcamera: yaml_parser: Preserve order of items in dictionary
The std::map container used to store dictionary items in YamlObject
doesn't preserve the YAML data order, as maps are ordered by key, not by
insertion order. While this is compliant with the YAML specification
which doesn't guarantee ordering of mappings, the Raspberry Pi IPA
relies on elements being ordered as in the YAML data. To replace the
dependency on boost with the YamlParser class, we thus need to guarantee
that the order is preserved.

Preserve the order by storing items in list_ unconditionally. Turn the
list_ vector from storing YamlObject unique pointers to storing
key-value pairs, with the key being absent when the object is a list,
not a dictionary.

The YamlObject implementation is updated to preserve the existing API,
with the only difference being that YamlObject::memberNames() now
returns member names in the same order as in the YAML file.

The ordering is an implementation detail, so changing it doesn't violate
the YAML specification. The documentation is not updated to reflect
this, as we don't want any new user to rely on a particular ordering.
This commit could be reverted if desired when the Raspberry Pi IPA
updates to a new tuning data format and drops support for the old
format.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
2022-07-28 13:47:48 +03:00
Laurent Pinchart
feb8c9be78 libcamera: yaml_parser: Replace ok flag to get() with std::optional
The YamlObject::get() function takes a default value and an optional
bool ok flag to handle parsing errors. This ad-hoc mechanism complicates
error handling in callers.

A better API is possible by dropping the default value and ok flag and
returning an std::optional. Not only does it simplify the calls, it also
lets callers handle errors through the standard std::optional class
instead of the current ad-hoc mechanism.

Provide a get() wrapper around std::optional::value_or() to further
simplify callers that don't need any specific error handling.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-07-28 13:47:13 +03:00
Naushir Patuck
f95bae418c raspberrypi: Update Copyright statement in all Raspberry Pi source files
s/Raspberry Pi (Trading) Limited/Raspberry Pi Ltd/ to reflect the new
Raspberry Pi entity name.

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>
2022-07-27 18:12:15 +03:00
Naushir Patuck
8b02645845 libcamera: controls: Suppress error message from ControlList::get()
Now that ControlList::get() returns a std::optional<T> to handle missing
controls, the error log message in the call to ControlList::find() is
unnecessary and likely invalid.

Fix this by avoiding the call to ControlList::find() from
ControlList::get() and replacing with a call to the underlying
std::unordered_map::find().

Fixes: 1c4d480185 ("libcamera: controls: Use std::optional to handle invalid control values")
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-20 13:25:06 +03:00
Laurent Pinchart
4d22621ec1 libcamera: controls: Drop ControlList::contains()
The ControlList::contains(const ControlId &id) function isn't used, as
it has been replaced by usage of the get() function. Document get as
being the preferred way to check for the presence of a control in a
ControlList, and drop the contains() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2022-07-20 13:25:04 +03:00
Laurent Pinchart
9caee4c662 libcamera: Remove extra ':' after '\todo'
The doxygen '\todo' directory doesn't need to be followed by a colon,
yet a few strayed occurrences have made their way in. Fix them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-07-20 12:47:08 +03:00
Christian Rauch
1c4d480185 libcamera: controls: Use std::optional to handle invalid control values
Previously, ControlList::get<T>() would use default constructed objects to
indicate that a ControlList does not have the requested Control. This has
several disadvantages: 1) It requires types to be default constructible,
2) it does not differentiate between a default constructed object and an
object that happens to have the same state as a default constructed object.

std::optional<T> additionally stores the information if the object is valid
or not, and therefore is more expressive than a default constructed object.

Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-19 14:21:54 +03:00
Kieran Bingham
6f539a6d2f delayed_controls: Remove reduandant firstSequence_
The DelayedControls implementation tracked the sequence numbers to
determine the offset if a device did not commence with a sequence number
of 0.

This guarantee is now handled by the V4L2VideoDevice.

Remove the firstSequence_ offset and the corresponding running_ flag
which was used to track setting firstSequence_ from the DelayedControls.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-07-05 11:23:35 +01:00
Laurent Pinchart
d5b0cec839 libcamera: framebuffer: Turn the cookie into a 64-bit integer
To allow associating pointers with FrameBuffer instances, turn the
cookie into a 64-bit integer. This matches the Request cookie with is
also a uint64_t.

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>
2022-07-04 23:07:29 +03:00
Naushir Patuck
ac955c425d pipeline: ipa: raspberrypi: Correctly report available control limits
The ipa currently advertises a static ControlInfoMap to specify the available
controls and their limits. Fix this limitation by having the IPA populate a new
ControlInfoMap with updated limits for ExposureTime, AnalogueGain, and
FrameDurationLimits controls based on the current sensor mode. This new
ControlInfoMap is then returned back to the pipeline handler and available to
the application after a successful Camera::configure() call.

Before the first call to Camera::configure(), this ControlInfoMap provides some
reasonable default limits for ExposureTime, AnalogueGain, and
FrameDurationLimits. However, applications must not rely on these values, but
obtain the correct limits after the call to Camera::configure().

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-29 13:55:17 +01:00
Naushir Patuck
53ada24e63 pipeline: ipa: raspberrypi: Move ControlInfoMap to the IPA
Currently the pipeline handler advertises controls handled by the IPA from a
static ControlInfoMap defined in the raspberrypi.h header. This change removes
this header file, and instead the IPA returns the ControlInfoMap to the pipeline
handler from the ipa::init() function. This is done to allow the IPA to adjust
the limits of the controls based on the sensor mode in a subsequent change.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=83
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-29 13:54:51 +01:00
Kieran Bingham
1c9dc0fd89 libcamera: v4l2_videodevice: Identify non-zero stream starts
V4L2 Video devices should always start streaming from index zero.
Identify and report a warning if they don't, and correct for any offset.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-27 10:32:06 +01:00
Laurent Pinchart
c7d260c03a libcamera: yaml_parser: Add get() specializations for 16-bit integers
Extend the YamlObject::get() function template to support 16-bit
integers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20 15:12:27 +03:00
Laurent Pinchart
9dacead615 libcamera: yaml_parser: Remove memberNames() function
Now that YamlObject supports iteration, the memberNames() function isn't
useful anymore as it can be implemented using utils::map_keys() if
really needed. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20 15:12:26 +03:00
Laurent Pinchart
3a18ad1607 libcamera: yaml_parser: Add iterator API
Allow using range-based for loops over YamlObject instances by
implementing iterators. New YamlObject::DictAdapter and
YamlObject::ListAdapter adapter classes are introduced to provide
different iterators depending on the object type.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20 15:12:11 +03:00
Laurent Pinchart
40f8cbda60 libcamera: yaml_parser: Use std::is_same_v<>
As the YamlObject class is internal to libcamera, it can use the full
C++17 API. Replace std::is_same<>::value with std::is_same_v<>.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20 15:11:57 +03:00
Laurent Pinchart
d6d0a675bf libcamera: yaml_parser: Switch from FILE to File
THe FILE object isn't very user-friendly as it requires manual close.
Replace it with File to provide RAII-style resource management in the
YamlParser API.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16 02:43:47 +03:00
Laurent Pinchart
27fb47f70b libcamera: yaml_parser: Extend YamlObject::size() to dictionaries
Dictionaries have a size too, extend the size() function to support
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16 02:43:47 +03:00
Laurent Pinchart
27483e971f libcamera: yaml_object: Turn Type into an enum class
Turn the Type enum into an enum class to force qualifying 'List' and
'Dictionary' in the YamlObject namespace scope. This will help avoiding
ambiguities when adding iterator support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16 02:43:46 +03:00
Laurent Pinchart
6132521b47 libcamera: base: log: Color the log prefix
Add coloring to the log prefix to increase log readability.

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>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-06 15:09:49 +03:00
Laurent Pinchart
5757038946 libcamera: base: log: Add coloring to the log output
Extend the logger to support coloring messages. The log level is
colorized with per-level colors, and the category with a fixed color.
This makes the log output more readable.

Coloring is enabled by default when logging to std::cerr, and can be
disabled by setting the LIBCAMERA_LOG_NO_COLOR environment variable.
When logging to a file with LIBCAMERA_LOG_FILE, coloring is disabled. It
can be enabled for file logging using the logSetFile() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-06 15:09:42 +03:00
Jacopo Mondi
161d24377c libcamera: request: Add operator<<()
With the recent addition of operator<<() in most libcamera core classes
to replace usage of the toString() function the Request class was left
behind.

Add operator<<() for the Request class and reimplement toString().

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-06-05 14:48:08 +02:00
Laurent Pinchart
c3515cf6e5 libcamera: ipa: Move IPA control serialization structures to libcamera namespace
The C structures used to serialize controls are currently defined in the
root namespace, which places them at the root level in the class list
generated by Doxygen. Move them to the libcamera namespace to fix that.

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>
2022-05-27 16:07:01 +03:00
Laurent Pinchart
7d1f03e5ba libcamera: media_device: Return string references to avoid copies
The MediaDevice::driver(), deviceNode() and model() functions return a
const std::string, copying the string stored internally in the class.
Return references instead to avoid copies.

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>
2022-05-27 16:06:21 +03:00
David Plowman
065a9e6c05 libcamera: raspberrypi: Fetch correct value for SensorSensitivity
These changes retrieve the correct value for sensitivity of the mode
selected for the sensor. This value is known to the CamHelper which
passes it across to the pipeline handler so that it can be set
correctly in the camera properties.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-05-10 14:24:45 +01:00
Tomi Valkeinen
1ddda31f14 meson: Use new project_*_root() functions
meson.source_root() and meson.build_root() are deprecated. Use
meson.project_source_root() and meson.project_build_root() instead.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.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>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-05-10 13:53:43 +02:00
Han-Lin Chen
fcb0ea001a libcamera: Introduce YamlParser as a helper to parse yaml files
Introduce YamlParser as a helper to convert contents of a yaml file to
a tree based structure for easier reading, and to avoid writing parser
with raw yaml tokens. The class is based on libyaml, and only support
reading but not writing a yaml file.

The interface is inspired by Json::Value class from jsoncpp:
http://jsoncpp.sourceforge.net/class_json_1_1_value.html

Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-10 00:22:36 +03:00
Laurent Pinchart
d5d6dbe85c libcamera: Add operator<<() for V4L2 format classes
Implement the stream output operator<<() for the V4L2DeviceFormat and
V4L2SubdeviceFormat classes to simplify printing them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-04 14:11:31 +03:00
Laurent Pinchart
08d6133113 libcamera: bayer_format: Add operator<<()
Implement the stream output operator<<() for the BayerFormat class to
simplify printing them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-04 14:11:31 +03:00
Laurent Pinchart
2efd8ab36a libcamera: Add operator<<() for pixel format classes
Implement the stream output operator<<() for the PixelFormat and
V4L2PixelFormat classes to simplify printing them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-04 14:11:30 +03:00
Laurent Pinchart
e8f35e5f33 libcamera: geometry: Add missing ostream header in geometry.h
Commit c730dc7479 ("libcamera: geometry: Add operator<< for classes in
geometry") added usage of std::ostream in geometry.h but forget to
include the corresponding header. Fix it to avoid future compilation
breakages if indirect inclusions are changed.

Fixes: c730dc7479 ("libcamera: geometry: Add operator<< for classes in geometry")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-04 14:11:29 +03:00
Han-Lin Chen
c730dc7479 libcamera: geometry: Add operator<< for classes in geometry
Add operator<< for geometry classes for easier logging.

Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-04-22 00:38:50 +03:00
Dorota Czaplejewicz
d98af71eaa libcamera: framebuffer: Make FrameBuffer::cancel() private
FrameBuffer::cancel() is not meant to be used by applications. Move it
to the FrameBuffer::Private class.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
[Kieran: Handle rebase]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-04-14 00:19:36 +02:00
Umang Jain
cef3e15324 ipa: vimc: Synchronise parameter buffer ops naming
Synchronise the names of the operations with respect to parameters
buffer with the names used in other IPA interfaces.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-04-13 19:04:58 +05:30
Umang Jain
52cd4dacd0 ipa: vimc: Establish logical order of operations
It is preferred that the interface definition should represent
the logical order in which the operations will be called.

The patch has no functional changes.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-04-13 19:00:02 +05:30
Umang Jain
cbfa81cb4e ipa: ipu3: Replace event-based ops with dedicated functions
The IPAIPU3 interface currently uses event-type based structures in
order to communicate with the pipeline-handler (and vice-versa).
Replace the event based structures with dedicated functions associated
to each operation.

The translated naming scheme of actions to signals are:
  ActionSetSensorControls => setSensorControls
  ActionParamFilled       => paramsBufferReady
  ActionMetadataReady     => metadataReady

The translated naming scheme of events to dedicated functions are:
  EventProcessControls    => queueRequest()
  EventStatReady          => processStatsBuffer()
  EventFillParams         => fillParamsBuffer()

The dedicated functions are called from pipeline-handler to the IPA
using IPC. These functions run asynchronously and when completed,
the IPA emits the respective signals as stated above in the translated
naming scheme.

The EventProcessControls is translated to queueRequest() to bring
symmetry to the IPU3 interface with other IPA interfaces.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-04-08 12:55:10 +05:30
Laurent Pinchart
e2d00fbcbb libcamera: base: utils: Add missing constructor for Duration
The Duration class is missing the equivalent to the
std::chrono::duration constructor that takes a number of ticks expressed
as a scalar. Fix it, which allows initializing a Duration instance to 0
or 0.0.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-04-07 10:20:28 +03:00
Laurent Pinchart
1a9587b8f2 libcamera: camera_sensor: Drop const on the return value of sizes()
The sizes() function returns a value, not a reference. There's no need
for it to be const.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-04-06 20:25:48 +03:00
Naushir Patuck
04faa8477a pipeline: raspberrypi: Add a Unicam dequeue timeout
Enable the V4L2VideoDevice dequeue timeout for the Unicam Image node, and
connect the timeout signal to a slot in the pipeline handler. This slot will
log an error message informing the user of a possible hardware stall.

The timeout is calculated as 2x the maximum frame length possible for a given
mode, returned by the IPA.

Signed-off-by: Naushir Patuck <naush@raspberrypi.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>
2022-04-06 15:44:37 +03:00
Naushir Patuck
16f3d2de50 libcamera: v4l2_videodevice: Add a dequeue timer
Add a timer that gets reset on every buffer dequeue event. If the timeout
expires, optionally call a slot in the pipeline handler to handle this
condition. This may be useful in detecting and handling stalls in either the
hardware or device driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.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>
2022-04-06 15:44:32 +03:00
David Plowman
8dc2699bb8 ipa: raspberrypi: Correct some of the ControlInfo ranges and defaults
Some of the values were listed incorrectly. Specifically:

ExposureValue: the range is now centred correctly on zero
Brightness: the default value (0.0) is made explicit
Contrast: the default value is corrected to be 1.0
Saturation: the default value is corrected to be 1.0

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-04-06 12:52:24 +03:00
Umang Jain
28a44e80f0 ipa: vimc: Rename processControls() to queueRequest()
Synchronise with other IPA interfaces (for e.g. IPU3, RkISP1)
that uses queueRequest() to pass in the request controls to
IPA.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-04-02 01:09:56 +05:30
Umang Jain
08d7e66df0 ipa: rkisp1: Split queuing of request and parameter filling
Queuing of request (i.e. passing of controls to the IPA)
and filling of the parameters buffer are two separate operations.
Treat them as such by splitting them into two functions in
the rkisp1 IPA interface.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-04-02 00:34:22 +05:30
Naushir Patuck
5704856681 libcamera: v4l2_videodevice: Empty the V4L2 buffer cache on streamOff()
When streamOff() is called, ensure the cache entries for the remaining queued
buffers are freed since this will not happen via the dequeueBuffer() mechanism.

Additionally, add a V4L2BufferCache::isEmpty() function and assert that the
cache is empty at the end of the streamOff() call.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.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>
2022-03-28 02:18:34 +03:00
Naushir Patuck
988ec3f417 libcamera: v4l2_videodevice: Better tracking of the device state
Replace the existing streaming_ state variable with an enum to track the
following three state: Streaming, Stopping, and Stopped. The alternate states
will be used in a subsequent commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.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>
2022-03-28 02:17:22 +03:00
Laurent Pinchart
54398c1583 libcamera: base: timer: Drop start() overload with int argument
The start(unsigned int msec) overload is error-prone, as the argument
unit can easily be mistaken in callers. Drop it and update all callers
to use the start(std::chrono::milliseconds) overload instead.

The callers now need to use std::chrono_literals. The using statement
could be added to timer.h for convenience, but "using" is discouraged in
header files to avoid namespace pollution. Update the callers instead,
and while at it, sort the "using" statements alphabetically in tests.

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>
2022-03-25 13:11:12 +02:00
Umang Jain
c7d4599565 ipa: rkisp1: Replace event-based ops with dedicated functions
The IPARkISP1Interface currently uses event-type based structures in
order to communicate with the pipeline-handler (and vice-versa).
Replace the event based structures with dedicated functions associated
to each operation.

The translated naming scheme of operations to dedicated functions:
  ActionV4L2Set         => setSensorControls
  ActionParamFilled     => paramsBufferReady
  ActionMetadata        => metdataReady
  EventSignalStatBuffer => processStatsBuffer()
  EventQueueRequest     => queueRequest()

The lexical of IPARkISP1::metadataReady() will now conflict with the
metadataReady Signal being introduced in this patch as part of the
interface change. Hence, rename IPARkISP1::metadataReady() to
IPARkISP1::prepareReady() to prevent the conflict.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2022-03-23 21:53:42 +05:30
Daniel Scally
5413e78893 libcamera: ipa: Add lens control member to ipu3 ipa interface
Add further members to the ipu3 ipa interface that will hold lens
controls passed in by configInfo

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-03-15 17:20:59 +00:00
Daniel Scally
931556c37c libcamera: camera_lens: Add function to fetch subdev controls
Add a function to the CameraLens class to fetch the V4L2 controls
for its V4L2 subdev

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-03-15 17:20:59 +00:00