summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_device.cpp
AgeCommit message (Collapse)Author
2021-06-25libcamera/base: Move event_notifier to baseKieran Bingham
Move the event notifier, and associated header updates. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25libcamera/base: Move extended base functionalityKieran Bingham
Move the functionality for the following components to the new base support library: - BoundMethod - EventDispatcher - EventDispatcherPoll - Log - Message - Object - Signal - Semaphore - Thread - Timer While it would be preferable to see these split to move one component per commit, these components are all interdependent upon each other, which leaves us with one big change performing the move for all of them. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25libcamera/base: Move utils to the base libraryKieran Bingham
Move the utils functionality to the libcamera/base library. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-14libcamera: V4L2Device: Support v4l2 menu controlHirokazu Honda
This adds a support of v4l2 menu. The control info for v4l2 menu contains indices without names and 64bit values of querymenu. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-06-07libcamera: V4L2Device: Remove the controls order assumption in updateControls()Hirokazu Honda
The original updateControls() has the assumption that ctrls and v4l2Ctrls lists are in the same order. It is dependent on the caller implementation though. This changes updateControls() implementation so that it works without the assumption. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-25Revert "libcamera: V4L2Device: Remove the controls order assumption in ↵Laurent Pinchart
updateControls()" This reverts commit 34bee5e84ecba01e0ded5cacbc46c277c5a0edba. The commit introduced a breakage in the master branch, reported by linux-surface users already. Let's revert it while discussing the propert fix. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Tested-by: Umang Jain <umang.jain@ideasonboard.com>
2021-05-25libcamera: V4L2Device: Remove the controls order assumption in updateControls()Hirokazu Honda
The original updateControls() has the assumption that ctrls and v4l2Ctrls lists are in the same order. It is dependent on the caller implementation though. This changes updateControls() implementation so that it works without the assumption. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24libcamera: V4L2Control: remove V4L2Control classesHirokazu Honda
V4L2ControlId and V4L2ControlInfo are just convenience classes to create ControlId and ControlInfo from v4l2_query_ext_control. Therefore, there is no need of being a class. It is used only from V4L2Device. This removes the classes and put the equivalent functions of creating ControlId and ControlInfo in v4l2_device.cpp. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-11libcamera: camera_sensor: Fix frame lengths calculated by sensorInfo()David Plowman
The minimum and maximum vblanking can change when a new format is applied to the sensor subdevice, so be sure to retrieve up-to-date values. The V4L2Device acquires the new updateControlInfo() method to perform this function, and which the CameraSensor calls automatically if its setFormat method is used to update the sensor. However, not all pipeline handlers invoke the setFormat method directly, so the new method must be made publicly available for pipeline handlers to call if they need to. Signed-off-by: David Plowman <david.plowman@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>
2021-04-26libcamera: V4L2Device: Use Span in updateControls()Hirokazu Honda
V4L2Device::updateControls() takes two arguments, raw array and its size, for the v4l2_ext_control values. This replaces it with libcamera::Span. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26libcamera: V4L2Device: Replace VLA with std::vector in setControls()Hirokazu Honda
The original code uses Variable-Length-Array, which is not officially supported in C++. This replaces the array with std::vector. Signed-off-by: Hirokazu Honda <hiroh@chromium.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> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-26libcamera: V4L2Device: Replace VLA with std::vector in getControls()Hirokazu Honda
The original code uses Variable-Length-Array, which is not officially supported in C++. This replaces the array with std::vector. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
2020-11-15libcamera: Move EventDispatcher to internal APILaurent Pinchart
There's no user of the EventDispatcher (and the related EventNotifier and Timer classes) outside of libcamera. Move those classes to the internal API. 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>
2020-11-10libcamera: v4l2_device: Move start of frame detection to V4L2DeviceNiklas Söderlund
The V4L2_EVENT_FRAME_SYNC event may occur on both V4L2 video-devices (V4L2VideoDevice) and sub-devices (V4L2Subdevice). Move the start of frame detection to the common base class of the two, V4L2Device. There is no functional change. 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-10-28libcamera: v4l2_device: Remove unused set of retNiklas Söderlund
The last assignment of the ret variable in getControls() is not consumed so it's unnecessary to set it. This likely originates from a similar code flow in setControls() where the ret variable is later consumed. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-09-29libcamera: Allow access to v4l2_query_ext_ctrl structure for a V4L2 controlDavid Plowman
The V4L2Device::controlInfo method simply returns a pointer to the v4l2_query_ext_ctrl structure for the given control, which has already been retrieved and stored. 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> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-05libcamera: v4l2_device: Add method to lookup device pathNiklas Söderlund
Add a method to lookup a V4L2 devices path in sysfs. 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-05-16libcamera: Move internal headers to include/libcamera/internal/Laurent Pinchart
The libcamera internal headers are located in src/libcamera/include/. The directory is added to the compiler headers search path with a meson include_directories() directive, and internal headers are included with (e.g. for the internal semaphore.h header) #include "semaphore.h" All was well, until libcxx decided to implement the C++20 synchronization library. The __threading_support header gained a #include <semaphore.h> to include the pthread's semaphore support. As include_directories() adds src/libcamera/include/ to the compiler search path with -I, the internal semaphore.h is included instead of the pthread version. Needless to say, the compiler isn't happy. Three options have been considered to fix this issue: - Use -iquote instead of -I. The -iquote option instructs gcc to only consider the header search path for headers included with the "" version. Meson unfortunately doesn't support this option. - Rename the internal semaphore.h header. This was deemed to be the beginning of a long whack-a-mole game, where namespace clashes with system libraries would appear over time (possibly dependent on particular system configurations) and would need to be constantly fixed. - Move the internal headers to another directory to create a unique namespace through path components. This causes lots of churn in all the existing source files through the all project. The first option would be best, but isn't available to us due to missing support in meson. Even if -iquote support was added, we would need to fix the problem before a new version of meson containing the required support would be released. The third option is thus the only practical solution available. Bite the bullet, and do it, moving headers to include/libcamera/internal/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-28libcamera: v4l2_device: Simplify usage of getControls()Laurent Pinchart
The V4L2Device::getControls() function takes a ControlList that needs to be pre-populated with dummy entries for the controls that need to be read. This is a cumbersome API, especially when reading a single control. Make it nicer by passing the list of V4L2 controls as a vector of control IDs, and returning a ControlList. 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>
2020-04-26libcamera: v4l2_device: Update documentationJacopo Mondi
Compound controls are now supported, but they're still listed as unsupported in some parts of the V4L2Device class documentation. Fix this by removing those parts. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-03-23libcamera: v4l2_device: Enable enumeration of U8 controlsJacopo Mondi
Enable the enumeration of V4L2 array controls with V4L2_CTRL_TYPE_U8 type. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-03-23libcamera: v4l2_device: Support reading U8 array controlsJacopo Mondi
Add support to retrieve the value of array controls of type V4L2_CTRL_TYPE_U8. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-03-23libcamera: v4l2_device: Support writing array U8 controlsJacopo Mondi
Add support to write array controls of type V4L2_CTRL_TYPE_U8. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-03-23libcamera: v4l2_controls: Cache query control informationJacopo Mondi
Cache the V4L2 control info retrieved with VIDIOC_QUERY_EXT_CTRL at control listing time for later use. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-03-20libcamera: controls: Rename ControlRange to ControlInfoLaurent Pinchart
To prepare for storage of additional information in the ControlRange structure, rename it to ControlInfo. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-03-20libcamera: v4l2_controls: Fix usage of strerror()Jacopo Mondi
On failure, the return code from V4L2Device::ioctl() is the negative error code set by the failed ::ioctl() system call. When the return code of V4L2Device::ioctl() is provided to strerror() it has to be negated again to obtain the positive error code. Fix a few wrong usages of the return code which provided to the strerror() function a negative error code. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-01-14libcamera: Switch from utils::make_unique to std::make_uniqueLaurent Pinchart
Now that we're using C++-14, drop utils::make_unique for std::make_unique. 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>
2020-01-03libcamera: v4l2_device, v4l2_videodevice: call open system call directlyPaul Elder
We are preparing to integrate the V4L2 adaptation layer, which will intercept open() calls (among others) via LD_PRELOAD. To prevent libcamera's own open() calls from being intercepted, replace them with a direct syscall. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-11-20libcamera: controls: Index ControlList by unsigned intLaurent Pinchart
In preparation for serialization, index the ControlList by unsigned int. This will allow deserializing a ControlList without requiring external information. 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>
2019-10-15libcamera: controls: Merge ControlInfoMap and V4L2ControlInfoMapLaurent Pinchart
The ControlInfoMap and V4L2ControlInfoMap classes are very similar, with the latter adding convenience accessors based on numerical IDs for the former, as well as a cached idmap. Both features can be useful for ControlInfoMap in the context of serialisation, and merging the two classes will further simplify the IPA API. Import all the features of V4L2ControlInfoMap into ControlInfoMap, turning the latter into a real class. A few new constructors and assignment operators are added for completeness. 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>
2019-10-15libcamera: v4l2_controls: Derive V4L2ControlInfoMap from ControlInfoMapLaurent Pinchart
Replace the std::map<> used as the base type for V4L2ControlInfoMap by ControlInfoMap, which is an alias for an std::unsorted_map<> with the same key and value types. This shortens the code. 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>
2019-10-15libcamera: v4l2_controls: Store a ControlRange in V4L2ControlInfoMapLaurent Pinchart
V4L2ControlRange only offers a convenience constructor for a ControlRange. Store the ControlRange instead of V4L2ControlRange in V4L2ControlInfoMap to make the map less dependent on V4L2 types. 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>
2019-10-15libcamera: v4l2_controls: Replace V4L2ControlInfo with V4L2ControlRangeLaurent Pinchart
The V4L2ControlInfo class only stores a ControlRange. Make it inherit from ControlRange to provide a convenience constructor from a struct v4l2_query_ext_ctrl and rename it to V4L2ControlRange. 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>
2019-10-15libcamera: v4l2_controls: Index V4L2ControlInfoMap by ControlId *Laurent Pinchart
To bring the libcamera and V4L2 control info maps closer, index the latter by ControlId * like the former. As V4L2ControlInfoMap is widely indexed by V4L2 numerical IDs, add accessors based on numerical IDs. This allows complete removal of the ControId pointer from the V4L2ControlInfo, as the ControId is accessible as the key when iterating over the map. A handful of users have to be modified to adapt to the change. The controlInfo argument from V4L2Device::updateControls() can also be removed as it itsn't used anymore. 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>
2019-10-15libcamera: v4l2_controls: Move V4L2ControlId out of V4L2ControlInfoJacopo Mondi
In order to reconcile the libcamera and V4L2 control info maps, we need to move the V4L2ControlId embedded in V4L2ControlInfo map out of the class. Store the V4L2ControlId instances in the V4L2Device that creates them, and only reference them from V4L2ControlInfo. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> 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>
2019-10-15libcamera: v4l2_controls: Remove V4L2ControlInfo::size()Laurent Pinchart
We don't support V4L2 compound controls, the size field is thus unused. Remove it to ease merging of the libcamera and V4L2 control info classes. Support for array controls can then be added later on top, and would be useful for libcamera controls too. 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>
2019-10-15libcamera: v4l2_device: Print control ID in unknown type log messaggeLaurent Pinchart
When the type of a control enumerated from a V4L2 device is not supported, we log a debug message that mentions the control type. This makes it hard to figure out which control is faulty. Print the control ID instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-13libcamera: v4l2_device: Replace V4L2ControlList with ControlListLaurent Pinchart
The V4L2Device class uses V4L2ControlList as a controls container for the getControls() and setControls() operations. Having a distinct container from ControlList will makes the IPA API more complex, as it needs to explicitly transport both types of lists. This will become even more painful when implementing serialisation and deserialisation. To simplify the IPA API and ease the implementation of serialisation and deserialisation, replace usage of V4L2ControlList with ControlList in the V4L2Device (and thus CameraSensor) API. The V4L2ControlList class becomes a thin wrapper around ControlList that slightly simplifies the creation of control lists for V4L2 controls, and may be removed in the future. 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> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-13libcamera: v4l2_controls: Turn V4L2ControlInfoMap into a classLaurent Pinchart
In preparation for extending V4L2ControlInfoMap with control idmap support, turn it into a real class. Make it inherit from std::map<> instead of wrapping it to keep the API simple. V4L2ControlInfoMap is meant to be constructed with a set of control info, and never modified afterwards. To ensure this, inherit from std::map<> with private access specifier, and explicitly expose the std::map<> methods that do not allow insertion or removal of elements. A custom move assignment operator is implemented to allow efficient construction of the V4L2ControlInfoMap. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-13libcamera: v4l2_controls: Remove V4L2ControlInfo type fieldLaurent Pinchart
The V4L2ControlInfo type field stores the V4L2 control type. It partly duplicates the V4L2ControlInfo id().type() that stores the corresponding libcamera control type. The two fields are not strictly identical, but having two types doesn't provide us with any extra value. As this is confusing, remove the V4L2ControlInfo type field. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-13libcamera: v4l2_controls: Add V4L2ControlIdLaurent Pinchart
Add a V4L2 specialisation of the ControlId class, in order to construct a ControlId from a v4l2_query_ext_ctrl. The V4L2ControlId is embedded in V4L2ControlInfo, and thus needs to be copyable to allow for V4L2ControlInfo to be passed to IPAs. The ControlId copy constructor and assignment operators are thus restored, but made protected to avoid the Control class being copyable. This is needed in order to use ControlList for V4L2 controls, as ControlList requires ControlId instances for all controls. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-13libcamera: v4l2_device: Avoid copy of V4L2ControlInfoLaurent Pinchart
The V4L2Device::listControls() method creates an instance of V4L2ControlInfo and then inserts it in the device's list of controls. The insertion uses std::map::emplace(), but passes the V4L2ControlInfo, resulting in a copy being performed (using the copy constructor of V4L2ControlInfo). Optimise this by really constructing the V4L2ControlInfo in-place. The use of std::piecewise_construct is required for gcc-5 that seems to have trouble with std::map::emplace() on non-copyable values in this case. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-05libcamera: v4l2_controls: Use the ControlValue class for data storageLaurent Pinchart
Use the ControlValue class to replace the manually crafted data storage in V4L2Control. This will help sharing code when more data types will be supported. 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-08-29libcamera: v4l2_device: Fix error messages in setControls()Niklas Söderlund
The error messages are copied from getControls() without being updated for the set controls case, fix this. Fixes: eb068f4e67eedacd ("libcamera: v4l2_device: Implement get and set controls") Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-08-13libcamera: v4l2_device: Add setFd()Kieran Bingham
Provide a means for V4L2 device instances to set the fd_ explicitly. This allows for V4L2Devices to operate when they must use an external open() call. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-07-15libcamera: Fix spellings and grammarKieran Bingham
Fix a number of spelling errors and word duplications throughout the comments within libcamera. These were picked up with spellintian. Also one capitalisation of the first word of a \return statement picked up by checkstyle.py while creating this patch. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-07-02libcamera: v4l2_device: Add method to retrieve all supported controlsLaurent Pinchart
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-06-30libcamera: v4l2_device: Fix variable-sized object initializationNiklas Söderlund
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>
2019-06-27libcamera: v4l2_device: Fix control enumeration bugJacopo Mondi
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>
2019-06-25libcamera: v4l2_device: Implement get and set controlsJacopo Mondi
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>