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
47struct media_entity_operations {
48 int (*link_setup)(struct media_entity *entity,
49 const struct media_pad *local,
50 const struct media_pad *remote, u32 flags);
51 int (*link_validate)(struct media_link *link);
52};
53
54struct media_entity {
55 struct list_head list;
56 struct media_device *parent;
57 u32 id;
58
59 const char *name;
60 u32 type;
61 u32 revision;
62 unsigned long flags;
63 u32 group_id;
64
65 u16 num_pads;
66 u16 num_links;
67
68 u16 num_backlinks;
69 u16 max_links;
70
71 struct media_pad *pads;
72 struct media_link *links;
73
74 const struct media_entity_operations *ops;
75
76
77
78
79
80 int stream_count;
81 int use_count;
82
83 struct media_pipeline *pipe;
84
85 union {
86
87 struct {
88 u32 major;
89 u32 minor;
90 } v4l;
91 struct {
92 u32 major;
93 u32 minor;
94 } fb;
95 struct {
96 u32 card;
97 u32 device;
98 u32 subdevice;
99 } alsa;
100 int dvb;
101
102
103
104 } info;
105};
106
107static inline u32 media_entity_type(struct media_entity *entity)
108{
109 return entity->type & MEDIA_ENT_TYPE_MASK;
110}
111
112static inline u32 media_entity_subtype(struct media_entity *entity)
113{
114 return entity->type & MEDIA_ENT_SUBTYPE_MASK;
115}
116
117#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
118#define MEDIA_ENTITY_ENUM_MAX_ID 64
119
120struct media_entity_graph {
121 struct {
122 struct media_entity *entity;
123 int link;
124 } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
125
126 DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
127 int top;
128};
129
130int media_entity_init(struct media_entity *entity, u16 num_pads,
131 struct media_pad *pads, u16 extra_links);
132void media_entity_cleanup(struct media_entity *entity);
133
134int media_entity_create_link(struct media_entity *source, u16 source_pad,
135 struct media_entity *sink, u16 sink_pad, u32 flags);
136void __media_entity_remove_links(struct media_entity *entity);
137void media_entity_remove_links(struct media_entity *entity);
138
139int __media_entity_setup_link(struct media_link *link, u32 flags);
140int media_entity_setup_link(struct media_link *link, u32 flags);
141struct media_link *media_entity_find_link(struct media_pad *source,
142 struct media_pad *sink);
143struct media_pad *media_entity_remote_pad(struct media_pad *pad);
144
145struct media_entity *media_entity_get(struct media_entity *entity);
146void media_entity_put(struct media_entity *entity);
147
148void media_entity_graph_walk_start(struct media_entity_graph *graph,
149 struct media_entity *entity);
150struct media_entity *
151media_entity_graph_walk_next(struct media_entity_graph *graph);
152__must_check int media_entity_pipeline_start(struct media_entity *entity,
153 struct media_pipeline *pipe);
154void media_entity_pipeline_stop(struct media_entity *entity);
155
156#define media_entity_call(entity, operation, args...) \
157 (((entity)->ops && (entity)->ops->operation) ? \
158 (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
159
160#endif
161