aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-22 08:31:16 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-23 07:04:21 -0400
commit46f74f1d3efe6608a6cfc7e3bb653b5f11f87a15 (patch)
tree98e93426564e479abba254a9d5cd6e30208b5d55 /Documentation/media
parent378d4a54aec014b8d2e8ed2ac6bb985e7371c098 (diff)
[media] v4l2-fh.rst: add cross references and markups
Add cross-references with the kernel-doc functions/structs and improve the markups. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'Documentation/media')
-rw-r--r--Documentation/media/kapi/v4l2-fh.rst111
1 files changed, 56 insertions, 55 deletions
diff --git a/Documentation/media/kapi/v4l2-fh.rst b/Documentation/media/kapi/v4l2-fh.rst
index f39374262d3f..a212698d5725 100644
--- a/Documentation/media/kapi/v4l2-fh.rst
+++ b/Documentation/media/kapi/v4l2-fh.rst
@@ -1,27 +1,35 @@
1V4L2 File handlers 1V4L2 File handlers
2------------------ 2------------------
3 3
4struct v4l2_fh provides a way to easily keep file handle specific data 4struct :c:type:`v4l2_fh` provides a way to easily keep file handle specific
5that is used by the V4L2 framework. New drivers must use struct v4l2_fh 5data that is used by the V4L2 framework.
6since it is also used to implement priority handling (VIDIOC_G/S_PRIORITY).
7 6
8The users of v4l2_fh (in the V4L2 framework, not the driver) know 7.. attention::
9whether a driver uses v4l2_fh as its file->private_data pointer by 8 New drivers must use struct :c:type:`v4l2_fh`
10testing the V4L2_FL_USES_V4L2_FH bit in video_device->flags. This bit is 9 since it is also used to implement priority handling
11set whenever v4l2_fh_init() is called. 10 (:ref:`VIDIOC_G_PRIORITY`).
12 11
13struct v4l2_fh is allocated as a part of the driver's own file handle 12The users of :c:type:`v4l2_fh` (in the V4L2 framework, not the driver) know
14structure and file->private_data is set to it in the driver's open 13whether a driver uses :c:type:`v4l2_fh` as its ``file->private_data`` pointer
14by testing the ``V4L2_FL_USES_V4L2_FH`` bit in :c:type:`video_device`->flags.
15This bit is set whenever :cpp:func:`v4l2_fh_init` is called.
16
17struct :c:type:`v4l2_fh` is allocated as a part of the driver's own file handle
18structure and ``file->private_data`` is set to it in the driver's ``open()``
15function by the driver. 19function by the driver.
16 20
17In many cases the struct v4l2_fh will be embedded in a larger structure. 21In many cases the struct :c:type:`v4l2_fh` will be embedded in a larger
18In that case you should call v4l2_fh_init+v4l2_fh_add in open() and 22structure. In that case you should call:
19v4l2_fh_del+v4l2_fh_exit in release(). 23
24#) :cpp:func:`v4l2_fh_init` and :cpp:func:`v4l2_fh_add` in ``open()``
25#) :cpp:func:`v4l2_fh_del` and :cpp:func:`v4l2_fh_exit` in ``release()``
20 26
21Drivers can extract their own file handle structure by using the container_of 27Drivers can extract their own file handle structure by using the container_of
22macro. Example: 28macro.
29
30Example:
23 31
24.. code-block:: none 32.. code-block:: c
25 33
26 struct my_fh { 34 struct my_fh {
27 int blah; 35 int blah;
@@ -63,73 +71,66 @@ macro. Example:
63 return 0; 71 return 0;
64 } 72 }
65 73
66Below is a short description of the v4l2_fh functions used: 74Below is a short description of the :c:type:`v4l2_fh` functions used:
67 75
68.. code-block:: none 76:cpp:func:`v4l2_fh_init <v4l2_fh_init>`
77(:c:type:`fh <v4l2_fh>`, :c:type:`vdev <video_device>`)
69 78
70 void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
71 79
72 Initialise the file handle. This *MUST* be performed in the driver's 80- Initialise the file handle. This **MUST** be performed in the driver's
73 v4l2_file_operations->open() handler. 81 :c:type:`v4l2_file_operations`->open() handler.
74 82
75.. code-block:: none
76 83
77 void v4l2_fh_add(struct v4l2_fh *fh) 84:cpp:func:`v4l2_fh_add <v4l2_fh_add>`
85(:c:type:`fh <v4l2_fh>`)
78 86
79 Add a v4l2_fh to video_device file handle list. Must be called once the 87- Add a :c:type:`v4l2_fh` to :c:type:`video_device` file handle list.
80 file handle is completely initialized. 88 Must be called once the file handle is completely initialized.
81 89
82.. code-block:: none 90:cpp:func:`v4l2_fh_del <v4l2_fh_del>`
91(:c:type:`fh <v4l2_fh>`)
83 92
84 void v4l2_fh_del(struct v4l2_fh *fh) 93- Unassociate the file handle from :c:type:`video_device`. The file handle
85
86 Unassociate the file handle from video_device(). The file handle
87 exit function may now be called. 94 exit function may now be called.
88 95
89.. code-block:: none 96:cpp:func:`v4l2_fh_exit <v4l2_fh_exit>`
90 97(:c:type:`fh <v4l2_fh>`)
91 void v4l2_fh_exit(struct v4l2_fh *fh)
92 98
93 Uninitialise the file handle. After uninitialisation the v4l2_fh 99- Uninitialise the file handle. After uninitialisation the :c:type:`v4l2_fh`
94 memory can be freed. 100 memory can be freed.
95 101
96 102
97If struct v4l2_fh is not embedded, then you can use these helper functions: 103If struct :c:type:`v4l2_fh` is not embedded, then you can use these helper functions:
98 104
99.. code-block:: none 105:cpp:func:`v4l2_fh_open <v4l2_fh_open>`
106(struct file \*filp)
100 107
101 int v4l2_fh_open(struct file *filp) 108- This allocates a struct :c:type:`v4l2_fh`, initializes it and adds it to
109 the struct :c:type:`video_device` associated with the file struct.
102 110
103 This allocates a struct v4l2_fh, initializes it and adds it to the struct 111:cpp:func:`v4l2_fh_release <v4l2_fh_release>`
104 video_device associated with the file struct. 112(struct file \*filp)
105 113
106.. code-block:: none 114- This deletes it from the struct :c:type:`video_device` associated with the
107 115 file struct, uninitialised the :c:type:`v4l2_fh` and frees it.
108 int v4l2_fh_release(struct file *filp)
109
110 This deletes it from the struct video_device associated with the file
111 struct, uninitialised the v4l2_fh and frees it.
112
113These two functions can be plugged into the v4l2_file_operation's open() and
114release() ops.
115 116
117These two functions can be plugged into the v4l2_file_operation's ``open()``
118and ``release()`` ops.
116 119
117Several drivers need to do something when the first file handle is opened and 120Several drivers need to do something when the first file handle is opened and
118when the last file handle closes. Two helper functions were added to check 121when the last file handle closes. Two helper functions were added to check
119whether the v4l2_fh struct is the only open filehandle of the associated 122whether the :c:type:`v4l2_fh` struct is the only open filehandle of the
120device node: 123associated device node:
121
122.. code-block:: none
123
124 int v4l2_fh_is_singular(struct v4l2_fh *fh)
125 124
126 Returns 1 if the file handle is the only open file handle, else 0. 125:cpp:func:`v4l2_fh_is_singular <v4l2_fh_is_singular>`
126(:c:type:`fh <v4l2_fh>`)
127 127
128.. code-block:: none 128- Returns 1 if the file handle is the only open file handle, else 0.
129 129
130 int v4l2_fh_is_singular_file(struct file *filp) 130:cpp:func:`v4l2_fh_is_singular_file <v4l2_fh_is_singular_file>`
131(struct file \*filp)
131 132
132 Same, but it calls v4l2_fh_is_singular with filp->private_data. 133- Same, but it calls v4l2_fh_is_singular with filp->private_data.
133 134
134 135
135V4L2 File Handler kAPI 136V4L2 File Handler kAPI