[media] uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl
[deliverable/linux.git] / include / media / media-device.h
CommitLineData
176fb0d1
LP
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
176fb0d1 26#include <linux/list.h>
503c3d82 27#include <linux/mutex.h>
53e269c1 28#include <linux/spinlock.h>
176fb0d1
LP
29
30#include <media/media-devnode.h>
53e269c1 31#include <media/media-entity.h>
176fb0d1 32
313162d0
PG
33struct device;
34
176fb0d1
LP
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
bfab2aac 44 * @entity_id: Unique ID used on the last entity registered
18710dc6 45 * @pad_id: Unique ID used on the last pad registered
6b6a4278 46 * @link_id: Unique ID used on the last link registered
27e543fa 47 * @intf_devnode_id: Unique ID used on the last interface devnode registered
53e269c1 48 * @entities: List of registered entities
57cf79b7 49 * @interfaces: List of registered interfaces
53e269c1 50 * @lock: Entities list lock
503c3d82 51 * @graph_mutex: Entities graph operation lock
813f5c0a 52 * @link_notify: Link state change notification callback
176fb0d1
LP
53 *
54 * This structure represents an abstract high-level media device. It allows easy
55 * access to entities and provides basic media device-level support. The
56 * structure can be allocated directly or embedded in a larger structure.
57 *
58 * The parent @dev is a physical device. It must be set before registering the
59 * media device.
60 *
61 * @model is a descriptive model name exported through sysfs. It doesn't have to
62 * be unique.
63 */
64struct media_device {
65 /* dev->driver_data points to this struct. */
66 struct device *dev;
67 struct media_devnode devnode;
68
69 char model[32];
70 char serial[40];
71 char bus_info[32];
72 u32 hw_revision;
73 u32 driver_version;
53e269c1
LP
74
75 u32 entity_id;
18710dc6 76 u32 pad_id;
6b6a4278 77 u32 link_id;
27e543fa 78 u32 intf_devnode_id;
bfab2aac 79
53e269c1 80 struct list_head entities;
57cf79b7 81 struct list_head interfaces;
53e269c1
LP
82
83 /* Protects the entities list */
84 spinlock_t lock;
503c3d82
LP
85 /* Serializes graph operations. */
86 struct mutex graph_mutex;
97548ed4 87
813f5c0a
SN
88 int (*link_notify)(struct media_link *link, u32 flags,
89 unsigned int notification);
176fb0d1
LP
90};
91
e576d60b
SK
92#ifdef CONFIG_MEDIA_CONTROLLER
93
813f5c0a
SN
94/* Supported link_notify @notification values. */
95#define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0
96#define MEDIA_DEV_NOTIFY_POST_LINK_CH 1
97
176fb0d1
LP
98/* media_devnode to media_device */
99#define to_media_device(node) container_of(node, struct media_device, devnode)
100
85de721c
SA
101int __must_check __media_device_register(struct media_device *mdev,
102 struct module *owner);
103#define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE)
176fb0d1
LP
104void media_device_unregister(struct media_device *mdev);
105
53e269c1
LP
106int __must_check media_device_register_entity(struct media_device *mdev,
107 struct media_entity *entity);
108void media_device_unregister_entity(struct media_entity *entity);
d062f911
SK
109struct media_device *media_device_get_devres(struct device *dev);
110struct media_device *media_device_find_devres(struct device *dev);
53e269c1
LP
111
112/* Iterate over all entities. */
113#define media_device_for_each_entity(entity, mdev) \
114 list_for_each_entry(entity, &(mdev)->entities, list)
115
e576d60b
SK
116#else
117static inline int media_device_register(struct media_device *mdev)
118{
119 return 0;
120}
121static inline void media_device_unregister(struct media_device *mdev)
122{
123}
124static inline int media_device_register_entity(struct media_device *mdev,
125 struct media_entity *entity)
126{
127 return 0;
128}
129static inline void media_device_unregister_entity(struct media_entity *entity)
130{
131}
132static inline struct media_device *media_device_get_devres(struct device *dev)
133{
134 return NULL;
135}
136static inline struct media_device *media_device_find_devres(struct device *dev)
137{
138 return NULL;
139}
140#endif /* CONFIG_MEDIA_CONTROLLER */
176fb0d1 141#endif
This page took 0.18189 seconds and 5 git commands to generate.