V4L/DVB (4756): Cx88: cleanups
[safe/jmp/linux-2.6] / drivers / media / video / videodev.c
index 26e7ea2..41ec0c4 100644 (file)
  */
 
 #define dbgarg(cmd, fmt, arg...) \
-               if (vfd->debug & V4L2_DEBUG_IOCTL_ARG)                  \
+               if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {                \
                        printk (KERN_DEBUG "%s: ",  vfd->name);         \
                        v4l_printk_ioctl(cmd);                          \
-                       printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg);
+                       printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); \
+               }
 
 #define dbgarg2(fmt, arg...) \
                if (vfd->debug & V4L2_DEBUG_IOCTL_ARG)                  \
@@ -104,7 +105,7 @@ static DEFINE_MUTEX(videodev_lock);
 
 struct video_device* video_devdata(struct file *file)
 {
-       return video_device[iminor(file->f_dentry->d_inode)];
+       return video_device[iminor(file->f_path.dentry->d_inode)];
 }
 
 /*
@@ -1283,9 +1284,36 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
        case VIDIOC_G_PARM:
        {
                struct v4l2_streamparm *p=arg;
-               if (!vfd->vidioc_g_parm)
-                       break;
-               ret=vfd->vidioc_g_parm(file, fh, p);
+               if (vfd->vidioc_g_parm) {
+                       ret=vfd->vidioc_g_parm(file, fh, p);
+               } else {
+                       struct v4l2_standard s;
+                       int i;
+
+                       if (!vfd->tvnormsize) {
+                               printk (KERN_WARNING "%s: no TV norms defined!\n",
+                                                       vfd->name);
+                               break;
+                       }
+
+                       if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+                               return -EINVAL;
+
+                       for (i = 0; i < vfd->tvnormsize; i++)
+                               if (vfd->tvnorms[i].id == vfd->current_norm)
+                                       break;
+                       if (i >= vfd->tvnormsize)
+                               return -EINVAL;
+
+                       v4l2_video_std_construct(&s, vfd->current_norm,
+                                                vfd->tvnorms[i].name);
+
+                       memset(p,0,sizeof(*p));
+
+                       p->parm.capture.timeperframe = s.frameperiod;
+                       ret=0;
+               }
+
                dbgarg (cmd, "type=%d\n", p->type);
                break;
        }