From f9eb4dd2063c0fd843a2ee08ba23f9535bc636ed Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Fri, 27 Jun 2014 11:33:06 +0100 Subject: [PATCH] v4l2object: drop workaround for misbehaving TRY_FMT This workaround from 2011 was causing 25 S_FMT ioctls to be sent to my UVC webcam from under gst_v4l2_object_get_caps as it probes all the formats. In total, this adds up to about 5 seconds of execution time, or a 10 second delay while starting up cheese. These ioctls come from a workaround from 2011 where TRY_FMT might make changes to hardware settings, so S_FMT was used to restore the original config: https://bugzilla.gnome.org/show_bug.cgi?id=649067 The driver bug is now assumed fixed. Remove the workaround to fix the long startup delay. https://bugzilla.gnome.org/show_bug.cgi?id=732326 --- sys/v4l2/gstv4l2object.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 69990ff022..61e6989e43 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -2129,10 +2129,9 @@ static gboolean gst_v4l2_object_get_nearest_size (GstV4l2Object * v4l2object, guint32 pixelformat, gint * width, gint * height, gboolean * interlaced) { - struct v4l2_format fmt, prevfmt; + struct v4l2_format fmt; int fd; int r; - int prevfmt_valid = FALSE; gboolean ret = FALSE; g_return_val_if_fail (width != NULL, FALSE); @@ -2145,15 +2144,6 @@ gst_v4l2_object_get_nearest_size (GstV4l2Object * v4l2object, fd = v4l2object->video_fd; memset (&fmt, 0, sizeof (struct v4l2_format)); - memset (&prevfmt, 0, sizeof (struct v4l2_format)); - - /* Some drivers are buggy and will modify the currently set format - when processing VIDIOC_TRY_FMT, so we remember what is set at the - minute, and will reset it when done. */ - if (!v4l2object->no_initial_format) { - prevfmt.type = v4l2object->type; - prevfmt_valid = (v4l2_ioctl (fd, VIDIOC_G_FMT, &prevfmt) >= 0); - } /* get size delimiters */ memset (&fmt, 0, sizeof (fmt)); @@ -2234,12 +2224,6 @@ error: GST_WARNING_OBJECT (v4l2object->element, "Unable to try format: %s", g_strerror (errno)); } - if (prevfmt_valid) - if (v4l2_ioctl (fd, VIDIOC_S_FMT, &prevfmt) < 0) { - GST_WARNING_OBJECT (v4l2object->element, - "Unable to restore format after trying format: %s", - g_strerror (errno)); - } return ret; }