Linux Kernel media框架(三)

Graphtraversal

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

图遍历

 

Themedia framework provides APIs to iterate over entities in a graph.

媒体框架提供API以在图中的实体之间进行迭代。

 

Toiterate over all entities belonging to a media device, drivers can use the media_device_for_each_entity macro,defined in include/media/media-device.h.

要迭代属于媒体设备的所有实体,驱动程序可以使用media_device_for_each_entity宏(在include /media / media-device.h中定义)。

 

struct media_entity *entity;

 

media_device_for_each_entity(entity, mdev) {

/* entity will point to each entity in turn */

...

}

 

Driversmight also need to iterate over all entities in a graph that can be reached only through enabled linksstarting at a given entity. The media framework provides a depth-first graph traversal API for thatpurpose.

 

Notethat graphs with cycles (whether directed or undirected) are *NOT* supported by the graph traversal API. Toprevent infinite loops, the graph traversal code limits the maximum depth toMEDIA_ENTITY_ENUM_MAX_DEPTH, currentlydefined as 16.

 

驱动程序可能还需要迭代图形中的所有实体,只有通过从给定实体开始的已启用链接才能到达。媒体框架为此目的提供了深度优先图遍历API

 

注意,具有循环(无论是定向还是无向)的图形都不是图形遍历API支持的。为了防止无限循环,图形遍历代码将最大深度限制为MEDIA_ENTITY_ENUM_MAX_DEPTH,当前定义为16

 

Driversinitiate a graph traversal by calling

驱动程序通过调用启动图遍历

 

media_entity_graph_walk_start(struct media_entity_graph *graph,

      struct media_entity*entity);

 

Thegraph structure, provided by the caller, is initialized to start graph traversal at the given entity.

 

Driverscan then retrieve the next entity by calling

由调用者提供的图结构被初始化以在给定实体处开始图遍历。

 

然后驱动程序可以通过调用检索下一个实体

 

media_entity_graph_walk_next(struct media_entity_graph *graph);

 

When thegraph traversal is complete the function will return NULL.

 

Graphtraversal can be interrupted at any moment. No cleanup function call is required and the graph structure can befreed normally.

 

Helperfunctions can be used to find a link between two given pads, or a pad connected to another pad through anenabled link

当图遍历完成时,函数将返回NULL

 

图形遍历可以随时中断。不需要清除函数调用,并且图结构可以正常释放。

 

辅助功能可以用于找到两个给定焊盘之间的链路,或者通过使能的链路连接到另一个焊盘的焊盘

 

media_entity_find_link(struct media_pad *source,

       struct media_pad*sink);

 

media_entity_remote_source(struct media_pad *pad);

 

Refer tothe kerneldoc documentation for more information.

有关详细信息,请参阅kerneldoc文档。

 

Usecount and power handling

使用计数和功耗处理

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

 

Dueto the wide differences between drivers regarding power management needs, the media controller does not implementpower management. However, the media_entity structure includes a use_count field that mediadrivers can use to track thenumber of users of every entity for power management needs.

 

Theuse_count field is owned by media drivers and must not be touched by entity drivers. Access to the field must beprotected by the media device graph_mutex lock.

由于关于电源管理需求的驱动程序之间的广泛差异,介质控制器不实现电源管理。 但是,media_entity结构包括一个use_count字段,媒体驱动程序可以使用它来跟踪每个实体的用户数量,以满足电源管理需求。

 

use_count字段由媒体驱动程序拥有,且不能被实体驱动程序触及。 对该字段的访问必须由介质设备graph_mutex锁保护。

 

 

Linkssetup

链接设置

-----------

 

Linkproperties can be modified at runtime by calling

链接属性可以在运行时通过以下调用来修改

 

media_entity_setup_link(struct media_link *link, u32 flags);

 

Theflags argument contains the requested new link flags.

flags参数包含请求的新链路标志。

 

Theonly configurable property is the ENABLED link flag to enable/disable a link. Links marked with the IMMUTABLE linkflag can not be enabled or disabled.

唯一可配置的属性是ENABLED链路标志,用于启用/禁用链路。标记有IMMUTable链接标志的链接不能启用或禁用。

 

Whena link is enabled or disabled, the media framework calls the link_setup operation for the two entitiesat the source and sink of the link, in that order. If the second link_setup call fails, anotherlink_setup call is made on thefirst entity to restore the original link flags.

当链路被启用或禁用时,媒体框架以该顺序为链路的源和宿处的两个实体调用link_setup操作。如果第二个link_setup调用失败,则在第一个实体上进行另一个link_setup调用,以恢复原始链接标志。

 

Mediadevice drivers can be notified of link setup operations by setting the media_device::link_notify pointer to acallback function. If provided, the notification callback will be called before enabling and afterdisabling links.

可以通过将media_device:: link_notify指针设置为回调函数来通知媒体设备驱动程序链接设置操作。如果提供,将在启用之前和禁用链接之后调用通知回调。

 

Entitydrivers must implement the link_setup operation if any of their links is non-immutable. The operation musteither configure the hardware or store the configuration information to be applied later.

如果任何链接是不可变的,实体驱动程序必须实现link_setup操作。该操作必须配置硬件或存储稍后应用的配置信息。

 

Linkconfiguration must not have any side effect on other links. If an enabled link at a sink pad prevents another linkat the same pad from being enabled, the link_setup operation must return -EBUSY and can't implicitlydisable the first enabledlink.

链路配置不得对其他链路有任何副作用。如果在接收器pad处启用的链路防止在同一pad处的另一链路被启用,则link_setup操作必须返回-EBUSY并且不能隐式地禁用第一启用的链路。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值