summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-08-08 13:34:19 +0200
committerHans Verkuil <hverkuil@xs4all.nl>2008-08-08 13:34:19 +0200
commitc43087924dbe5c50c0198979ed5a40e3e00c3bab (patch)
tree4e798bd1d2a9f4c7965a337933ab0f0e4dd0056b /linux/drivers/media
parent7e060a1f1573031a7925ebba3789faf730c97ecb (diff)
downloadmediapointer-dvb-s2-c43087924dbe5c50c0198979ed5a40e3e00c3bab.tar.gz
mediapointer-dvb-s2-c43087924dbe5c50c0198979ed5a40e3e00c3bab.tar.bz2
v4l2: add v4l2_ctrl_query_menu_valid_items support function
From: Hans Verkuil <hverkuil@xs4all.nl> 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 <hverkuil@xs4all.nl>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/video/v4l2-common.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/linux/drivers/media/video/v4l2-common.c b/linux/drivers/media/video/v4l2-common.c
index 596b66e30..8dfe3cb8b 100644
--- a/linux/drivers/media/video/v4l2-common.c
+++ b/linux/drivers/media/video/v4l2-common.c
@@ -644,6 +644,7 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
{
int i;
+ qmenu->reserved = 0;
if (menu_items == NULL ||
(qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum)))
return -EINVAL;
@@ -651,11 +652,31 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
if (menu_items[i] == NULL || menu_items[i][0] == '\0')
return -EINVAL;
snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]);
- qmenu->reserved = 0;
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;
+ 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.
Each array must be sorted low to high and belong to the same control