diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-07-17 14:58:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-07-17 15:30:36 -0400 |
commit | 1bed13f521fc3d22d1b128999ea2b128aea50728 (patch) | |
tree | 99ca03ddd8cdcb8fdf1139a78a0c580f6483d4c3 | |
parent | 9488fed623eff249273b83503abfc8a20409f6b1 (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.rst | 51 | ||||
-rw-r--r-- | Documentation/media/media_drivers.rst | 1 |
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 @@ | |||
1 | An introduction to the videobuf layer | 1 | Videobuf Framework |
2 | Jonathan Corbet <corbet@lwn.net> | 2 | ================== |
3 | |||
4 | Author: Jonathan Corbet <corbet@lwn.net> | ||
5 | |||
3 | Current as of 2.6.33 | 6 | Current 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 | |||
13 | Introduction | ||
14 | ------------ | ||
15 | |||
5 | The videobuf layer functions as a sort of glue layer between a V4L2 driver | 16 | The videobuf layer functions as a sort of glue layer between a V4L2 driver |
6 | and user space. It handles the allocation and management of buffers for | 17 | and user space. It handles the allocation and management of buffers for |
7 | the storage of video frames. There is a set of functions which can be used | 18 | the 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 | |||
14 | a consistent implementation of the V4L2 user-space API. | 25 | a consistent implementation of the V4L2 user-space API. |
15 | 26 | ||
16 | Buffer types | 27 | Buffer types |
28 | ------------ | ||
17 | 29 | ||
18 | Not all video devices use the same kind of buffers. In fact, there are (at | 30 | Not all video devices use the same kind of buffers. In fact, there are (at |
19 | least) three common variations: | 31 | least) three common variations: |
@@ -48,10 +60,13 @@ the kernel and a description of this technique is currently beyond the | |||
48 | scope of this document.] | 60 | scope of this document.] |
49 | 61 | ||
50 | Data structures, callbacks, and initialization | 62 | Data structures, callbacks, and initialization |
63 | ---------------------------------------------- | ||
51 | 64 | ||
52 | Depending on which type of buffers are being used, the driver should | 65 | Depending on which type of buffers are being used, the driver should |
53 | include one of the following files: | 66 | include 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. | |||
65 | The next step is to write four simple callbacks to help videobuf deal with | 80 | The next step is to write four simple callbacks to help videobuf deal with |
66 | the management of buffers: | 81 | the 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, | |||
91 | and field fields properly. If the buffer's state field is | 108 | and field fields properly. If the buffer's state field is |
92 | VIDEOBUF_NEEDS_INIT, the driver should pass it to: | 109 | VIDEOBUF_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 | |||
110 | used. The driver should ensure that there is no I/O active on the buffer, | 129 | used. The driver should ensure that there is no I/O active on the buffer, |
111 | then pass it to the appropriate free routine(s): | 130 | then 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 | ||
125 | One way to ensure that a buffer is no longer under I/O is to pass it to: | 146 | One 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 | ||
129 | Here, vb is the buffer, non_blocking indicates whether non-blocking I/O | 152 | Here, 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 | |||
131 | controls whether an interruptible wait is used. | 154 | controls whether an interruptible wait is used. |
132 | 155 | ||
133 | File operations | 156 | File operations |
157 | --------------- | ||
134 | 158 | ||
135 | At this point, much of the work is done; much of the rest is slipping | 159 | At this point, much of the work is done; much of the rest is slipping |
136 | videobuf calls into the implementation of the other driver callbacks. The | 160 | videobuf calls into the implementation of the other driver callbacks. The |
137 | first step is in the open() function, which must initialize the | 161 | first step is in the open() function, which must initialize the |
138 | videobuf queue. The function to use depends on the type of buffer used: | 162 | videobuf 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 | |||
182 | easy to do that with the same code. To implement read(), the driver need | 208 | easy to do that with the same code. To implement read(), the driver need |
183 | only make a call to one of: | 209 | only 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 | ||
202 | The poll() function can usually be implemented with a direct call to: | 230 | The 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 | |||
213 | V4L2 drivers, the often-complex mmap() implementation simplifies to a | 243 | V4L2 drivers, the often-complex mmap() implementation simplifies to a |
214 | single call to: | 244 | single 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 | ||
221 | The release() function requires two separate videobuf calls: | 253 | The 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 | |||
233 | ignores its return value. | 267 | ignores its return value. |
234 | 268 | ||
235 | ioctl() operations | 269 | ioctl() operations |
270 | ------------------ | ||
236 | 271 | ||
237 | The V4L2 API includes a very long list of driver callbacks to respond to | 272 | The V4L2 API includes a very long list of driver callbacks to respond to |
238 | the many ioctl() commands made available to user space. A number of these | 273 | the 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 |
240 | calls. The relevant helper functions are: | 275 | calls. 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 | |||
259 | stopping the capture engine. | 296 | stopping the capture engine. |
260 | 297 | ||
261 | Buffer allocation | 298 | Buffer allocation |
299 | ----------------- | ||
262 | 300 | ||
263 | Thus far, we have talked about buffers, but have not looked at how they are | 301 | Thus far, we have talked about buffers, but have not looked at how they are |
264 | allocated. The scatter/gather case is the most complex on this front. For | 302 | allocated. 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 | |||
272 | the vidioc_reqbufs() function, *after* calling videobuf_reqbufs(). The | 310 | the vidioc_reqbufs() function, *after* calling videobuf_reqbufs(). The |
273 | first step is a call to: | 311 | first 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 | ||
277 | The returned videobuf_dmabuf structure (defined in | 317 | The 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 | |||
300 | drivers. | 342 | drivers. |
301 | 343 | ||
302 | Filling the buffers | 344 | Filling the buffers |
345 | ------------------- | ||
303 | 346 | ||
304 | The final part of a videobuf implementation has no direct callback - it's | 347 | The final part of a videobuf implementation has no direct callback - it's |
305 | the portion of the code which actually puts frame data into the buffers, | 348 | the 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 | |||
331 | scatterlist structure described above. Drivers using the vmalloc() method | 374 | scatterlist structure described above. Drivers using the vmalloc() method |
332 | can get a memory pointer with: | 375 | can 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 | ||
336 | For contiguous DMA drivers, the function to use is: | 381 | For 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 | ||
340 | The contiguous DMA API goes out of its way to hide the kernel-space address | 387 | The 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 |