Commit graph

572 commits

Author SHA1 Message Date
Laurent Pinchart
91a65e9ee6 utils: checkstyle.py: Add Doxygen formatter
Add a formatter for doxygen comments. In its initial implementation the
formatter ensures that the first word of a \return statement starts with
an uppercase letter.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-07-04 14:58:11 +03:00
Jacopo Mondi
79e03cdf40 libcamera: v4l2_videodevice: Re-group operations
Group together operations to enumerate formats and operations to handle
memory handling, alternating public and private operations but
respecting the ordering within each group. Cosmetic change only.

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>
2019-07-04 11:17:29 +02:00
Paul Elder
851bf31df8 libcamera: ipa_module: elfLoadSymbol find symbol regardless of size
Make elfLoadSymbol more generic by making the symbol size an output
rather than an input. Also move the memcpy out of elfLoadSymbol.

If the size of struct IPAModuleInfo changes between versions, we still
want to be able to load it and perhaps do conversions for backwards
compatibility. In this case the size should not be a restriction when
searching for the symbol.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-04 11:51:29 +09:00
Paul Elder
d68a29771f libcamera: ipa_module: add path to module loading error message
Add an error message to tell, if an IPA module failed to load, the
path to the IPA module shared object that was attempted to be loaded.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-04 11:51:01 +09:00
Paul Elder
83e3300a2d libcamera: ipa_module: add path getter
Add a method to IPAModule to get the path of the IPA module shared
object that the IPAModule was constructed from.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-02 23:18:03 +09:00
Paul Elder
0c2f97a0ab libcamera: ipa_module_info: remove cplusplus guards
IPA modules must be implemented in C++, which means we no longer need
__cplusplus guards, so remove them.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-02 23:18:03 +09:00
Kieran Bingham
6481c71a61 libcamera: test: Add ControlList tests
Add tests of the ControlList infrastructure and public API.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-02 16:59:53 +03:00
Kieran Bingham
41c184afc3 libcamera: test: Add ControlInfo test
Provide an initial test coverage for the ControlInfo class.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-02 16:59:49 +03:00
Kieran Bingham
4cbf83da40 libcamera: test: Add ControlValue test
Add initial basic testing for the new ControlValue class.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-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>
2019-07-02 16:59:46 +03:00
Laurent Pinchart
9ea9dc5830 libcamera: pipeline: vimc: Add controls support
Implement control support in the VIMC pipeline handler by dynamically
querying the V4L2 device for the supported V4L2 controls and populating
the list of camera controls accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-07-02 16:59:43 +03:00
Kieran Bingham
e441f2c7f4 libcamera: pipeline: uvcvideo: Add controls support
Implement control support in the UVC pipeline handler by dynamically
querying the V4L2 device for the supported V4L2 controls and populating
the list of camera controls accordingly.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-07-02 16:59:38 +03:00
Laurent Pinchart
57d9d25a0e libcamera: controls: Add a set of initial controls
Add an initial set of controls to demonstrate how controls are defined.

Proper documentation for each control is missing.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-07-02 16:59:36 +03:00
Kieran Bingham
b69ea51c7c libcamera: request: Add a ControlList
Provide a ControlList on request objects to facilitate setting controls.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-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>
2019-07-02 16:59:32 +03:00
Laurent Pinchart
0adc13ff76 libcamera: controls: Extend ControlList to access controls by ID
The ControlList class implements a map from control specifier to control
ID. To avoid constant lookups of ControlInfo when using the class in the
libcamera core or in pipeline handlers, the map uses ControlInfo
pointers instead of ControlId values. This is however not very
convenient for applications or pipeline handlers, as they would be
forced to first look up the ControlInfo pointers for the controls they
want to access. Facilitate ease of use of ControlLists by implementing
an internal lookup of the ControlInfo from the controls provided by the
Camera.

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>
2019-07-02 16:59:29 +03:00
Kieran Bingham
b9bf9514eb libcamera: camera: Provide a list of ControlInfo
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>
2019-07-02 16:59:28 +03:00
Kieran Bingham
20d5640ca4 libcamera: controls: Introduce control-related data types
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>
2019-07-02 16:59:20 +03:00
Laurent Pinchart
a110cc94ab libcamera: v4l2_device: Add method to retrieve all supported controls
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>
2019-07-02 16:59:19 +03:00
Laurent Pinchart
bd0245a0dc libcamera: v4l2_controls: Add min and max to V4L2ControlInfo
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>
2019-07-02 16:59:17 +03:00
Laurent Pinchart
f137451817 libcamera: ipc: unix: Make socket operation asynchronous
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>
2019-07-02 02:37:18 +03:00
Niklas Söderlund
a00fdabacd test: ipc: unix: Add test for IPCUnixSocket
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>
2019-07-02 02:25:59 +03:00
Niklas Söderlund
13dd7a01ec libcamera: ipc: unix: Add a IPC mechanism based on Unix sockets
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>
2019-07-02 02:25:49 +03:00
Laurent Pinchart
3952d49d8d test: timer: Add dynamically allocated timer test
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>
2019-07-01 23:48:37 +02:00
Niklas Söderlund
08b2e03a8a libcamera: timer: Stop timer when it is deleted
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>
2019-07-01 23:48:03 +02:00
Kieran Bingham
dba2de3a0f libcamera: Use 'files()' function to specify gen-header.sh
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: 90de3690c4 ("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>
2019-07-01 02:26:55 +03:00
Laurent Pinchart
6f0c4d0742 utils: checkstyle.py: Add meson.build checker
Add a meson.build checker that warns when tabs are used.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-01 02:24:21 +03:00
Laurent Pinchart
bc6b758c71 utils: checkstyle.py: Refactor formatters and checkers support
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>
2019-07-01 02:24:21 +03:00
Niklas Söderlund
0116a940ba libcamera: v4l2_device: Fix variable-sized object initialization
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: eb068f4e67 ("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>
2019-06-30 13:49:52 +02:00
Jacopo Mondi
6948ec44c7 libcamera: v4l2_device: Fix control enumeration bug
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: 030ce6491e ("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>
2019-06-27 10:16:10 +02:00
Kieran Bingham
caf25dc5cf libcamera: event_dispatcher_poll: Remove struct keyword from for-range
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: 8356f8a6ab ("libcamera: Add a poll-based event dispatcher")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-06-25 21:35:23 +01:00
Helen Koike
059ed93beb cam: capture: Stop stream when queueRequest() fails
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>
2019-06-25 20:40:41 +01:00
Jacopo Mondi
cb21bb3311 libcamera: ipu3: Set pipe_mode based on stream configuration
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>
2019-06-25 14:03:49 +02:00
Jacopo Mondi
3ef81b7f7f libcamera: camera_sensor: Add V4L2 control operations
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>
2019-06-25 14:01:47 +02:00
Jacopo Mondi
eb068f4e67 libcamera: v4l2_device: Implement get and set controls
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>
2019-06-25 14:01:37 +02:00
Jacopo Mondi
030ce6491e libcamera: v4l2_device: List valid controls at open
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>
2019-06-25 14:01:35 +02:00
Jacopo Mondi
bab8b01895 libcamera: Add V4L2Controls
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>
2019-06-25 14:01:17 +02:00
Laurent Pinchart
8b7a24e20f meson: Link against libc++ with compiling with clang
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>
2019-06-19 18:47:56 +03:00
Jacopo Mondi
d78fbdba87 libcamera: formats: Add missing include
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: 1cf709b1d2 ("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>
2019-06-19 17:25:17 +02:00
Laurent Pinchart
329b38d254 libcamera: stream: Include missing array header
The file uses the std::array class but doesn't include the corresponding
header. This breaks compilation with clang and libc++. Fix it.

Fixes: 63c578ed99 ("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>
2019-06-19 17:51:12 +03:00
Jacopo Mondi
e32d82e655 libcamera: v4l2_videodevice: Update documentation
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>
2019-06-19 15:46:44 +02:00
Jacopo Mondi
d6bb56a90a libcamera: Introduce V4L2Device base class
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>
2019-06-19 15:46:44 +02:00
Jacopo Mondi
3a6c4bd146 libcamera: Rename V4L2Device to V4L2VideoDevice
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>
2019-06-19 15:46:44 +02:00
Laurent Pinchart
20807a8c17 cam: Support base 16 and base 8 when parsing integer options
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>
2019-06-19 16:04:35 +03:00
Niklas Söderlund
b4f3fc1d56 libcamera: pipeline: uvcvideo: Add format information and validation
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>
2019-06-19 12:25:12 +02:00
Niklas Söderlund
802d47068b cam: Add --info option to print information about stream(s)
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>
2019-06-19 12:25:12 +02:00
Niklas Söderlund
7c856201c7 cam: Validate camera configuration
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>
2019-06-19 12:25:12 +02:00
Niklas Söderlund
afef18d35a cam: Move camera configuration preparation to CamApp
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>
2019-06-19 12:25:12 +02:00
Niklas Söderlund
5ed3a89480 test: stream: Add test for StreamFormat
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>
2019-06-19 12:25:12 +02:00
Niklas Söderlund
a502896429 libcamera: stream: StreamConfiguration: Add StreamFormats information
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>
2019-06-19 12:24:23 +02:00
Niklas Söderlund
63c578ed99 libcamera: stream: Add StreamFormats
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>
2019-06-19 12:14:37 +02:00
Niklas Söderlund
87e46f7f59 libcamera: v4l2_device: Add enumeration of pixelformats and frame sizes
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>
2019-06-19 11:54:30 +02:00