diff options
Diffstat (limited to 'Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml')
-rw-r--r-- | Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml index 0a4b90fcf2da..4e16112df992 100644 --- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml @@ -106,7 +106,9 @@ value or if an error is returned.</para> &EINVAL;. When the value is out of bounds drivers can choose to take the closest valid value or return an &ERANGE;, whatever seems more appropriate. In the first case the new value is set in -&v4l2-ext-control;.</para> +&v4l2-ext-control;. If the new control value is inappropriate (e.g. the +given menu index is not supported by the menu control), then this will +also result in an &EINVAL; error.</para> <para>The driver will only set/get these controls if all control values are correct. This prevents the situation where only some of the @@ -199,13 +201,46 @@ also be zero.</entry> <row> <entry>__u32</entry> <entry><structfield>error_idx</structfield></entry> - <entry>Set by the driver in case of an error. If it is equal -to <structfield>count</structfield>, then no actual changes were made to -controls. In other words, the error was not associated with setting a particular -control. If it is another value, then only the controls up to <structfield>error_idx-1</structfield> -were modified and control <structfield>error_idx</structfield> is the one that -caused the error. The <structfield>error_idx</structfield> value is undefined -if the ioctl returned 0 (success).</entry> + <entry><para>Set by the driver in case of an error. If the error is +associated with a particular control, then <structfield>error_idx</structfield> +is set to the index of that control. If the error is not related to a specific +control, or the validation step failed (see below), then +<structfield>error_idx</structfield> is set to <structfield>count</structfield>. +The value is undefined if the ioctl returned 0 (success).</para> + +<para>Before controls are read from/written to hardware a validation step +takes place: this checks if all controls in the list are valid controls, +if no attempt is made to write to a read-only control or read from a write-only +control, and any other up-front checks that can be done without accessing the +hardware. The exact validations done during this step are driver dependent +since some checks might require hardware access for some devices, thus making +it impossible to do those checks up-front. However, drivers should make a +best-effort to do as many up-front checks as possible.</para> + +<para>This check is done to avoid leaving the hardware in an inconsistent state due +to easy-to-avoid problems. But it leads to another problem: the application needs to +know whether an error came from the validation step (meaning that the hardware +was not touched) or from an error during the actual reading from/writing to hardware.</para> + +<para>The, in hindsight quite poor, solution for that is to set <structfield>error_idx</structfield> +to <structfield>count</structfield> if the validation failed. This has the +unfortunate side-effect that it is not possible to see which control failed the +validation. If the validation was successful and the error happened while +accessing the hardware, then <structfield>error_idx</structfield> is less than +<structfield>count</structfield> and only the controls up to +<structfield>error_idx-1</structfield> were read or written correctly, and the +state of the remaining controls is undefined.</para> + +<para>Since <constant>VIDIOC_TRY_EXT_CTRLS</constant> does not access hardware +there is also no need to handle the validation step in this special way, +so <structfield>error_idx</structfield> will just be set to the control that +failed the validation step instead of to <structfield>count</structfield>. +This means that if <constant>VIDIOC_S_EXT_CTRLS</constant> fails with +<structfield>error_idx</structfield> set to <structfield>count</structfield>, +then you can call <constant>VIDIOC_TRY_EXT_CTRLS</constant> to try to discover +the actual control that failed the validation step. Unfortunately, there +is no <constant>TRY</constant> equivalent for <constant>VIDIOC_G_EXT_CTRLS</constant>. +</para></entry> </row> <row> <entry>__u32</entry> @@ -298,8 +333,10 @@ These controls are described in <xref <term><errorcode>EINVAL</errorcode></term> <listitem> <para>The &v4l2-ext-control; <structfield>id</structfield> -is invalid or the &v4l2-ext-controls; -<structfield>ctrl_class</structfield> is invalid. This error code is +is invalid, the &v4l2-ext-controls; +<structfield>ctrl_class</structfield> is invalid, or the &v4l2-ext-control; +<structfield>value</structfield> was inappropriate (e.g. the given menu +index is not supported by the driver). This error code is also returned by the <constant>VIDIOC_S_EXT_CTRLS</constant> and <constant>VIDIOC_TRY_EXT_CTRLS</constant> ioctls if two or more control values are in conflict.</para> |