v4l2object: Quirks for dev without initial format

Most M2M have undefined behaviour initially when VIDIOC_G_FMT is called.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
This commit is contained in:
Nicolas Dufresne 2013-11-28 17:10:29 -05:00
parent 080f58166e
commit 4a85f90c79
2 changed files with 14 additions and 5 deletions

View file

@ -589,6 +589,8 @@ gst_v4l2_object_new (GstElement * element,
*/ */
v4l2object->prefered_non_contiguous = TRUE; v4l2object->prefered_non_contiguous = TRUE;
v4l2object->no_initial_format = FALSE;
return v4l2object; return v4l2object;
} }
@ -2292,7 +2294,7 @@ gst_v4l2_object_get_nearest_size (GstV4l2Object * v4l2object,
struct v4l2_format fmt, prevfmt; struct v4l2_format fmt, prevfmt;
int fd; int fd;
int r; int r;
int prevfmt_valid; int prevfmt_valid = FALSE;
gboolean ret = FALSE; gboolean ret = FALSE;
g_return_val_if_fail (width != NULL, FALSE); g_return_val_if_fail (width != NULL, FALSE);
@ -2307,8 +2309,10 @@ gst_v4l2_object_get_nearest_size (GstV4l2Object * v4l2object,
/* Some drivers are buggy and will modify the currently set 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 when processing VIDIOC_TRY_FMT, so we remember what is set at the
minute, and will reset it when done. */ minute, and will reset it when done. */
prevfmt.type = v4l2object->type; if (!v4l2object->no_initial_format) {
prevfmt_valid = (v4l2_ioctl (fd, VIDIOC_G_FMT, &prevfmt) >= 0); prevfmt.type = v4l2object->type;
prevfmt_valid = (v4l2_ioctl (fd, VIDIOC_G_FMT, &prevfmt) >= 0);
}
/* get size delimiters */ /* get size delimiters */
memset (&fmt, 0, sizeof (fmt)); memset (&fmt, 0, sizeof (fmt));
@ -2545,8 +2549,10 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
memset (&format, 0x00, sizeof (struct v4l2_format)); memset (&format, 0x00, sizeof (struct v4l2_format));
format.type = v4l2object->type; format.type = v4l2object->type;
if (v4l2_ioctl (fd, VIDIOC_G_FMT, &format) < 0) if (!v4l2object->no_initial_format) {
goto get_fmt_failed; if (v4l2_ioctl (fd, VIDIOC_G_FMT, &format) < 0)
goto get_fmt_failed;
}
if (V4L2_TYPE_IS_MULTIPLANAR (v4l2object->type)) { if (V4L2_TYPE_IS_MULTIPLANAR (v4l2object->type)) {
/* even in v4l2 multiplanar mode we can work in contiguous mode /* even in v4l2 multiplanar mode we can work in contiguous mode

View file

@ -181,6 +181,9 @@ struct _GstV4l2Object {
/* Quirks */ /* Quirks */
/* Skips interlacing probes */ /* Skips interlacing probes */
gboolean never_interlaced; gboolean never_interlaced;
/* Allow to skip reading initial format through G_FMT. Some devices
* just fails if you don't call S_FMT first. (ex: M2M decoders) */
gboolean no_initial_format;
}; };
struct _GstV4l2ObjectClassHelper { struct _GstV4l2ObjectClassHelper {