diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-08-20 08:07:34 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-01-11 09:18:44 -0500 |
commit | 27e543fa87deea308f0cc5224ab19e397b0a5ded (patch) | |
tree | 08663a0ad6f7dcedaed61874aeb7f661c108bc3f /include/media | |
parent | a1d2510ebd7a14f0d1a89c138101beaeac076dd2 (diff) |
[media] media: add functions to allow creating interfaces
Interfaces are different than entities: they represent a
Kernel<->userspace interaction, while entities represent a
piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to
store the interfaces.
Later patches should change the existing drivers and logic
to split the current interface embedded inside the entity
structure (device nodes) into a separate object of the graph.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/media-device.h | 2 | ||||
-rw-r--r-- | include/media/media-entity.h | 48 |
2 files changed, 50 insertions, 0 deletions
diff --git a/include/media/media-device.h b/include/media/media-device.h index 05414e351f8e..3b14394d5701 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h | |||
@@ -44,6 +44,7 @@ struct device; | |||
44 | * @entity_id: Unique ID used on the last entity registered | 44 | * @entity_id: Unique ID used on the last entity registered |
45 | * @pad_id: Unique ID used on the last pad registered | 45 | * @pad_id: Unique ID used on the last pad registered |
46 | * @link_id: Unique ID used on the last link registered | 46 | * @link_id: Unique ID used on the last link registered |
47 | * @intf_devnode_id: Unique ID used on the last interface devnode registered | ||
47 | * @entities: List of registered entities | 48 | * @entities: List of registered entities |
48 | * @lock: Entities list lock | 49 | * @lock: Entities list lock |
49 | * @graph_mutex: Entities graph operation lock | 50 | * @graph_mutex: Entities graph operation lock |
@@ -73,6 +74,7 @@ struct media_device { | |||
73 | u32 entity_id; | 74 | u32 entity_id; |
74 | u32 pad_id; | 75 | u32 pad_id; |
75 | u32 link_id; | 76 | u32 link_id; |
77 | u32 intf_devnode_id; | ||
76 | 78 | ||
77 | struct list_head entities; | 79 | struct list_head entities; |
78 | 80 | ||
diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a493dd9910f4..4d5fc91c4134 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h | |||
@@ -36,11 +36,14 @@ | |||
36 | * @MEDIA_GRAPH_ENTITY: Identify a media entity | 36 | * @MEDIA_GRAPH_ENTITY: Identify a media entity |
37 | * @MEDIA_GRAPH_PAD: Identify a media pad | 37 | * @MEDIA_GRAPH_PAD: Identify a media pad |
38 | * @MEDIA_GRAPH_LINK: Identify a media link | 38 | * @MEDIA_GRAPH_LINK: Identify a media link |
39 | * @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via | ||
40 | * a device node | ||
39 | */ | 41 | */ |
40 | enum media_gobj_type { | 42 | enum media_gobj_type { |
41 | MEDIA_GRAPH_ENTITY, | 43 | MEDIA_GRAPH_ENTITY, |
42 | MEDIA_GRAPH_PAD, | 44 | MEDIA_GRAPH_PAD, |
43 | MEDIA_GRAPH_LINK, | 45 | MEDIA_GRAPH_LINK, |
46 | MEDIA_GRAPH_INTF_DEVNODE, | ||
44 | }; | 47 | }; |
45 | 48 | ||
46 | #define MEDIA_BITS_PER_TYPE 8 | 49 | #define MEDIA_BITS_PER_TYPE 8 |
@@ -141,6 +144,34 @@ struct media_entity { | |||
141 | } info; | 144 | } info; |
142 | }; | 145 | }; |
143 | 146 | ||
147 | /** | ||
148 | * struct media_intf_devnode - Define a Kernel API interface | ||
149 | * | ||
150 | * @graph_obj: embedded graph object | ||
151 | * @type: Type of the interface as defined at the | ||
152 | * uapi/media/media.h header, e. g. | ||
153 | * MEDIA_INTF_T_* | ||
154 | * @flags: Interface flags as defined at uapi/media/media.h | ||
155 | */ | ||
156 | struct media_interface { | ||
157 | struct media_gobj graph_obj; | ||
158 | u32 type; | ||
159 | u32 flags; | ||
160 | }; | ||
161 | |||
162 | /** | ||
163 | * struct media_intf_devnode - Define a Kernel API interface via a device node | ||
164 | * | ||
165 | * @intf: embedded interface object | ||
166 | * @major: Major number of a device node | ||
167 | * @minor: Minor number of a device node | ||
168 | */ | ||
169 | struct media_intf_devnode { | ||
170 | struct media_interface intf; | ||
171 | u32 major; | ||
172 | u32 minor; | ||
173 | }; | ||
174 | |||
144 | static inline u32 media_entity_type(struct media_entity *entity) | 175 | static inline u32 media_entity_type(struct media_entity *entity) |
145 | { | 176 | { |
146 | return entity->type & MEDIA_ENT_TYPE_MASK; | 177 | return entity->type & MEDIA_ENT_TYPE_MASK; |
@@ -205,6 +236,18 @@ struct media_entity_graph { | |||
205 | #define gobj_to_link(gobj) \ | 236 | #define gobj_to_link(gobj) \ |
206 | container_of(gobj, struct media_link, graph_obj) | 237 | container_of(gobj, struct media_link, graph_obj) |
207 | 238 | ||
239 | #define gobj_to_link(gobj) \ | ||
240 | container_of(gobj, struct media_link, graph_obj) | ||
241 | |||
242 | #define gobj_to_pad(gobj) \ | ||
243 | container_of(gobj, struct media_pad, graph_obj) | ||
244 | |||
245 | #define gobj_to_intf(gobj) \ | ||
246 | container_of(gobj, struct media_interface, graph_obj) | ||
247 | |||
248 | #define intf_to_devnode(intf) \ | ||
249 | container_of(intf, struct media_intf_devnode, intf) | ||
250 | |||
208 | void media_gobj_init(struct media_device *mdev, | 251 | void media_gobj_init(struct media_device *mdev, |
209 | enum media_gobj_type type, | 252 | enum media_gobj_type type, |
210 | struct media_gobj *gobj); | 253 | struct media_gobj *gobj); |
@@ -236,6 +279,11 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, | |||
236 | struct media_pipeline *pipe); | 279 | struct media_pipeline *pipe); |
237 | void media_entity_pipeline_stop(struct media_entity *entity); | 280 | void media_entity_pipeline_stop(struct media_entity *entity); |
238 | 281 | ||
282 | struct media_intf_devnode *media_devnode_create(struct media_device *mdev, | ||
283 | u32 type, u32 flags, | ||
284 | u32 major, u32 minor, | ||
285 | gfp_t gfp_flags); | ||
286 | void media_devnode_remove(struct media_intf_devnode *devnode); | ||
239 | #define media_entity_call(entity, operation, args...) \ | 287 | #define media_entity_call(entity, operation, args...) \ |
240 | (((entity)->ops && (entity)->ops->operation) ? \ | 288 | (((entity)->ops && (entity)->ops->operation) ? \ |
241 | (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) | 289 | (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) |