[media] v4l2_prio: move from v4l2-common to v4l2-dev
authorHans Verkuil <hverkuil@xs4all.nl>
Wed, 29 Dec 2010 13:05:02 +0000 (10:05 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 22 Mar 2011 19:37:54 +0000 (16:37 -0300)
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>
drivers/media/video/v4l2-common.c
drivers/media/video/v4l2-dev.c
include/media/v4l2-common.h
include/media/v4l2-dev.h

index 940b5db3463ee8e52d6eba260a64afcb9d3214e2..06b9f9f82013c33b1c61e812038aa3bd660469ad 100644 (file)
@@ -80,69 +80,6 @@ MODULE_LICENSE("GPL");
  *  Video Standard Operations (contributed by Michael Schimek)
  */
 
-
-/* ----------------------------------------------------------------- */
-/* priority handling                                                 */
-
-#define V4L2_PRIO_VALID(val) (val == V4L2_PRIORITY_BACKGROUND   || \
-                             val == V4L2_PRIORITY_INTERACTIVE  || \
-                             val == V4L2_PRIORITY_RECORD)
-
-void v4l2_prio_init(struct v4l2_prio_state *global)
-{
-       memset(global, 0, sizeof(*global));
-}
-EXPORT_SYMBOL(v4l2_prio_init);
-
-int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
-                    enum v4l2_priority new)
-{
-       if (!V4L2_PRIO_VALID(new))
-               return -EINVAL;
-       if (*local == new)
-               return 0;
-
-       atomic_inc(&global->prios[new]);
-       if (V4L2_PRIO_VALID(*local))
-               atomic_dec(&global->prios[*local]);
-       *local = new;
-       return 0;
-}
-EXPORT_SYMBOL(v4l2_prio_change);
-
-void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
-{
-       v4l2_prio_change(global, local, V4L2_PRIORITY_DEFAULT);
-}
-EXPORT_SYMBOL(v4l2_prio_open);
-
-void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local)
-{
-       if (V4L2_PRIO_VALID(local))
-               atomic_dec(&global->prios[local]);
-}
-EXPORT_SYMBOL(v4l2_prio_close);
-
-enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
-{
-       if (atomic_read(&global->prios[V4L2_PRIORITY_RECORD]) > 0)
-               return V4L2_PRIORITY_RECORD;
-       if (atomic_read(&global->prios[V4L2_PRIORITY_INTERACTIVE]) > 0)
-               return V4L2_PRIORITY_INTERACTIVE;
-       if (atomic_read(&global->prios[V4L2_PRIORITY_BACKGROUND]) > 0)
-               return V4L2_PRIORITY_BACKGROUND;
-       return V4L2_PRIORITY_UNSET;
-}
-EXPORT_SYMBOL(v4l2_prio_max);
-
-int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local)
-{
-       return (local < v4l2_prio_max(global)) ? -EBUSY : 0;
-}
-EXPORT_SYMBOL(v4l2_prio_check);
-
-/* ----------------------------------------------------------------- */
-
 /* Helper functions for control handling                            */
 
 /* Check for correctness of the ctrl's value based on the data from
index e405b8094b94036730cdfcf457c2d85fa7c48229..65d546f35ef4f21725d0a46d2d473f91cc2fbc75 100644 (file)
@@ -182,6 +182,70 @@ struct video_device *video_devdata(struct file *file)
 }
 EXPORT_SYMBOL(video_devdata);
 
+
+/* Priority handling */
+
+static inline bool prio_is_valid(enum v4l2_priority prio)
+{
+       return prio == V4L2_PRIORITY_BACKGROUND ||
+              prio == V4L2_PRIORITY_INTERACTIVE ||
+              prio == V4L2_PRIORITY_RECORD;
+}
+
+void v4l2_prio_init(struct v4l2_prio_state *global)
+{
+       memset(global, 0, sizeof(*global));
+}
+EXPORT_SYMBOL(v4l2_prio_init);
+
+int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
+                    enum v4l2_priority new)
+{
+       if (!prio_is_valid(new))
+               return -EINVAL;
+       if (*local == new)
+               return 0;
+
+       atomic_inc(&global->prios[new]);
+       if (prio_is_valid(*local))
+               atomic_dec(&global->prios[*local]);
+       *local = new;
+       return 0;
+}
+EXPORT_SYMBOL(v4l2_prio_change);
+
+void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
+{
+       v4l2_prio_change(global, local, V4L2_PRIORITY_DEFAULT);
+}
+EXPORT_SYMBOL(v4l2_prio_open);
+
+void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local)
+{
+       if (prio_is_valid(local))
+               atomic_dec(&global->prios[local]);
+}
+EXPORT_SYMBOL(v4l2_prio_close);
+
+enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
+{
+       if (atomic_read(&global->prios[V4L2_PRIORITY_RECORD]) > 0)
+               return V4L2_PRIORITY_RECORD;
+       if (atomic_read(&global->prios[V4L2_PRIORITY_INTERACTIVE]) > 0)
+               return V4L2_PRIORITY_INTERACTIVE;
+       if (atomic_read(&global->prios[V4L2_PRIORITY_BACKGROUND]) > 0)
+               return V4L2_PRIORITY_BACKGROUND;
+       return V4L2_PRIORITY_UNSET;
+}
+EXPORT_SYMBOL(v4l2_prio_max);
+
+int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local)
+{
+       return (local < v4l2_prio_max(global)) ? -EBUSY : 0;
+}
+EXPORT_SYMBOL(v4l2_prio_check);
+
+
 static ssize_t v4l2_read(struct file *filp, char __user *buf,
                size_t sz, loff_t *off)
 {
index a659319e858257d0bfe2c736f8a97fb2b4fcdcb8..a298ec49ddc489ba70d47003fba8a39f32335ff4 100644 (file)
 
 /* ------------------------------------------------------------------------- */
 
-/* Priority helper functions */
-
-struct v4l2_prio_state {
-       atomic_t prios[4];
-};
-void v4l2_prio_init(struct v4l2_prio_state *global);
-int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
-                    enum v4l2_priority new);
-void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
-void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
-enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
-int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
-
-/* ------------------------------------------------------------------------- */
-
 /* Control helper functions */
 
 int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
index 51b2c515f687e061777c7e540f2d5786d57f9c18..9193703f4f0fbc182e81d5dbdb41a45e0d29dc47 100644 (file)
@@ -37,6 +37,21 @@ struct v4l2_ctrl_handler;
 #define V4L2_FL_REGISTERED     (0)
 #define V4L2_FL_USES_V4L2_FH   (1)
 
+/* Priority helper functions */
+
+struct v4l2_prio_state {
+       atomic_t prios[4];
+};
+
+void v4l2_prio_init(struct v4l2_prio_state *global);
+int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
+                    enum v4l2_priority new);
+void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
+void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
+enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
+int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
+
+
 struct v4l2_file_operations {
        struct module *owner;
        ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);