diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-12-29 08:05:02 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 15:37:54 -0400 |
commit | 022654930891c7ddfdb1ea34d6c4af9d1096bf91 (patch) | |
tree | 396edb9d7c4dcde4e862e89b2ed4b770ad830462 | |
parent | 8c1476ffc0b820f6ca8cc0b3f50c8a0f57e8d82d (diff) |
[media] v4l2_prio: move from v4l2-common to v4l2-dev
We are going to move priority handling into the v4l2 core. As a consequence
the v4l2_prio helper functions need to be moved into the core videodev
module as well to prevent circular dependencies.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/v4l2-common.c | 63 | ||||
-rw-r--r-- | drivers/media/video/v4l2-dev.c | 64 | ||||
-rw-r--r-- | include/media/v4l2-common.h | 15 | ||||
-rw-r--r-- | include/media/v4l2-dev.h | 15 |
4 files changed, 79 insertions, 78 deletions
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 940b5db3463e..06b9f9f82013 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -80,69 +80,6 @@ MODULE_LICENSE("GPL"); | |||
80 | * Video Standard Operations (contributed by Michael Schimek) | 80 | * Video Standard Operations (contributed by Michael Schimek) |
81 | */ | 81 | */ |
82 | 82 | ||
83 | |||
84 | /* ----------------------------------------------------------------- */ | ||
85 | /* priority handling */ | ||
86 | |||
87 | #define V4L2_PRIO_VALID(val) (val == V4L2_PRIORITY_BACKGROUND || \ | ||
88 | val == V4L2_PRIORITY_INTERACTIVE || \ | ||
89 | val == V4L2_PRIORITY_RECORD) | ||
90 | |||
91 | void v4l2_prio_init(struct v4l2_prio_state *global) | ||
92 | { | ||
93 | memset(global, 0, sizeof(*global)); | ||
94 | } | ||
95 | EXPORT_SYMBOL(v4l2_prio_init); | ||
96 | |||
97 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | ||
98 | enum v4l2_priority new) | ||
99 | { | ||
100 | if (!V4L2_PRIO_VALID(new)) | ||
101 | return -EINVAL; | ||
102 | if (*local == new) | ||
103 | return 0; | ||
104 | |||
105 | atomic_inc(&global->prios[new]); | ||
106 | if (V4L2_PRIO_VALID(*local)) | ||
107 | atomic_dec(&global->prios[*local]); | ||
108 | *local = new; | ||
109 | return 0; | ||
110 | } | ||
111 | EXPORT_SYMBOL(v4l2_prio_change); | ||
112 | |||
113 | void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) | ||
114 | { | ||
115 | v4l2_prio_change(global, local, V4L2_PRIORITY_DEFAULT); | ||
116 | } | ||
117 | EXPORT_SYMBOL(v4l2_prio_open); | ||
118 | |||
119 | void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local) | ||
120 | { | ||
121 | if (V4L2_PRIO_VALID(local)) | ||
122 | atomic_dec(&global->prios[local]); | ||
123 | } | ||
124 | EXPORT_SYMBOL(v4l2_prio_close); | ||
125 | |||
126 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) | ||
127 | { | ||
128 | if (atomic_read(&global->prios[V4L2_PRIORITY_RECORD]) > 0) | ||
129 | return V4L2_PRIORITY_RECORD; | ||
130 | if (atomic_read(&global->prios[V4L2_PRIORITY_INTERACTIVE]) > 0) | ||
131 | return V4L2_PRIORITY_INTERACTIVE; | ||
132 | if (atomic_read(&global->prios[V4L2_PRIORITY_BACKGROUND]) > 0) | ||
133 | return V4L2_PRIORITY_BACKGROUND; | ||
134 | return V4L2_PRIORITY_UNSET; | ||
135 | } | ||
136 | EXPORT_SYMBOL(v4l2_prio_max); | ||
137 | |||
138 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local) | ||
139 | { | ||
140 | return (local < v4l2_prio_max(global)) ? -EBUSY : 0; | ||
141 | } | ||
142 | EXPORT_SYMBOL(v4l2_prio_check); | ||
143 | |||
144 | /* ----------------------------------------------------------------- */ | ||
145 | |||
146 | /* Helper functions for control handling */ | 83 | /* Helper functions for control handling */ |
147 | 84 | ||
148 | /* Check for correctness of the ctrl's value based on the data from | 85 | /* Check for correctness of the ctrl's value based on the data from |
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index e405b8094b94..65d546f35ef4 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -182,6 +182,70 @@ struct video_device *video_devdata(struct file *file) | |||
182 | } | 182 | } |
183 | EXPORT_SYMBOL(video_devdata); | 183 | EXPORT_SYMBOL(video_devdata); |
184 | 184 | ||
185 | |||
186 | /* Priority handling */ | ||
187 | |||
188 | static inline bool prio_is_valid(enum v4l2_priority prio) | ||
189 | { | ||
190 | return prio == V4L2_PRIORITY_BACKGROUND || | ||
191 | prio == V4L2_PRIORITY_INTERACTIVE || | ||
192 | prio == V4L2_PRIORITY_RECORD; | ||
193 | } | ||
194 | |||
195 | void v4l2_prio_init(struct v4l2_prio_state *global) | ||
196 | { | ||
197 | memset(global, 0, sizeof(*global)); | ||
198 | } | ||
199 | EXPORT_SYMBOL(v4l2_prio_init); | ||
200 | |||
201 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | ||
202 | enum v4l2_priority new) | ||
203 | { | ||
204 | if (!prio_is_valid(new)) | ||
205 | return -EINVAL; | ||
206 | if (*local == new) | ||
207 | return 0; | ||
208 | |||
209 | atomic_inc(&global->prios[new]); | ||
210 | if (prio_is_valid(*local)) | ||
211 | atomic_dec(&global->prios[*local]); | ||
212 | *local = new; | ||
213 | return 0; | ||
214 | } | ||
215 | EXPORT_SYMBOL(v4l2_prio_change); | ||
216 | |||
217 | void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) | ||
218 | { | ||
219 | v4l2_prio_change(global, local, V4L2_PRIORITY_DEFAULT); | ||
220 | } | ||
221 | EXPORT_SYMBOL(v4l2_prio_open); | ||
222 | |||
223 | void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local) | ||
224 | { | ||
225 | if (prio_is_valid(local)) | ||
226 | atomic_dec(&global->prios[local]); | ||
227 | } | ||
228 | EXPORT_SYMBOL(v4l2_prio_close); | ||
229 | |||
230 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) | ||
231 | { | ||
232 | if (atomic_read(&global->prios[V4L2_PRIORITY_RECORD]) > 0) | ||
233 | return V4L2_PRIORITY_RECORD; | ||
234 | if (atomic_read(&global->prios[V4L2_PRIORITY_INTERACTIVE]) > 0) | ||
235 | return V4L2_PRIORITY_INTERACTIVE; | ||
236 | if (atomic_read(&global->prios[V4L2_PRIORITY_BACKGROUND]) > 0) | ||
237 | return V4L2_PRIORITY_BACKGROUND; | ||
238 | return V4L2_PRIORITY_UNSET; | ||
239 | } | ||
240 | EXPORT_SYMBOL(v4l2_prio_max); | ||
241 | |||
242 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local) | ||
243 | { | ||
244 | return (local < v4l2_prio_max(global)) ? -EBUSY : 0; | ||
245 | } | ||
246 | EXPORT_SYMBOL(v4l2_prio_check); | ||
247 | |||
248 | |||
185 | static ssize_t v4l2_read(struct file *filp, char __user *buf, | 249 | static ssize_t v4l2_read(struct file *filp, char __user *buf, |
186 | size_t sz, loff_t *off) | 250 | size_t sz, loff_t *off) |
187 | { | 251 | { |
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index a659319e8582..a298ec49ddc4 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h | |||
@@ -80,21 +80,6 @@ | |||
80 | 80 | ||
81 | /* ------------------------------------------------------------------------- */ | 81 | /* ------------------------------------------------------------------------- */ |
82 | 82 | ||
83 | /* Priority helper functions */ | ||
84 | |||
85 | struct v4l2_prio_state { | ||
86 | atomic_t prios[4]; | ||
87 | }; | ||
88 | void v4l2_prio_init(struct v4l2_prio_state *global); | ||
89 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | ||
90 | enum v4l2_priority new); | ||
91 | void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
92 | void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local); | ||
93 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global); | ||
94 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local); | ||
95 | |||
96 | /* ------------------------------------------------------------------------- */ | ||
97 | |||
98 | /* Control helper functions */ | 83 | /* Control helper functions */ |
99 | 84 | ||
100 | int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, | 85 | int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, |
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 51b2c515f687..9193703f4f0f 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
@@ -37,6 +37,21 @@ struct v4l2_ctrl_handler; | |||
37 | #define V4L2_FL_REGISTERED (0) | 37 | #define V4L2_FL_REGISTERED (0) |
38 | #define V4L2_FL_USES_V4L2_FH (1) | 38 | #define V4L2_FL_USES_V4L2_FH (1) |
39 | 39 | ||
40 | /* Priority helper functions */ | ||
41 | |||
42 | struct v4l2_prio_state { | ||
43 | atomic_t prios[4]; | ||
44 | }; | ||
45 | |||
46 | void v4l2_prio_init(struct v4l2_prio_state *global); | ||
47 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, | ||
48 | enum v4l2_priority new); | ||
49 | void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local); | ||
50 | void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local); | ||
51 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global); | ||
52 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local); | ||
53 | |||
54 | |||
40 | struct v4l2_file_operations { | 55 | struct v4l2_file_operations { |
41 | struct module *owner; | 56 | struct module *owner; |
42 | ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); | 57 | ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); |