Linux Kernel media框架(一)
Linuxkernel media framework
Linux内核媒体框架
============================
Thisdocument describes the Linux kernel media framework, its data structures, functions and their usage.
本文档描述了Linux内核媒体框架,其数据结构,功能及其用法。
Introduction
介绍
------------
Themedia controller API is documented in DocBook format inDocumentation/DocBook/media/v4l/media-controller.xml.This document will focus onthe kernel-side implementation of the media framework.
媒体控制器API以DocBook格式记录在Documentation / DocBook / media / v4l /media-controller.xml中。本文档将重点介绍媒体框架的内核端实现。
Abstractmedia device model
抽象媒体设备模型
---------------------------
Discoveringa device internal topology, and configuring it at runtime, is one of the goals of the media framework. Toachieve this, hardware devices are modeled as an oriented graph of building blocks called entitiesconnected through pads.
媒体框架的目标之一是发现设备内部拓扑,实时配置。为了实现这个目标,硬件设备被建模为一些图形积木,称为用垫子连接的实体。
Anentity is a basic media hardware building block. It can correspond to a large variety of logical blocks such asphysical hardware devices (CMOSsensor for instance), logical hardware devices (a building block in a System-on-Chip image processingpipeline), DMA channels or physical connectors.
一个entity是一个基本的媒体硬件积木。它可以和大量的逻辑模块--譬如物理硬件设备(CMOS传感器), 逻辑硬件设备(一个SOC图形处理流水线积木),DMA通道或者物理连接器通信。
Apad is a connection endpoint through which an entity can interact with other entities. Data (not restricted tovideo) produced by an entity flowsfrom the entity's output to one or more entity inputs. Pads should not be confused with physical pins at chipboundaries.
pad是用于entity和其他entity互通的连接端点。entity产生的数据(不仅是video)从该entity的输出流向一个或多个entity的输入。pads不能与芯片的物理pin脚弄混了。
Alink is a point-to-point oriented connection between two pads, either on the same entity or on differententities. Data flows from a source pad to a sink pad.
一个link是两个pads之间的点对点连接,可以是同一个entity或者不同的entity之间。数据从pad源流向pad终点。
Mediadevice
媒体设备
------------
Amedia device is represented by a struct media_device instance, defined in include/media/media-device.h. Allocationof the structure is handled by the media device driver, usually by embedding the media_device instancein a larger driver-specificstructure.
一个媒体设备是用media_device来代表,媒体设备驱动会申请该结构体,通常一个media_device实体是嵌入在一个特定的驱动结构体中。
驱动调用该函数来注册媒体设备
media_device_register(struct media_device *mdev);
Thecaller is responsible for initializing the media_device structure before registration. The following fields must beset:
调用者必须在注册前初始化media_device结构体,以下域必须设置:
- dev must point to the parent device (usuallya pci_dev, usb_interface or platform_device instance).
- dev必须指向父设备(通常是pci_dev,usb_interface或platform_device实例)。
- model must be filled with the device modelname as a NUL-terminated UTF-8 string. The device/model revision must not bestored in this field.
- 模型必须用设备型号名称作为NUL终止的UTF-8字符串填充。 设备/型号修订版不能存储在此字段中。
以下域是可选择的:
- serial is a unique serial number stored as aNUL-terminated ASCII string. Thefield is big enough to store a GUID in text form. If the hardware doesn'tprovide a unique serial number this field must be left empty.
- serial是存储以NUL为终止符的ASCII字符串的唯一序列号。该字段足够大,可以以文本形式存储GUID。如果硬件不提供唯一的序列号,则此字段必须留空。
- bus_info represents the location of thedevice in the system as a NUL-terminated ASCII string. For PCI/PCIe devicesbus_info must be set to "PCI:" (or "PCIe:") followed by thevalue of pci_name(). For USB devices, the usb_make_path() function must beused. This field is used by applications to distinguish between otherwise identical devices thatdon't provide a serial number.
- bus_info表示设备在系统中的位置,以NUL为终止符的ASCII字符串。对于PCI / PCIe设备,bus_info必须设置为“PCI:”(或“PCIe:”),后跟pci_name()的值。对于USB设备,必须使用usb_make_path()函数。此字段被应用程序用于区分不提供序列号的其他相同设备。
- hw_revision is the hardware device revisionin a driver-specific format. Whenpossible the revision should be formatted with the KERNEL_VERSION macro.
- hw_revision是驱动程序特定格式的硬件设备版本。如果可能,修订版本应使用KERNEL_VERSION宏进行格式化。
- driver_version is formatted with theKERNEL_VERSION macro. The version minormust be incremented when new features are added to the userspace API without breaking binary compatibility. Theversion major must be incremented whenbinary compatibility is broken.
- driver_version使用KERNEL_VERSION宏格式化。在将新功能添加到用户空间API时不会破坏二进制兼容性,必须增加次编号。当二进制兼容性损坏时,主编号必须递增。
Uponsuccessful registration a character device named media[0-9]+ is created. The device major and minor numbers aredynamic. The model name is exported as a sysfs attribute.
Driversunregister media device instances by calling
media_device_unregister(struct media_device *mdev);
Unregisteringa media device that hasn't been registered is *NOT* safe.
成功注册后,将创建一个名为media[0-9] +的字符设备。 设备主编号和次编号是动态的。模型名称导出为sysfs属性。
驱动程序通过调用注销媒体设备实例
media_device_unregister(structmedia_device * mdev);
注销尚未注册的媒体设备是不安全的。
更多推荐
所有评论(0)