summaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLuca Ceresoli <luca@lucaceresoli.net>2019-06-13 10:18:22 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-06-21 17:04:03 -0400
commite36160b84253d7125d0fa4109a3d69f0c55fc5d0 (patch)
tree8322d6a64fb73f3c0697e5afe8dad494d1d12a82 /Documentation
parent9e75efb0f2c56c7285f28bba877da14f428a730c (diff)
downloadlinux-e36160b84253d7125d0fa4109a3d69f0c55fc5d0.tar.gz
linux-e36160b84253d7125d0fa4109a3d69f0c55fc5d0.tar.bz2
linux-e36160b84253d7125d0fa4109a3d69f0c55fc5d0.zip
media: docs: v4l2-controls: rearrange control initialization sequence
The code snippet showing how to add controls to the driver’s top-level struct is present twice, but only the second time it is split in the V4L2 and subdev cases. Consolidate everything at the beginning. Also remove the "Where foo->bar is of type struct baz" sentences, this obvious from the code. Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/media/kapi/v4l2-controls.rst40
1 files changed, 17 insertions, 23 deletions
diff --git a/Documentation/media/kapi/v4l2-controls.rst b/Documentation/media/kapi/v4l2-controls.rst
index 0c3f486727ed..5281c9b1fd66 100644
--- a/Documentation/media/kapi/v4l2-controls.rst
+++ b/Documentation/media/kapi/v4l2-controls.rst
@@ -52,15 +52,29 @@ Basic usage for V4L2 and sub-device drivers
1.1) Add the handler to your driver's top-level struct:
+For V4L2 drivers:
+
.. code-block:: none
struct foo_dev {
...
+ struct v4l2_device v4l2_dev;
+ ...
struct v4l2_ctrl_handler ctrl_handler;
...
};
- struct foo_dev *foo;
+For sub-device drivers:
+
+.. code-block:: none
+
+ struct foo_dev {
+ ...
+ struct v4l2_subdev sd;
+ ...
+ struct v4l2_ctrl_handler ctrl_handler;
+ ...
+ };
1.2) Initialize the handler:
@@ -74,43 +88,23 @@ information. It is a hint only.
1.3) Hook the control handler into the driver:
-1.3.1) For V4L2 drivers do this:
+For V4L2 drivers:
.. code-block:: none
- struct foo_dev {
- ...
- struct v4l2_device v4l2_dev;
- ...
- struct v4l2_ctrl_handler ctrl_handler;
- ...
- };
-
foo->v4l2_dev.ctrl_handler = &foo->ctrl_handler;
-Where foo->v4l2_dev is of type struct v4l2_device.
-
Finally, remove all control functions from your v4l2_ioctl_ops (if any):
vidioc_queryctrl, vidioc_query_ext_ctrl, vidioc_querymenu, vidioc_g_ctrl,
vidioc_s_ctrl, vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls.
Those are now no longer needed.
-1.3.2) For sub-device drivers do this:
+For sub-device drivers:
.. code-block:: none
- struct foo_dev {
- ...
- struct v4l2_subdev sd;
- ...
- struct v4l2_ctrl_handler ctrl_handler;
- ...
- };
-
foo->sd.ctrl_handler = &foo->ctrl_handler;
-Where foo->sd is of type struct v4l2_subdev.
-
1.4) Clean up the handler at the end:
.. code-block:: none