Linux Kernel media框架(二)

Entities,pads and links

实体,垫和链接

------------------------

 

-Entities

- 实体

Entitiesare represented by a struct media_entity instance, defined in include/media/media-entity.h. Thestructure is usually embedded into a higher-level structure, such as a v4l2_subdev or video_deviceinstance, although drivers canallocate entities directly.

 

实体由一个structmedia_entity实例表示,在include / media / media-entity.h中定义。 结构通常嵌入到一个较高级别的结构,例如v4l2_subdevvideo_device实例,虽然驱动程序可以直接分配实体。

 

Driversinitialize entities by calling

 

驱动程序通过调用来初始化实体

 

media_entity_init(struct media_entity *entity, u16 num_pads,

  struct media_pad *pads, u16extra_links);

 

Themedia_entity name, type, flags, revision and group_id fields can be initialized before or after callingmedia_entity_init. Entities embedded in higher-level standard structures can have some of those fields setby the higher-level framework.

 

Asthe number of pads is known in advance, the pads array is not allocated dynamically but is managed by the entitydriver. Most drivers will embed the pads array in a driver-specific structure, avoiding dynamicallocation.

 

Driversmust set the direction of every pad in the pads array before calling media_entity_init. The function willinitialize the other pads fields.

 

Unlikethe number of pads, the total number of links isn't always known in advance by the entity driver. As aninitial estimate, media_entity_init pre-allocates a number of links equal to the number of pads plus anoptional number of extralinks. The links array will be reallocated if it grows beyond the initial estimate.

可以在调用media_entity_init之前或之后初始化media_entity name, type, flagsrevisiongroup_id字段。 嵌入在较高级别标准结构中的实体可以具有由较高级别框架设置其中的某些字段。

 

由于pad的数目是预先已知的,所以pad阵列不是动态分配的,而是由实体驱动器管理。 大多数驱动程序会将驱动程序阵列嵌入到驱动程序特定的结构中,从而避免动态分配。

 

驱动程序必须在调用media_entity_init之前设置pad数组中每个pad的方向。 该功能将初始化其他pad字段。

 

pad的数量不同,链接的总数不总是由实体驱动程序预先知道。 作为初始估计,media_entity_init预分配等于衬垫数量的链路数量加上可选数量的额外链路。如果链路数组增长超过初始估计,它将被重新分配。

 

Driversregister entities with a media device by calling

驱动程序通过下面调用向媒体设备注册实体

 

media_device_register_entity(structmedia_device *mdev,

     struct media_entity*entity);

 

Entitiesare identified by a unique positive integer ID. Drivers can provide an ID by filling the media_entity id fieldprior to registration, or request the media controller framework to assign an ID automatically. Driversthat provide IDs manually mustensure that all IDs are unique. IDs are not guaranteed to be contiguous even when they are all assignedautomatically by the framework.

实体由唯一的正整数ID标识。 驱动程序可以在注册之前填充media_entity id字段来提供ID,或者请求媒体控制器框架自动分配ID。 手动提供ID的驱动程序必须确保所有ID是唯一的。 ID不能保证是连续的,即使它们都由框架自动分配。

 

Driversunregister entities by calling

驱动程序通过调用注销实体

 

media_device_unregister_entity(structmedia_entity *entity);

 

Unregisteringan entity will not change the IDs of the other entities, and the ID will never be reused for a newlyregistered entity.

 

Whena media device is unregistered, all its entities are unregistered automatically. No manual entitiesunregistration is then required.

 

注销实体不会更改其他实体的ID,并且ID将永远不会重新用于新注册的实体。

 

当媒体设备未注册时,其所有实体都将自动取消注册。 不需要手动实体注销。

 

Driversfree resources associated with an entity by calling

驱动程序通过调用与实体相关联的自由资源

media_entity_cleanupstructmedia_entity * entity;

 

Thisfunction must be called during the cleanup phase after unregistering the entity. Note that the media_entityinstance itself must be freed explicitly by the driver if required.

在注销实体后,必须在清除阶段调用此函数。请注意,如果需要,驱动程序必须显式释放media_entity实例本身。

 

 

Entitieshave flags that describe the entity capabilities and state.

实体具有描述实体能力和状态的标志。

MEDIA_ENT_FL_DEFAULT indicates the default entity for a given type. This can be used to report the defaultaudio and video devices or the default camera sensor.

MEDIA_ENT_FL_DEFAULT表示给定类型的默认实体。这可用于报告默认的音频和视频设备或默认相机传感器。

Logicalentity groups can be defined by setting the group ID of all member entities to the same non-zero value. Anentity group serves no purpose in the kernel, but is reported to userspace during entities enumeration.The group_id field belongs tothe media device driver and must not by touched by entity drivers.

 

Mediadevice drivers should define groups if several entities are logically bound together. Example usages includereporting

- ALSA, VBI and video nodes that carry the same media stream

- lens and flash controllers associated with a sensor

 

逻辑实体组可以通过将所有成员实体的组ID设置为相同的非零值来定义。实体组在内核中不起作用,但在实体枚举期间会报告给用户空间。 group_id字段属于媒体设备驱动程序,且不能由实体驱动程序触摸。

 

如果几个实体在逻辑上绑定在一起,媒体设备驱动程序应该定义组。示例用法包括报告

- 携带相同媒体流的ALSAVBI和视频节点

- 与传感器相关联的透镜和闪光控制器

 

- Pads

 

Padsare represented by a struct media_pad instance, defined in include/media/media-entity.h. Each entitystores its pads in a pads array managed by the entity driver. Drivers usually embed the array in a driver-specific structure.

 

Padsare identified by their entity and their 0-based index in the pads array. Both information are stored in themedia_pad structure, making the media_pad pointer the canonical way to store and pass link references.

Padshave flags that describe the pad capabilities and state.

 

MEDIA_PAD_FL_SINK indicates that the pad supports sinking data.

MEDIA_PAD_FL_SOURCE indicates that the pad supports sourcing data.

 

Oneand only one of MEDIA_PAD_FL_SINK and MEDIA_PAD_FL_SOURCE must be set for each pad.

pad由一个struct media_pad实例表示,在include / media / media-entity.h中定义。 每个实体将其焊盘存储在由实体驱动器管理的焊盘阵列中。 驱动程序通常将数组嵌入到驱动程序特定的结构中。

 

pads由其实体和其在pads阵列中的基于0的索引来标识。 这两个信息都存储在media_pad结构中,使media_pad指针可以存储和传递链接引用的规范方式。

pads具有描述pad的能力和状态的标志。

 

MEDIA_PAD_FL_SINK表示该pad支持目标数据。

MEDIA_PAD_FL_SOURCE表示该pad支持源数据。

 

必须为每个pad设置MEDIA_PAD_FL_SINKMEDIA_PAD_FL_SOURCE中的一个且仅有一个。

 

- Links

 

Linksare represented by a struct media_link instance, defined in include/media/media-entity.h. Each entitystores all links originating at or targeting any of its pads in a links array. A given link is thusstored twice, once in thesource entity and once in the target entity. The array is pre-allocated and grows dynamically asneeded.

- 链接

 

链接由structmedia_link实例表示,在include / media / media-entity.h中定义。每个实体存储源自或针对链路阵列中的任何其pads的所有链路。因此,给定链接被存储两次,一次在源实体中,一次在目标实体中。数组是预分配并根据需要动态增长。

 

Driverscreate links by calling

驱动程序通过调用创建链接

 

media_entity_create_link(struct media_entity *source, u16source_pad,

 struct media_entity*sink,   u16 sink_pad,

 u32 flags);

 

Anentry in the link array of each entity is allocated and stores pointers to source and sink pads.

 

Linkshave flags that describe the link capabilities and state.

 

每个实体的链接阵列中的条目被分配并且存储指向源和接收pads的指针。

 

链接具有描述链接能力和状态的标志。

 

MEDIA_LNK_FL_ENABLED indicates that the link is enabled and can beused to transfer media data.When two or more links target a sink pad, only one of them can be enabled at a time.

MEDIA_LNK_FL_IMMUTABLE indicates that the link enabled state can'tbe modified at runtime. IfMEDIA_LNK_FL_IMMUTABLE is set, then MEDIA_LNK_FL_ENABLED must also be set since an immutable link isalways enabled.

 

MEDIA_LNK_FL_ENABLED表示链接已启用,可用于传输媒体数据。当两个或更多链路以接收器焊盘为目标时,每次只能启用其中一个。

MEDIA_LNK_FL_IMMUTABLE指示无法在运行时修改链接启用状态。如果设置MEDIA_LNK_FL_IMMUTABLE,则由于始终启用不可变链接,因此也必须设置MEDIA_LNK_FL_ENABLED

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值