asm-generic/ptrace.h: start a common low level ptrace helper
[firefly-linux-kernel-4.4.55.git] / include / media / v4l2-dev.h
index 15802a067a127da4592ce731049a336f9edc46d6..93e96fb934526e44b327e8d677bb91f7accd80c4 100644 (file)
 #include <linux/mutex.h>
 #include <linux/videodev2.h>
 
+#include <media/media-entity.h>
+
 #define VIDEO_MAJOR    81
 
 #define VFL_TYPE_GRABBER       0
 #define VFL_TYPE_VBI           1
 #define VFL_TYPE_RADIO         2
-#define VFL_TYPE_MAX           3
+#define VFL_TYPE_SUBDEV                3
+#define VFL_TYPE_MAX           4
 
 struct v4l2_ioctl_callbacks;
 struct video_device;
@@ -32,7 +35,25 @@ struct v4l2_ctrl_handler;
    Drivers can clear this flag if they want to block all future
    device access. It is cleared by video_unregister_device. */
 #define V4L2_FL_REGISTERED     (0)
+/* file->private_data points to struct v4l2_fh */
 #define V4L2_FL_USES_V4L2_FH   (1)
+/* Use the prio field of v4l2_fh for core priority checking */
+#define V4L2_FL_USE_FH_PRIO    (2)
+
+/* 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;
@@ -41,6 +62,8 @@ struct v4l2_file_operations {
        unsigned int (*poll) (struct file *, struct poll_table_struct *);
        long (*ioctl) (struct file *, unsigned int, unsigned long);
        long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
+       unsigned long (*get_unmapped_area) (struct file *, unsigned long,
+                               unsigned long, unsigned long, unsigned long);
        int (*mmap) (struct file *, struct vm_area_struct *);
        int (*open) (struct file *);
        int (*release) (struct file *);
@@ -54,6 +77,9 @@ struct v4l2_file_operations {
 
 struct video_device
 {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       struct media_entity entity;
+#endif
        /* device ops */
        const struct v4l2_file_operations *fops;
 
@@ -68,6 +94,9 @@ struct video_device
        /* Control handler associated with this device node. May be NULL. */
        struct v4l2_ctrl_handler *ctrl_handler;
 
+       /* Priority state. If NULL, then v4l2_dev->prio will be used. */
+       struct v4l2_prio_state *prio;
+
        /* device info */
        char name[32];
        int vfl_type;
@@ -99,18 +128,31 @@ struct video_device
        struct mutex *lock;
 };
 
+#define media_entity_to_video_device(entity) \
+       container_of(entity, struct video_device, entity)
 /* dev to video-device */
 #define to_video_device(cd) container_of(cd, struct video_device, dev)
 
+int __must_check __video_register_device(struct video_device *vdev, int type,
+               int nr, int warn_if_nr_in_use, struct module *owner);
+
 /* Register video devices. Note that if video_register_device fails,
    the release() callback of the video_device structure is *not* called, so
    the caller is responsible for freeing any data. Usually that means that
    you call video_device_release() on failure. */
-int __must_check video_register_device(struct video_device *vdev, int type, int nr);
+static inline int __must_check video_register_device(struct video_device *vdev,
+               int type, int nr)
+{
+       return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
+}
 
 /* Same as video_register_device, but no warning is issued if the desired
    device node number was already in use. */
-int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr);
+static inline int __must_check video_register_device_no_warn(
+               struct video_device *vdev, int type, int nr)
+{
+       return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
+}
 
 /* Unregister video devices. Will do nothing if vdev == NULL or
    video_is_registered() returns false. */