diff options
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ctrls.c | 33 | ||||
-rw-r--r-- | include/media/v4l2-ctrls.h | 8 |
2 files changed, 32 insertions, 9 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 4b105713e549..e6c98a705b19 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c | |||
@@ -1759,18 +1759,27 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, | |||
1759 | const struct v4l2_ctrl_type_ops *type_ops, | 1759 | const struct v4l2_ctrl_type_ops *type_ops, |
1760 | u32 id, const char *name, enum v4l2_ctrl_type type, | 1760 | u32 id, const char *name, enum v4l2_ctrl_type type, |
1761 | s64 min, s64 max, u64 step, s64 def, | 1761 | s64 min, s64 max, u64 step, s64 def, |
1762 | u32 elem_size, | 1762 | const u32 dims[V4L2_CTRL_MAX_DIMS], u32 elem_size, |
1763 | u32 flags, const char * const *qmenu, | 1763 | u32 flags, const char * const *qmenu, |
1764 | const s64 *qmenu_int, void *priv) | 1764 | const s64 *qmenu_int, void *priv) |
1765 | { | 1765 | { |
1766 | struct v4l2_ctrl *ctrl; | 1766 | struct v4l2_ctrl *ctrl; |
1767 | unsigned sz_extra; | 1767 | unsigned sz_extra; |
1768 | unsigned nr_of_dims = 0; | ||
1769 | unsigned elems = 1; | ||
1768 | void *data; | 1770 | void *data; |
1769 | int err; | 1771 | int err; |
1770 | 1772 | ||
1771 | if (hdl->error) | 1773 | if (hdl->error) |
1772 | return NULL; | 1774 | return NULL; |
1773 | 1775 | ||
1776 | while (dims && dims[nr_of_dims]) { | ||
1777 | elems *= dims[nr_of_dims]; | ||
1778 | nr_of_dims++; | ||
1779 | if (nr_of_dims == V4L2_CTRL_MAX_DIMS) | ||
1780 | break; | ||
1781 | } | ||
1782 | |||
1774 | if (type == V4L2_CTRL_TYPE_INTEGER64) | 1783 | if (type == V4L2_CTRL_TYPE_INTEGER64) |
1775 | elem_size = sizeof(s64); | 1784 | elem_size = sizeof(s64); |
1776 | else if (type == V4L2_CTRL_TYPE_STRING) | 1785 | else if (type == V4L2_CTRL_TYPE_STRING) |
@@ -1828,6 +1837,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, | |||
1828 | ctrl->is_string = type == V4L2_CTRL_TYPE_STRING; | 1837 | ctrl->is_string = type == V4L2_CTRL_TYPE_STRING; |
1829 | ctrl->is_ptr = type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; | 1838 | ctrl->is_ptr = type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; |
1830 | ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; | 1839 | ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; |
1840 | ctrl->elems = elems; | ||
1841 | ctrl->nr_of_dims = nr_of_dims; | ||
1842 | if (nr_of_dims) | ||
1843 | memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); | ||
1831 | ctrl->elem_size = elem_size; | 1844 | ctrl->elem_size = elem_size; |
1832 | if (type == V4L2_CTRL_TYPE_MENU) | 1845 | if (type == V4L2_CTRL_TYPE_MENU) |
1833 | ctrl->qmenu = qmenu; | 1846 | ctrl->qmenu = qmenu; |
@@ -1892,8 +1905,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, | |||
1892 | 1905 | ||
1893 | ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, | 1906 | ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, |
1894 | type, min, max, | 1907 | type, min, max, |
1895 | is_menu ? cfg->menu_skip_mask : step, | 1908 | is_menu ? cfg->menu_skip_mask : step, def, |
1896 | def, cfg->elem_size, | 1909 | cfg->dims, cfg->elem_size, |
1897 | flags, qmenu, qmenu_int, priv); | 1910 | flags, qmenu, qmenu_int, priv); |
1898 | if (ctrl) | 1911 | if (ctrl) |
1899 | ctrl->is_private = cfg->is_private; | 1912 | ctrl->is_private = cfg->is_private; |
@@ -1918,7 +1931,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | |||
1918 | return NULL; | 1931 | return NULL; |
1919 | } | 1932 | } |
1920 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, | 1933 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, |
1921 | min, max, step, def, 0, | 1934 | min, max, step, def, NULL, 0, |
1922 | flags, NULL, NULL, NULL); | 1935 | flags, NULL, NULL, NULL); |
1923 | } | 1936 | } |
1924 | EXPORT_SYMBOL(v4l2_ctrl_new_std); | 1937 | EXPORT_SYMBOL(v4l2_ctrl_new_std); |
@@ -1951,7 +1964,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | |||
1951 | return NULL; | 1964 | return NULL; |
1952 | } | 1965 | } |
1953 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, | 1966 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, |
1954 | 0, max, mask, def, 0, | 1967 | 0, max, mask, def, NULL, 0, |
1955 | flags, qmenu, qmenu_int, NULL); | 1968 | flags, qmenu, qmenu_int, NULL); |
1956 | } | 1969 | } |
1957 | EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); | 1970 | EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); |
@@ -1983,8 +1996,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, | |||
1983 | return NULL; | 1996 | return NULL; |
1984 | } | 1997 | } |
1985 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, | 1998 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, |
1986 | 0, max, mask, def, | 1999 | 0, max, mask, def, NULL, 0, |
1987 | 0, flags, qmenu, NULL, NULL); | 2000 | flags, qmenu, NULL, NULL); |
1988 | 2001 | ||
1989 | } | 2002 | } |
1990 | EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); | 2003 | EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); |
@@ -2008,7 +2021,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, | |||
2008 | return NULL; | 2021 | return NULL; |
2009 | } | 2022 | } |
2010 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, | 2023 | return v4l2_ctrl_new(hdl, ops, NULL, id, name, type, |
2011 | 0, max, 0, def, 0, | 2024 | 0, max, 0, def, NULL, 0, |
2012 | flags, NULL, qmenu_int, NULL); | 2025 | flags, NULL, qmenu_int, NULL); |
2013 | } | 2026 | } |
2014 | EXPORT_SYMBOL(v4l2_ctrl_new_int_menu); | 2027 | EXPORT_SYMBOL(v4l2_ctrl_new_int_menu); |
@@ -2354,7 +2367,9 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctr | |||
2354 | if (ctrl->is_ptr) | 2367 | if (ctrl->is_ptr) |
2355 | qc->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD; | 2368 | qc->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD; |
2356 | qc->elem_size = ctrl->elem_size; | 2369 | qc->elem_size = ctrl->elem_size; |
2357 | qc->elems = 1; | 2370 | qc->elems = ctrl->elems; |
2371 | qc->nr_of_dims = ctrl->nr_of_dims; | ||
2372 | memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); | ||
2358 | qc->minimum = ctrl->minimum; | 2373 | qc->minimum = ctrl->minimum; |
2359 | qc->maximum = ctrl->maximum; | 2374 | qc->maximum = ctrl->maximum; |
2360 | qc->default_value = ctrl->default_value; | 2375 | qc->default_value = ctrl->default_value; |
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index eb69c52e2f64..d30da09b7b69 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h | |||
@@ -129,7 +129,10 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); | |||
129 | * @maximum: The control's maximum value. | 129 | * @maximum: The control's maximum value. |
130 | * @default_value: The control's default value. | 130 | * @default_value: The control's default value. |
131 | * @step: The control's step value for non-menu controls. | 131 | * @step: The control's step value for non-menu controls. |
132 | * @elems: The number of elements in the N-dimensional array. | ||
132 | * @elem_size: The size in bytes of the control. | 133 | * @elem_size: The size in bytes of the control. |
134 | * @dims: The size of each dimension. | ||
135 | * @nr_of_dims:The number of dimensions in @dims. | ||
133 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it | 136 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it |
134 | * easy to skip menu items that are not valid. If bit X is set, | 137 | * easy to skip menu items that are not valid. If bit X is set, |
135 | * then menu item X is skipped. Of course, this only works for | 138 | * then menu item X is skipped. Of course, this only works for |
@@ -176,7 +179,10 @@ struct v4l2_ctrl { | |||
176 | const char *name; | 179 | const char *name; |
177 | enum v4l2_ctrl_type type; | 180 | enum v4l2_ctrl_type type; |
178 | s64 minimum, maximum, default_value; | 181 | s64 minimum, maximum, default_value; |
182 | u32 elems; | ||
179 | u32 elem_size; | 183 | u32 elem_size; |
184 | u32 dims[V4L2_CTRL_MAX_DIMS]; | ||
185 | u32 nr_of_dims; | ||
180 | union { | 186 | union { |
181 | u64 step; | 187 | u64 step; |
182 | u64 menu_skip_mask; | 188 | u64 menu_skip_mask; |
@@ -255,6 +261,7 @@ struct v4l2_ctrl_handler { | |||
255 | * @max: The control's maximum value. | 261 | * @max: The control's maximum value. |
256 | * @step: The control's step value for non-menu controls. | 262 | * @step: The control's step value for non-menu controls. |
257 | * @def: The control's default value. | 263 | * @def: The control's default value. |
264 | * @dims: The size of each dimension. | ||
258 | * @elem_size: The size in bytes of the control. | 265 | * @elem_size: The size in bytes of the control. |
259 | * @flags: The control's flags. | 266 | * @flags: The control's flags. |
260 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it | 267 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it |
@@ -280,6 +287,7 @@ struct v4l2_ctrl_config { | |||
280 | s64 max; | 287 | s64 max; |
281 | u64 step; | 288 | u64 step; |
282 | s64 def; | 289 | s64 def; |
290 | u32 dims[V4L2_CTRL_MAX_DIMS]; | ||
283 | u32 elem_size; | 291 | u32 elem_size; |
284 | u32 flags; | 292 | u32 flags; |
285 | u64 menu_skip_mask; | 293 | u64 menu_skip_mask; |