8000 update vidioc_enum_framesizes and vidioc_enum_frameintervals · v4l2loopback/v4l2loopback@46bb1a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 46bb1a9

Browse files
committed
update vidioc_enum_framesizes and vidioc_enum_frameintervals
According to V4L2 documentation: Applications can assume that the enumeration data does not change without any interaction from the application itself. This means that the enumeration data is consistent if the application does not perform any other ioctl calls while it runs the frame size enumeration. This change always returns all supported formats. Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
1 parent 03a69b4 commit 46bb1a9

File tree

1 file changed

+24
-45
lines changed

1 file changed

+24
-45
lines changed

v4l2loopback.c

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -704,34 +704,21 @@ static int vidioc_enum_framesizes(struct file *file, void *fh,
704704
return -EINVAL;
705705

706706
dev = file_to_loopdev(file);
707-
if (dev->ready_for_capture) {
708-
/* format has already been negotiated
709-
* cannot change during runtime
710-
*/
711-
if (argp->pixel_format != dev->pix_format.pixelformat)
712-
return -EINVAL;
713707

714-
argp->type = V4L2_FRMSIZE_TYPE_DISCRETE;
708+
if (NULL == format_by_fourcc(argp->pixel_format))
709+
return -EINVAL;
715710

716-
argp->discrete.width = dev->pix_format.width;
717-
argp->discrete.height = dev->pix_format.height;
718-
} else {
719-
/* if the format has not been negotiated yet, we accept anything
720-
*/
721-
if (NULL == format_by_fourcc(argp->pixel_format))
722-
return -EINVAL;
711+
argp->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
723712

724-
argp->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
713+
argp->stepwise.min_width = V4L2LOOPBACK_SIZE_MIN_WIDTH;
714+
argp->stepwise.min_height = V4L2LOOPBACK_SIZE_MIN_HEIGHT;
725715

726-
argp->stepwise.min_width = V4L2LOOPBACK_SIZE_MIN_WIDTH;
727-
argp->stepwise.min_height = V4L2LOOPBACK_SIZE_MIN_HEIGHT;
716+
argp->stepwise.max_width = dev->max_width;
717+
argp->stepwise.max_height = dev->max_height;
728718

729-
argp->stepwise.max_width = dev->max_width;
730-
argp->stepwise.max_height = dev->max_height;
719+
argp->stepwise.step_width = 1;
720+
argp->stepwise.step_height = 1;
731721

732-
argp->stepwise.step_width = 1;
733-
argp->stepwise.step_height = 1;
734-
}
735722
return 0;
736723
}
737724

@@ -747,30 +734,20 @@ static int vidioc_enum_frameintervals(struct file *file, void *fh,
747734
if (argp->index)
748735
return -EINVAL;
749736

750-
if (dev->ready_for_capture) {
751-
if (argp->width != dev->pix_format.width ||
752-
argp->height != dev->pix_format.height ||
753-
argp->pixel_format != dev->pix_format.pixelformat)
754-
return -EINVAL;
755-
756-
argp->type = V4L2_FRMIVAL_TYPE_DISCRETE;
757-
argp->discrete = dev->capture_param.timeperframe;
758-
} else {
759-
if (argp->width < V4L2LOOPBACK_SIZE_MIN_WIDTH ||
760-
argp->width > dev->max_width ||
761-
argp->height < V4L2LOOPBACK_SIZE_MIN_HEIGHT ||
762-
argp->height > dev->max_height ||
763-
NULL == format_by_fourcc(argp->pixel_format))
764-
return -EINVAL;
737+
if (argp->width < V4L2LOOPBACK_SIZE_MIN_WIDTH ||
738+
argp->width > dev->max_width ||
739+
argp->height < V4L2LOOPBACK_SIZE_MIN_HEIGHT ||
740+
argp->height > dev->max_height ||
741+
NULL == format_by_fourcc(argp->pixel_format))
742+
return -EINVAL;
765743

766-
argp->type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
767-
argp->stepwise.min.numerator = 1;
768-
argp->stepwise.min.denominator = V4L2LOOPBACK_FPS_MAX;
769-
argp->stepwise.max.numerator = 1;
770-
argp->stepwise.max.denominator = V4L2LOOPBACK_FPS_MIN;
771-
argp->stepwise.step.numerator = 1;
772-
argp->stepwise.step.denominator = 1;
773-
}
744+
argp->type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
745+
argp->stepwise.min.numerator = 1;
746+
argp->stepwise.min.denominator = V4L2LOOPBACK_FPS_MAX;
747+
argp->stepwise.max.numerator = 1;
748+
argp->stepwise.max.denominator = V4L2LOOPBACK_FPS_MIN;
749+
argp->stepwise.step.numerator = 1;
750+
argp->stepwise.step.denominator = 1;
774751

775752
return 0;
776753
}
@@ -2448,6 +2425,8 @@ static const struct v4l2_file_operations output_fops = {
24482425
static const struct v4l2_ioctl_ops output_ioctl_ops = {
24492426
// clang-format off
24502427
.vidioc_querycap = vidioc_querycap,
2428+
.vidioc_enum_framesizes = vidioc_enum_framesizes,
2429+
.vidioc_enum_frameintervals = vidioc_enum_frameintervals,
24512430

24522431
.vidioc_enum_output = vidioc_enum_output,
24532432
.vidioc_g_output = vidioc_g_output,

0 commit comments

Comments
 (0)
0