[media] media_device: add a topology version field
[deliverable/linux.git] / include / media / media-device.h
1 /*
2 * Media device
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_DEVICE_H
24 #define _MEDIA_DEVICE_H
25
26 #include <linux/list.h>
27 #include <linux/mutex.h>
28 #include <linux/spinlock.h>
29
30 #include <media/media-devnode.h>
31 #include <media/media-entity.h>
32
33 struct device;
34
35 /**
36 * struct media_device - Media device
37 * @dev: Parent device
38 * @devnode: Media device node
39 * @model: Device model name
40 * @serial: Device serial number (optional)
41 * @bus_info: Unique and stable device location identifier
42 * @hw_revision: Hardware device revision
43 * @driver_version: Device driver version
44 * @topology_version: Monotonic counter for storing the version of the graph
45 * topology. Should be incremented each time the topology changes.
46 * @entity_id: Unique ID used on the last entity registered
47 * @pad_id: Unique ID used on the last pad registered
48 * @link_id: Unique ID used on the last link registered
49 * @intf_devnode_id: Unique ID used on the last interface devnode registered
50 * @entities: List of registered entities
51 * @interfaces: List of registered interfaces
52 * @pads: List of registered pads
53 * @links: List of registered links
54 * @lock: Entities list lock
55 * @graph_mutex: Entities graph operation lock
56 * @link_notify: Link state change notification callback
57 *
58 * This structure represents an abstract high-level media device. It allows easy
59 * access to entities and provides basic media device-level support. The
60 * structure can be allocated directly or embedded in a larger structure.
61 *
62 * The parent @dev is a physical device. It must be set before registering the
63 * media device.
64 *
65 * @model is a descriptive model name exported through sysfs. It doesn't have to
66 * be unique.
67 */
68 struct media_device {
69 /* dev->driver_data points to this struct. */
70 struct device *dev;
71 struct media_devnode devnode;
72
73 char model[32];
74 char serial[40];
75 char bus_info[32];
76 u32 hw_revision;
77 u32 driver_version;
78
79 u32 topology_version;
80
81 u32 entity_id;
82 u32 pad_id;
83 u32 link_id;
84 u32 intf_devnode_id;
85
86 struct list_head entities;
87 struct list_head interfaces;
88 struct list_head pads;
89 struct list_head links;
90
91 /* Protects the entities list */
92 spinlock_t lock;
93 /* Serializes graph operations. */
94 struct mutex graph_mutex;
95
96 int (*link_notify)(struct media_link *link, u32 flags,
97 unsigned int notification);
98 };
99
100 #ifdef CONFIG_MEDIA_CONTROLLER
101
102 /* Supported link_notify @notification values. */
103 #define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0
104 #define MEDIA_DEV_NOTIFY_POST_LINK_CH 1
105
106 /* media_devnode to media_device */
107 #define to_media_device(node) container_of(node, struct media_device, devnode)
108
109 int __must_check __media_device_register(struct media_device *mdev,
110 struct module *owner);
111 #define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE)
112 void media_device_unregister(struct media_device *mdev);
113
114 int __must_check media_device_register_entity(struct media_device *mdev,
115 struct media_entity *entity);
116 void media_device_unregister_entity(struct media_entity *entity);
117 struct media_device *media_device_get_devres(struct device *dev);
118 struct media_device *media_device_find_devres(struct device *dev);
119
120 /* Iterate over all entities. */
121 #define media_device_for_each_entity(entity, mdev) \
122 list_for_each_entry(entity, &(mdev)->entities, graph_obj.list)
123
124 /* Iterate over all interfaces. */
125 #define media_device_for_each_intf(intf, mdev) \
126 list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list)
127
128 /* Iterate over all pads. */
129 #define media_device_for_each_pad(pad, mdev) \
130 list_for_each_entry(pad, &(mdev)->pads, graph_obj.list)
131
132 /* Iterate over all links. */
133 #define media_device_for_each_link(link, mdev) \
134 list_for_each_entry(link, &(mdev)->links, graph_obj.list)
135
136
137 #else
138 static inline int media_device_register(struct media_device *mdev)
139 {
140 return 0;
141 }
142 static inline void media_device_unregister(struct media_device *mdev)
143 {
144 }
145 static inline int media_device_register_entity(struct media_device *mdev,
146 struct media_entity *entity)
147 {
148 return 0;
149 }
150 static inline void media_device_unregister_entity(struct media_entity *entity)
151 {
152 }
153 static inline struct media_device *media_device_get_devres(struct device *dev)
154 {
155 return NULL;
156 }
157 static inline struct media_device *media_device_find_devres(struct device *dev)
158 {
159 return NULL;
160 }
161 #endif /* CONFIG_MEDIA_CONTROLLER */
162 #endif
This page took 0.041299 seconds and 5 git commands to generate.