Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l2-controls.txt: update to the new way of accessing controls

The way current and new values are accessed has changed. Update the
document to bring it up to date with the code.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
04d8b04e 680a5139

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