c7d4cdf7370b0d51464e210843afb4bf876b56e8
[media-ctl.git] / media.h
1 /*
2  * Media controller test application
3  *
4  * Copyright (C) 2010 Ideas on board SPRL <laurent.pinchart@ideasonboard.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  */
19
20 #ifndef __MEDIA_H__
21 #define __MEDIA_H__
22
23 #include <linux/media.h>
24
25 struct media_entity_link {
26         struct media_entity_pad *source;
27         struct media_entity_pad *sink;
28         struct media_entity_link *twin;
29         __u32 flags;
30         __u32 padding[3];
31 };
32
33 struct media_entity_pad {
34         struct media_entity *entity;
35         __u32 index;
36         __u32 flags;
37         __u32 padding[3];
38 };
39
40 struct media_entity {
41         struct media_entity_desc info;
42         struct media_entity_pad *pads;
43         struct media_entity_link *links;
44         unsigned int max_links;
45         unsigned int num_links;
46
47         char devname[32];
48         int fd;
49         __u32 padding[6];
50 };
51
52 struct media_device {
53         int fd;
54         struct media_entity *entities;
55         unsigned int entities_count;
56         __u32 padding[6];
57 };
58
59 struct media_device *media_open(const char *name, int verbose);
60 void media_close(struct media_device *media);
61
62 struct media_entity_pad *media_entity_remote_source(struct media_entity_pad *pad);
63
64 static inline unsigned int media_entity_type(struct media_entity *entity)
65 {
66         return entity->info.type & MEDIA_ENTITY_TYPE_MASK;
67 }
68
69 struct media_entity *media_get_entity_by_name(struct media_device *media,
70         const char *name, size_t length);
71 struct media_entity *media_get_entity_by_id(struct media_device *media,
72         __u32 id);
73 int media_setup_link(struct media_device *media,
74         struct media_entity_pad *source, struct media_entity_pad *sink,
75         __u32 flags);
76 int media_reset_links(struct media_device *media);
77
78 #endif
79