Age | Commit message (Collapse) | Author |
|
Extend the Camera class to expose the controls it supports. Each
pipeline should generate a list of controls supported by each camera it
creates. These are represented by a ControlInfoMap, and an associated
ControlList of default values.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Add a set of data types to support controls:
- ControlValue stores a control type and value in a generic way
- ControlId enumerates all the control identifiers
- ControlIdentifier declares the types of a control and map their names
- ControlInfo stores runtime information for controls
- ControlList contains a set of control info and value pairs
The control definitions map is generated from the controls documentation
to ensure that the two will always be synchronised.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
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>
|
|
Add a new controls() method to the V4L2Device class to retrieve the map
of all supported controls. This is needed in order to dynamically query
the supported controls, for instance for drivers that support different
sets of controls depending on the device model.
To make the API easier to use, create a type alias for the control ID to
ControlInfo and use it.
Remove the getControlInfo() method that is not used externally, as it
can now be replaced by accessing the full list of controls.
Update the CameraSensor API accordingly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Add min() and max() methods to V4L2ControlInfo to report the control's
minimum and maximum value respectively.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Blocking socket operation when receiving messages may lead to long
delays, and possibly a complete deadlock, if the remote side delays
sending of the payload after the header, or doesn't send the payload at
all. To avoid this, make the socket non-blocking and implement a simple
state machine to receive the header synchronously with the socket read
notification. The payload read is still synchronous with the receive()
method to avoid data copies.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Test that the IPC supports sending data and file descriptors over the
IPC medium. To be able to execute the test two parts are needed, one
to drive the test and act as the libcamera (master) and a one to act as
the IPA (slave).
The master drives the testing posting requests to the slave to process
and sometimes respond to. A few different tests are performed.
- Master sends an array to the slave which responds with a reversed copy
of the array. The master verifies that a reversed array is returned.
- Master tries to send an empty message making sure that the send call
fails.
- Master sends a list of file descriptors and ask the slave to calculate
and respond with the sum of the size of the files. The master verifies
that the calculated size is correct.
- Master sends a pre-computed size and a list of file descriptors and
asks the slave to verify that the pre-computed size matches the sum of
the size of the file descriptors.
- Master sends two file descriptors and asks the slave to join the file
contents in a new file and respond with its file descriptor. The
master then verifies that the content of the returned file descriptor
matches the order of the original two files.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
To be able to isolate an IPA component in a separate process an IPC
mechanism is needed to communicate with it. Add an IPC mechanism based
on Unix sockets which allows users to pass both data and file descriptors
to and from the IPA process.
The implementation allows users to send both data and file descriptors
in the same message. This allows users to more easily implement
serialization and deserialization of objects as all elements belonging
to an object can be sent in one message.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Timers should be automatically stopped and unregistered when deleted.
Add a test to verify this is the case.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
If a timer is running while it's deleted it is still register with the
event dispatcher. This causes a segmentation fault when the timer
time-out and its signal is emitted. Fix this my stopping the timer when
it's deleted.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The files() function generates a variable with the location of the
referenced files.
This is shorter than joining the current_source_dir() of which use is
somewhat frowned upon.
Fixes: 90de3690c456 ("libcamera: Auto-generate libcamera.h")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add a meson.build checker that warns when tabs are used.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Introduce two new base classes for the code formatters and style
checkers, with an auto-registration mechanism that automatically uses
all derived classes. This will allow easier addition of new formatters
and checkers.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Compiling with clang renders errors as a variable-sized arrays are not
allowed to be initialized. Solve this by using memset() for v4l2Ctrls
which is the only one of the two arrays that needs to be zeroed.
../../src/libcamera/v4l2_device.cpp:155:37: error: variable-sized object may not be initialized
const V4L2ControlInfo *controlInfo[count] = {};
^~~~~
../../src/libcamera/v4l2_device.cpp:156:36: error: variable-sized object may not be initialized
struct v4l2_ext_control v4l2Ctrls[count] = {};
^~~~~
../../src/libcamera/v4l2_device.cpp:227:37: error: variable-sized object may not be initialized
const V4L2ControlInfo *controlInfo[count] = {};
^~~~~
../../src/libcamera/v4l2_device.cpp:228:36: error: variable-sized object may not be initialized
struct v4l2_ext_control v4l2Ctrls[count] = {};
^~~~~
Fixes: eb068f4e67eedacd ("libcamera: v4l2_device: Implement get and set controls")
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>
|
|
When enumerating the available V4L2 controls at video device open
time set the V4L2_CTRL_FLAG_NEXT_CTRL flag if an unsupported control
type is encountered to prevent infinite loops.
While at it, downgrade the message reporting the unsupported control
type to Debug, as it is not an error worth being reported unconditionally.
Fixes: 030ce6491ed3 ("libcamera: v4l2_device: List valid controls at open")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
When using -std=c++11, GCC versions 6.2 and 6.3 take objection to
declaring a struct type when using a range based iterator:
event_dispatcher_poll.cpp:231:13: error: types may not be defined
in a for-range-declaration [-Werror]
for (const struct pollfd &pfd : pollfds) {
^~~~~~
cc1plus: all warnings being treated as errors
Removing the keyword 'struct' ensures that the compiler does not try to
declare the type, and instead uses the type as already defined by the
relevant poll.h header.
This issue does not affect later compiler versions.
Reported-by: [autobuild.buildroot.net] Thomas Petazzoni <thomas.petazzoni@bootlin.com>
http://autobuild.buildroot.net/results/f6dd4c60c04892c8b1669e6000fce7edb2b6349e/
Fixes: 8356f8a6ab87 ("libcamera: Add a poll-based event dispatcher")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
queueRequest() is called after starting the stream.
If it fails, the stream should be stopped, otherwise it can get a
"Device or resource busy" error, due to VIDIOC_REQBUFS ioctls being
called after VIDIOC_STREAMON without VIDIOC_STREAMOFF in-between.
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Set the ImgU pipe_mode control based on the active stream configuration.
Use 'Video' pipe mode unless the viewfinder stream is not active.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add operations to get and set control and to retrieve the informations
on a V4L2 control. For simple camera sensors, the operations are
directly called on the underlying V4L2 subdevice.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Implement getControls() and setControls() operations in V4L2Device class.
Both operations take a V4L2Controls instance and read or write the V4L2
controls on the V4L2 device.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Enumerate all the valid controls a device supports at open() time.
A control is valid only if its type is supported.
Store the control information in a map inside the device to save
querying the control when setting or getting its value from the device
and provide an operation to retrieve information by control ID.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add libcamera V4L2 control support, implemented using the V4L2 Extended
Control APIs. This patch defines the types used to create and manage
controls.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
libc++ is used by Chrome OS, and likely as well by other environments
based on clang. Using it by default if available when compiling with
clang will help extending the compile-testing coverage. The drawback is
that issues specific to clang with libstdc++ will not be caught as
easily, but based on the experience with clang so far, code compiling
correctly with gcc/libstdc++ has failed with clang due to either
clang-specific or libc++-specific behaviour, never due only to the
combination of clang with libstdc++.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Include errno.h header to fix missing definition of -EEXIST error code:
src/libcamera/formats.cpp:43:11: error: use of undeclared identifier 'EEXIST'
Fixes: 1cf709b1d2bb ("libcamera: formats: Add ImageFormats")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The file uses the std::array class but doesn't include the corresponding
header. This breaks compilation with clang and libc++. Fix it.
Fixes: 63c578ed9993 ("libcamera: stream: Add StreamFormats")
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>
|
|
Now that we have V4L2Device and V4L2VideoDevice update the documentation
of the latter to use "video device" every time the term "device" was
used in the V4L2 context.
While at it clean up by removing a stale todo entry.
Documentation only change, no functional changes intended.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The V4L2 devices and subdevices share a few common operations,like
opening and closing a device node, and perform IOCTLs on the device.
With the forthcoming introduction of support for V4L2 controls, the
quantity of shared code will increase, as the control support
implementation is identical for the two derived classes.
To maximize code re-use and avoid duplications, provide a V4L2Device
base class which groups the common operations and members.
The newly introduced base class provides methods to open/close a device
node, access the file descriptor, and perform IOCTLs on the device.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
In preparation of creating a new V4L2Device base class, rename
V4L2Device to V4L2VideoDevice.
This is a project wide rename without any intended functional change.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Integer options have to use base 10. This isn't user-friendly when
specifying pixel formats. Detect the base automatically to support base
16. As a side effect, integer values starting with 0 will be interpreted
in base 8.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
Extend the uvcvideo pipeline with format information and validation. The
format information is gathered by enumerating the v4l2 device. This
enumeration approach is valid for UVC as it has a static and simple
media graph.
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>
|
|
Add a new option to the cam tool that prints information about the
configuration supplied by the user. If the option is specified,
information about the configuration is printed after the configuration
has been verified and possibly adjusted by the camera.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Use CameraConfiguration::validate() to validate and possibly update the
camera configuration when its prepared.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Most of the camera configuration preparation that is done in the
Capture module is not specific to capturing and could be useful for
other modules. Extract the generic parts to CamApp and do basic
preparation of the configuration before passing it to modules.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Test that both discrete and range based stream format descriptions
result in good discrete frame sizes. The range based stream formats
needs to be fitted with a table of resolutions inside libcamera so if
that table is updated this test might need to be updated.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Allow StreamFormats to be associated to a StreamConfiguration. The
intention is that pipeline handlers should associate formats to a
StreamConfiguration when it's created in generateConfiguration().
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>
|
|
Add a StreamFormats class which describes all the formats supported by a
stream. The object does not collect any information itself but can
simplify user interactions with formats as it's able to translate a
stream format range into a discrete list and a discrete list to a range.
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>
|
|
Add methods to enumerate pixelformats and frame sizes from a V4L2
device. The interface is similar to how V4L2Subdevice enumerates mbus
codes and frame sizes.
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>
|
|
Replace all usage of FormatEnum with ImageFormats and completely
remove FormatEnum which is no longer needed.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Align the enumPadSizes() interface and implementation with that of
enumPadCodes(). There is 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>
|
|
Simplify frame size enumeration by breaking out mbus code enumeration in
a helper, making the code easier to read while also preparing for
enhancing the frame size enumeration. There is 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>
|
|
Add a new class to hold format information for V4L2 devices and
subdevices. The object describes the relationship between either pixel
formats (V4L2 devices) or media bus codes (V4L2 subdevice) and a list of
image sizes which can be produced with that format.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add a method to check if a Size can fit inside a SizeRange. When
determining if a size is containable take step values into account if
they are not set to 0.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
It's useful to be able to print a string representation of a SizeRange
to the log or console, add a toString() method. While at it turn the
structure into a class as it contains functions as well as data.
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 size range described might be subject to certain step
limitations. Make it possible to record this information.
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 SizeRange can describe a single size where min == max. Add a
constructor to help create such a description.
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>
|
|
As camera names can be cumbersome to type, selection of cameras by index
from a list can be useful. Print the list of detected cameras with an
index for each item, and interpret the camera name as an index if it is
a numerical value in the range from 1 to the number of cameras.
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>
|
|
Add a test to verify media bus codes, sizes and resolution retrieval
through the CameraSensor API based on the Sensor A in the vimc pipeline.
Also check that the getFormat() method returns the expected media bus
code and size.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
According to the documentation, the CameraSensor::getFormat() method
should select the first media bus code from the mbusCodes parameter that
is supported by the sensor. However, the current implementation wrongly
selects the first media bus code from the codes supported by the sensor
that is listed in the mbusCodes parameter. This results in the
preference order specified by the caller being ignored. Fix it.
Signed-off-by: Mickael Guene <mickael.guene@st.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
If the environment variable LIBCAMERA_IPA_MODULE_PATH is not set
utils::secure_getenv() will return a nullptr. Assigning a nullptr to a
std::string is not valid and results in a crash,
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Fix this by operating directly on the returned char array instead of
turning it into a std::string.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Upstream commit 2978a505aaa981b2 ("media: vimc: stream: fix thread state
before sleep") changes the frame rate when capturing from the vimc raw
capture video nodes. The commit changes the frame rate from thousands of
frames per second to to roughly fifty.
The libcamera capture test was written with the assumption that vimc
would keep providing this fast frame rate and ran for a very short time
to decrease the overall run time of tests. This is no longer possible
and the test fails as it can't capture enough frames in its runtime,
increase the runtime to match the new vimc frame rate.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Match the style of the SizeRange() which specifies the hStep and vStep,
and wrap the lines in pairs of min and max values.
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|