mirror of
https://github.com/torvalds/linux.git
synced 2024-09-21 15:33:19 +00:00
[media] media: v4l2-ctrl: add a helper function to add standard control with driver specific menu
Add helper function v4l2_ctrl_new_std_menu_items(), which adds a standard menu control, with driver specific menu. Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
5ebef0fbe0
commit
117a711a2c
|
@ -136,11 +136,25 @@ Or alternatively for integer menu controls, by calling v4l2_ctrl_new_int_menu:
|
||||||
const struct v4l2_ctrl_ops *ops,
|
const struct v4l2_ctrl_ops *ops,
|
||||||
u32 id, s32 max, s32 def, const s64 *qmenu_int);
|
u32 id, s32 max, s32 def, const s64 *qmenu_int);
|
||||||
|
|
||||||
|
Standard menu controls with a driver specific menu are added by calling
|
||||||
|
v4l2_ctrl_new_std_menu_items:
|
||||||
|
|
||||||
|
struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(
|
||||||
|
struct v4l2_ctrl_handler *hdl,
|
||||||
|
const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
|
||||||
|
s32 skip_mask, s32 def, const char * const *qmenu);
|
||||||
|
|
||||||
These functions are typically called right after the v4l2_ctrl_handler_init:
|
These functions are typically called right after the v4l2_ctrl_handler_init:
|
||||||
|
|
||||||
static const s64 exp_bias_qmenu[] = {
|
static const s64 exp_bias_qmenu[] = {
|
||||||
-2, -1, 0, 1, 2
|
-2, -1, 0, 1, 2
|
||||||
};
|
};
|
||||||
|
static const char * const test_pattern[] = {
|
||||||
|
"Disabled",
|
||||||
|
"Vertical Bars",
|
||||||
|
"Solid Black",
|
||||||
|
"Solid White",
|
||||||
|
};
|
||||||
|
|
||||||
v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
|
v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
|
||||||
v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
|
v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
|
||||||
|
@ -156,6 +170,9 @@ These functions are typically called right after the v4l2_ctrl_handler_init:
|
||||||
ARRAY_SIZE(exp_bias_qmenu) - 1,
|
ARRAY_SIZE(exp_bias_qmenu) - 1,
|
||||||
ARRAY_SIZE(exp_bias_qmenu) / 2 - 1,
|
ARRAY_SIZE(exp_bias_qmenu) / 2 - 1,
|
||||||
exp_bias_qmenu);
|
exp_bias_qmenu);
|
||||||
|
v4l2_ctrl_new_std_menu_items(&foo->ctrl_handler, &foo_ctrl_ops,
|
||||||
|
V4L2_CID_TEST_PATTERN, ARRAY_SIZE(test_pattern) - 1, 0,
|
||||||
|
0, test_pattern);
|
||||||
...
|
...
|
||||||
if (foo->ctrl_handler.error) {
|
if (foo->ctrl_handler.error) {
|
||||||
int err = foo->ctrl_handler.error;
|
int err = foo->ctrl_handler.error;
|
||||||
|
@ -185,6 +202,13 @@ v4l2_ctrl_new_std_menu in that it doesn't have the mask argument and takes
|
||||||
as the last argument an array of signed 64-bit integers that form an exact
|
as the last argument an array of signed 64-bit integers that form an exact
|
||||||
menu item list.
|
menu item list.
|
||||||
|
|
||||||
|
The v4l2_ctrl_new_std_menu_items function is very similar to
|
||||||
|
v4l2_ctrl_new_std_menu but takes an extra parameter qmenu, which is the driver
|
||||||
|
specific menu for an otherwise standard menu control. A good example for this
|
||||||
|
control is the test pattern control for capture/display/sensors devices that
|
||||||
|
have the capability to generate test patterns. These test patterns are hardware
|
||||||
|
specific, so the contents of the menu will vary from device to device.
|
||||||
|
|
||||||
Note that if something fails, the function will return NULL or an error and
|
Note that if something fails, the function will return NULL or an error and
|
||||||
set ctrl_handler->error to the error code. If ctrl_handler->error was already
|
set ctrl_handler->error to the error code. If ctrl_handler->error was already
|
||||||
set, then it will just return and do nothing. This is also true for
|
set, then it will just return and do nothing. This is also true for
|
||||||
|
|
|
@ -1650,6 +1650,36 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
|
EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
|
||||||
|
|
||||||
|
/* Helper function for standard menu controls with driver defined menu */
|
||||||
|
struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
|
||||||
|
const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
|
||||||
|
s32 mask, s32 def, const char * const *qmenu)
|
||||||
|
{
|
||||||
|
enum v4l2_ctrl_type type;
|
||||||
|
const char *name;
|
||||||
|
u32 flags;
|
||||||
|
s32 step;
|
||||||
|
s32 min;
|
||||||
|
|
||||||
|
/* v4l2_ctrl_new_std_menu_items() should only be called for
|
||||||
|
* standard controls without a standard menu.
|
||||||
|
*/
|
||||||
|
if (v4l2_ctrl_get_menu(id)) {
|
||||||
|
handler_set_err(hdl, -EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags);
|
||||||
|
if (type != V4L2_CTRL_TYPE_MENU || qmenu == NULL) {
|
||||||
|
handler_set_err(hdl, -EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return v4l2_ctrl_new(hdl, ops, id, name, type, 0, max, mask, def,
|
||||||
|
flags, qmenu, NULL, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items);
|
||||||
|
|
||||||
/* Helper function for standard integer menu controls */
|
/* Helper function for standard integer menu controls */
|
||||||
struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
|
struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
|
||||||
const struct v4l2_ctrl_ops *ops,
|
const struct v4l2_ctrl_ops *ops,
|
||||||
|
|
|
@ -351,6 +351,29 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
|
||||||
const struct v4l2_ctrl_ops *ops,
|
const struct v4l2_ctrl_ops *ops,
|
||||||
u32 id, s32 max, s32 mask, s32 def);
|
u32 id, s32 max, s32 mask, s32 def);
|
||||||
|
|
||||||
|
/** v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
|
||||||
|
* with driver specific menu.
|
||||||
|
* @hdl: The control handler.
|
||||||
|
* @ops: The control ops.
|
||||||
|
* @id: The control ID.
|
||||||
|
* @max: The control's maximum value.
|
||||||
|
* @mask: The control's skip mask for menu controls. This makes it
|
||||||
|
* easy to skip menu items that are not valid. If bit X is set,
|
||||||
|
* then menu item X is skipped. Of course, this only works for
|
||||||
|
* menus with <= 32 menu items. There are no menus that come
|
||||||
|
* close to that number, so this is OK. Should we ever need more,
|
||||||
|
* then this will have to be extended to a u64 or a bit array.
|
||||||
|
* @def: The control's default value.
|
||||||
|
* @qmenu: The new menu.
|
||||||
|
*
|
||||||
|
* Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
|
||||||
|
* menu of this control.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
|
||||||
|
const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
|
||||||
|
s32 mask, s32 def, const char * const *qmenu);
|
||||||
|
|
||||||
/** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
|
/** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
|
||||||
* @hdl: The control handler.
|
* @hdl: The control handler.
|
||||||
* @ops: The control ops.
|
* @ops: The control ops.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user