Documentation/userspace-api/media/v4l/capture.c.rst
Source file repositories/reference/linux-study-clean/Documentation/userspace-api/media/v4l/capture.c.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/userspace-api/media/v4l/capture.c.rst- Extension
.rst- Size
- 15035 bytes
- Lines
- 666
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstring.hassert.hgetopt.hfcntl.hunistd.herrno.hsys/stat.hsys/types.hsys/time.hsys/mman.hsys/ioctl.hlinux/videodev2.h
Detected Declarations
struct bufferenum io_methodfunction errno_exitfunction xioctlfunction process_imagefunction read_framefunction mainloopfunction stop_capturingfunction start_capturingfunction uninit_devicefunction init_readfunction init_mmapfunction init_userpfunction init_devicefunction close_devicefunction open_devicefunction usagefunction main
Annotated Snippet
struct buffer {
void *start;
size_t length;
};
static char *dev_name;
static enum io_method io = IO_METHOD_MMAP;
static int fd = -1;
struct buffer *buffers;
static unsigned int n_buffers;
static int out_buf;
static int force_format;
static int frame_count = 70;
static void errno_exit(const char *s)
{
fprintf(stderr, "%s error %d, %s\n", s, errno, strerror(errno));
exit(EXIT_FAILURE);
}
static int xioctl(int fh, int request, void *arg)
{
int r;
do {
r = ioctl(fh, request, arg);
} while (-1 == r && EINTR == errno);
return r;
}
static void process_image(const void *p, int size)
{
if (out_buf)
fwrite(p, size, 1, stdout);
fflush(stderr);
fprintf(stderr, ".");
fflush(stdout);
}
static int read_frame(void)
{
struct v4l2_buffer buf;
unsigned int i;
switch (io) {
case IO_METHOD_READ:
if (-1 == read(fd, buffers[0].start, buffers[0].length)) {
switch (errno) {
case EAGAIN:
return 0;
case EIO:
/* Could ignore EIO, see spec. */
/* fall through */
default:
errno_exit("read");
}
}
process_image(buffers[0].start, buffers[0].length);
break;
case IO_METHOD_MMAP:
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `assert.h`, `getopt.h`, `fcntl.h`, `unistd.h`, `errno.h`.
- Detected declarations: `struct buffer`, `enum io_method`, `function errno_exit`, `function xioctl`, `function process_image`, `function read_frame`, `function mainloop`, `function stop_capturing`, `function start_capturing`, `function uninit_device`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.