aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/video4linux/v4l2-controls.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/video4linux/v4l2-controls.txt')
-rw-r--r--Documentation/video4linux/v4l2-controls.txt63
1 files changed, 39 insertions, 24 deletions
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt
index 06cf3ac83631..0f84ce8c9a7b 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -77,9 +77,9 @@ Basic usage for V4L2 and sub-device drivers
77 77
78 Where foo->v4l2_dev is of type struct v4l2_device. 78 Where foo->v4l2_dev is of type struct v4l2_device.
79 79
80 Finally, remove all control functions from your v4l2_ioctl_ops: 80 Finally, remove all control functions from your v4l2_ioctl_ops (if any):
81 vidioc_queryctrl, vidioc_querymenu, vidioc_g_ctrl, vidioc_s_ctrl, 81 vidioc_queryctrl, vidioc_query_ext_ctrl, vidioc_querymenu, vidioc_g_ctrl,
82 vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls. 82 vidioc_s_ctrl, vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls.
83 Those are now no longer needed. 83 Those are now no longer needed.
84 84
851.3.2) For sub-device drivers do this: 851.3.2) For sub-device drivers do this:
@@ -258,8 +258,8 @@ The new control value has already been validated, so all you need to do is
258to actually update the hardware registers. 258to actually update the hardware registers.
259 259
260You're done! And this is sufficient for most of the drivers we have. No need 260You're done! And this is sufficient for most of the drivers we have. No need
261to do any validation of control values, or implement QUERYCTRL/QUERYMENU. And 261to do any validation of control values, or implement QUERYCTRL, QUERY_EXT_CTRL
262G/S_CTRL as well as G/TRY/S_EXT_CTRLS are automatically supported. 262and QUERYMENU. And G/S_CTRL as well as G/TRY/S_EXT_CTRLS are automatically supported.
263 263
264 264
265============================================================================== 265==============================================================================
@@ -288,30 +288,45 @@ of v4l2_device.
288Accessing Control Values 288Accessing Control Values
289======================== 289========================
290 290
291The v4l2_ctrl struct contains these two unions: 291The following union is used inside the control framework to access control
292values:
292 293
293 /* The current control value. */ 294union v4l2_ctrl_ptr {
294 union { 295 s32 *p_s32;
296 s64 *p_s64;
297 char *p_char;
298 void *p;
299};
300
301The v4l2_ctrl struct contains these fields that can be used to access both
302current and new values:
303
304 s32 val;
305 struct {
295 s32 val; 306 s32 val;
296 s64 val64;
297 char *string;
298 } cur; 307 } cur;
299 308
300 /* The new control value. */
301 union {
302 s32 val;
303 s64 val64;
304 char *string;
305 };
306 309
307Within the control ops you can freely use these. The val and val64 speak for 310 union v4l2_ctrl_ptr p_new;
308themselves. The string pointers point to character buffers of length 311 union v4l2_ctrl_ptr p_cur;
312
313If the control has a simple s32 type type, then:
314
315 &ctrl->val == ctrl->p_new.p_s32
316 &ctrl->cur.val == ctrl->p_cur.p_s32
317
318For all other types use ctrl->p_cur.p<something>. Basically the val
319and cur.val fields can be considered an alias since these are used so often.
320
321Within the control ops you can freely use these. The val and cur.val speak for
322themselves. The p_char pointers point to character buffers of length
309ctrl->maximum + 1, and are always 0-terminated. 323ctrl->maximum + 1, and are always 0-terminated.
310 324
311In most cases 'cur' contains the current cached control value. When you create 325Unless the control is marked volatile the p_cur field points to the the
312a new control this value is made identical to the default value. After calling 326current cached control value. When you create a new control this value is made
313v4l2_ctrl_handler_setup() this value is passed to the hardware. It is generally 327identical to the default value. After calling v4l2_ctrl_handler_setup() this
314a good idea to call this function. 328value is passed to the hardware. It is generally a good idea to call this
329function.
315 330
316Whenever a new value is set that new value is automatically cached. This means 331Whenever a new value is set that new value is automatically cached. This means
317that most drivers do not need to implement the g_volatile_ctrl() op. The 332that most drivers do not need to implement the g_volatile_ctrl() op. The
@@ -362,8 +377,8 @@ will result in a deadlock since these helpers lock the handler as well.
362You can also take the handler lock yourself: 377You can also take the handler lock yourself:
363 378
364 mutex_lock(&state->ctrl_handler.lock); 379 mutex_lock(&state->ctrl_handler.lock);
365 printk(KERN_INFO "String value is '%s'\n", ctrl1->cur.string); 380 pr_info("String value is '%s'\n", ctrl1->p_cur.p_char);
366 printk(KERN_INFO "Integer value is '%s'\n", ctrl2->cur.val); 381 pr_info("Integer value is '%s'\n", ctrl2->cur.val);
367 mutex_unlock(&state->ctrl_handler.lock); 382 mutex_unlock(&state->ctrl_handler.lock);
368 383
369 384