From 7a2741c9e1ede7297f3b346e4f17f9f9a10630d9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 19 Sep 2020 13:32:47 +0200 Subject: [PATCH] v4l2: do TRY_FMT on the filter format Do a TRY_FMT on the filter format before enumerating the sizes with it because some drivers don't check the format anymore. Fixes #294 --- spa/plugins/v4l2/v4l2-utils.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index eac07064f..e29297f32 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -566,6 +566,8 @@ spa_v4l2_enum_format(struct impl *this, int seq, while (port->next_fmtdesc) { if (filter) { + struct v4l2_format fmt; + video_format = enum_filter_format(filter_media_type, filter_media_subtype, filter, port->fmtdesc.index); @@ -580,6 +582,21 @@ spa_v4l2_enum_format(struct impl *this, int seq, goto next_fmtdesc; port->fmtdesc.pixelformat = info->fourcc; + + fmt.type = port->fmtdesc.type; + fmt.fmt.pix.pixelformat = info->fourcc; + fmt.fmt.pix.field = V4L2_FIELD_ANY; + fmt.fmt.pix.width = 0; + fmt.fmt.pix.height = 0; + + if ((res = xioctl(dev->fd, VIDIOC_TRY_FMT, &fmt)) < 0) { + spa_log_error(this->log, "v4l2: '%s' VIDIOC_TRY_FMT: %m", + this->props.device); + goto next_fmtdesc; + } + if (fmt.fmt.pix.pixelformat != info->fourcc) + goto next_fmtdesc; + } else { if ((res = xioctl(dev->fd, VIDIOC_ENUM_FMT, &port->fmtdesc)) < 0) { if (errno == EINVAL)