diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/media/v4l2-device.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'include/media/v4l2-device.h')
-rw-r--r-- | include/media/v4l2-device.h | 83 |
1 files changed, 65 insertions, 18 deletions
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h index 8bcbd7a0271c..d61febfb1668 100644 --- a/include/media/v4l2-device.h +++ b/include/media/v4l2-device.h | |||
@@ -21,7 +21,9 @@ | |||
21 | #ifndef _V4L2_DEVICE_H | 21 | #ifndef _V4L2_DEVICE_H |
22 | #define _V4L2_DEVICE_H | 22 | #define _V4L2_DEVICE_H |
23 | 23 | ||
24 | #include <media/media-device.h> | ||
24 | #include <media/v4l2-subdev.h> | 25 | #include <media/v4l2-subdev.h> |
26 | #include <media/v4l2-dev.h> | ||
25 | 27 | ||
26 | /* Each instance of a V4L2 device should create the v4l2_device struct, | 28 | /* Each instance of a V4L2 device should create the v4l2_device struct, |
27 | either stand-alone or embedded in a larger struct. | 29 | either stand-alone or embedded in a larger struct. |
@@ -39,6 +41,9 @@ struct v4l2_device { | |||
39 | Note: dev might be NULL if there is no parent device | 41 | Note: dev might be NULL if there is no parent device |
40 | as is the case with e.g. ISA devices. */ | 42 | as is the case with e.g. ISA devices. */ |
41 | struct device *dev; | 43 | struct device *dev; |
44 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
45 | struct media_device *mdev; | ||
46 | #endif | ||
42 | /* used to keep track of the registered subdevs */ | 47 | /* used to keep track of the registered subdevs */ |
43 | struct list_head subdevs; | 48 | struct list_head subdevs; |
44 | /* lock this struct; can be used by the driver as well if this | 49 | /* lock this struct; can be used by the driver as well if this |
@@ -51,8 +56,23 @@ struct v4l2_device { | |||
51 | unsigned int notification, void *arg); | 56 | unsigned int notification, void *arg); |
52 | /* The control handler. May be NULL. */ | 57 | /* The control handler. May be NULL. */ |
53 | struct v4l2_ctrl_handler *ctrl_handler; | 58 | struct v4l2_ctrl_handler *ctrl_handler; |
59 | /* Device's priority state */ | ||
60 | struct v4l2_prio_state prio; | ||
61 | /* BKL replacement mutex. Temporary solution only. */ | ||
62 | struct mutex ioctl_lock; | ||
63 | /* Keep track of the references to this struct. */ | ||
64 | struct kref ref; | ||
65 | /* Release function that is called when the ref count goes to 0. */ | ||
66 | void (*release)(struct v4l2_device *v4l2_dev); | ||
54 | }; | 67 | }; |
55 | 68 | ||
69 | static inline void v4l2_device_get(struct v4l2_device *v4l2_dev) | ||
70 | { | ||
71 | kref_get(&v4l2_dev->ref); | ||
72 | } | ||
73 | |||
74 | int v4l2_device_put(struct v4l2_device *v4l2_dev); | ||
75 | |||
56 | /* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev. | 76 | /* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev. |
57 | dev may be NULL in rare cases (ISA devices). In that case you | 77 | dev may be NULL in rare cases (ISA devices). In that case you |
58 | must fill in the v4l2_dev->name field before calling this function. */ | 78 | must fill in the v4l2_dev->name field before calling this function. */ |
@@ -94,6 +114,12 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, | |||
94 | wasn't registered. In that case it will do nothing. */ | 114 | wasn't registered. In that case it will do nothing. */ |
95 | void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); | 115 | void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); |
96 | 116 | ||
117 | /* Register device nodes for all subdev of the v4l2 device that are marked with | ||
118 | * the V4L2_SUBDEV_FL_HAS_DEVNODE flag. | ||
119 | */ | ||
120 | int __must_check | ||
121 | v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev); | ||
122 | |||
97 | /* Iterate over all subdevs. */ | 123 | /* Iterate over all subdevs. */ |
98 | #define v4l2_device_for_each_subdev(sd, v4l2_dev) \ | 124 | #define v4l2_device_for_each_subdev(sd, v4l2_dev) \ |
99 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) | 125 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) |
@@ -101,46 +127,67 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); | |||
101 | /* Call the specified callback for all subdevs matching the condition. | 127 | /* Call the specified callback for all subdevs matching the condition. |
102 | Ignore any errors. Note that you cannot add or delete a subdev | 128 | Ignore any errors. Note that you cannot add or delete a subdev |
103 | while walking the subdevs list. */ | 129 | while walking the subdevs list. */ |
104 | #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ | 130 | #define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \ |
105 | do { \ | 131 | do { \ |
106 | struct v4l2_subdev *sd; \ | 132 | list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \ |
133 | if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \ | ||
134 | (sd)->ops->o->f((sd) , ##args); \ | ||
135 | } while (0) | ||
136 | |||
137 | #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ | ||
138 | do { \ | ||
139 | struct v4l2_subdev *__sd; \ | ||
107 | \ | 140 | \ |
108 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) \ | 141 | __v4l2_device_call_subdevs_p(v4l2_dev, __sd, cond, o, \ |
109 | if ((cond) && sd->ops->o && sd->ops->o->f) \ | 142 | f , ##args); \ |
110 | sd->ops->o->f(sd , ##args); \ | ||
111 | } while (0) | 143 | } while (0) |
112 | 144 | ||
113 | /* Call the specified callback for all subdevs matching the condition. | 145 | /* Call the specified callback for all subdevs matching the condition. |
114 | If the callback returns an error other than 0 or -ENOIOCTLCMD, then | 146 | If the callback returns an error other than 0 or -ENOIOCTLCMD, then |
115 | return with that error code. Note that you cannot add or delete a | 147 | return with that error code. Note that you cannot add or delete a |
116 | subdev while walking the subdevs list. */ | 148 | subdev while walking the subdevs list. */ |
117 | #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ | 149 | #define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \ |
118 | ({ \ | 150 | ({ \ |
119 | struct v4l2_subdev *sd; \ | 151 | long __err = 0; \ |
120 | long err = 0; \ | ||
121 | \ | 152 | \ |
122 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) { \ | 153 | list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) { \ |
123 | if ((cond) && sd->ops->o && sd->ops->o->f) \ | 154 | if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \ |
124 | err = sd->ops->o->f(sd , ##args); \ | 155 | __err = (sd)->ops->o->f((sd) , ##args); \ |
125 | if (err && err != -ENOIOCTLCMD) \ | 156 | if (__err && __err != -ENOIOCTLCMD) \ |
126 | break; \ | 157 | break; \ |
127 | } \ | 158 | } \ |
128 | (err == -ENOIOCTLCMD) ? 0 : err; \ | 159 | (__err == -ENOIOCTLCMD) ? 0 : __err; \ |
160 | }) | ||
161 | |||
162 | #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ | ||
163 | ({ \ | ||
164 | struct v4l2_subdev *__sd; \ | ||
165 | __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, cond, o, \ | ||
166 | f , ##args); \ | ||
129 | }) | 167 | }) |
130 | 168 | ||
131 | /* Call the specified callback for all subdevs matching grp_id (if 0, then | 169 | /* Call the specified callback for all subdevs matching grp_id (if 0, then |
132 | match them all). Ignore any errors. Note that you cannot add or delete | 170 | match them all). Ignore any errors. Note that you cannot add or delete |
133 | a subdev while walking the subdevs list. */ | 171 | a subdev while walking the subdevs list. */ |
134 | #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ | 172 | #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ |
135 | __v4l2_device_call_subdevs(v4l2_dev, \ | 173 | do { \ |
136 | !(grpid) || sd->grp_id == (grpid), o, f , ##args) | 174 | struct v4l2_subdev *__sd; \ |
175 | \ | ||
176 | __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \ | ||
177 | !(grpid) || __sd->grp_id == (grpid), o, f , \ | ||
178 | ##args); \ | ||
179 | } while (0) | ||
137 | 180 | ||
138 | /* Call the specified callback for all subdevs matching grp_id (if 0, then | 181 | /* Call the specified callback for all subdevs matching grp_id (if 0, then |
139 | match them all). If the callback returns an error other than 0 or | 182 | match them all). If the callback returns an error other than 0 or |
140 | -ENOIOCTLCMD, then return with that error code. Note that you cannot | 183 | -ENOIOCTLCMD, then return with that error code. Note that you cannot |
141 | add or delete a subdev while walking the subdevs list. */ | 184 | add or delete a subdev while walking the subdevs list. */ |
142 | #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ | 185 | #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ |
143 | __v4l2_device_call_subdevs_until_err(v4l2_dev, \ | 186 | ({ \ |
144 | !(grpid) || sd->grp_id == (grpid), o, f , ##args) | 187 | struct v4l2_subdev *__sd; \ |
188 | __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \ | ||
189 | !(grpid) || __sd->grp_id == (grpid), o, f , \ | ||
190 | ##args); \ | ||
191 | }) | ||
145 | 192 | ||
146 | #endif | 193 | #endif |