summaryrefslogtreecommitdiff
path: root/src/libcamera/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-06-30 15:24:08 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-07-02 16:59:19 +0300
commita110cc94ab5dfb26bf6a5eae61ea5ba2deb6d3f3 (patch)
tree60979b897f51e184cc4f2618312d696056682bc4 /src/libcamera/include
parentbd0245a0dc6ff036dc25dee1f776e03e84c02953 (diff)
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>
Diffstat (limited to 'src/libcamera/include')
-rw-r--r--src/libcamera/include/camera_sensor.h5
-rw-r--r--src/libcamera/include/v4l2_controls.h6
-rw-r--r--src/libcamera/include/v4l2_device.h9
3 files changed, 10 insertions, 10 deletions
diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h
index b42e7b8e..fe033fb3 100644
--- a/src/libcamera/include/camera_sensor.h
+++ b/src/libcamera/include/camera_sensor.h
@@ -13,12 +13,11 @@
#include <libcamera/geometry.h>
#include "log.h"
+#include "v4l2_controls.h"
namespace libcamera {
class MediaEntity;
-class V4L2ControlInfo;
-class V4L2ControlList;
class V4L2Subdevice;
struct V4L2SubdeviceFormat;
@@ -43,7 +42,7 @@ public:
const Size &size) const;
int setFormat(V4L2SubdeviceFormat *format);
- const V4L2ControlInfo *getControlInfo(unsigned int id) const;
+ const V4L2ControlInfoMap &controls() const;
int getControls(V4L2ControlList *ctrls);
int setControls(V4L2ControlList *ctrls);
diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h
index 0047efab..10b72650 100644
--- a/src/libcamera/include/v4l2_controls.h
+++ b/src/libcamera/include/v4l2_controls.h
@@ -8,11 +8,11 @@
#ifndef __LIBCAMERA_V4L2_CONTROLS_H__
#define __LIBCAMERA_V4L2_CONTROLS_H__
+#include <map>
+#include <stdint.h>
#include <string>
#include <vector>
-#include <stdint.h>
-
#include <linux/v4l2-controls.h>
#include <linux/videodev2.h>
@@ -41,6 +41,8 @@ private:
int64_t max_;
};
+using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;
+
class V4L2Control
{
public:
diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
index 24a0134a..e7e9829c 100644
--- a/src/libcamera/include/v4l2_device.h
+++ b/src/libcamera/include/v4l2_device.h
@@ -13,19 +13,18 @@
#include <linux/videodev2.h>
#include "log.h"
+#include "v4l2_controls.h"
namespace libcamera {
-class V4L2ControlInfo;
-class V4L2ControlList;
-
class V4L2Device : protected Loggable
{
public:
void close();
bool isOpen() const { return fd_ != -1; }
- const V4L2ControlInfo *getControlInfo(unsigned int id) const;
+ const V4L2ControlInfoMap &controls() const { return controls_; }
+
int getControls(V4L2ControlList *ctrls);
int setControls(V4L2ControlList *ctrls);
@@ -48,7 +47,7 @@ private:
const struct v4l2_ext_control *v4l2Ctrls,
unsigned int count);
- std::map<unsigned int, V4L2ControlInfo> controls_;
+ V4L2ControlInfoMap controls_;
std::string deviceNode_;
int fd_;
};