Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media: Entities, pads and links

As video hardware pipelines become increasingly complex and
configurable, the current hardware description through v4l2 subdevices
reaches its limits. In addition to enumerating and configuring
subdevices, video camera drivers need a way to discover and modify at
runtime how those subdevices are connected. This is done through new
elements called entities, pads and links.

An entity is a basic media hardware building block. It can correspond to
a large variety of logical blocks such as physical hardware devices
(CMOS sensor for instance), logical hardware devices (a building block
in a System-on-Chip image processing pipeline), DMA channels or physical
connectors.

A pad is a connection endpoint through which an entity can interact with
other entities. Data (not restricted to video) produced by an entity
flows from the entity's output to one or more entity inputs. Pads should
not be confused with physical pins at chip boundaries.

A link is a point-to-point oriented connection between two pads, either
on the same entity or on different entities. Data flows from a source
pad to a sink pad.

Links are stored in the source entity. To make backwards graph walk
faster, a copy of all links is also stored in the sink entity. The copy
is known as a backlink and is only used to help graph traversal.

The entity API is made of three functions:

- media_entity_init() initializes an entity. The caller must provide an
array of pads as well as an estimated number of links. The links array
is allocated dynamically and will be reallocated if it grows beyond the
initial estimate.

- media_entity_cleanup() frees resources allocated for an entity. It
must be called during the cleanup phase after unregistering the entity
and before freeing it.

- media_entity_create_link() creates a link between two entities. An
entry in the link array of each entity is allocated and stores pointers
to source and sink pads.

When a media device is unregistered, all its entities are unregistered
automatically.

The code is based on Hans Verkuil <hverkuil@xs4all.nl> initial work.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
53e269c1 176fb0d1

+516 -1
+20
Documentation/DocBook/v4l/media-controller.xml
··· 53 53 implementing policies that belong to userspace.</para> 54 54 <para>The media controller API aims at solving those problems.</para> 55 55 </section> 56 + 57 + <section id="media-controller-model"> 58 + <title>Media device model</title> 59 + <para>Discovering a device internal topology, and configuring it at runtime, 60 + is one of the goals of the media controller API. To achieve this, hardware 61 + devices are modelled as an oriented graph of building blocks called entities 62 + connected through pads.</para> 63 + <para>An entity is a basic media hardware or software building block. It can 64 + correspond to a large variety of logical blocks such as physical hardware 65 + devices (CMOS sensor for instance), logical hardware devices (a building 66 + block in a System-on-Chip image processing pipeline), DMA channels or 67 + physical connectors.</para> 68 + <para>A pad is a connection endpoint through which an entity can interact 69 + with other entities. Data (not restricted to video) produced by an entity 70 + flows from the entity's output to one or more entity inputs. Pads should not 71 + be confused with physical pins at chip boundaries.</para> 72 + <para>A link is a point-to-point oriented connection between two pads, 73 + either on the same entity or on different entities. Data flows from a source 74 + pad to a sink pad.</para> 75 + </section> 56 76 </chapter>
+151
Documentation/media-framework.txt
··· 13 13 the kernel-side implementation of the media framework. 14 14 15 15 16 + Abstract media device model 17 + --------------------------- 18 + 19 + Discovering a device internal topology, and configuring it at runtime, is one 20 + of the goals of the media framework. To achieve this, hardware devices are 21 + modeled as an oriented graph of building blocks called entities connected 22 + through pads. 23 + 24 + An entity is a basic media hardware building block. It can correspond to 25 + a large variety of logical blocks such as physical hardware devices 26 + (CMOS sensor for instance), logical hardware devices (a building block 27 + in a System-on-Chip image processing pipeline), DMA channels or physical 28 + connectors. 29 + 30 + A pad is a connection endpoint through which an entity can interact with 31 + other entities. Data (not restricted to video) produced by an entity 32 + flows from the entity's output to one or more entity inputs. Pads should 33 + not be confused with physical pins at chip boundaries. 34 + 35 + A link is a point-to-point oriented connection between two pads, either 36 + on the same entity or on different entities. Data flows from a source 37 + pad to a sink pad. 38 + 39 + 16 40 Media device 17 41 ------------ 18 42 ··· 89 65 media_device_unregister(struct media_device *mdev); 90 66 91 67 Unregistering a media device that hasn't been registered is *NOT* safe. 68 + 69 + 70 + Entities, pads and links 71 + ------------------------ 72 + 73 + - Entities 74 + 75 + Entities are represented by a struct media_entity instance, defined in 76 + include/media/media-entity.h. The structure is usually embedded into a 77 + higher-level structure, such as a v4l2_subdev or video_device instance, 78 + although drivers can allocate entities directly. 79 + 80 + Drivers initialize entities by calling 81 + 82 + media_entity_init(struct media_entity *entity, u16 num_pads, 83 + struct media_pad *pads, u16 extra_links); 84 + 85 + The media_entity name, type, flags, revision and group_id fields can be 86 + initialized before or after calling media_entity_init. Entities embedded in 87 + higher-level standard structures can have some of those fields set by the 88 + higher-level framework. 89 + 90 + As the number of pads is known in advance, the pads array is not allocated 91 + dynamically but is managed by the entity driver. Most drivers will embed the 92 + pads array in a driver-specific structure, avoiding dynamic allocation. 93 + 94 + Drivers must set the direction of every pad in the pads array before calling 95 + media_entity_init. The function will initialize the other pads fields. 96 + 97 + Unlike the number of pads, the total number of links isn't always known in 98 + advance by the entity driver. As an initial estimate, media_entity_init 99 + pre-allocates a number of links equal to the number of pads plus an optional 100 + number of extra links. The links array will be reallocated if it grows beyond 101 + the initial estimate. 102 + 103 + Drivers register entities with a media device by calling 104 + 105 + media_device_register_entity(struct media_device *mdev, 106 + struct media_entity *entity); 107 + 108 + Entities are identified by a unique positive integer ID. Drivers can provide an 109 + ID by filling the media_entity id field prior to registration, or request the 110 + media controller framework to assign an ID automatically. Drivers that provide 111 + IDs manually must ensure that all IDs are unique. IDs are not guaranteed to be 112 + contiguous even when they are all assigned automatically by the framework. 113 + 114 + Drivers unregister entities by calling 115 + 116 + media_device_unregister_entity(struct media_entity *entity); 117 + 118 + Unregistering an entity will not change the IDs of the other entities, and the 119 + ID will never be reused for a newly registered entity. 120 + 121 + When a media device is unregistered, all its entities are unregistered 122 + automatically. No manual entities unregistration is then required. 123 + 124 + Drivers free resources associated with an entity by calling 125 + 126 + media_entity_cleanup(struct media_entity *entity); 127 + 128 + This function must be called during the cleanup phase after unregistering the 129 + entity. Note that the media_entity instance itself must be freed explicitly by 130 + the driver if required. 131 + 132 + Entities have flags that describe the entity capabilities and state. 133 + 134 + MEDIA_ENT_FL_DEFAULT indicates the default entity for a given type. 135 + This can be used to report the default audio and video devices or the 136 + default camera sensor. 137 + 138 + Logical entity groups can be defined by setting the group ID of all member 139 + entities to the same non-zero value. An entity group serves no purpose in the 140 + kernel, but is reported to userspace during entities enumeration. The group_id 141 + field belongs to the media device driver and must not by touched by entity 142 + drivers. 143 + 144 + Media device drivers should define groups if several entities are logically 145 + bound together. Example usages include reporting 146 + 147 + - ALSA, VBI and video nodes that carry the same media stream 148 + - lens and flash controllers associated with a sensor 149 + 150 + - Pads 151 + 152 + Pads are represented by a struct media_pad instance, defined in 153 + include/media/media-entity.h. Each entity stores its pads in a pads array 154 + managed by the entity driver. Drivers usually embed the array in a 155 + driver-specific structure. 156 + 157 + Pads are identified by their entity and their 0-based index in the pads array. 158 + Both information are stored in the media_pad structure, making the media_pad 159 + pointer the canonical way to store and pass link references. 160 + 161 + Pads have flags that describe the pad capabilities and state. 162 + 163 + MEDIA_PAD_FL_SINK indicates that the pad supports sinking data. 164 + MEDIA_PAD_FL_SOURCE indicates that the pad supports sourcing data. 165 + 166 + One and only one of MEDIA_PAD_FL_SINK and MEDIA_PAD_FL_SOURCE must be set for 167 + each pad. 168 + 169 + - Links 170 + 171 + Links are represented by a struct media_link instance, defined in 172 + include/media/media-entity.h. Each entity stores all links originating at or 173 + targetting any of its pads in a links array. A given link is thus stored 174 + twice, once in the source entity and once in the target entity. The array is 175 + pre-allocated and grows dynamically as needed. 176 + 177 + Drivers create links by calling 178 + 179 + media_entity_create_link(struct media_entity *source, u16 source_pad, 180 + struct media_entity *sink, u16 sink_pad, 181 + u32 flags); 182 + 183 + An entry in the link array of each entity is allocated and stores pointers 184 + to source and sink pads. 185 + 186 + Links have flags that describe the link capabilities and state. 187 + 188 + MEDIA_LNK_FL_ENABLED indicates that the link is enabled and can be used 189 + to transfer media data. When two or more links target a sink pad, only 190 + one of them can be enabled at a time. 191 + MEDIA_LNK_FL_IMMUTABLE indicates that the link enabled state can't be 192 + modified at runtime. If MEDIA_LNK_FL_IMMUTABLE is set, then 193 + MEDIA_LNK_FL_ENABLED must also be set since an immutable link is always 194 + enabled.
+1 -1
drivers/media/Makefile
··· 2 2 # Makefile for the kernel multimedia device drivers. 3 3 # 4 4 5 - media-objs := media-device.o media-devnode.o 5 + media-objs := media-device.o media-devnode.o media-entity.o 6 6 7 7 ifeq ($(CONFIG_MEDIA_CONTROLLER),y) 8 8 obj-$(CONFIG_MEDIA_SUPPORT) += media.o
+56
drivers/media/media-device.c
··· 25 25 26 26 #include <media/media-device.h> 27 27 #include <media/media-devnode.h> 28 + #include <media/media-entity.h> 28 29 29 30 static const struct media_file_operations media_device_fops = { 30 31 .owner = THIS_MODULE, ··· 70 69 if (WARN_ON(mdev->dev == NULL || mdev->model[0] == 0)) 71 70 return -EINVAL; 72 71 72 + mdev->entity_id = 1; 73 + INIT_LIST_HEAD(&mdev->entities); 74 + spin_lock_init(&mdev->lock); 75 + 73 76 /* Register the device node. */ 74 77 mdev->devnode.fops = &media_device_fops; 75 78 mdev->devnode.parent = mdev->dev; ··· 99 94 */ 100 95 void media_device_unregister(struct media_device *mdev) 101 96 { 97 + struct media_entity *entity; 98 + struct media_entity *next; 99 + 100 + list_for_each_entry_safe(entity, next, &mdev->entities, list) 101 + media_device_unregister_entity(entity); 102 + 102 103 device_remove_file(&mdev->devnode.dev, &dev_attr_model); 103 104 media_devnode_unregister(&mdev->devnode); 104 105 } 105 106 EXPORT_SYMBOL_GPL(media_device_unregister); 107 + 108 + /** 109 + * media_device_register_entity - Register an entity with a media device 110 + * @mdev: The media device 111 + * @entity: The entity 112 + */ 113 + int __must_check media_device_register_entity(struct media_device *mdev, 114 + struct media_entity *entity) 115 + { 116 + /* Warn if we apparently re-register an entity */ 117 + WARN_ON(entity->parent != NULL); 118 + entity->parent = mdev; 119 + 120 + spin_lock(&mdev->lock); 121 + if (entity->id == 0) 122 + entity->id = mdev->entity_id++; 123 + else 124 + mdev->entity_id = max(entity->id + 1, mdev->entity_id); 125 + list_add_tail(&entity->list, &mdev->entities); 126 + spin_unlock(&mdev->lock); 127 + 128 + return 0; 129 + } 130 + EXPORT_SYMBOL_GPL(media_device_register_entity); 131 + 132 + /** 133 + * media_device_unregister_entity - Unregister an entity 134 + * @entity: The entity 135 + * 136 + * If the entity has never been registered this function will return 137 + * immediately. 138 + */ 139 + void media_device_unregister_entity(struct media_entity *entity) 140 + { 141 + struct media_device *mdev = entity->parent; 142 + 143 + if (mdev == NULL) 144 + return; 145 + 146 + spin_lock(&mdev->lock); 147 + list_del(&entity->list); 148 + spin_unlock(&mdev->lock); 149 + entity->parent = NULL; 150 + } 151 + EXPORT_SYMBOL_GPL(media_device_unregister_entity);
+147
drivers/media/media-entity.c
··· 1 + /* 2 + * Media entity 3 + * 4 + * Copyright (C) 2010 Nokia Corporation 5 + * 6 + * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 7 + * Sakari Ailus <sakari.ailus@iki.fi> 8 + * 9 + * This program is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License version 2 as 11 + * published by the Free Software Foundation. 12 + * 13 + * This program is distributed in the hope that it will be useful, 14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + * 18 + * You should have received a copy of the GNU General Public License 19 + * along with this program; if not, write to the Free Software 20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 + */ 22 + 23 + #include <linux/module.h> 24 + #include <linux/slab.h> 25 + #include <media/media-entity.h> 26 + 27 + /** 28 + * media_entity_init - Initialize a media entity 29 + * 30 + * @num_pads: Total number of sink and source pads. 31 + * @extra_links: Initial estimate of the number of extra links. 32 + * @pads: Array of 'num_pads' pads. 33 + * 34 + * The total number of pads is an intrinsic property of entities known by the 35 + * entity driver, while the total number of links depends on hardware design 36 + * and is an extrinsic property unknown to the entity driver. However, in most 37 + * use cases the entity driver can guess the number of links which can safely 38 + * be assumed to be equal to or larger than the number of pads. 39 + * 40 + * For those reasons the links array can be preallocated based on the entity 41 + * driver guess and will be reallocated later if extra links need to be 42 + * created. 43 + * 44 + * This function allocates a links array with enough space to hold at least 45 + * 'num_pads' + 'extra_links' elements. The media_entity::max_links field will 46 + * be set to the number of allocated elements. 47 + * 48 + * The pads array is managed by the entity driver and passed to 49 + * media_entity_init() where its pointer will be stored in the entity structure. 50 + */ 51 + int 52 + media_entity_init(struct media_entity *entity, u16 num_pads, 53 + struct media_pad *pads, u16 extra_links) 54 + { 55 + struct media_link *links; 56 + unsigned int max_links = num_pads + extra_links; 57 + unsigned int i; 58 + 59 + links = kzalloc(max_links * sizeof(links[0]), GFP_KERNEL); 60 + if (links == NULL) 61 + return -ENOMEM; 62 + 63 + entity->group_id = 0; 64 + entity->max_links = max_links; 65 + entity->num_links = 0; 66 + entity->num_backlinks = 0; 67 + entity->num_pads = num_pads; 68 + entity->pads = pads; 69 + entity->links = links; 70 + 71 + for (i = 0; i < num_pads; i++) { 72 + pads[i].entity = entity; 73 + pads[i].index = i; 74 + } 75 + 76 + return 0; 77 + } 78 + EXPORT_SYMBOL_GPL(media_entity_init); 79 + 80 + void 81 + media_entity_cleanup(struct media_entity *entity) 82 + { 83 + kfree(entity->links); 84 + } 85 + EXPORT_SYMBOL_GPL(media_entity_cleanup); 86 + 87 + static struct media_link *media_entity_add_link(struct media_entity *entity) 88 + { 89 + if (entity->num_links >= entity->max_links) { 90 + struct media_link *links = entity->links; 91 + unsigned int max_links = entity->max_links + 2; 92 + unsigned int i; 93 + 94 + links = krealloc(links, max_links * sizeof(*links), GFP_KERNEL); 95 + if (links == NULL) 96 + return NULL; 97 + 98 + for (i = 0; i < entity->num_links; i++) 99 + links[i].reverse->reverse = &links[i]; 100 + 101 + entity->max_links = max_links; 102 + entity->links = links; 103 + } 104 + 105 + return &entity->links[entity->num_links++]; 106 + } 107 + 108 + int 109 + media_entity_create_link(struct media_entity *source, u16 source_pad, 110 + struct media_entity *sink, u16 sink_pad, u32 flags) 111 + { 112 + struct media_link *link; 113 + struct media_link *backlink; 114 + 115 + BUG_ON(source == NULL || sink == NULL); 116 + BUG_ON(source_pad >= source->num_pads); 117 + BUG_ON(sink_pad >= sink->num_pads); 118 + 119 + link = media_entity_add_link(source); 120 + if (link == NULL) 121 + return -ENOMEM; 122 + 123 + link->source = &source->pads[source_pad]; 124 + link->sink = &sink->pads[sink_pad]; 125 + link->flags = flags; 126 + 127 + /* Create the backlink. Backlinks are used to help graph traversal and 128 + * are not reported to userspace. 129 + */ 130 + backlink = media_entity_add_link(sink); 131 + if (backlink == NULL) { 132 + source->num_links--; 133 + return -ENOMEM; 134 + } 135 + 136 + backlink->source = &source->pads[source_pad]; 137 + backlink->sink = &sink->pads[sink_pad]; 138 + backlink->flags = flags; 139 + 140 + link->reverse = backlink; 141 + backlink->reverse = link; 142 + 143 + sink->num_backlinks++; 144 + 145 + return 0; 146 + } 147 + EXPORT_SYMBOL_GPL(media_entity_create_link);
+19
include/media/media-device.h
··· 25 25 26 26 #include <linux/device.h> 27 27 #include <linux/list.h> 28 + #include <linux/spinlock.h> 28 29 29 30 #include <media/media-devnode.h> 31 + #include <media/media-entity.h> 30 32 31 33 /** 32 34 * struct media_device - Media device ··· 39 37 * @bus_info: Unique and stable device location identifier 40 38 * @hw_revision: Hardware device revision 41 39 * @driver_version: Device driver version 40 + * @entity_id: ID of the next entity to be registered 41 + * @entities: List of registered entities 42 + * @lock: Entities list lock 42 43 * 43 44 * This structure represents an abstract high-level media device. It allows easy 44 45 * access to entities and provides basic media device-level support. The ··· 63 58 char bus_info[32]; 64 59 u32 hw_revision; 65 60 u32 driver_version; 61 + 62 + u32 entity_id; 63 + struct list_head entities; 64 + 65 + /* Protects the entities list */ 66 + spinlock_t lock; 66 67 }; 67 68 68 69 /* media_devnode to media_device */ ··· 76 65 77 66 int __must_check media_device_register(struct media_device *mdev); 78 67 void media_device_unregister(struct media_device *mdev); 68 + 69 + int __must_check media_device_register_entity(struct media_device *mdev, 70 + struct media_entity *entity); 71 + void media_device_unregister_entity(struct media_entity *entity); 72 + 73 + /* Iterate over all entities. */ 74 + #define media_device_for_each_entity(entity, mdev) \ 75 + list_for_each_entry(entity, &(mdev)->entities, list) 79 76 80 77 #endif
+122
include/media/media-entity.h
··· 1 + /* 2 + * Media entity 3 + * 4 + * Copyright (C) 2010 Nokia Corporation 5 + * 6 + * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 7 + * Sakari Ailus <sakari.ailus@iki.fi> 8 + * 9 + * This program is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License version 2 as 11 + * published by the Free Software Foundation. 12 + * 13 + * This program is distributed in the hope that it will be useful, 14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + * 18 + * You should have received a copy of the GNU General Public License 19 + * along with this program; if not, write to the Free Software 20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 + */ 22 + 23 + #ifndef _MEDIA_ENTITY_H 24 + #define _MEDIA_ENTITY_H 25 + 26 + #include <linux/list.h> 27 + 28 + #define MEDIA_ENT_TYPE_SHIFT 16 29 + #define MEDIA_ENT_TYPE_MASK 0x00ff0000 30 + #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff 31 + 32 + #define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) 33 + #define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) 34 + #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) 35 + #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) 36 + #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) 37 + 38 + #define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT) 39 + #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1) 40 + #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2) 41 + #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3) 42 + 43 + #define MEDIA_ENT_FL_DEFAULT (1 << 0) 44 + 45 + #define MEDIA_LNK_FL_ENABLED (1 << 0) 46 + #define MEDIA_LNK_FL_IMMUTABLE (1 << 1) 47 + 48 + #define MEDIA_PAD_FL_SINK (1 << 0) 49 + #define MEDIA_PAD_FL_SOURCE (1 << 1) 50 + 51 + struct media_link { 52 + struct media_pad *source; /* Source pad */ 53 + struct media_pad *sink; /* Sink pad */ 54 + struct media_link *reverse; /* Link in the reverse direction */ 55 + unsigned long flags; /* Link flags (MEDIA_LNK_FL_*) */ 56 + }; 57 + 58 + struct media_pad { 59 + struct media_entity *entity; /* Entity this pad belongs to */ 60 + u16 index; /* Pad index in the entity pads array */ 61 + unsigned long flags; /* Pad flags (MEDIA_PAD_FL_*) */ 62 + }; 63 + 64 + struct media_entity { 65 + struct list_head list; 66 + struct media_device *parent; /* Media device this entity belongs to*/ 67 + u32 id; /* Entity ID, unique in the parent media 68 + * device context */ 69 + const char *name; /* Entity name */ 70 + u32 type; /* Entity type (MEDIA_ENT_T_*) */ 71 + u32 revision; /* Entity revision, driver specific */ 72 + unsigned long flags; /* Entity flags (MEDIA_ENT_FL_*) */ 73 + u32 group_id; /* Entity group ID */ 74 + 75 + u16 num_pads; /* Number of sink and source pads */ 76 + u16 num_links; /* Number of existing links, both 77 + * enabled and disabled */ 78 + u16 num_backlinks; /* Number of backlinks */ 79 + u16 max_links; /* Maximum number of links */ 80 + 81 + struct media_pad *pads; /* Pads array (num_pads elements) */ 82 + struct media_link *links; /* Links array (max_links elements)*/ 83 + 84 + union { 85 + /* Node specifications */ 86 + struct { 87 + u32 major; 88 + u32 minor; 89 + } v4l; 90 + struct { 91 + u32 major; 92 + u32 minor; 93 + } fb; 94 + struct { 95 + u32 card; 96 + u32 device; 97 + u32 subdevice; 98 + } alsa; 99 + int dvb; 100 + 101 + /* Sub-device specifications */ 102 + /* Nothing needed yet */ 103 + }; 104 + }; 105 + 106 + static inline u32 media_entity_type(struct media_entity *entity) 107 + { 108 + return entity->type & MEDIA_ENT_TYPE_MASK; 109 + } 110 + 111 + static inline u32 media_entity_subtype(struct media_entity *entity) 112 + { 113 + return entity->type & MEDIA_ENT_SUBTYPE_MASK; 114 + } 115 + 116 + int media_entity_init(struct media_entity *entity, u16 num_pads, 117 + struct media_pad *pads, u16 extra_links); 118 + void media_entity_cleanup(struct media_entity *entity); 119 + int media_entity_create_link(struct media_entity *source, u16 source_pad, 120 + struct media_entity *sink, u16 sink_pad, u32 flags); 121 + 122 + #endif