V4L/DVB (8430): videodev: move some functions from v4l2-dev.h to v4l2-common.h or...
[safe/jmp/linux-2.6] / include / media / v4l2-dev.h
index 62dae1a..ad62d32 100644 (file)
@@ -9,21 +9,20 @@
 #ifndef _V4L2_DEV_H
 #define _V4L2_DEV_H
 
-#define OBSOLETE_OWNER 1 /* to be removed soon */
+#define OBSOLETE_OWNER   1 /* to be removed soon */
+#define OBSOLETE_DEVDATA 1 /* to be removed soon */
 
 #include <linux/poll.h>
 #include <linux/fs.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/compiler.h> /* need __user */
-#ifdef CONFIG_VIDEO_V4L1
+#ifdef CONFIG_VIDEO_V4L1_COMPAT
 #include <linux/videodev.h>
 #else
 #include <linux/videodev2.h>
 #endif
 
-#include <linux/fs.h>
-
 #define VIDEO_MAJOR    81
 /* Minor device allocation */
 #define MINOR_VFL_TYPE_GRABBER_MIN   0
 #define VFL_TYPE_RADIO         2
 #define VFL_TYPE_VTX           3
 
-/*  Video standard functions  */
-extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs);
-extern int v4l2_video_std_construct(struct v4l2_standard *vs,
-                                   int id, char *name);
-
-/* prority handling */
-struct v4l2_prio_state {
-       atomic_t prios[4];
-};
-int 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);
-int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
-int 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);
-
-/* names for fancy debug output */
-extern char *v4l2_field_names[];
-extern char *v4l2_type_names[];
-
-/*  Compatibility layer interface  --  v4l1-compat module */
-typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
-                          unsigned int cmd, void *arg);
-#ifdef CONFIG_VIDEO_V4L1_COMPAT
-int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
-                              int cmd, void *arg, v4l2_kioctl driver_ioctl);
-#else
-#define v4l_compat_translate_ioctl(inode,file,cmd,arg,ioctl) -EINVAL
-#endif
-
-/* 32 Bits compatibility layer for 64 bits processors */
-extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
-                               unsigned long arg);
-
 /*
  * Newer version of video_device, handled by videodev2.c
  *     This version moves redundant code from video device code to
  *     the common handler
  */
-struct v4l2_tvnorm {
-       char          *name;
-       v4l2_std_id   id;
-
-       void          *priv_data;
-};
 
 struct video_device
 {
        /* device ops */
        const struct file_operations *fops;
 
+       /* sysfs */
+       struct device dev;              /* v4l device */
+       struct device *parent;          /* device parent */
+
        /* device info */
-       struct device *dev;
        char name[32];
-       int type;       /* v4l1 */
-       int type2;      /* v4l2 */
-       int hardware;
+       int type;                       /* v4l1 */
+       int type2;                      /* v4l2 */
        int minor;
+       /* attribute to diferentiate multiple indexs on one physical device */
+       int index;
 
-       int debug;      /* Activates debug level*/
+       int debug;                      /* Activates debug level*/
 
        /* Video standard vars */
-       int tvnormsize; /* Size of tvnorm array */
-       v4l2_std_id current_norm; /* Current tvnorm */
-       struct v4l2_tvnorm *tvnorms;
+       v4l2_std_id tvnorms;            /* Supported tv norms */
+       v4l2_std_id current_norm;       /* Current tvnorm */
 
        /* callbacks */
        void (*release)(struct video_device *vfd);
@@ -122,66 +83,76 @@ struct video_device
                                    enum v4l2_priority p);
 
        /* VIDIOC_ENUM_FMT handlers */
-       int (*vidioc_enum_fmt_cap)         (struct file *file, void *fh,
-                                           struct v4l2_fmtdesc *f);
-       int (*vidioc_enum_fmt_overlay)     (struct file *file, void *fh,
-                                           struct v4l2_fmtdesc *f);
-       int (*vidioc_enum_fmt_vbi)         (struct file *file, void *fh,
+       int (*vidioc_enum_fmt_vid_cap)     (struct file *file, void *fh,
                                            struct v4l2_fmtdesc *f);
-       int (*vidioc_enum_fmt_vbi_capture) (struct file *file, void *fh,
+       int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
                                            struct v4l2_fmtdesc *f);
-       int (*vidioc_enum_fmt_video_output)(struct file *file, void *fh,
+       int (*vidioc_enum_fmt_vid_out)     (struct file *file, void *fh,
                                            struct v4l2_fmtdesc *f);
-       int (*vidioc_enum_fmt_vbi_output)  (struct file *file, void *fh,
+#if 1
+       /* deprecated, will be removed in 2.6.28 */
+       int (*vidioc_enum_fmt_vbi_cap)     (struct file *file, void *fh,
                                            struct v4l2_fmtdesc *f);
+#endif
        int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
                                            struct v4l2_fmtdesc *f);
 
        /* VIDIOC_G_FMT handlers */
-       int (*vidioc_g_fmt_cap)        (struct file *file, void *fh,
+       int (*vidioc_g_fmt_vid_cap)    (struct file *file, void *fh,
+                                       struct v4l2_format *f);
+       int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
+                                       struct v4l2_format *f);
+       int (*vidioc_g_fmt_vid_out)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_g_fmt_overlay)    (struct file *file, void *fh,
+       int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_g_fmt_vbi)        (struct file *file, void *fh,
+       int (*vidioc_g_fmt_vbi_cap)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_g_fmt_vbi_output) (struct file *file, void *fh,
+       int (*vidioc_g_fmt_vbi_out)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_g_fmt_vbi_capture)(struct file *file, void *fh,
+       int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_g_fmt_video_output)(struct file *file, void *fh,
+       int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
                                        struct v4l2_format *f);
        int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
                                        struct v4l2_format *f);
 
        /* VIDIOC_S_FMT handlers */
-       int (*vidioc_s_fmt_cap)        (struct file *file, void *fh,
+       int (*vidioc_s_fmt_vid_cap)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
-
-       int (*vidioc_s_fmt_overlay)    (struct file *file, void *fh,
+       int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
+                                       struct v4l2_format *f);
+       int (*vidioc_s_fmt_vid_out)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_s_fmt_vbi)        (struct file *file, void *fh,
+       int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_s_fmt_vbi_output) (struct file *file, void *fh,
+       int (*vidioc_s_fmt_vbi_cap)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_s_fmt_vbi_capture)(struct file *file, void *fh,
+       int (*vidioc_s_fmt_vbi_out)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
-       int (*vidioc_s_fmt_video_output)(struct file *file, void *fh,
+       int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
+                                       struct v4l2_format *f);
+       int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
                                        struct v4l2_format *f);
        int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
                                        struct v4l2_format *f);
 
        /* VIDIOC_TRY_FMT handlers */
-       int (*vidioc_try_fmt_cap)        (struct file *file, void *fh,
+       int (*vidioc_try_fmt_vid_cap)    (struct file *file, void *fh,
+                                         struct v4l2_format *f);
+       int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
+                                         struct v4l2_format *f);
+       int (*vidioc_try_fmt_vid_out)    (struct file *file, void *fh,
                                          struct v4l2_format *f);
-       int (*vidioc_try_fmt_overlay)    (struct file *file, void *fh,
+       int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
                                          struct v4l2_format *f);
-       int (*vidioc_try_fmt_vbi)        (struct file *file, void *fh,
+       int (*vidioc_try_fmt_vbi_cap)    (struct file *file, void *fh,
                                          struct v4l2_format *f);
-       int (*vidioc_try_fmt_vbi_output) (struct file *file, void *fh,
+       int (*vidioc_try_fmt_vbi_out)    (struct file *file, void *fh,
                                          struct v4l2_format *f);
-       int (*vidioc_try_fmt_vbi_capture)(struct file *file, void *fh,
+       int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
                                          struct v4l2_format *f);
-       int (*vidioc_try_fmt_video_output)(struct file *file, void *fh,
+       int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
                                          struct v4l2_format *f);
        int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
                                          struct v4l2_format *f);
@@ -194,7 +165,7 @@ struct video_device
 
 
        int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
-#ifdef HAVE_V4L1
+#ifdef CONFIG_VIDEO_V4L1_COMPAT
                        /* buffer type is struct vidio_mbuf * */
        int (*vidiocgmbuf)  (struct file *file, void *fh, struct video_mbuf *p);
 #endif
@@ -208,9 +179,10 @@ struct video_device
        int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
 
                /* Standard handling
-                       G_STD and ENUMSTD are handled by videodev.c
+                       ENUMSTD is handled by videodev.c
                 */
-       int (*vidioc_s_std)    (struct file *file, void *fh, v4l2_std_id a);
+       int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
+       int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
        int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
 
                /* Input handling */
@@ -220,7 +192,7 @@ struct video_device
        int (*vidioc_s_input)   (struct file *file, void *fh, unsigned int i);
 
                /* Output handling */
-       int (*vidioc_enumoutput) (struct file *file, void *fh,
+       int (*vidioc_enum_output) (struct file *file, void *fh,
                                  struct v4l2_output *a);
        int (*vidioc_g_output)   (struct file *file, void *fh, unsigned int *i);
        int (*vidioc_s_output)   (struct file *file, void *fh, unsigned int i);
@@ -268,14 +240,16 @@ struct video_device
        int (*vidioc_s_crop)           (struct file *file, void *fh,
                                        struct v4l2_crop *a);
        /* Compression ioctls */
-       int (*vidioc_g_mpegcomp)       (struct file *file, void *fh,
-                                       struct v4l2_mpeg_compression *a);
-       int (*vidioc_s_mpegcomp)       (struct file *file, void *fh,
-                                       struct v4l2_mpeg_compression *a);
        int (*vidioc_g_jpegcomp)       (struct file *file, void *fh,
                                        struct v4l2_jpegcompression *a);
        int (*vidioc_s_jpegcomp)       (struct file *file, void *fh,
                                        struct v4l2_jpegcompression *a);
+       int (*vidioc_g_enc_index)      (struct file *file, void *fh,
+                                       struct v4l2_enc_idx *a);
+       int (*vidioc_encoder_cmd)      (struct file *file, void *fh,
+                                       struct v4l2_encoder_cmd *a);
+       int (*vidioc_try_encoder_cmd)  (struct file *file, void *fh,
+                                       struct v4l2_encoder_cmd *a);
 
        /* Stream type-dependent parameter ioctls */
        int (*vidioc_g_parm)           (struct file *file, void *fh,
@@ -300,6 +274,23 @@ struct video_device
        /* Log status ioctl */
        int (*vidioc_log_status)       (struct file *file, void *fh);
 
+       int (*vidioc_s_hw_freq_seek)   (struct file *file, void *fh,
+                                       struct v4l2_hw_freq_seek *a);
+
+       /* Debugging ioctls */
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+       int (*vidioc_g_register)       (struct file *file, void *fh,
+                                       struct v4l2_register *reg);
+       int (*vidioc_s_register)       (struct file *file, void *fh,
+                                       struct v4l2_register *reg);
+#endif
+       int (*vidioc_g_chip_ident)     (struct file *file, void *fh,
+                                       struct v4l2_chip_ident *chip);
+
+       /* For other private ioctls */
+       int (*vidioc_default)          (struct file *file, void *fh,
+                                       int cmd, void *arg);
+
 
 #ifdef OBSOLETE_OWNER /* to be removed soon */
 /* obsolete -- fops->owner is used instead */
@@ -314,46 +305,43 @@ void *priv;
        /* for videodev.c intenal usage -- please don't touch */
        int users;                     /* video_exclusive_{open|close} ... */
        struct mutex lock;             /* ... helper function uses these   */
-       struct class_device class_dev; /* sysfs */
 };
 
+/* Class-dev to video-device */
+#define to_video_device(cd) container_of(cd, struct video_device, dev)
+
 /* Version 2 functions */
 extern int video_register_device(struct video_device *vfd, int type, int nr);
+int video_register_device_index(struct video_device *vfd, int type, int nr,
+                                       int index);
 void video_unregister_device(struct video_device *);
-extern int video_ioctl2(struct inode *inode, struct file *file,
-                         unsigned int cmd, unsigned long arg);
 
 /* helper functions to alloc / release struct video_device, the
    later can be used for video_device->release() */
 struct video_device *video_device_alloc(void);
 void video_device_release(struct video_device *vfd);
 
-/* Include support for obsoleted stuff */
-extern int video_usercopy(struct inode *inode, struct file *file,
-                         unsigned int cmd, unsigned long arg,
-                         int (*func)(struct inode *inode, struct file *file,
-                                     unsigned int cmd, void *arg));
-
-
-#ifdef HAVE_V4L1
+#ifdef CONFIG_VIDEO_V4L1_COMPAT
 #include <linux/mm.h>
 
-extern struct video_device* video_devdata(struct file*);
-
-#define to_video_device(cd) container_of(cd, struct video_device, class_dev)
-static inline void
+static inline int __must_check
 video_device_create_file(struct video_device *vfd,
-                        struct class_device_attribute *attr)
+                        struct device_attribute *attr)
 {
-       class_device_create_file(&vfd->class_dev, attr);
+       int ret = device_create_file(&vfd->dev, attr);
+       if (ret < 0)
+               printk(KERN_WARNING "%s error: %d\n", __func__, ret);
+       return ret;
 }
 static inline void
 video_device_remove_file(struct video_device *vfd,
-                        struct class_device_attribute *attr)
+                        struct device_attribute *attr)
 {
-       class_device_remove_file(&vfd->class_dev, attr);
+       device_remove_file(&vfd->dev, attr);
 }
 
+#endif /* CONFIG_VIDEO_V4L1_COMPAT */
+
 #ifdef OBSOLETE_OWNER /* to be removed soon */
 /* helper functions to access driver private data. */
 static inline void *video_get_drvdata(struct video_device *dev)
@@ -365,10 +353,14 @@ static inline void video_set_drvdata(struct video_device *dev, void *data)
 {
        dev->priv = data;
 }
+
 #endif
 
+#ifdef OBSOLETE_DEVDATA /* to be removed soon */
+/* Obsolete stuff - Still needed for radio devices and obsolete drivers */
+extern struct video_device* video_devdata(struct file*);
 extern int video_exclusive_open(struct inode *inode, struct file *file);
 extern int video_exclusive_release(struct inode *inode, struct file *file);
-#endif /* HAVE_V4L1 */
+#endif
 
 #endif /* _V4L2_DEV_H */