This set of patches is created by Sylwester Nawrocki, with small changes by me.

This set of patches extends the camera class with control
V4L2_CID_AUTO_FOCUS_AREA for determining the area of the frame that
camera uses for auto-focus.
The control takes care of three cases:
- V4L2_AUTO_FOCUS_AREA_ALL, normal auto-focus, 
        whole frame is used for auto-focus,
- V4L2_AUTO_FOCUS_AREA_RECTANGLE, user provides rectangle or spot
        as an area of interest,
- V4L2_AUTO_FOCUS_AREA_OBJECT_DETECTION, object/face detection engine
        of the camera should be used for auto-focus.

In case of the rectangle or the spot its coordinates shall be passed
to the driver using selection API (VIDIOC_SUBDEV_S_SELECTION) with
V4L2_SEL_TGT_AUTO_FOCUS as a target name. In case of spot width and
height of the rectangle shall be set to 0.

We (me and Sylwester) are not sure if this is the best solution.

I would like to propose another solution which seems to me more natural,
but probably it would require extending controls API.
The solution is neither formalized, neither implemented at the moment.

The solution takes an advantage of the fact VIDIOC_(G/S/TRY)_EXT_CTRLS
ioctls can be called with multiple controls per call.
There could be added four pseudo-controls, lets call them for short:
LEFT, TOP, WIDTH, HEIGHT.
Those controls could be passed together with V4L2_AUTO_FOCUS_AREA_RECTANGLE
control in one ioctl as a kind of control parameters.

For example setting auto-focus spot would require calling VIDIOC_S_EXT_CTRLS
with the following controls:
- V4L2_CID_AUTO_FOCUS_AREA = V4L2_AUTO_FOCUS_AREA_RECTANGLE
- LEFT = ...
- RIGHT = ...

Setting AF rectangle:
- V4L2_CID_AUTO_FOCUS_AREA = V4L2_AUTO_FOCUS_AREA_RECTANGLE
- LEFT = ...
- TOP = ...
- WIDTH = ...
- HEIGHT = ...

Setting  AF object detection:
- V4L2_CID_AUTO_FOCUS_AREA = V4L2_AUTO_FOCUS_AREA_OBJECT_DETECTION

I have presented all three cases to show the advantages of this solution:
- atomicity - control and its parameters are passed in one call,
- flexibility - we are not limited by a fixed number of parameters,
- no-redundancy(?) - we can pass only required parameters
        (no need to pass null width and height in case of spot selection),
- extensibility - it is possible to extend parameters in the future,
for example add parameters to V4L2_AUTO_FOCUS_AREA_OBJECT_DETECTION,
- backward compatibility, 
- re-usability - this schema could be used in other controls,
        pseudo-controls could be re-used in other controls as well.

I hope this e-mail will trigger some discussion about the proposed solution.

Regards
Andrzej Hajda

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to