Commit d9a25471 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] v4l2-ctrls: add support for compound types

This patch implements initial support for compound types.

The changes are fairly obvious: basic support for is_ptr types, the
type_is_int function is replaced by a is_int bitfield, and
v4l2_query_ext_ctrl is added.

Note that this patch does not yet add support for N-dimensional
arrays, that comes later. So v4l2_query_ext_ctrl just sets elems to
1 and nr_of_dims and dims[] are all zero.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 5082c241
This diff is collapsed.
...@@ -73,6 +73,12 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); ...@@ -73,6 +73,12 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
* members are in 'automatic' mode or 'manual' mode. This is * members are in 'automatic' mode or 'manual' mode. This is
* used for autogain/gain type clusters. Drivers should never * used for autogain/gain type clusters. Drivers should never
* set this flag directly. * set this flag directly.
* @is_int: If set, then this control has a simple integer value (i.e. it
* uses ctrl->val).
* @is_string: If set, then this control has type V4L2_CTRL_TYPE_STRING.
* @is_ptr: If set, then this control is an array and/or has type >= V4L2_CTRL_COMPOUND_TYPES
* and/or has type V4L2_CTRL_TYPE_STRING. In other words, struct
* v4l2_ext_control uses field p to point to the data.
* @has_volatiles: If set, then one or more members of the cluster are volatile. * @has_volatiles: If set, then one or more members of the cluster are volatile.
* Drivers should never touch this flag. * Drivers should never touch this flag.
* @call_notify: If set, then call the handler's notify function whenever the * @call_notify: If set, then call the handler's notify function whenever the
...@@ -90,6 +96,7 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); ...@@ -90,6 +96,7 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
* @maximum: The control's maximum value. * @maximum: The control's maximum value.
* @default_value: The control's default value. * @default_value: The control's default value.
* @step: The control's step value for non-menu controls. * @step: The control's step value for non-menu controls.
* @elem_size: The size in bytes of the control.
* @menu_skip_mask: The control's skip mask for menu controls. This makes it * @menu_skip_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, * 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 * then menu item X is skipped. Of course, this only works for
...@@ -104,7 +111,6 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); ...@@ -104,7 +111,6 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
* @cur: The control's current value. * @cur: The control's current value.
* @val: The control's new s32 value. * @val: The control's new s32 value.
* @val64: The control's new s64 value. * @val64: The control's new s64 value.
* @string: The control's new string value.
* @priv: The control's private pointer. For use by the driver. It is * @priv: The control's private pointer. For use by the driver. It is
* untouched by the control framework. Note that this pointer is * untouched by the control framework. Note that this pointer is
* not freed when the control is deleted. Should this be needed * not freed when the control is deleted. Should this be needed
...@@ -123,6 +129,9 @@ struct v4l2_ctrl { ...@@ -123,6 +129,9 @@ struct v4l2_ctrl {
unsigned int is_new:1; unsigned int is_new:1;
unsigned int is_private:1; unsigned int is_private:1;
unsigned int is_auto:1; unsigned int is_auto:1;
unsigned int is_int:1;
unsigned int is_string:1;
unsigned int is_ptr:1;
unsigned int has_volatiles:1; unsigned int has_volatiles:1;
unsigned int call_notify:1; unsigned int call_notify:1;
unsigned int manual_mode_value:8; unsigned int manual_mode_value:8;
...@@ -132,6 +141,7 @@ struct v4l2_ctrl { ...@@ -132,6 +141,7 @@ struct v4l2_ctrl {
const char *name; const char *name;
enum v4l2_ctrl_type type; enum v4l2_ctrl_type type;
s64 minimum, maximum, default_value; s64 minimum, maximum, default_value;
u32 elem_size;
union { union {
u64 step; u64 step;
u64 menu_skip_mask; u64 menu_skip_mask;
...@@ -141,17 +151,19 @@ struct v4l2_ctrl { ...@@ -141,17 +151,19 @@ struct v4l2_ctrl {
const s64 *qmenu_int; const s64 *qmenu_int;
}; };
unsigned long flags; unsigned long flags;
void *priv;
union { union {
s32 val; s32 val;
s64 val64; s64 val64;
char *string; char *string;
} cur; void *p;
};
union { union {
s32 val; s32 val;
s64 val64; s64 val64;
char *string; char *string;
}; void *p;
void *priv; } cur;
}; };
/** struct v4l2_ctrl_ref - The control reference. /** struct v4l2_ctrl_ref - The control reference.
...@@ -212,6 +224,7 @@ struct v4l2_ctrl_handler { ...@@ -212,6 +224,7 @@ struct v4l2_ctrl_handler {
* @max: The control's maximum value. * @max: The control's maximum value.
* @step: The control's step value for non-menu controls. * @step: The control's step value for non-menu controls.
* @def: The control's default value. * @def: The control's default value.
* @elem_size: The size in bytes of the control.
* @flags: The control's flags. * @flags: The control's flags.
* @menu_skip_mask: The control's skip mask for menu controls. This makes it * @menu_skip_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, * easy to skip menu items that are not valid. If bit X is set,
...@@ -235,6 +248,7 @@ struct v4l2_ctrl_config { ...@@ -235,6 +248,7 @@ struct v4l2_ctrl_config {
s64 max; s64 max;
u64 step; u64 step;
s64 def; s64 def;
u32 elem_size;
u32 flags; u32 flags;
u64 menu_skip_mask; u64 menu_skip_mask;
const char * const *qmenu; const char * const *qmenu;
...@@ -659,6 +673,7 @@ unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); ...@@ -659,6 +673,7 @@ unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
/* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctrl *qc);
int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl); int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment