Video4Linux2第一部分 API: 简介

原文地址:http://lwn.net/Articles/203924/

The Video4Linux2 API: an introduction

[Posted October 11, 2006 by corbet]

Video4Linux2 API: 简介

Your editor has recently had the opportunity to write a Linux driver for a camera device - the camera which will be packaged with the One Laptop Per Child system, in particular. This driver works with the internal kernel API designed for such purposes: the Video4Linux2 API. In the process of writing this code, your editor made the shocking discovery that, in fact, this API is not particularly well documented - though the user-space side is, instead, quite well documented indeed. In an attempt to remedy the situation somewhat, LWN will, over the coming months, publish a series of articles describing how to write drivers for the V4L2 interface.

摄像设备将会集成到每一个便携式电脑系统中,因此,你会有机会为摄像设备编写Linux驱动。专门针对这个目的设计的内核API登场了:Video4Linux2 API。在编写这类代码的时候,你可能会震惊,该API的文档并不是十分齐全的,虽然用户空间的那一侧是良好的,你可以在用户空间文档看到。为了弥补这种状况,LWN将会在后续的几个月内,发表一系列文章,描述如何使用V4L2接口编写驱动。

 

V4L2 has a long history - the first gleam came into Bill Dirks's eye back around August of 1998. Development proceeded for years, and the V4L2 API was finally merged into the mainline in November, 2002, when 2.5.46 was released. To this day, however, quite a few Linux drivers do not support the newer API; the conversion process is an ongoing task. Meanwhile, the V4L2 API continues to evolve, with some major changes being made in 2.6.18. Applications which work with V4L2 remain relatively scarce.

V4L2已有很长的历史了,第一次闪现大约是在1998年8月,Bill Dirk开始的。经过数年的发展,V4L2 API最终于2002年11月融入主线,当时2.5.46版本的内核发布了。然后,截止到今天,还有一些Linux驱动并不支持新版的API;这个转换过程仍然是正在进行中的人物。与此同时,V4L2 API继续演进,2.6.18版本又出现了几个主要的变化。使用V4L2作的应用程序仍然相对罕见。

 

V4L2 is designed to support a wide variety of devices, only some of which are truly "video" in nature:

V4L2设计用来支持大量的广泛的设备,其实只有其中几种属于真正的“视频”设备:

1. The video capture interface grabs video data from a tuner or camera device. For many, video capture will be the primary application for V4L2. Since your editor's experience is strongest in this area, this series will tend to emphasize the capture API, but there is more to V4L2 than that.

1. 视频捕获接口用于从调谐器或者摄像设备抓取视频数据。视频捕获仍然是V4L2的首要应用。你对此领域的经验也更为丰富,我们的系列文章也着重于捕获API,但是V4L2能做的事情不止于此。

2. The video output interface allows applications to drive peripherals which can provide video images - perhaps in the form of a television signal - outside of the computer. 

2. 视频输出接口允许应用程序驱动设备输出视频图像-可能是以电视信号的形式-在电脑之外。

3. A variant of the capture interface can be found in the video overlay interface, whose job is to facilitate the direct display of video data from a capture device. Video data moves directly from the capture device to the display, without passing through the system's CPU.

3. 视频覆盖接口的任务是:便于直接显示视频数据,从捕获设备捕获,直达显示设备,没有经过CPU。

4. The VBI interfaces provide access to data transmitted during the video blanking interval. There are two of them, the "raw" and "sliced" interfaces, which differ in the amount of processing of the VBI data performed in hardware.

4. VBI接口提供了通道处理视频隔行数据。有两种形式的处理接口,原生态接口和条带式接口,这区别于硬件能够处理的VBI数据的数量。

5. The radio interface provides access to audio streams from AM and FM tuner devices.

5. 无线电波接口提供了通道处理AM(调幅)和FM(调频)调谐设备接收下来的无线电波数据流。

 

Other types of devices are possible. The V4L2 API has some stubs for "codec" and "effect" devices, both of which perform transformations on video data streams. Those areas have not yet been completely specified, however, much less implemented. There are also the "teletext" and "radio data system" interfaces currently implemented in the older V4L1 API; those have not been moved to V4L2 and there do not appear to be any immediate plans to do so.

当然,可能还有另外一些种类的设备。比如:“编解码设备”,“特效设备”,这两种都用于视频数据流的转换上面。这些领域还没有被完全的规格化,当然,实施就更为罕见了。还有一些“电报”接口和“无线电波数据系统”接口,现在是用较老的V4L1 API实施的;现在还没有迁移到V4L2,也没有出现一些急迫的计划去这样做。

 

Video devices differ from many others in the vast number of ways in which they can be configured. As a result, much of a V4L2 driver implements code which enables applications to discover a given device's capabilities and to configure that device to operate in the desired manner. The V4L2 API defines several dozen callbacks for the configuration of parameters like tuner frequencies, windowing and cropping, frame rates, video compression, image parameters (brightness, contrast, ...), video standards, video formats, etc. Much of this series will be devoted to looking at how this configuration process happens.

视频设备不同于其他设备,它有非常多的方式可以配置。因此,V4L2驱动代码提供了接口供应用程序ufaxian制定设备的能力,并以自己想要的方式配置它,操作它。V4L2 API定义了一打回调函数接口用于配置参数,诸如:调谐器的频率,显示窗口和裁剪窗口,帧率,视频压缩算法,图像参数(亮度,对比度,...),视频制式,视频格式,等等。我们的系列文章大部分是讲配置过程的。

 

Then, there is the small task of actually performing I/O at video rates in an efficient manner. The V4L2 API defines three different ways of moving video data between user space and the peripheral, some of which can be on the complex side. Separate articles will look at video I/O and the video-buf layer which has been provided to handle common tasks.

接下来,还有个小任务,是视频数据I/O的效率问题。V4L2 API定义了三种方式用于在用户空间和外围设备传输数据。后面会有独立的几篇文章探索视频I/O和视频缓冲层(用于处理一些通用的任务)。

 

Subsequent articles will appear every few weeks, and will be added to the list below:

后续的文章将会在每周出现,如下列表所示:

Part 2: registration and open()

第二部分:注册和打开

Part 3: Basic ioctl() handling

第三部分:基本ioctl()处理

Part 4: Inputs and Outputs

Part 5a: Colors and formats

Part 5b: Format negotiation

Part 6a: Basic frame I/O

Part 6b: Streaming I/O

Part 7: Controls

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值