V4L/DVB (10138): v4l2-ioctl: change to long return type to match unlocked_ioctl.
[safe/jmp/linux-2.6] / include / media / videobuf-core.h
index 0ac21ae..874f134 100644 (file)
@@ -13,6 +13,9 @@
  * the Free Software Foundation; either version 2
  */
 
+#ifndef _VIDEOBUF_CORE_H
+#define _VIDEOBUF_CORE_H
+
 #include <linux/poll.h>
 #ifdef CONFIG_VIDEO_V4L1_COMPAT
 #include <linux/videodev.h>
@@ -56,13 +59,13 @@ struct videobuf_mapping {
 };
 
 enum videobuf_state {
-       STATE_NEEDS_INIT = 0,
-       STATE_PREPARED   = 1,
-       STATE_QUEUED     = 2,
-       STATE_ACTIVE     = 3,
-       STATE_DONE       = 4,
-       STATE_ERROR      = 5,
-       STATE_IDLE       = 6,
+       VIDEOBUF_NEEDS_INIT = 0,
+       VIDEOBUF_PREPARED   = 1,
+       VIDEOBUF_QUEUED     = 2,
+       VIDEOBUF_ACTIVE     = 3,
+       VIDEOBUF_DONE       = 4,
+       VIDEOBUF_ERROR      = 5,
+       VIDEOBUF_IDLE       = 6,
 };
 
 struct videobuf_buffer {
@@ -97,6 +100,9 @@ struct videobuf_buffer {
        /* buffer addr (userland ptr!) */
        unsigned long           baddr;
 
+       /* for mmap'ed buffers */
+       struct videobuf_mapping *map;
+
        /* Private pointer to allow specific methods to store their data */
        int                     privsize;
        void                    *priv;
@@ -120,7 +126,8 @@ struct videobuf_queue_ops {
 struct videobuf_qtype_ops {
        u32                     magic;
 
-       void* (*alloc)          (size_t size);
+       void *(*alloc)          (size_t size);
+       void *(*vmalloc)        (struct videobuf_buffer *buf);
        int (*iolock)           (struct videobuf_queue* q,
                                 struct videobuf_buffer *vb,
                                 struct v4l2_framebuffer *fbuf);
@@ -130,7 +137,7 @@ struct videobuf_qtype_ops {
                                 enum v4l2_memory memory);
        int (*sync)             (struct videobuf_queue* q,
                                 struct videobuf_buffer *buf);
-       int (*copy_to_user)     (struct videobuf_queue *q,
+       int (*video_copy_to_user)(struct videobuf_queue *q,
                                 char __user *data,
                                 size_t count,
                                 int nonblocking);
@@ -143,13 +150,14 @@ struct videobuf_qtype_ops {
        int (*mmap_free)        (struct videobuf_queue *q);
        int (*mmap_mapper)      (struct videobuf_queue *q,
                                struct vm_area_struct *vma);
-       int (*is_mmapped)       (struct videobuf_buffer *buf);
 };
 
 struct videobuf_queue {
-       struct mutex               lock;
+       struct mutex               vb_lock;
        spinlock_t                 *irqlock;
-       void                       *dev; /* on pci, points to struct pci_dev */
+       struct device              *dev;
+
+       wait_queue_head_t          wait; /* wait if queue is empty */
 
        enum v4l2_buf_type         type;
        unsigned int               inputs; /* for V4L2_BUF_FLAG_INPUT */
@@ -160,20 +168,19 @@ struct videobuf_queue {
        struct videobuf_queue_ops  *ops;
        struct videobuf_qtype_ops  *int_ops;
 
+       unsigned int               streaming:1;
+       unsigned int               reading:1;
+       unsigned int               is_mmapped:1;
+
        /* capture via mmap() + ioctl(QBUF/DQBUF) */
-       unsigned int               streaming;
        struct list_head           stream;
 
        /* capture via read() */
-       unsigned int               reading;
        unsigned int               read_off;
        struct videobuf_buffer     *read_buf;
 
        /* driver private data */
        void                       *priv_data;
-
-       /*FIXME: should be removed after completing the vb conversion */
-       void                       *priv_ops;
 };
 
 int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
@@ -182,14 +189,19 @@ int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
 
 void *videobuf_alloc(struct videobuf_queue* q);
 
-void videobuf_queue_init(struct videobuf_queue *q,
+/* Used on videobuf-dvb */
+void *videobuf_queue_to_vmalloc (struct videobuf_queue* q,
+                                struct videobuf_buffer *buf);
+
+void videobuf_queue_core_init(struct videobuf_queue *q,
                         struct videobuf_queue_ops *ops,
-                        void *dev,
+                        struct device *dev,
                         spinlock_t *irqlock,
                         enum v4l2_buf_type type,
                         enum v4l2_field field,
                         unsigned int msize,
-                        void *priv);
+                        void *priv,
+                        struct videobuf_qtype_ops *int_ops);
 int  videobuf_queue_is_busy(struct videobuf_queue *q);
 void videobuf_queue_cancel(struct videobuf_queue *q);
 
@@ -208,6 +220,8 @@ int videobuf_cgmbuf(struct videobuf_queue *q,
 int videobuf_streamon(struct videobuf_queue *q);
 int videobuf_streamoff(struct videobuf_queue *q);
 
+void videobuf_stop(struct videobuf_queue *q);
+
 int videobuf_read_start(struct videobuf_queue *q);
 void videobuf_read_stop(struct videobuf_queue *q);
 ssize_t videobuf_read_stream(struct videobuf_queue *q,
@@ -223,14 +237,11 @@ unsigned int videobuf_poll_stream(struct file *file,
 int videobuf_mmap_setup(struct videobuf_queue *q,
                        unsigned int bcount, unsigned int bsize,
                        enum v4l2_memory memory);
+int __videobuf_mmap_setup(struct videobuf_queue *q,
+                       unsigned int bcount, unsigned int bsize,
+                       enum v4l2_memory memory);
 int videobuf_mmap_free(struct videobuf_queue *q);
 int videobuf_mmap_mapper(struct videobuf_queue *q,
                         struct vm_area_struct *vma);
 
-/* --------------------------------------------------------------------- */
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
+#endif