aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-17 14:58:51 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-17 15:30:36 -0400
commit1bed13f521fc3d22d1b128999ea2b128aea50728 (patch)
tree99ca03ddd8cdcb8fdf1139a78a0c580f6483d4c3
parent9488fed623eff249273b83503abfc8a20409f6b1 (diff)
[media] doc-rst: Convert videobuf documentation to ReST
The videobuf documentation is almost at rst format: we just needed to add titles and add some code-blocks there and that's it. Also, add a notice that this framework is deprecated. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--Documentation/media/kapi/videobuf.rst51
-rw-r--r--Documentation/media/media_drivers.rst1
2 files changed, 50 insertions, 2 deletions
diff --git a/Documentation/media/kapi/videobuf.rst b/Documentation/media/kapi/videobuf.rst
index 3ffe9e960b6f..01156728203c 100644
--- a/Documentation/media/kapi/videobuf.rst
+++ b/Documentation/media/kapi/videobuf.rst
@@ -1,7 +1,18 @@
1An introduction to the videobuf layer 1Videobuf Framework
2Jonathan Corbet <corbet@lwn.net> 2==================
3
4Author: Jonathan Corbet <corbet@lwn.net>
5
3Current as of 2.6.33 6Current as of 2.6.33
4 7
8.. note::
9
10 The videobuf framework was deprecated in favor of videobuf2. Shouldn't
11 be used on new drivers.
12
13Introduction
14------------
15
5The videobuf layer functions as a sort of glue layer between a V4L2 driver 16The videobuf layer functions as a sort of glue layer between a V4L2 driver
6and user space. It handles the allocation and management of buffers for 17and user space. It handles the allocation and management of buffers for
7the storage of video frames. There is a set of functions which can be used 18the storage of video frames. There is a set of functions which can be used
@@ -14,6 +25,7 @@ author, but the payback comes in the form of reduced code in the driver and
14a consistent implementation of the V4L2 user-space API. 25a consistent implementation of the V4L2 user-space API.
15 26
16Buffer types 27Buffer types
28------------
17 29
18Not all video devices use the same kind of buffers. In fact, there are (at 30Not all video devices use the same kind of buffers. In fact, there are (at
19least) three common variations: 31least) three common variations:
@@ -48,10 +60,13 @@ the kernel and a description of this technique is currently beyond the
48scope of this document.] 60scope of this document.]
49 61
50Data structures, callbacks, and initialization 62Data structures, callbacks, and initialization
63----------------------------------------------
51 64
52Depending on which type of buffers are being used, the driver should 65Depending on which type of buffers are being used, the driver should
53include one of the following files: 66include one of the following files:
54 67
68.. code-block:: none
69
55 <media/videobuf-dma-sg.h> /* Physically scattered */ 70 <media/videobuf-dma-sg.h> /* Physically scattered */
56 <media/videobuf-vmalloc.h> /* vmalloc() buffers */ 71 <media/videobuf-vmalloc.h> /* vmalloc() buffers */
57 <media/videobuf-dma-contig.h> /* Physically contiguous */ 72 <media/videobuf-dma-contig.h> /* Physically contiguous */
@@ -65,6 +80,8 @@ the queue.
65The next step is to write four simple callbacks to help videobuf deal with 80The next step is to write four simple callbacks to help videobuf deal with
66the management of buffers: 81the management of buffers:
67 82
83.. code-block:: none
84
68 struct videobuf_queue_ops { 85 struct videobuf_queue_ops {
69 int (*buf_setup)(struct videobuf_queue *q, 86 int (*buf_setup)(struct videobuf_queue *q,
70 unsigned int *count, unsigned int *size); 87 unsigned int *count, unsigned int *size);
@@ -91,6 +108,8 @@ passed to buf_prepare(), which should set the buffer's size, width, height,
91and field fields properly. If the buffer's state field is 108and field fields properly. If the buffer's state field is
92VIDEOBUF_NEEDS_INIT, the driver should pass it to: 109VIDEOBUF_NEEDS_INIT, the driver should pass it to:
93 110
111.. code-block:: none
112
94 int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb, 113 int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
95 struct v4l2_framebuffer *fbuf); 114 struct v4l2_framebuffer *fbuf);
96 115
@@ -110,6 +129,8 @@ Finally, buf_release() is called when a buffer is no longer intended to be
110used. The driver should ensure that there is no I/O active on the buffer, 129used. The driver should ensure that there is no I/O active on the buffer,
111then pass it to the appropriate free routine(s): 130then pass it to the appropriate free routine(s):
112 131
132.. code-block:: none
133
113 /* Scatter/gather drivers */ 134 /* Scatter/gather drivers */
114 int videobuf_dma_unmap(struct videobuf_queue *q, 135 int videobuf_dma_unmap(struct videobuf_queue *q,
115 struct videobuf_dmabuf *dma); 136 struct videobuf_dmabuf *dma);
@@ -124,6 +145,8 @@ then pass it to the appropriate free routine(s):
124 145
125One way to ensure that a buffer is no longer under I/O is to pass it to: 146One way to ensure that a buffer is no longer under I/O is to pass it to:
126 147
148.. code-block:: none
149
127 int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); 150 int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
128 151
129Here, vb is the buffer, non_blocking indicates whether non-blocking I/O 152Here, vb is the buffer, non_blocking indicates whether non-blocking I/O
@@ -131,12 +154,15 @@ should be used (it should be zero in the buf_release() case), and intr
131controls whether an interruptible wait is used. 154controls whether an interruptible wait is used.
132 155
133File operations 156File operations
157---------------
134 158
135At this point, much of the work is done; much of the rest is slipping 159At this point, much of the work is done; much of the rest is slipping
136videobuf calls into the implementation of the other driver callbacks. The 160videobuf calls into the implementation of the other driver callbacks. The
137first step is in the open() function, which must initialize the 161first step is in the open() function, which must initialize the
138videobuf queue. The function to use depends on the type of buffer used: 162videobuf queue. The function to use depends on the type of buffer used:
139 163
164.. code-block:: none
165
140 void videobuf_queue_sg_init(struct videobuf_queue *q, 166 void videobuf_queue_sg_init(struct videobuf_queue *q,
141 struct videobuf_queue_ops *ops, 167 struct videobuf_queue_ops *ops,
142 struct device *dev, 168 struct device *dev,
@@ -182,6 +208,8 @@ applications have a chance of working with the device. Videobuf makes it
182easy to do that with the same code. To implement read(), the driver need 208easy to do that with the same code. To implement read(), the driver need
183only make a call to one of: 209only make a call to one of:
184 210
211.. code-block:: none
212
185 ssize_t videobuf_read_one(struct videobuf_queue *q, 213 ssize_t videobuf_read_one(struct videobuf_queue *q,
186 char __user *data, size_t count, 214 char __user *data, size_t count,
187 loff_t *ppos, int nonblocking); 215 loff_t *ppos, int nonblocking);
@@ -201,6 +229,8 @@ anticipation of another read() call happening in the near future).
201 229
202The poll() function can usually be implemented with a direct call to: 230The poll() function can usually be implemented with a direct call to:
203 231
232.. code-block:: none
233
204 unsigned int videobuf_poll_stream(struct file *file, 234 unsigned int videobuf_poll_stream(struct file *file,
205 struct videobuf_queue *q, 235 struct videobuf_queue *q,
206 poll_table *wait); 236 poll_table *wait);
@@ -213,6 +243,8 @@ the mmap() system call to enable user space to access the data. In many
213V4L2 drivers, the often-complex mmap() implementation simplifies to a 243V4L2 drivers, the often-complex mmap() implementation simplifies to a
214single call to: 244single call to:
215 245
246.. code-block:: none
247
216 int videobuf_mmap_mapper(struct videobuf_queue *q, 248 int videobuf_mmap_mapper(struct videobuf_queue *q,
217 struct vm_area_struct *vma); 249 struct vm_area_struct *vma);
218 250
@@ -220,6 +252,8 @@ Everything else is handled by the videobuf code.
220 252
221The release() function requires two separate videobuf calls: 253The release() function requires two separate videobuf calls:
222 254
255.. code-block:: none
256
223 void videobuf_stop(struct videobuf_queue *q); 257 void videobuf_stop(struct videobuf_queue *q);
224 int videobuf_mmap_free(struct videobuf_queue *q); 258 int videobuf_mmap_free(struct videobuf_queue *q);
225 259
@@ -233,12 +267,15 @@ buffers are still mapped, but every driver in the 2.6.32 kernel cheerfully
233ignores its return value. 267ignores its return value.
234 268
235ioctl() operations 269ioctl() operations
270------------------
236 271
237The V4L2 API includes a very long list of driver callbacks to respond to 272The V4L2 API includes a very long list of driver callbacks to respond to
238the many ioctl() commands made available to user space. A number of these 273the many ioctl() commands made available to user space. A number of these
239- those associated with streaming I/O - turn almost directly into videobuf 274- those associated with streaming I/O - turn almost directly into videobuf
240calls. The relevant helper functions are: 275calls. The relevant helper functions are:
241 276
277.. code-block:: none
278
242 int videobuf_reqbufs(struct videobuf_queue *q, 279 int videobuf_reqbufs(struct videobuf_queue *q,
243 struct v4l2_requestbuffers *req); 280 struct v4l2_requestbuffers *req);
244 int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b); 281 int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b);
@@ -259,6 +296,7 @@ complex, of course, since they will also need to deal with starting and
259stopping the capture engine. 296stopping the capture engine.
260 297
261Buffer allocation 298Buffer allocation
299-----------------
262 300
263Thus far, we have talked about buffers, but have not looked at how they are 301Thus far, we have talked about buffers, but have not looked at how they are
264allocated. The scatter/gather case is the most complex on this front. For 302allocated. The scatter/gather case is the most complex on this front. For
@@ -272,11 +310,15 @@ If the driver needs to do its own memory allocation, it should be done in
272the vidioc_reqbufs() function, *after* calling videobuf_reqbufs(). The 310the vidioc_reqbufs() function, *after* calling videobuf_reqbufs(). The
273first step is a call to: 311first step is a call to:
274 312
313.. code-block:: none
314
275 struct videobuf_dmabuf *videobuf_to_dma(struct videobuf_buffer *buf); 315 struct videobuf_dmabuf *videobuf_to_dma(struct videobuf_buffer *buf);
276 316
277The returned videobuf_dmabuf structure (defined in 317The returned videobuf_dmabuf structure (defined in
278<media/videobuf-dma-sg.h>) includes a couple of relevant fields: 318<media/videobuf-dma-sg.h>) includes a couple of relevant fields:
279 319
320.. code-block:: none
321
280 struct scatterlist *sglist; 322 struct scatterlist *sglist;
281 int sglen; 323 int sglen;
282 324
@@ -300,6 +342,7 @@ kernel drivers, or those contained within huge pages, will work with these
300drivers. 342drivers.
301 343
302Filling the buffers 344Filling the buffers
345-------------------
303 346
304The final part of a videobuf implementation has no direct callback - it's 347The final part of a videobuf implementation has no direct callback - it's
305the portion of the code which actually puts frame data into the buffers, 348the portion of the code which actually puts frame data into the buffers,
@@ -331,10 +374,14 @@ For scatter/gather drivers, the needed memory pointers will be found in the
331scatterlist structure described above. Drivers using the vmalloc() method 374scatterlist structure described above. Drivers using the vmalloc() method
332can get a memory pointer with: 375can get a memory pointer with:
333 376
377.. code-block:: none
378
334 void *videobuf_to_vmalloc(struct videobuf_buffer *buf); 379 void *videobuf_to_vmalloc(struct videobuf_buffer *buf);
335 380
336For contiguous DMA drivers, the function to use is: 381For contiguous DMA drivers, the function to use is:
337 382
383.. code-block:: none
384
338 dma_addr_t videobuf_to_dma_contig(struct videobuf_buffer *buf); 385 dma_addr_t videobuf_to_dma_contig(struct videobuf_buffer *buf);
339 386
340The contiguous DMA API goes out of its way to hide the kernel-space address 387The contiguous DMA API goes out of its way to hide the kernel-space address
diff --git a/Documentation/media/media_drivers.rst b/Documentation/media/media_drivers.rst
index 5941fea2607e..8e0f455ff6e0 100644
--- a/Documentation/media/media_drivers.rst
+++ b/Documentation/media/media_drivers.rst
@@ -19,6 +19,7 @@ License".
19 19
20 kapi/v4l2-framework 20 kapi/v4l2-framework
21 kapi/v4l2-controls 21 kapi/v4l2-controls
22 kapi/videobuf
22 kapi/v4l2-core 23 kapi/v4l2-core
23 kapi/dtv-core 24 kapi/dtv-core
24 kapi/rc-core 25 kapi/rc-core