diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2011-06-14 09:04:06 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:53:31 -0400 |
commit | eb5b16efb26ff5b2d0ba25a114394db69c433f86 (patch) | |
tree | df68e2737553e18218e94247fd6924eeaf09051f /include/media/v4l2-ctrls.h | |
parent | c12fcfd676e16a82e47ee44fe2d13dc21717063a (diff) |
[media] v4l2-ctrls: improve discovery of controls of the same cluster
The implementation of VIDIOC_G/S/TRY_EXT_CTRLS in the control framework has
to figure out which controls in the control list belong to the same cluster.
Since controls belonging to the same cluster need to be handled as a unit,
this is important information.
It did that by going over the controls in the list and for each control that
belonged to a multi-control cluster it would walk the remainder of the list
to try and find controls that belong to that same cluster.
This approach has two disadvantages:
1) it was a potentially quadratic algorithm (although highly unlikely that
it would ever be that bad in practice).
2) it took place with the control handler's lock held.
Since we want to make it possible in the future to change control values
from interrupt context, doing a lot of work while holding a lock is not a
good idea.
In the new code the algorithm is no longer quadratic but linear in the
number of controls in the list. Also, it now can be done beforehand.
Another change that was made was to so the try and set at the same time.
Before when S_TRY_EXT_CTRLS was called it would 'try' the controls first,
and then it would 'set' them. The idea was that any 'try' errors would
prevent the 'set' from happening, thus avoiding having partially set
control lists.
However, this caused more problems than it solved because between the 'try'
and the 'set' changes might have happened, so it had to try a second time,
and since actual controls with a try_ctrl op are very rare (and those that
we have just adjust values and do not return an error), I've decided to
drop that two-stage approach and just combine try and set.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media/v4l2-ctrls.h')
-rw-r--r-- | include/media/v4l2-ctrls.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 69662912e50c..fe55a4e0324f 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | /* forward references */ | 28 | /* forward references */ |
29 | struct v4l2_ctrl_handler; | 29 | struct v4l2_ctrl_handler; |
30 | struct v4l2_ctrl_helper; | ||
30 | struct v4l2_ctrl; | 31 | struct v4l2_ctrl; |
31 | struct video_device; | 32 | struct video_device; |
32 | struct v4l2_subdev; | 33 | struct v4l2_subdev; |
@@ -150,6 +151,7 @@ struct v4l2_ctrl { | |||
150 | * @node: List node for the sorted list. | 151 | * @node: List node for the sorted list. |
151 | * @next: Single-link list node for the hash. | 152 | * @next: Single-link list node for the hash. |
152 | * @ctrl: The actual control information. | 153 | * @ctrl: The actual control information. |
154 | * @helper: Pointer to helper struct. Used internally in prepare_ext_ctrls(). | ||
153 | * | 155 | * |
154 | * Each control handler has a list of these refs. The list_head is used to | 156 | * Each control handler has a list of these refs. The list_head is used to |
155 | * keep a sorted-by-control-ID list of all controls, while the next pointer | 157 | * keep a sorted-by-control-ID list of all controls, while the next pointer |
@@ -159,6 +161,7 @@ struct v4l2_ctrl_ref { | |||
159 | struct list_head node; | 161 | struct list_head node; |
160 | struct v4l2_ctrl_ref *next; | 162 | struct v4l2_ctrl_ref *next; |
161 | struct v4l2_ctrl *ctrl; | 163 | struct v4l2_ctrl *ctrl; |
164 | struct v4l2_ctrl_helper *helper; | ||
162 | }; | 165 | }; |
163 | 166 | ||
164 | /** struct v4l2_ctrl_handler - The control handler keeps track of all the | 167 | /** struct v4l2_ctrl_handler - The control handler keeps track of all the |