From 5cd3115fdae5989c5765d7fa53454488a17287c2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 30 Apr 2011 14:43:16 +0200 Subject: 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 --- yavta.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/yavta.c b/yavta.c index 7d6bfb9..821e526 100644 --- a/yavta.c +++ b/yavta.c @@ -439,20 +439,19 @@ static int video_enable(struct device *dev, int enable) 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 @@ static void video_list_controls(struct device *dev) 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++; } -- cgit v1.2.3