Commit 83143486 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] v4l: v4l1-compat fix

From: Gerd Knorr <kraxel@bytesex.org>

Minor tweak in the v4l1 compatibility layer: Make sure that capture actually
is active before going to wait for a frame so we don't block forever.
parent 2e061730
...@@ -289,6 +289,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -289,6 +289,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
{ {
struct v4l2_capability *cap2 = NULL; struct v4l2_capability *cap2 = NULL;
struct v4l2_format *fmt2 = NULL; struct v4l2_format *fmt2 = NULL;
enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct v4l2_framebuffer fbuf2; struct v4l2_framebuffer fbuf2;
struct v4l2_input input2; struct v4l2_input input2;
...@@ -465,6 +466,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -465,6 +466,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL);
memset(fmt2,0,sizeof(*fmt2)); memset(fmt2,0,sizeof(*fmt2));
fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type);
err1 = drv(inode, file, VIDIOC_G_FMT, fmt2); err1 = drv(inode, file, VIDIOC_G_FMT, fmt2);
if (err1 < 0) if (err1 < 0)
dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n",err); dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n",err);
...@@ -503,11 +505,10 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -503,11 +505,10 @@ v4l_compat_translate_ioctl(struct inode *inode,
int *on = arg; int *on = arg;
if (0 == *on) { if (0 == *on) {
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
/* dirty hack time. But v4l1 has no STREAMOFF /* dirty hack time. But v4l1 has no STREAMOFF
* equivalent in the API, and this one at * equivalent in the API, and this one at
* least comes close ... */ * least comes close ... */
drv(inode, file, VIDIOC_STREAMOFF, &type); drv(inode, file, VIDIOC_STREAMOFF, &captype);
} }
err = drv(inode, file, VIDIOC_OVERLAY, arg); err = drv(inode, file, VIDIOC_OVERLAY, arg);
if (err < 0) if (err < 0)
...@@ -858,7 +859,6 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -858,7 +859,6 @@ v4l_compat_translate_ioctl(struct inode *inode,
case VIDIOCMCAPTURE: /* capture a frame */ case VIDIOCMCAPTURE: /* capture a frame */
{ {
struct video_mmap *mm = arg; struct video_mmap *mm = arg;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL);
memset(&buf2,0,sizeof(buf2)); memset(&buf2,0,sizeof(buf2));
...@@ -899,7 +899,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -899,7 +899,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n",err); dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n",err);
break; break;
} }
err = drv(inode, file, VIDIOC_STREAMON, &type); err = drv(inode, file, VIDIOC_STREAMON, &captype);
if (err < 0) if (err < 0)
dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n",err); dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n",err);
break; break;
...@@ -922,6 +922,13 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -922,6 +922,13 @@ v4l_compat_translate_ioctl(struct inode *inode,
break; break;
} }
/* make sure capture actually runs so we don't block forever */
err = drv(inode, file, VIDIOC_STREAMON, &captype);
if (err < 0) {
dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n",err);
break;
}
/* Loop as long as the buffer is queued, but not done */ /* Loop as long as the buffer is queued, but not done */
while ((buf2.flags & while ((buf2.flags &
(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE)) (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE))
......
...@@ -430,6 +430,7 @@ struct video_code ...@@ -430,6 +430,7 @@ struct video_code
#define VID_HARDWARE_VICAM 34 #define VID_HARDWARE_VICAM 34
#define VID_HARDWARE_SF16FMR2 35 #define VID_HARDWARE_SF16FMR2 35
#define VID_HARDWARE_W9968CF 36 #define VID_HARDWARE_W9968CF 36
#define VID_HARDWARE_SAA7114H 37
#endif /* __LINUX_VIDEODEV_H */ #endif /* __LINUX_VIDEODEV_H */
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment