115 lines
3.8 KiB
Diff
115 lines
3.8 KiB
Diff
From 67429ff939ad15a313663a05461d7a07d209449f Mon Sep 17 00:00:00 2001
|
|
From: Jacopo Mondi <jacopo@jmondi.org>
|
|
Date: Sat, 9 May 2020 11:04:52 +0200
|
|
Subject: [PATCH] media: v4l2-ctrls: Add helper to register
|
|
properties
|
|
|
|
Add an helper function to v4l2-ctrls to register controls associated
|
|
with a device property.
|
|
|
|
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
|
|
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
|
|
|
|
Commit e0a360630debdf12355d9ec9f1417172c3fa6756 upstream
|
|
|
|
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
---
|
|
drivers/media/v4l2-core/v4l2-ctrls.c | 40 ++++++++++++++++++++++++++++
|
|
include/media/v4l2-ctrls.h | 26 ++++++++++++++++++
|
|
2 files changed, 66 insertions(+)
|
|
|
|
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
|
|
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
|
|
@@ -17,6 +17,7 @@
|
|
#include <media/v4l2-ctrls.h>
|
|
#include <media/v4l2-event.h>
|
|
#include <media/v4l2-dev.h>
|
|
+#include <media/v4l2-fwnode.h>
|
|
|
|
#define dprintk(vdev, fmt, arg...) do { \
|
|
if (!WARN_ON(!(vdev)) && ((vdev)->dev_debug & V4L2_DEV_DEBUG_CTRL)) \
|
|
@@ -4578,3 +4579,42 @@ __poll_t v4l2_ctrl_poll(struct file *fil
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(v4l2_ctrl_poll);
|
|
+
|
|
+int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,
|
|
+ const struct v4l2_ctrl_ops *ctrl_ops,
|
|
+ const struct v4l2_fwnode_device_properties *p)
|
|
+{
|
|
+ if (p->orientation != V4L2_FWNODE_PROPERTY_UNSET) {
|
|
+ u32 orientation_ctrl;
|
|
+
|
|
+ switch (p->orientation) {
|
|
+ case V4L2_FWNODE_ORIENTATION_FRONT:
|
|
+ orientation_ctrl = V4L2_CAMERA_ORIENTATION_FRONT;
|
|
+ break;
|
|
+ case V4L2_FWNODE_ORIENTATION_BACK:
|
|
+ orientation_ctrl = V4L2_CAMERA_ORIENTATION_BACK;
|
|
+ break;
|
|
+ case V4L2_FWNODE_ORIENTATION_EXTERNAL:
|
|
+ orientation_ctrl = V4L2_CAMERA_ORIENTATION_EXTERNAL;
|
|
+ break;
|
|
+ default:
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ if (!v4l2_ctrl_new_std_menu(hdl, ctrl_ops,
|
|
+ V4L2_CID_CAMERA_ORIENTATION,
|
|
+ V4L2_CAMERA_ORIENTATION_EXTERNAL, 0,
|
|
+ orientation_ctrl))
|
|
+ return hdl->error;
|
|
+ }
|
|
+
|
|
+ if (p->rotation != V4L2_FWNODE_PROPERTY_UNSET) {
|
|
+ if (!v4l2_ctrl_new_std(hdl, ctrl_ops,
|
|
+ V4L2_CID_CAMERA_SENSOR_ROTATION,
|
|
+ p->rotation, p->rotation, 1,
|
|
+ p->rotation))
|
|
+ return hdl->error;
|
|
+ }
|
|
+
|
|
+ return hdl->error;
|
|
+}
|
|
+EXPORT_SYMBOL(v4l2_ctrl_new_fwnode_properties);
|
|
--- a/include/media/v4l2-ctrls.h
|
|
+++ b/include/media/v4l2-ctrls.h
|
|
@@ -29,6 +29,7 @@ struct v4l2_ctrl_handler;
|
|
struct v4l2_ctrl_helper;
|
|
struct v4l2_ctrl;
|
|
struct video_device;
|
|
+struct v4l2_fwnode_device_properties;
|
|
struct v4l2_subdev;
|
|
struct v4l2_subscribed_event;
|
|
struct v4l2_fh;
|
|
@@ -1379,4 +1380,29 @@ int v4l2_ctrl_subdev_subscribe_event(str
|
|
*/
|
|
int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
|
|
|
|
+/**
|
|
+ * v4l2_ctrl_new_fwnode_properties() - Register controls for the device
|
|
+ * properties
|
|
+ *
|
|
+ * @hdl: pointer to &struct v4l2_ctrl_handler to register controls on
|
|
+ * @ctrl_ops: pointer to &struct v4l2_ctrl_ops to register controls with
|
|
+ * @p: pointer to &struct v4l2_fwnode_device_properties
|
|
+ *
|
|
+ * This function registers controls associated to device properties, using the
|
|
+ * property values contained in @p parameter, if the property has been set to
|
|
+ * a value.
|
|
+ *
|
|
+ * Currently the following v4l2 controls are parsed and registered:
|
|
+ * - V4L2_CID_CAMERA_ORIENTATION
|
|
+ * - V4L2_CID_CAMERA_SENSOR_ROTATION;
|
|
+ *
|
|
+ * Controls already registered by the caller with the @hdl control handler are
|
|
+ * not overwritten. Callers should register the controls they want to handle
|
|
+ * themselves before calling this function.
|
|
+ *
|
|
+ * Return: 0 on success, a negative error code on failure.
|
|
+ */
|
|
+int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,
|
|
+ const struct v4l2_ctrl_ops *ctrl_ops,
|
|
+ const struct v4l2_fwnode_device_properties *p);
|
|
#endif
|