1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _MEDIA_ENTITY_H
24#define _MEDIA_ENTITY_H
25
26#include <linux/bitops.h>
27#include <linux/kernel.h>
28#include <linux/list.h>
29#include <linux/media.h>
30
31struct media_pipeline {
32};
33
34struct media_link {
35 struct media_pad *source;
36 struct media_pad *sink;
37 struct media_link *reverse;
38 unsigned long flags;
39};
40
41struct media_pad {
42 struct media_entity *entity;
43 u16 index;
44 unsigned long flags;
45};
46
47
48
49
50
51
52
53
54
55
56struct media_entity_operations {
57 int (*link_setup)(struct media_entity *entity,
58 const struct media_pad *local,
59 const struct media_pad *remote, u32 flags);
60 int (*link_validate)(struct media_link *link);
61};
62
63struct media_entity {
64 struct list_head list;
65 struct media_device *parent;
66 u32 id;
67
68 const char *name;
69 u32 type;
70 u32 revision;
71 unsigned long flags;
72 u32 group_id;
73
74 u16 num_pads;
75 u16 num_links;
76
77 u16 num_backlinks;
78 u16 max_links;
79
80 struct media_pad *pads;
81 struct media_link *links;
82
83 const struct media_entity_operations *ops;
84
85
86
87
88
89 int stream_count;
90 int use_count;
91
92 struct media_pipeline *pipe;
93
94 union {
95
96 struct {
97 u32 major;
98 u32 minor;
99 } dev;
100
101
102
103 } info;
104};
105
106static inline u32 media_entity_type(struct media_entity *entity)
107{
108 return entity->type & MEDIA_ENT_TYPE_MASK;
109}
110
111static inline u32 media_entity_subtype(struct media_entity *entity)
112{
113 return entity->type & MEDIA_ENT_SUBTYPE_MASK;
114}
115
116#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
117#define MEDIA_ENTITY_ENUM_MAX_ID 64
118
119struct media_entity_graph {
120 struct {
121 struct media_entity *entity;
122 int link;
123 } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
124
125 DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
126 int top;
127};
128
129int media_entity_init(struct media_entity *entity, u16 num_pads,
130 struct media_pad *pads, u16 extra_links);
131void media_entity_cleanup(struct media_entity *entity);
132
133int media_entity_create_link(struct media_entity *source, u16 source_pad,
134 struct media_entity *sink, u16 sink_pad, u32 flags);
135void __media_entity_remove_links(struct media_entity *entity);
136void media_entity_remove_links(struct media_entity *entity);
137
138int __media_entity_setup_link(struct media_link *link, u32 flags);
139int media_entity_setup_link(struct media_link *link, u32 flags);
140struct media_link *media_entity_find_link(struct media_pad *source,
141 struct media_pad *sink);
142struct media_pad *media_entity_remote_pad(struct media_pad *pad);
143
144struct media_entity *media_entity_get(struct media_entity *entity);
145void media_entity_put(struct media_entity *entity);
146
147void media_entity_graph_walk_start(struct media_entity_graph *graph,
148 struct media_entity *entity);
149struct media_entity *
150media_entity_graph_walk_next(struct media_entity_graph *graph);
151__must_check int media_entity_pipeline_start(struct media_entity *entity,
152 struct media_pipeline *pipe);
153void media_entity_pipeline_stop(struct media_entity *entity);
154
155#define media_entity_call(entity, operation, args...) \
156 (((entity)->ops && (entity)->ops->operation) ? \
157 (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
158
159#endif
160