The patch number 8637 was added via Hans Verkuil <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.
Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel
If anyone has any objections, please let us know by sending a message to:
[EMAIL PROTECTED]
------
From: Hans Verkuil <[EMAIL PROTECTED]>
v4l2: add v4l2_ctrl_query_menu_valid_items support function
v4l2_ctrl_query_menu_valid_items() makes it easy to handle control menus
that have a lot of invalid 'holes'. For example, many MPEG encoders only
support a limited subset of audio bitrates. In that case a driver can
specify an array listing the set of valid bitrates and pass that to
this function.
Priority: normal
Signed-off-by: Hans Verkuil <[EMAIL PROTECTED]>
---
linux/drivers/media/video/v4l2-common.c | 27 +++++++++++++++++++++---
linux/include/media/v4l2-common.h | 2 +
2 files changed, 26 insertions(+), 3 deletions(-)
diff -r 5e200c8fd7fe -r e79d11d6a256 linux/drivers/media/video/v4l2-common.c
--- a/linux/drivers/media/video/v4l2-common.c Fri Aug 08 12:55:00 2008 +0200
+++ b/linux/drivers/media/video/v4l2-common.c Fri Aug 08 13:34:19 2008 +0200
@@ -644,6 +644,7 @@ int v4l2_ctrl_query_menu(struct v4l2_que
{
int i;
+ qmenu->reserved = 0;
if (menu_items == NULL ||
(qctrl && (qmenu->index < qctrl->minimum || qmenu->index >
qctrl->maximum)))
return -EINVAL;
@@ -651,10 +652,30 @@ int v4l2_ctrl_query_menu(struct v4l2_que
if (menu_items[i] == NULL || menu_items[i][0] == '\0')
return -EINVAL;
snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]);
+ return 0;
+}
+EXPORT_SYMBOL(v4l2_ctrl_query_menu);
+
+/* Fill in a struct v4l2_querymenu based on the specified array of valid
+ menu items (terminated by V4L2_CTRL_MENU_IDS_END).
+ Use this if there are 'holes' in the list of valid menu items. */
+int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32
*ids)
+{
+ const char **menu_items = v4l2_ctrl_get_menu(qmenu->id);
+
qmenu->reserved = 0;
- return 0;
-}
-EXPORT_SYMBOL(v4l2_ctrl_query_menu);
+ if (menu_items == NULL || ids == NULL)
+ return -EINVAL;
+ while (*ids != V4L2_CTRL_MENU_IDS_END) {
+ if (*ids++ == qmenu->index) {
+ snprintf(qmenu->name, sizeof(qmenu->name),
+ menu_items[qmenu->index]);
+ return 0;
+ }
+ }
+ return -EINVAL;
+}
+EXPORT_SYMBOL(v4l2_ctrl_query_menu_valid_items);
/* ctrl_classes points to an array of u32 pointers, the last element is
a NULL pointer. Each u32 array is a 0-terminated array of control IDs.
diff -r 5e200c8fd7fe -r e79d11d6a256 linux/include/media/v4l2-common.h
--- a/linux/include/media/v4l2-common.h Fri Aug 08 12:55:00 2008 +0200
+++ b/linux/include/media/v4l2-common.h Fri Aug 08 13:34:19 2008 +0200
@@ -82,6 +82,8 @@ int v4l2_ctrl_query_fill_std(struct v4l2
int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl);
int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu,
struct v4l2_queryctrl *qctrl, const char **menu_items);
+#define V4L2_CTRL_MENU_IDS_END (0xffffffff)
+int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32
*ids);
u32 v4l2_ctrl_next(const u32 * const *ctrl_classes, u32 id);
/* ------------------------------------------------------------------------- */
---
Patch is available at:
http://linuxtv.org/hg/v4l-dvb/rev/e79d11d6a2568b7ee331531d0e8b26683febb718
_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits