aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook/v4l/io.xml
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/DocBook/v4l/io.xml')
-rw-r--r--Documentation/DocBook/v4l/io.xml36
1 files changed, 18 insertions, 18 deletions
diff --git a/Documentation/DocBook/v4l/io.xml b/Documentation/DocBook/v4l/io.xml
index d424886beda0..a9750437000c 100644
--- a/Documentation/DocBook/v4l/io.xml
+++ b/Documentation/DocBook/v4l/io.xml
@@ -141,63 +141,63 @@ struct {
141} *buffers; 141} *buffers;
142unsigned int i; 142unsigned int i;
143 143
144memset (&reqbuf, 0, sizeof (reqbuf)); 144memset(&reqbuf, 0, sizeof(reqbuf));
145reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 145reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
146reqbuf.memory = V4L2_MEMORY_MMAP; 146reqbuf.memory = V4L2_MEMORY_MMAP;
147reqbuf.count = 20; 147reqbuf.count = 20;
148 148
149if (-1 == ioctl (fd, &VIDIOC-REQBUFS;, &reqbuf)) { 149if (-1 == ioctl (fd, &VIDIOC-REQBUFS;, &reqbuf)) {
150 if (errno == EINVAL) 150 if (errno == EINVAL)
151 printf ("Video capturing or mmap-streaming is not supported\n"); 151 printf("Video capturing or mmap-streaming is not supported\n");
152 else 152 else
153 perror ("VIDIOC_REQBUFS"); 153 perror("VIDIOC_REQBUFS");
154 154
155 exit (EXIT_FAILURE); 155 exit(EXIT_FAILURE);
156} 156}
157 157
158/* We want at least five buffers. */ 158/* We want at least five buffers. */
159 159
160if (reqbuf.count < 5) { 160if (reqbuf.count < 5) {
161 /* You may need to free the buffers here. */ 161 /* You may need to free the buffers here. */
162 printf ("Not enough buffer memory\n"); 162 printf("Not enough buffer memory\n");
163 exit (EXIT_FAILURE); 163 exit(EXIT_FAILURE);
164} 164}
165 165
166buffers = calloc (reqbuf.count, sizeof (*buffers)); 166buffers = calloc(reqbuf.count, sizeof(*buffers));
167assert (buffers != NULL); 167assert(buffers != NULL);
168 168
169for (i = 0; i < reqbuf.count; i++) { 169for (i = 0; i < reqbuf.count; i++) {
170 &v4l2-buffer; buffer; 170 &v4l2-buffer; buffer;
171 171
172 memset (&buffer, 0, sizeof (buffer)); 172 memset(&buffer, 0, sizeof(buffer));
173 buffer.type = reqbuf.type; 173 buffer.type = reqbuf.type;
174 buffer.memory = V4L2_MEMORY_MMAP; 174 buffer.memory = V4L2_MEMORY_MMAP;
175 buffer.index = i; 175 buffer.index = i;
176 176
177 if (-1 == ioctl (fd, &VIDIOC-QUERYBUF;, &buffer)) { 177 if (-1 == ioctl (fd, &VIDIOC-QUERYBUF;, &buffer)) {
178 perror ("VIDIOC_QUERYBUF"); 178 perror("VIDIOC_QUERYBUF");
179 exit (EXIT_FAILURE); 179 exit(EXIT_FAILURE);
180 } 180 }
181 181
182 buffers[i].length = buffer.length; /* remember for munmap() */ 182 buffers[i].length = buffer.length; /* remember for munmap() */
183 183
184 buffers[i].start = mmap (NULL, buffer.length, 184 buffers[i].start = mmap(NULL, buffer.length,
185 PROT_READ | PROT_WRITE, /* recommended */ 185 PROT_READ | PROT_WRITE, /* recommended */
186 MAP_SHARED, /* recommended */ 186 MAP_SHARED, /* recommended */
187 fd, buffer.m.offset); 187 fd, buffer.m.offset);
188 188
189 if (MAP_FAILED == buffers[i].start) { 189 if (MAP_FAILED == buffers[i].start) {
190 /* If you do not exit here you should unmap() and free() 190 /* If you do not exit here you should unmap() and free()
191 the buffers mapped so far. */ 191 the buffers mapped so far. */
192 perror ("mmap"); 192 perror("mmap");
193 exit (EXIT_FAILURE); 193 exit(EXIT_FAILURE);
194 } 194 }
195} 195}
196 196
197/* Cleanup. */ 197/* Cleanup. */
198 198
199for (i = 0; i < reqbuf.count; i++) 199for (i = 0; i < reqbuf.count; i++)
200 munmap (buffers[i].start, buffers[i].length); 200 munmap(buffers[i].start, buffers[i].length);
201 </programlisting> 201 </programlisting>
202 </example> 202 </example>
203 203