Support holes in menu indices
When querying menu entries, don't stop at the first error returned by
the driver but loop over the [min,max] range and print supported menu
entries only.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
diff --git a/yavta.c b/yavta.c
index 7d6bfb9..821e526 100644
--- a/yavta.c
+++ b/yavta.c
@@ -439,20 +439,19 @@
return 0;
}
-static void video_query_menu(struct device *dev, unsigned int id)
+static void video_query_menu(struct device *dev, unsigned int id,
+ unsigned int min, unsigned int max)
{
struct v4l2_querymenu menu;
int ret;
- menu.index = 0;
- while (1) {
+ for (menu.index = min; menu.index <= max; menu.index++) {
menu.id = id;
ret = ioctl(dev->fd, VIDIOC_QUERYMENU, &menu);
if (ret < 0)
- break;
+ continue;
printf(" %u: %.32s\n", menu.index, menu.name);
- menu.index++;
};
}
@@ -493,7 +492,7 @@
query.step, query.default_value, value);
if (query.type == V4L2_CTRL_TYPE_MENU)
- video_query_menu(dev, query.id);
+ video_query_menu(dev, query.id, query.minimum, query.maximum);
nctrls++;
}