linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: add parameters to V4L controls
@ 2013-01-07 10:46 Andrzej Hajda
  2013-01-07 12:10 ` Hans Verkuil
  2013-01-12 22:05 ` Sakari Ailus
  0 siblings, 2 replies; 13+ messages in thread
From: Andrzej Hajda @ 2013-01-07 10:46 UTC (permalink / raw)
  To: linux-media; +Cc: Sylwester Nawrocki

Hi,

I have included this proposition already in the post "[PATCH RFC 0/2] 
V4L: Add auto focus area control and selection" but it left unanswered.
I repost it again in a separate e-mail, I hope this way it will be 
easier to attract attention.

Problem description

Currently V4L2 controls can have only single value (of type int, int64, 
string). Some hardware controls require more than single int parameter, 
for example to set auto-focus (AF) rectangle four coordinates should be 
passed, to set auto-focus spot two coordinates should be passed.

Current solution

In case of AF rectangle we can reuse selection API as in "[PATCH RFC 
0/2] V4L: Add auto focus area control and selection" post.
Pros:
- reuse existing API,
Cons:
- two IOCTL's to perform one action,
- non-atomic operation,
- fits well only for rectangles and spots (but with unused fields width, 
height), in case of other parameters we should find a different way.

Proposed solution

The solution takes an advantage of the fact VIDIOC_(G/S/TRY)_EXT_CTRLS
ioctls can be called with multiple controls per call.

I will present it using AF area control example.

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 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 (no parameters required):
- 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,
without breaking API,
- backward compatibility,
- re-usability - this schema could be used in other controls,
	pseudo-controls could be re-used in other controls as well.
- API backward compatibility.


Regards
Andrzej Hajda

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-02-12  8:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 10:46 RFC: add parameters to V4L controls Andrzej Hajda
2013-01-07 12:10 ` Hans Verkuil
2013-01-07 20:02   ` Laurent Pinchart
2013-01-08 12:26     ` Andrzej Hajda
2013-01-31 17:17   ` Sylwester Nawrocki
2013-02-01 22:17     ` Laurent Pinchart
2013-02-03 18:53       ` Sylwester Nawrocki
2013-02-06 20:26         ` Sakari Ailus
2013-02-10 19:44           ` Sylwester Nawrocki
2013-02-12  8:14           ` Hans Verkuil
2013-01-12 22:05 ` Sakari Ailus
2013-01-15 14:34   ` Andrzej Hajda
2013-01-21 11:17     ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).