diff options
Diffstat (limited to 'include/media/media-device.h')
-rw-r--r-- | include/media/media-device.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/include/media/media-device.h b/include/media/media-device.h new file mode 100644 index 000000000000..6a27d916c250 --- /dev/null +++ b/include/media/media-device.h | |||
@@ -0,0 +1,95 @@ | |||
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/device.h> | ||
27 | #include <linux/list.h> | ||
28 | #include <linux/mutex.h> | ||
29 | #include <linux/spinlock.h> | ||
30 | |||
31 | #include <media/media-devnode.h> | ||
32 | #include <media/media-entity.h> | ||
33 | |||
34 | /** | ||
35 | * struct media_device - Media device | ||
36 | * @dev: Parent device | ||
37 | * @devnode: Media device node | ||
38 | * @model: Device model name | ||
39 | * @serial: Device serial number (optional) | ||
40 | * @bus_info: Unique and stable device location identifier | ||
41 | * @hw_revision: Hardware device revision | ||
42 | * @driver_version: Device driver version | ||
43 | * @entity_id: ID of the next entity to be registered | ||
44 | * @entities: List of registered entities | ||
45 | * @lock: Entities list lock | ||
46 | * @graph_mutex: Entities graph operation lock | ||
47 | * | ||
48 | * This structure represents an abstract high-level media device. It allows easy | ||
49 | * access to entities and provides basic media device-level support. The | ||
50 | * structure can be allocated directly or embedded in a larger structure. | ||
51 | * | ||
52 | * The parent @dev is a physical device. It must be set before registering the | ||
53 | * media device. | ||
54 | * | ||
55 | * @model is a descriptive model name exported through sysfs. It doesn't have to | ||
56 | * be unique. | ||
57 | */ | ||
58 | struct media_device { | ||
59 | /* dev->driver_data points to this struct. */ | ||
60 | struct device *dev; | ||
61 | struct media_devnode devnode; | ||
62 | |||
63 | char model[32]; | ||
64 | char serial[40]; | ||
65 | char bus_info[32]; | ||
66 | u32 hw_revision; | ||
67 | u32 driver_version; | ||
68 | |||
69 | u32 entity_id; | ||
70 | struct list_head entities; | ||
71 | |||
72 | /* Protects the entities list */ | ||
73 | spinlock_t lock; | ||
74 | /* Serializes graph operations. */ | ||
75 | struct mutex graph_mutex; | ||
76 | |||
77 | int (*link_notify)(struct media_pad *source, | ||
78 | struct media_pad *sink, u32 flags); | ||
79 | }; | ||
80 | |||
81 | /* media_devnode to media_device */ | ||
82 | #define to_media_device(node) container_of(node, struct media_device, devnode) | ||
83 | |||
84 | int __must_check media_device_register(struct media_device *mdev); | ||
85 | void media_device_unregister(struct media_device *mdev); | ||
86 | |||
87 | int __must_check media_device_register_entity(struct media_device *mdev, | ||
88 | struct media_entity *entity); | ||
89 | void media_device_unregister_entity(struct media_entity *entity); | ||
90 | |||
91 | /* Iterate over all entities. */ | ||
92 | #define media_device_for_each_entity(entity, mdev) \ | ||
93 | list_for_each_entry(entity, &(mdev)->entities, list) | ||
94 | |||
95 | #endif | ||