News Archive (1999-2012) | 2013-current at LinuxGizmos | Current Tech News Portal |    About   

Tutorial explores V4L2 buffer management

Apr 16, 2009 — by Eric Brown — from the LinuxDevices Archive — 625 views

LinuxDevices has posted part 2 of an overview of Linux's V4L2 (Video for Linux 2) interface, focusing on developing a device driver that uses it. Written by Promwad engineer Vladimir Davydov (pictured), this second tutorial examines the V4L2 buffering interface, including initializing and releasing buffers.

Promwad, an embedded development services company located in Minsk, Belarus, has used the V4L2 interface in several development projects. Part 1 of the story examined V4L2's videodev base module, its VIVI driver for emulating video devices, and the Linux kernel's V4L libraries. It also explored V4L driver initialization and registration, with code examples.

Part 2 looks at the how the V4L driver manages capture buffers, as well as various options available with the V4L2 interface. Specific sections include:

  • Buffering management — Overview of V4L buffering management, as well as the kernel modules, such as videobuf-core, which make these functions available
  • Buffering structures — Inside the videobuf_buffer and videobu_queue structures
  • Types of capture buffers — An examination of Scatter-Gather DMA buffers, DMA supporting buffers for contiguous area of physical memory, and non-DMA buffers
  • Initializing capture buffers — Calling the function for initializing buffers by filling the video_queue_ops structure, and setting up buf_setup, buf_prepare, buf_queue, and buf_release methods, and then configuring the call initialization function by capture type
  • Releasing capture buffers — Releasing the buffers using the buf_release pointer in the videobuf_queue_ops structure, with examples for the three major buffer types
  • Processing the mmap system call — Configuring the mmap system call, which helps access capture buffers from the user application side by mapping memory allocated to buffers into the user process area
  • Processing the read system call — An mmap buffering function that can save driver developers from the need to write their own code
  • Processing the poll system call — Using “poll” to pause the execution until the driver receives the captured data
  • Processing commands of ioctl system call — Available functions within “ioctl”
  • Accessing capture buffer video data — What to do when granting direct access to video data in driver code is required
  • Quick reference — Short descriptions of structures and functions covered in the article

Click below to read the full article, the second of a two-part series:

Structures and helper functions in the V4L interface for buffering: Intro to V4L2 (Part 2)

This article was originally published on and has been donated to the open source community by QuinStreet Inc. Please visit for up-to-date news and articles about Linux and open source.

Comments are closed.