aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-08-08 07:34:19 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:36:48 -0400
commit1e55126666944c83bf98243564e25302f363e2a4 (patch)
treedd86e6c7cb97d5fd49f739dffe42cf7666e7332b /drivers/media/video
parent69028d7096a6092812f0482833f0820593f1cafd (diff)
V4L/DVB (8637): 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. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/v4l2-common.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index da4791de7050..a523af78bdb1 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -643,6 +643,7 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
643{ 643{
644 int i; 644 int i;
645 645
646 qmenu->reserved = 0;
646 if (menu_items == NULL || 647 if (menu_items == NULL ||
647 (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum))) 648 (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum)))
648 return -EINVAL; 649 return -EINVAL;
@@ -650,11 +651,31 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
650 if (menu_items[i] == NULL || menu_items[i][0] == '\0') 651 if (menu_items[i] == NULL || menu_items[i][0] == '\0')
651 return -EINVAL; 652 return -EINVAL;
652 snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]); 653 snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]);
653 qmenu->reserved = 0;
654 return 0; 654 return 0;
655} 655}
656EXPORT_SYMBOL(v4l2_ctrl_query_menu); 656EXPORT_SYMBOL(v4l2_ctrl_query_menu);
657 657
658/* Fill in a struct v4l2_querymenu based on the specified array of valid
659 menu items (terminated by V4L2_CTRL_MENU_IDS_END).
660 Use this if there are 'holes' in the list of valid menu items. */
661int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids)
662{
663 const char **menu_items = v4l2_ctrl_get_menu(qmenu->id);
664
665 qmenu->reserved = 0;
666 if (menu_items == NULL || ids == NULL)
667 return -EINVAL;
668 while (*ids != V4L2_CTRL_MENU_IDS_END) {
669 if (*ids++ == qmenu->index) {
670 snprintf(qmenu->name, sizeof(qmenu->name),
671 menu_items[qmenu->index]);
672 return 0;
673 }
674 }
675 return -EINVAL;
676}
677EXPORT_SYMBOL(v4l2_ctrl_query_menu_valid_items);
678
658/* ctrl_classes points to an array of u32 pointers, the last element is 679/* ctrl_classes points to an array of u32 pointers, the last element is
659 a NULL pointer. Each u32 array is a 0-terminated array of control IDs. 680 a NULL pointer. Each u32 array is a 0-terminated array of control IDs.
660 Each array must be sorted low to high and belong to the same control 681 Each array must be sorted low to high and belong to the same control