aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-04-27 02:22:17 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-17 10:56:47 -0400
commit0176077a813933a547b7a913377a87d615b7c108 (patch)
tree870aaec59c2a1f9328f582d5df1bce400a1f3b77 /include/media
parente6bee3685e732df82f48698254a36754cf15f0b0 (diff)
[media] v4l2-ctrls: create type_ops
Since compound controls can have non-standard types we need to be able to do type-specific checks etc. In order to make that easy type operations are added. There are four operations: - equal: check if two values are equal - init: initialize a value - log: log the value - validate: validate a new value The v4l2_ctrl struct adds p_new and p_cur unions at the end of the struct. This union provides a standard way of accessing control types through a pointer, which greatly simplifies internal control processing. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/v4l2-ctrls.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 9024daebdf3b..ddd9fdf1ac1a 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -36,6 +36,19 @@ struct v4l2_subscribed_event;
36struct v4l2_fh; 36struct v4l2_fh;
37struct poll_table_struct; 37struct poll_table_struct;
38 38
39/** union v4l2_ctrl_ptr - A pointer to a control value.
40 * @p_s32: Pointer to a 32-bit signed value.
41 * @p_s64: Pointer to a 64-bit signed value.
42 * @p_char: Pointer to a string.
43 * @p: Pointer to a compound value.
44 */
45union v4l2_ctrl_ptr {
46 s32 *p_s32;
47 s64 *p_s64;
48 char *p_char;
49 void *p;
50};
51
39/** struct v4l2_ctrl_ops - The control operations that the driver has to provide. 52/** struct v4l2_ctrl_ops - The control operations that the driver has to provide.
40 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant 53 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
41 * for volatile (and usually read-only) controls such as a control 54 * for volatile (and usually read-only) controls such as a control
@@ -54,6 +67,23 @@ struct v4l2_ctrl_ops {
54 int (*s_ctrl)(struct v4l2_ctrl *ctrl); 67 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
55}; 68};
56 69
70/** struct v4l2_ctrl_type_ops - The control type operations that the driver has to provide.
71 * @equal: return true if both values are equal.
72 * @init: initialize the value.
73 * @log: log the value.
74 * @validate: validate the value. Return 0 on success and a negative value otherwise.
75 */
76struct v4l2_ctrl_type_ops {
77 bool (*equal)(const struct v4l2_ctrl *ctrl,
78 union v4l2_ctrl_ptr ptr1,
79 union v4l2_ctrl_ptr ptr2);
80 void (*init)(const struct v4l2_ctrl *ctrl,
81 union v4l2_ctrl_ptr ptr);
82 void (*log)(const struct v4l2_ctrl *ctrl);
83 int (*validate)(const struct v4l2_ctrl *ctrl,
84 union v4l2_ctrl_ptr ptr);
85};
86
57typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); 87typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
58 88
59/** struct v4l2_ctrl - The control structure. 89/** struct v4l2_ctrl - The control structure.
@@ -89,6 +119,7 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
89 * value, then the whole cluster is in manual mode. Drivers should 119 * value, then the whole cluster is in manual mode. Drivers should
90 * never set this flag directly. 120 * never set this flag directly.
91 * @ops: The control ops. 121 * @ops: The control ops.
122 * @type_ops: The control type ops.
92 * @id: The control ID. 123 * @id: The control ID.
93 * @name: The control name. 124 * @name: The control name.
94 * @type: The control type. 125 * @type: The control type.
@@ -137,6 +168,7 @@ struct v4l2_ctrl {
137 unsigned int manual_mode_value:8; 168 unsigned int manual_mode_value:8;
138 169
139 const struct v4l2_ctrl_ops *ops; 170 const struct v4l2_ctrl_ops *ops;
171 const struct v4l2_ctrl_type_ops *type_ops;
140 u32 id; 172 u32 id;
141 const char *name; 173 const char *name;
142 enum v4l2_ctrl_type type; 174 enum v4l2_ctrl_type type;
@@ -164,6 +196,9 @@ struct v4l2_ctrl {
164 char *string; 196 char *string;
165 void *p; 197 void *p;
166 } cur; 198 } cur;
199
200 union v4l2_ctrl_ptr p_new;
201 union v4l2_ctrl_ptr p_cur;
167}; 202};
168 203
169/** struct v4l2_ctrl_ref - The control reference. 204/** struct v4l2_ctrl_ref - The control reference.
@@ -217,6 +252,7 @@ struct v4l2_ctrl_handler {
217 252
218/** struct v4l2_ctrl_config - Control configuration structure. 253/** struct v4l2_ctrl_config - Control configuration structure.
219 * @ops: The control ops. 254 * @ops: The control ops.
255 * @type_ops: The control type ops. Only needed for compound controls.
220 * @id: The control ID. 256 * @id: The control ID.
221 * @name: The control name. 257 * @name: The control name.
222 * @type: The control type. 258 * @type: The control type.
@@ -241,6 +277,7 @@ struct v4l2_ctrl_handler {
241 */ 277 */
242struct v4l2_ctrl_config { 278struct v4l2_ctrl_config {
243 const struct v4l2_ctrl_ops *ops; 279 const struct v4l2_ctrl_ops *ops;
280 const struct v4l2_ctrl_type_ops *type_ops;
244 u32 id; 281 u32 id;
245 const char *name; 282 const char *name;
246 enum v4l2_ctrl_type type; 283 enum v4l2_ctrl_type type;