V4L/DVB (9661): uvcvideo: Commit streaming parameters when enabling the video stream
authorLaurent Pinchart <laurent.pinchart@skynet.be>
Wed, 12 Nov 2008 14:46:43 +0000 (11:46 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 29 Dec 2008 19:53:36 +0000 (17:53 -0200)
Sonix-based cameras seem to require the host to commit video streaming
parameters before selecting the alternate endpoint. While most applications
issue a VIDIOC_S_FMT ioctl before starting streaming, this is not required
by the V4L2 specification.

The problem has been noticed on Ubuntu 8.10 with applications using libv4l.
The library blocks VIDIOC_S_FMT calls when the requested format is identical
to the currently selected format. As the driver commits video streaming
parameters when initialising the device, only the first run of a
libv4l-enabled application would succeed.

For the sake of completeness, experiment showed that the camera keeps sending
12 bytes isochronous packets (header only, no data) without toggling the FID
bit if video streaming parameters haven't been committed before selecting the
alternate endpoint.

Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/uvc/uvc_v4l2.c
drivers/media/video/uvc/uvc_video.c

index 624bf74de673468b30ad786886ab75052ef9645d..01b48a87a9b962759167eee6ba04ef019c3a8269 100644 (file)
@@ -252,9 +252,6 @@ static int uvc_v4l2_set_format(struct uvc_video_device *video,
        if (ret < 0)
                return ret;
 
-       if ((ret = uvc_commit_video(video, &probe)) < 0)
-               return ret;
-
        memcpy(&video->streaming->ctrl, &probe, sizeof probe);
        video->streaming->cur_format = format;
        video->streaming->cur_frame = frame;
@@ -315,10 +312,6 @@ static int uvc_v4l2_set_streamparm(struct uvc_video_device *video,
        if ((ret = uvc_probe_video(video, &probe)) < 0)
                return ret;
 
-       /* Commit the new settings. */
-       if ((ret = uvc_commit_video(video, &probe)) < 0)
-               return ret;
-
        memcpy(&video->streaming->ctrl, &probe, sizeof probe);
 
        /* Return the actual frame period. */
index e07bee98a00a62d9345af69e9fd5f09f0cfa8706..186ef9fad80bae87056c1ddb1c783b61d7e28c60 100644 (file)
@@ -889,7 +889,7 @@ int uvc_video_resume(struct uvc_video_device *video)
 
        video->frozen = 0;
 
-       if ((ret = uvc_set_video_ctrl(video, &video->streaming->ctrl, 0)) < 0) {
+       if ((ret = uvc_commit_video(video, &video->streaming->ctrl)) < 0) {
                uvc_queue_enable(&video->queue, 0);
                return ret;
        }
@@ -970,11 +970,8 @@ int uvc_video_init(struct uvc_video_device *video)
                        break;
        }
 
-       /* Commit the default settings. */
        probe->bFormatIndex = format->index;
        probe->bFrameIndex = frame->bFrameIndex;
-       if ((ret = uvc_set_video_ctrl(video, probe, 0)) < 0)
-               return ret;
 
        video->streaming->cur_format = format;
        video->streaming->cur_frame = frame;
@@ -1014,6 +1011,10 @@ int uvc_video_enable(struct uvc_video_device *video, int enable)
        if ((ret = uvc_queue_enable(&video->queue, 1)) < 0)
                return ret;
 
+       /* Commit the streaming parameters. */
+       if ((ret = uvc_commit_video(video, &video->streaming->ctrl)) < 0)
+               return ret;
+
        return uvc_init_video(video, GFP_KERNEL);
 }