Re: [yavta PATCH 1/3] Support integer menus.
Hi Sakari, Thanks for the patch. The code looks fine, but unfortunately breaks compilation when using kernel headers v3.5 (which is a pretty common case as of today ;-)). V4L2_CTRL_TYPE_INTEGER_MENU is an enumerated value, not a pre-processor #define, so it's difficult to test for it using conditional compilation. Maybe including a copy of videodev2.h in the yavta repository is the best option ? On Thursday 12 April 2012 11:41:33 Sakari Ailus wrote: Signed-off-by: Sakari Ailus sakari.ai...@iki.fi --- yavta.c | 18 +++--- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/yavta.c b/yavta.c index 72679c2..8db6e1e 100644 --- a/yavta.c +++ b/yavta.c @@ -564,19 +564,22 @@ static int video_enable(struct device *dev, int enable) return 0; } -static void video_query_menu(struct device *dev, unsigned int id, - unsigned int min, unsigned int max) +static void video_query_menu(struct device *dev, struct v4l2_queryctrl *query) { struct v4l2_querymenu menu; int ret; - for (menu.index = min; menu.index = max; menu.index++) { - menu.id = id; + for (menu.index = query-minimum; menu.index = query-maximum; + menu.index++) { + menu.id = query-id; ret = ioctl(dev-fd, VIDIOC_QUERYMENU, menu); if (ret 0) continue; - printf( %u: %.32s\n, menu.index, menu.name); + if (query-type == V4L2_CTRL_TYPE_MENU) + printf( %u: %.32s\n, menu.index, menu.name); + else + printf( %u: %lld\n, menu.index, menu.value); }; } @@ -621,8 +624,9 @@ static void video_list_controls(struct device *dev) query.id, query.name, query.minimum, query.maximum, query.step, query.default_value, value); - if (query.type == V4L2_CTRL_TYPE_MENU) - video_query_menu(dev, query.id, query.minimum, query.maximum); + if (query.type == V4L2_CTRL_TYPE_MENU || + query.type == V4L2_CTRL_TYPE_INTEGER_MENU) + video_query_menu(dev, query); nctrls++; } -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [yavta PATCH 1/3] Support integer menus.
Le vendredi 13 avril 2012 22:47:14 Laurent Pinchart, vous avez écrit : Hi Sakari, Thanks for the patch. The code looks fine, but unfortunately breaks compilation when using kernel headers v3.5 (which is a pretty common case as of today ;-)). V4L2_CTRL_TYPE_INTEGER_MENU is an enumerated value, not a pre-processor #define, so it's difficult to test for it using conditional compilation. Same problem with BITMASK already. The most common solution to this problem, although not found in V4L consists of defining the enumeration members in the header linux/videodev2.h: #define V4L2_CTRL_TYPE_INTEGER_MENU V4L2_CTRL_TYPE_INTEGER_MENU Then #ifdef works fine. libc has plenty of these, e.g. bits/socket.h. Or per package, autoconf can be used: AC_CHECK_HEADERS([linux/videodev2.h sys/videoio.h]) AC_CHECK_DECLS([V4L2_CTRL_TYPE_INTEGER_MENU],,, [ #ifdef HAVE_LINUX_VIDEODEV2_H # include linux/videodev2.h #endif #ifdef HAVE_SYS_VIDEOIO_H # include sys/videoio.h #endif ]) Then this works: #if HAVE_DECL_V4L2_CTRL_TYPE_INTEGER_MENU -- Rémi Denis-Courmont http://www.remlab.net/ http://fi.linkedin.com/in/remidenis -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [yavta PATCH 1/3] Support integer menus.
Hi Laurent, Thanks for the comments. Laurent Pinchart wrote: Hi Sakari, Thanks for the patch. The code looks fine, but unfortunately breaks compilation when using kernel headers v3.5 (which is a pretty common case as of today ;-)). V4L2_CTRL_TYPE_INTEGER_MENU is an enumerated value, not a pre-processor #define, so it's difficult to test for it using conditional compilation. Maybe including a copy of videodev2.h in the yavta repository is the best option ? Yeah; I agree. The value of the enum item we could still #define but the addition of the union to v4l2_queryctrl is more difficult. I can then remove existing code to cope with different versions of videodev2.h, too. Cheers, -- Sakari Ailus sakari.ai...@iki.fi -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[yavta PATCH 1/3] Support integer menus.
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi --- yavta.c | 18 +++--- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/yavta.c b/yavta.c index 72679c2..8db6e1e 100644 --- a/yavta.c +++ b/yavta.c @@ -564,19 +564,22 @@ static int video_enable(struct device *dev, int enable) return 0; } -static void video_query_menu(struct device *dev, unsigned int id, -unsigned int min, unsigned int max) +static void video_query_menu(struct device *dev, struct v4l2_queryctrl *query) { struct v4l2_querymenu menu; int ret; - for (menu.index = min; menu.index = max; menu.index++) { - menu.id = id; + for (menu.index = query-minimum; menu.index = query-maximum; +menu.index++) { + menu.id = query-id; ret = ioctl(dev-fd, VIDIOC_QUERYMENU, menu); if (ret 0) continue; - printf( %u: %.32s\n, menu.index, menu.name); + if (query-type == V4L2_CTRL_TYPE_MENU) + printf( %u: %.32s\n, menu.index, menu.name); + else + printf( %u: %lld\n, menu.index, menu.value); }; } @@ -621,8 +624,9 @@ static void video_list_controls(struct device *dev) query.id, query.name, query.minimum, query.maximum, query.step, query.default_value, value); - if (query.type == V4L2_CTRL_TYPE_MENU) - video_query_menu(dev, query.id, query.minimum, query.maximum); + if (query.type == V4L2_CTRL_TYPE_MENU || + query.type == V4L2_CTRL_TYPE_INTEGER_MENU) + video_query_menu(dev, query); nctrls++; } -- 1.7.2.5 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html