aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-21 16:05:35 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-23 07:04:21 -0400
commit243b6935aeeccc4e4e07ded08d2e743f21af3664 (patch)
tree591f791cf6de7bfba0139ede51883baee85b911d
parent81d866fdcda8888970dc1812da927e509f429ea9 (diff)
[media] v4l2-dev: add cross-references and improve markup
Add cross-references for the functions/structs and add the markup tags to improve its display. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--Documentation/media/kapi/v4l2-dev.rst362
-rw-r--r--Documentation/media/kapi/v4l2-videobuf.rst2
-rw-r--r--Documentation/media/kapi/v4l2-videobuf2.rst2
3 files changed, 195 insertions, 171 deletions
diff --git a/Documentation/media/kapi/v4l2-dev.rst b/Documentation/media/kapi/v4l2-dev.rst
index f9b75d211ca0..306306d8a43d 100644
--- a/Documentation/media/kapi/v4l2-dev.rst
+++ b/Documentation/media/kapi/v4l2-dev.rst
@@ -1,13 +1,13 @@
1Video device creation 1Video device creation
2===================== 2=====================
3 3
4The actual device nodes in the /dev directory are created using the 4The actual device nodes in the ``/dev`` directory are created using the
5video_device struct (v4l2-dev.h). This struct can either be allocated 5:c:type:`video_device` struct (``v4l2-dev.h``). This struct can either be
6dynamically or embedded in a larger struct. 6allocated dynamically or embedded in a larger struct.
7 7
8To allocate it dynamically use: 8To allocate it dynamically use :cpp:func:`video_device_alloc`:
9 9
10.. code-block:: none 10.. code-block:: c
11 11
12 struct video_device *vdev = video_device_alloc(); 12 struct video_device *vdev = video_device_alloc();
13 13
@@ -16,100 +16,110 @@ To allocate it dynamically use:
16 16
17 vdev->release = video_device_release; 17 vdev->release = video_device_release;
18 18
19If you embed it in a larger struct, then you must set the release() 19If you embed it in a larger struct, then you must set the ``release()``
20callback to your own function: 20callback to your own function:
21 21
22.. code-block:: none 22.. code-block:: c
23 23
24 struct video_device *vdev = &my_vdev->vdev; 24 struct video_device *vdev = &my_vdev->vdev;
25 25
26 vdev->release = my_vdev_release; 26 vdev->release = my_vdev_release;
27 27
28The release callback must be set and it is called when the last user 28The ``release()`` callback must be set and it is called when the last user
29of the video device exits. 29of the video device exits.
30 30
31The default video_device_release() callback just calls kfree to free the 31The default :cpp:func:`video_device_release` callback currently
32allocated memory. 32just calls ``kfree`` to free the allocated memory.
33 33
34There is also a video_device_release_empty() function that does nothing 34There is also a ::cpp:func:`video_device_release_empty` function that does
35(is empty) and can be used if the struct is embedded and there is nothing 35nothing (is empty) and should be used if the struct is embedded and there
36to do when it is released. 36is nothing to do when it is released.
37 37
38You should also set these fields: 38You should also set these fields of :c:type:`video_device`:
39 39
40- v4l2_dev: must be set to the v4l2_device parent device. 40- :c:type:`video_device`->v4l2_dev: must be set to the :c:type:`v4l2_device`
41 41 parent device.
42- name: set to something descriptive and unique. 42
43 43- :c:type:`video_device`->name: set to something descriptive and unique.
44- vfl_dir: set this to VFL_DIR_RX for capture devices (VFL_DIR_RX has value 0, 44
45 so this is normally already the default), set to VFL_DIR_TX for output 45- :c:type:`video_device`->vfl_dir: set this to ``VFL_DIR_RX`` for capture
46 devices and VFL_DIR_M2M for mem2mem (codec) devices. 46 devices (``VFL_DIR_RX`` has value 0, so this is normally already the
47 47 default), set to ``VFL_DIR_TX`` for output devices and ``VFL_DIR_M2M`` for mem2mem (codec) devices.
48- fops: set to the v4l2_file_operations struct. 48
49 49- :c:type:`video_device`->fops: set to the :c:type:`v4l2_file_operations`
50- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance 50 struct.
51 (highly recommended to use this and it might become compulsory in the 51
52 future!), then set this to your v4l2_ioctl_ops struct. The vfl_type and 52- :c:type:`video_device`->ioctl_ops: if you use the :c:type:`v4l2_ioctl_ops`
53 vfl_dir fields are used to disable ops that do not match the type/dir 53 to simplify ioctl maintenance (highly recommended to use this and it might
54 combination. E.g. VBI ops are disabled for non-VBI nodes, and output ops 54 become compulsory in the future!), then set this to your
55 are disabled for a capture device. This makes it possible to provide 55 :c:type:`v4l2_ioctl_ops` struct. The :c:type:`video_device`->vfl_type and
56 just one v4l2_ioctl_ops struct for both vbi and video nodes. 56 :c:type:`video_device`->vfl_dir fields are used to disable ops that do not
57 57 match the type/dir combination. E.g. VBI ops are disabled for non-VBI nodes,
58- lock: leave to NULL if you want to do all the locking in the driver. 58 and output ops are disabled for a capture device. This makes it possible to
59 Otherwise you give it a pointer to a struct mutex_lock and before the 59 provide just one :c:type:`v4l2_ioctl_ops struct` for both vbi and
60 unlocked_ioctl file operation is called this lock will be taken by the 60 video nodes.
61 core and released afterwards. See the next section for more details. 61
62 62- :c:type:`video_device`->lock: leave to ``NULL`` if you want to do all the
63- queue: a pointer to the struct vb2_queue associated with this device node. 63 locking in the driver. Otherwise you give it a pointer to a struct
64 If queue is non-NULL, and queue->lock is non-NULL, then queue->lock is 64 ``mutex_lock`` and before the :c:type:`video_device`->unlocked_ioctl
65 used for the queuing ioctls (VIDIOC_REQBUFS, CREATE_BUFS, QBUF, DQBUF, 65 file operation is called this lock will be taken by the core and released
66 QUERYBUF, PREPARE_BUF, STREAMON and STREAMOFF) instead of the lock above. 66 afterwards. See the next section for more details.
67 That way the vb2 queuing framework does not have to wait for other ioctls. 67
68 This queue pointer is also used by the vb2 helper functions to check for 68- :c:type:`video_device`->queue: a pointer to the struct :c:type:`vb2_queue`
69 associated with this device node.
70 If queue is not ``NULL``, and queue->lock is not ``NULL``, then queue->lock
71 is used for the queuing ioctls (``VIDIOC_REQBUFS``, ``CREATE_BUFS``,
72 ``QBUF``, ``DQBUF``, ``QUERYBUF``, ``PREPARE_BUF``, ``STREAMON`` and
73 ``STREAMOFF``) instead of the lock above.
74 That way the :ref:`vb2 <vb2_framework>` queuing framework does not have
75 to wait for other ioctls. This queue pointer is also used by the
76 :ref:`vb2 <vb2_framework>` helper functions to check for
69 queuing ownership (i.e. is the filehandle calling it allowed to do the 77 queuing ownership (i.e. is the filehandle calling it allowed to do the
70 operation). 78 operation).
71 79
72- prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY. 80- :c:type:`video_device`->prio: keeps track of the priorities. Used to
73 If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device. 81 implement ``VIDIOC_G_PRIORITY`` and ``VIDIOC_S_PRIORITY``.
74 If you want to have a separate priority state per (group of) device node(s), 82 If left to ``NULL``, then it will use the struct :c:type:`v4l2_prio_state`
75 then you can point it to your own struct v4l2_prio_state. 83 in :c:type:`v4l2_device`. If you want to have a separate priority state per
76 84 (group of) device node(s), then you can point it to your own struct
77- dev_parent: you only set this if v4l2_device was registered with NULL as 85 :c:type:`v4l2_prio_state`.
78 the parent device struct. This only happens in cases where one hardware 86
79 device has multiple PCI devices that all share the same v4l2_device core. 87- :c:type:`video_device`->dev_parent: you only set this if v4l2_device was
80 88 registered with ``NULL`` as the parent ``device`` struct. This only happens
81 The cx88 driver is an example of this: one core v4l2_device struct, but 89 in cases where one hardware device has multiple PCI devices that all share
82 it is used by both a raw video PCI device (cx8800) and a MPEG PCI device 90 the same :c:type:`v4l2_device` core.
83 (cx8802). Since the v4l2_device cannot be associated with two PCI devices 91
84 at the same time it is setup without a parent device. But when the struct 92 The cx88 driver is an example of this: one core :c:type:`v4l2_device` struct,
85 video_device is initialized you *do* know which parent PCI device to use and 93 but it is used by both a raw video PCI device (cx8800) and a MPEG PCI device
86 so you set dev_device to the correct PCI device. 94 (cx8802). Since the :c:type:`v4l2_device` cannot be associated with two PCI
87 95 devices at the same time it is setup without a parent device. But when the
88If you use v4l2_ioctl_ops, then you should set .unlocked_ioctl to video_ioctl2 96 struct :c:type:`video_device` is initialized you **do** know which parent
89in your v4l2_file_operations struct. 97 PCI device to use and so you set ``dev_device`` to the correct PCI device.
90 98
91Do not use .ioctl! This is deprecated and will go away in the future. 99If you use :c:type:`v4l2_ioctl_ops`, then you should set
100:c:type:`video_device`->unlocked_ioctl to :cpp:func:`video_ioctl2` in your
101:c:type:`v4l2_file_operations` struct.
92 102
93In some cases you want to tell the core that a function you had specified in 103In some cases you want to tell the core that a function you had specified in
94your v4l2_ioctl_ops should be ignored. You can mark such ioctls by calling this 104your :c:type:`v4l2_ioctl_ops` should be ignored. You can mark such ioctls by
95function before video_device_register is called: 105calling this function before :cpp:func:`video_register_device` is called:
96
97.. code-block:: none
98 106
99 void v4l2_disable_ioctl(struct video_device *vdev, unsigned int cmd); 107 :cpp:func:`v4l2_disable_ioctl <v4l2_disable_ioctl>`
108 (:c:type:`vdev <video_device>`, cmd).
100 109
101This tends to be needed if based on external factors (e.g. which card is 110This tends to be needed if based on external factors (e.g. which card is
102being used) you want to turns off certain features in v4l2_ioctl_ops without 111being used) you want to turns off certain features in :c:type:`v4l2_ioctl_ops`
103having to make a new struct. 112without having to make a new struct.
104 113
105The v4l2_file_operations struct is a subset of file_operations. The main 114The :c:type:`v4l2_file_operations` struct is a subset of file_operations.
106difference is that the inode argument is omitted since it is never used. 115The main difference is that the inode argument is omitted since it is never
116used.
107 117
108If integration with the media framework is needed, you must initialize the 118If integration with the media framework is needed, you must initialize the
109media_entity struct embedded in the video_device struct (entity field) by 119:c:type:`media_entity` struct embedded in the :c:type:`video_device` struct
110calling media_entity_pads_init(): 120(entity field) by calling :cpp:func:`media_entity_pads_init`:
111 121
112.. code-block:: none 122.. code-block:: c
113 123
114 struct media_pad *pad = &my_vdev->pad; 124 struct media_pad *pad = &my_vdev->pad;
115 int err; 125 int err;
@@ -126,47 +136,52 @@ ioctls and locking
126------------------ 136------------------
127 137
128The V4L core provides optional locking services. The main service is the 138The V4L core provides optional locking services. The main service is the
129lock field in struct video_device, which is a pointer to a mutex. If you set 139lock field in struct :c:type:`video_device`, which is a pointer to a mutex.
130this pointer, then that will be used by unlocked_ioctl to serialize all ioctls. 140If you set this pointer, then that will be used by unlocked_ioctl to
131 141serialize all ioctls.
132If you are using the videobuf2 framework, then there is a second lock that you 142
133can set: video_device->queue->lock. If set, then this lock will be used instead 143If you are using the :ref:`videobuf2 framework <vb2_framework>`, then there
134of video_device->lock to serialize all queuing ioctls (see the previous section 144is a second lock that you can set: :c:type:`video_device`->queue->lock. If
145set, then this lock will be used instead of :c:type:`video_device`->lock
146to serialize all queuing ioctls (see the previous section
135for the full list of those ioctls). 147for the full list of those ioctls).
136 148
137The advantage of using a different lock for the queuing ioctls is that for some 149The advantage of using a different lock for the queuing ioctls is that for some
138drivers (particularly USB drivers) certain commands such as setting controls 150drivers (particularly USB drivers) certain commands such as setting controls
139can take a long time, so you want to use a separate lock for the buffer queuing 151can take a long time, so you want to use a separate lock for the buffer queuing
140ioctls. That way your VIDIOC_DQBUF doesn't stall because the driver is busy 152ioctls. That way your ``VIDIOC_DQBUF`` doesn't stall because the driver is busy
141changing the e.g. exposure of the webcam. 153changing the e.g. exposure of the webcam.
142 154
143Of course, you can always do all the locking yourself by leaving both lock 155Of course, you can always do all the locking yourself by leaving both lock
144pointers at NULL. 156pointers at ``NULL``.
145 157
146If you use the old videobuf then you must pass the video_device lock to the 158If you use the old :ref:`videobuf framework <vb_framework>` then you must
147videobuf queue initialize function: if videobuf has to wait for a frame to 159pass the :c:type:`video_device`->lock to the videobuf queue initialize
148arrive, then it will temporarily unlock the lock and relock it afterwards. If 160function: if videobuf has to wait for a frame to arrive, then it will
149your driver also waits in the code, then you should do the same to allow other 161temporarily unlock the lock and relock it afterwards. If your driver also
162waits in the code, then you should do the same to allow other
150processes to access the device node while the first process is waiting for 163processes to access the device node while the first process is waiting for
151something. 164something.
152 165
153In the case of videobuf2 you will need to implement the wait_prepare and 166In the case of :ref:`videobuf2 <vb2_framework>` you will need to implement the
154wait_finish callbacks to unlock/lock if applicable. If you use the queue->lock 167``wait_prepare()`` and ``wait_finish()`` callbacks to unlock/lock if applicable.
155pointer, then you can use the helper functions vb2_ops_wait_prepare/finish. 168If you use the ``queue->lock`` pointer, then you can use the helper functions
169:cpp:func:`vb2_ops_wait_prepare` and :cpp:func:`vb2_ops_wait_finish`.
156 170
157The implementation of a hotplug disconnect should also take the lock from 171The implementation of a hotplug disconnect should also take the lock from
158video_device before calling v4l2_device_disconnect. If you are also using 172:c:type:`video_device` before calling v4l2_device_disconnect. If you are also
159video_device->queue->lock, then you have to first lock video_device->queue->lock 173using :c:type:`video_device`->queue->lock, then you have to first lock
160followed by video_device->lock. That way you can be sure no ioctl is running 174:c:type:`video_device`->queue->lock followed by :c:type:`video_device`->lock.
161when you call v4l2_device_disconnect. 175That way you can be sure no ioctl is running when you call
176:c:type:`v4l2_device_disconnect`.
162 177
163video_device registration 178Video device registration
164------------------------- 179-------------------------
165 180
166Next you register the video device: this will create the character device 181Next you register the video device with :cpp:func:`video_register_device`.
167for you. 182This will create the character device for you.
168 183
169.. code-block:: none 184.. code-block:: c
170 185
171 err = video_register_device(vdev, VFL_TYPE_GRABBER, -1); 186 err = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
172 if (err) { 187 if (err) {
@@ -174,19 +189,20 @@ for you.
174 return err; 189 return err;
175 } 190 }
176 191
177If the v4l2_device parent device has a non-NULL mdev field, the video device 192If the :c:type:`v4l2_device` parent device has a not ``NULL`` mdev field,
178entity will be automatically registered with the media device. 193the video device entity will be automatically registered with the media
194device.
179 195
180Which device is registered depends on the type argument. The following 196Which device is registered depends on the type argument. The following
181types exist: 197types exist:
182 198
183VFL_TYPE_GRABBER: videoX for video input/output devices 199- ``VFL_TYPE_GRABBER``: ``/dev/videoX`` for video input/output devices
184VFL_TYPE_VBI: vbiX for vertical blank data (i.e. closed captions, teletext) 200- ``VFL_TYPE_VBI``: ``/dev/vbiX`` for vertical blank data (i.e. closed captions, teletext)
185VFL_TYPE_RADIO: radioX for radio tuners 201- ``VFL_TYPE_RADIO``: ``/dev/radioX`` for radio tuners
186VFL_TYPE_SDR: swradioX for Software Defined Radio tuners 202- ``VFL_TYPE_SDR``: ``/dev/swradioX`` for Software Defined Radio tuners
187 203
188The last argument gives you a certain amount of control over the device 204The last argument gives you a certain amount of control over the device
189device node number used (i.e. the X in videoX). Normally you will pass -1 205device node number used (i.e. the X in ``videoX``). Normally you will pass -1
190to let the v4l2 framework pick the first free number. But sometimes users 206to let the v4l2 framework pick the first free number. But sometimes users
191want to select a specific node number. It is common that drivers allow 207want to select a specific node number. It is common that drivers allow
192the user to select a specific device node number through a driver module 208the user to select a specific device node number through a driver module
@@ -205,85 +221,90 @@ first free number.
205 221
206Since in this case you do not care about a warning about not being able 222Since in this case you do not care about a warning about not being able
207to select the specified device node number, you can call the function 223to select the specified device node number, you can call the function
208video_register_device_no_warn() instead. 224:cpp:func:`video_register_device_no_warn` instead.
209 225
210Whenever a device node is created some attributes are also created for you. 226Whenever a device node is created some attributes are also created for you.
211If you look in /sys/class/video4linux you see the devices. Go into e.g. 227If you look in ``/sys/class/video4linux`` you see the devices. Go into e.g.
212video0 and you will see 'name', 'dev_debug' and 'index' attributes. The 'name' 228``video0`` and you will see 'name', 'dev_debug' and 'index' attributes. The
213attribute is the 'name' field of the video_device struct. The 'dev_debug' attribute 229'name' attribute is the 'name' field of the video_device struct. The
214can be used to enable core debugging. See the next section for more detailed 230'dev_debug' attribute can be used to enable core debugging. See the next
215information on this. 231section for more detailed information on this.
216 232
217The 'index' attribute is the index of the device node: for each call to 233The 'index' attribute is the index of the device node: for each call to
218video_register_device() the index is just increased by 1. The first video 234:cpp:func:`video_register_device()` the index is just increased by 1. The
219device node you register always starts with index 0. 235first video device node you register always starts with index 0.
220 236
221Users can setup udev rules that utilize the index attribute to make fancy 237Users can setup udev rules that utilize the index attribute to make fancy
222device names (e.g. 'mpegX' for MPEG video capture device nodes). 238device names (e.g. '``mpegX``' for MPEG video capture device nodes).
223 239
224After the device was successfully registered, then you can use these fields: 240After the device was successfully registered, then you can use these fields:
225 241
226- vfl_type: the device type passed to video_register_device. 242- :c:type:`video_device`->vfl_type: the device type passed to
227- minor: the assigned device minor number. 243 :cpp:func:`video_register_device`.
228- num: the device node number (i.e. the X in videoX). 244- :c:type:`video_device`->minor: the assigned device minor number.
229- index: the device index number. 245- :c:type:`video_device`->num: the device node number (i.e. the X in
246 ``videoX``).
247- :c:type:`video_device`->index: the device index number.
230 248
231If the registration failed, then you need to call video_device_release() 249If the registration failed, then you need to call
232to free the allocated video_device struct, or free your own struct if the 250:cpp:func:`video_device_release` to free the allocated :c:type:`video_device`
233video_device was embedded in it. The vdev->release() callback will never 251struct, or free your own struct if the :c:type:`video_device` was embedded in
234be called if the registration failed, nor should you ever attempt to 252it. The ``vdev->release()`` callback will never be called if the registration
235unregister the device if the registration failed. 253failed, nor should you ever attempt to unregister the device if the
254registration failed.
236 255
237video device debugging 256video device debugging
238---------------------- 257----------------------
239 258
240The 'dev_debug' attribute that is created for each video, vbi, radio or swradio 259The 'dev_debug' attribute that is created for each video, vbi, radio or swradio
241device in /sys/class/video4linux/<devX>/ allows you to enable logging of 260device in ``/sys/class/video4linux/<devX>/`` allows you to enable logging of
242file operations. 261file operations.
243 262
244It is a bitmask and the following bits can be set: 263It is a bitmask and the following bits can be set:
245 264
246.. code-block:: none
247
248 0x01: Log the ioctl name and error code. VIDIOC_(D)QBUF ioctls are only logged
249 if bit 0x08 is also set.
250 0x02: Log the ioctl name arguments and error code. VIDIOC_(D)QBUF ioctls are
251 only logged if bit 0x08 is also set.
252 0x04: Log the file operations open, release, read, write, mmap and
253 get_unmapped_area. The read and write operations are only logged if
254 bit 0x08 is also set.
255 0x08: Log the read and write file operations and the VIDIOC_QBUF and
256 VIDIOC_DQBUF ioctls.
257 0x10: Log the poll file operation.
258 265
259video_device cleanup 266===== ================================================================
267Mask Description
268===== ================================================================
2690x01 Log the ioctl name and error code. VIDIOC_(D)QBUF ioctls are
270 only logged if bit 0x08 is also set.
2710x02 Log the ioctl name arguments and error code. VIDIOC_(D)QBUF
272 ioctls are
273 only logged if bit 0x08 is also set.
2740x04 Log the file operations open, release, read, write, mmap and
275 get_unmapped_area. The read and write operations are only
276 logged if bit 0x08 is also set.
2770x08 Log the read and write file operations and the VIDIOC_QBUF and
278 VIDIOC_DQBUF ioctls.
2790x10 Log the poll file operation.
280===== ================================================================
281
282Video device cleanup
260-------------------- 283--------------------
261 284
262When the video device nodes have to be removed, either during the unload 285When the video device nodes have to be removed, either during the unload
263of the driver or because the USB device was disconnected, then you should 286of the driver or because the USB device was disconnected, then you should
264unregister them: 287unregister them with:
265 288
266.. code-block:: none 289 :cpp:func:`video_unregister_device`
267 290 (:c:type:`vdev <video_device>`);
268 video_unregister_device(vdev);
269 291
270This will remove the device nodes from sysfs (causing udev to remove them 292This will remove the device nodes from sysfs (causing udev to remove them
271from /dev). 293from ``/dev``).
272 294
273After video_unregister_device() returns no new opens can be done. However, 295After :cpp:func:`video_unregister_device` returns no new opens can be done.
274in the case of USB devices some application might still have one of these 296However, in the case of USB devices some application might still have one of
275device nodes open. So after the unregister all file operations (except 297these device nodes open. So after the unregister all file operations (except
276release, of course) will return an error as well. 298release, of course) will return an error as well.
277 299
278When the last user of the video device node exits, then the vdev->release() 300When the last user of the video device node exits, then the ``vdev->release()``
279callback is called and you can do the final cleanup there. 301callback is called and you can do the final cleanup there.
280 302
281Don't forget to cleanup the media entity associated with the video device if 303Don't forget to cleanup the media entity associated with the video device if
282it has been initialized: 304it has been initialized:
283 305
284.. code-block:: none 306 :cpp:func:`media_entity_cleanup <media_entity_cleanup>`
285 307 (&vdev->entity);
286 media_entity_cleanup(&vdev->entity);
287 308
288This can be done from the release callback. 309This can be done from the release callback.
289 310
@@ -293,45 +314,44 @@ video_device helper functions
293 314
294There are a few useful helper functions: 315There are a few useful helper functions:
295 316
296- file/video_device private data 317- file and :c:type:`video_device` private data
297 318
298You can set/get driver private data in the video_device struct using: 319You can set/get driver private data in the video_device struct using:
299 320
300.. code-block:: none 321 :cpp:func:`video_get_drvdata <video_get_drvdata>`
322 (:c:type:`vdev <video_device>`);
301 323
302 void *video_get_drvdata(struct video_device *vdev); 324 :cpp:func:`video_set_drvdata <video_set_drvdata>`
303 void video_set_drvdata(struct video_device *vdev, void *data); 325 (:c:type:`vdev <video_device>`);
304 326
305Note that you can safely call video_set_drvdata() before calling 327Note that you can safely call :cpp:func:`video_set_drvdata` before calling
306video_register_device(). 328:cpp:func:`video_register_device`.
307 329
308And this function: 330And this function:
309 331
310.. code-block:: none 332 :cpp:func:`video_devdata <video_devdata>`
311 333 (struct file \*file);
312 struct video_device *video_devdata(struct file *file);
313 334
314returns the video_device belonging to the file struct. 335returns the video_device belonging to the file struct.
315 336
316The video_drvdata function combines video_get_drvdata with video_devdata: 337The :cpp:func:`video_devdata` function combines :cpp:func:`video_get_drvdata`
338with :cpp:func:`video_devdata`:
317 339
318.. code-block:: none 340 :cpp:func:`video_drvdata <video_drvdata>`
341 (struct file \*file);
319 342
320 void *video_drvdata(struct file *file); 343You can go from a :c:type:`video_device` struct to the v4l2_device struct using:
321 344
322You can go from a video_device struct to the v4l2_device struct using: 345.. code-block:: c
323
324.. code-block:: none
325 346
326 struct v4l2_device *v4l2_dev = vdev->v4l2_dev; 347 struct v4l2_device *v4l2_dev = vdev->v4l2_dev;
327 348
328- Device node name 349- Device node name
329 350
330The video_device node kernel name can be retrieved using 351The :c:type:`video_device` node kernel name can be retrieved using:
331
332.. code-block:: none
333 352
334 const char *video_device_node_name(struct video_device *vdev); 353 :cpp:func:`video_device_node_name <video_device_node_name>`
354 (:c:type:`vdev <video_device>`);
335 355
336The name is used as a hint by userspace tools such as udev. The function 356The name is used as a hint by userspace tools such as udev. The function
337should be used where possible instead of accessing the video_device::num and 357should be used where possible instead of accessing the video_device::num and
diff --git a/Documentation/media/kapi/v4l2-videobuf.rst b/Documentation/media/kapi/v4l2-videobuf.rst
index 01156728203c..54adfd772d28 100644
--- a/Documentation/media/kapi/v4l2-videobuf.rst
+++ b/Documentation/media/kapi/v4l2-videobuf.rst
@@ -1,3 +1,5 @@
1.. _vb_framework:
2
1Videobuf Framework 3Videobuf Framework
2================== 4==================
3 5
diff --git a/Documentation/media/kapi/v4l2-videobuf2.rst b/Documentation/media/kapi/v4l2-videobuf2.rst
index b4f2d6983ef3..bdb8b83f1ea0 100644
--- a/Documentation/media/kapi/v4l2-videobuf2.rst
+++ b/Documentation/media/kapi/v4l2-videobuf2.rst
@@ -1,3 +1,5 @@
1.. _vb2_framework:
2
1V4L2 videobuf2 kAPI 3V4L2 videobuf2 kAPI
2^^^^^^^^^^^^^^^^^^^ 4^^^^^^^^^^^^^^^^^^^
3 5