]> err.no Git - linux-2.6/blobdiff - drivers/media/video/videodev.c
V4L/DVB (5982): Dev.c: memset fix
[linux-2.6] / drivers / media / video / videodev.c
index 6a0e8ca7294803056cf29d11716d7ed175b35e5f..0334b9aaf12ad63dc8200e03adb9f61fa7c7f1dd 100644 (file)
@@ -30,8 +30,6 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/smp_lock.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/errno.h>
@@ -319,6 +317,7 @@ static char *v4l2_type_names_FIXME[] = {
        [V4L2_BUF_TYPE_VBI_OUTPUT]         = "vbi-out",
        [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT]  = "sliced-vbi-out",
        [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-capture",
+       [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over",
        [V4L2_BUF_TYPE_PRIVATE]            = "private",
 };
 
@@ -331,6 +330,8 @@ static char *v4l2_field_names_FIXME[] = {
        [V4L2_FIELD_SEQ_TB]     = "seq-tb",
        [V4L2_FIELD_SEQ_BT]     = "seq-bt",
        [V4L2_FIELD_ALTERNATE]  = "alternate",
+       [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
+       [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
 };
 
 #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown"
@@ -412,6 +413,10 @@ static int check_fmt (struct video_device *vfd, enum v4l2_buf_type type)
                if (vfd->vidioc_try_fmt_vbi_output)
                        return (0);
                break;
+       case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
+               if (vfd->vidioc_try_fmt_output_overlay)
+                       return (0);
+               break;
        case V4L2_BUF_TYPE_PRIVATE:
                if (vfd->vidioc_try_fmt_type_private)
                        return (0);
@@ -428,13 +433,43 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
        int                  ret = -EINVAL;
 
        if ( (vfd->debug & V4L2_DEBUG_IOCTL) &&
-                               !(vfd->debug | V4L2_DEBUG_IOCTL_ARG)) {
+                               !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
                v4l_print_ioctl(vfd->name, cmd);
        }
 
+#ifdef CONFIG_VIDEO_V4L1_COMPAT
+       /***********************************************************
+        Handles calls to the obsoleted V4L1 API
+        Due to the nature of VIDIOCGMBUF, each driver that supports
+        V4L1 should implement its own handler for this ioctl.
+        ***********************************************************/
+
+       /* --- streaming capture ------------------------------------- */
+       if (cmd == VIDIOCGMBUF) {
+               struct video_mbuf *p=arg;
+
+               memset(p, 0, sizeof(*p));
+
+               if (!vfd->vidiocgmbuf)
+                       return ret;
+               ret=vfd->vidiocgmbuf(file, fh, p);
+               if (!ret)
+                       dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
+                                               p->size, p->frames,
+                                               (unsigned long)p->offsets);
+               return ret;
+       }
+
+       /********************************************************
+        All other V4L1 calls are handled by v4l1_compat module.
+        Those calls will be translated into V4L2 calls, and
+        __video_do_ioctl will be called again, with one or more
+        V4L2 ioctls.
+        ********************************************************/
        if (_IOC_TYPE(cmd)=='v')
                return v4l_compat_translate_ioctl(inode,file,cmd,arg,
                                                __video_do_ioctl);
+#endif
 
        switch(cmd) {
        /* --- capabilities ------------------------------------------ */
@@ -526,6 +561,10 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                                ret=vfd->vidioc_enum_fmt_vbi_output(file,
                                                                fh, f);
                        break;
+               case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
+                       if (vfd->vidioc_enum_fmt_output_overlay)
+                               ret=vfd->vidioc_enum_fmt_output_overlay(file, fh, f);
+                       break;
                case V4L2_BUF_TYPE_PRIVATE:
                        if (vfd->vidioc_enum_fmt_type_private)
                                ret=vfd->vidioc_enum_fmt_type_private(file,
@@ -583,6 +622,10 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                                ret=vfd->vidioc_g_fmt_video_output(file,
                                                                fh, f);
                        break;
+               case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
+                       if (vfd->vidioc_g_fmt_output_overlay)
+                               ret=vfd->vidioc_g_fmt_output_overlay(file, fh, f);
+                       break;
                case V4L2_BUF_TYPE_VBI_OUTPUT:
                        if (vfd->vidioc_g_fmt_vbi_output)
                                ret=vfd->vidioc_g_fmt_vbi_output(file, fh, f);
@@ -631,6 +674,10 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                                ret=vfd->vidioc_s_fmt_video_output(file,
                                                                fh, f);
                        break;
+               case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
+                       if (vfd->vidioc_s_fmt_output_overlay)
+                               ret=vfd->vidioc_s_fmt_output_overlay(file, fh, f);
+                       break;
                case V4L2_BUF_TYPE_VBI_OUTPUT:
                        if (vfd->vidioc_s_fmt_vbi_output)
                                ret=vfd->vidioc_s_fmt_vbi_output(file,
@@ -681,6 +728,10 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                                ret=vfd->vidioc_try_fmt_video_output(file,
                                                                fh, f);
                        break;
+               case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
+                       if (vfd->vidioc_try_fmt_output_overlay)
+                               ret=vfd->vidioc_try_fmt_output_overlay(file, fh, f);
+                       break;
                case V4L2_BUF_TYPE_VBI_OUTPUT:
                        if (vfd->vidioc_try_fmt_vbi_output)
                                ret=vfd->vidioc_try_fmt_vbi_output(file,
@@ -770,24 +821,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                ret=vfd->vidioc_overlay(file, fh, *i);
                break;
        }
-#ifdef CONFIG_VIDEO_V4L1_COMPAT
-       /* --- streaming capture ------------------------------------- */
-       case VIDIOCGMBUF:
-       {
-               struct video_mbuf *p=arg;
-
-               memset(p,0,sizeof(p));
-
-               if (!vfd->vidiocgmbuf)
-                       break;
-               ret=vfd->vidiocgmbuf(file, fh, p);
-               if (!ret)
-                       dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
-                                               p->size, p->frames,
-                                               (unsigned long)p->offsets);
-               break;
-       }
-#endif
        case VIDIOC_G_FBUF:
        {
                struct v4l2_framebuffer *p=arg;
@@ -1343,9 +1376,50 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                        ret=vfd->vidioc_s_jpegcomp(file, fh, p);
                break;
        }
+       case VIDIOC_G_ENC_INDEX:
+       {
+               struct v4l2_enc_idx *p=arg;
+
+               if (!vfd->vidioc_g_enc_index)
+                       break;
+               ret=vfd->vidioc_g_enc_index(file, fh, p);
+               if (!ret)
+                       dbgarg (cmd, "entries=%d, entries_cap=%d\n",
+                                       p->entries,p->entries_cap);
+               break;
+       }
+       case VIDIOC_ENCODER_CMD:
+       {
+               struct v4l2_encoder_cmd *p=arg;
+
+               if (!vfd->vidioc_encoder_cmd)
+                       break;
+               ret=vfd->vidioc_encoder_cmd(file, fh, p);
+               if (!ret)
+                       dbgarg (cmd, "cmd=%d, flags=%d\n",
+                                       p->cmd,p->flags);
+               break;
+       }
+       case VIDIOC_TRY_ENCODER_CMD:
+       {
+               struct v4l2_encoder_cmd *p=arg;
+
+               if (!vfd->vidioc_try_encoder_cmd)
+                       break;
+               ret=vfd->vidioc_try_encoder_cmd(file, fh, p);
+               if (!ret)
+                       dbgarg (cmd, "cmd=%d, flags=%d\n",
+                                       p->cmd,p->flags);
+               break;
+       }
        case VIDIOC_G_PARM:
        {
                struct v4l2_streamparm *p=arg;
+               __u32 type=p->type;
+
+               memset(p,0,sizeof(*p));
+               p->type=type;
+
                if (vfd->vidioc_g_parm) {
                        ret=vfd->vidioc_g_parm(file, fh, p);
                } else {
@@ -1357,8 +1431,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                        v4l2_video_std_construct(&s, vfd->current_norm,
                                                 v4l2_norm_to_name(vfd->current_norm));
 
-                       memset(p,0,sizeof(*p));
-
                        p->parm.capture.timeperframe = s.frameperiod;
                        ret=0;
                }
@@ -1454,6 +1526,36 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
                ret=vfd->vidioc_log_status(file, fh);
                break;
        }
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+       case VIDIOC_DBG_G_REGISTER:
+       {
+               struct v4l2_register *p=arg;
+               if (!capable(CAP_SYS_ADMIN))
+                       ret=-EPERM;
+               else if (vfd->vidioc_g_register)
+                       ret=vfd->vidioc_g_register(file, fh, p);
+               break;
+       }
+       case VIDIOC_DBG_S_REGISTER:
+       {
+               struct v4l2_register *p=arg;
+               if (!capable(CAP_SYS_ADMIN))
+                       ret=-EPERM;
+               else if (vfd->vidioc_s_register)
+                       ret=vfd->vidioc_s_register(file, fh, p);
+               break;
+       }
+#endif
+       case VIDIOC_G_CHIP_IDENT:
+       {
+               struct v4l2_chip_ident *p=arg;
+               if (!vfd->vidioc_g_chip_ident)
+                       break;
+               ret=vfd->vidioc_g_chip_ident(file, fh, p);
+               if (!ret)
+                       dbgarg (cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
+               break;
+       }
        } /* switch */
 
        if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
@@ -1561,7 +1663,7 @@ out:
 }
 
 
-static struct file_operations video_fops;
+static const struct file_operations video_fops;
 
 /**
  *     video_register_device - register video4linux devices
@@ -1709,7 +1811,7 @@ void video_unregister_device(struct video_device *vfd)
 /*
  * Video fs operations
  */
-static struct file_operations video_fops=
+static const struct file_operations video_fops=
 {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,