Re: [PATCH/RFC][DRAFT] V4L: Add camera auto focus controls

2012-03-02 Thread Laurent Pinchart
Hi Sylwester,

On Friday 02 March 2012 00:26:27 Sylwester Nawrocki wrote:
 Hi Laurent,
 
 On 03/01/2012 11:30 PM, Laurent Pinchart wrote:
  One option would be to disable the focus area control when the focus
  distance is set to a value different than normal (or the other way
  around). Control change events could be used to report that to userspace.
  Would that work with your hardware ?
 
 What would work, would be disabling the focus distance control when the
 focus area is set to a value different than all.
 
 I have also been considering adding an extra menu entry for the focus
 distance control, indicating some neutral state, but disabling the other
 control sounds like a better idea. I couldn't find anything reasonable, as
 there was already the focus distance normal menu entry.
 
 Then, after the focus are is set to, for instance, spot, transition to
 the focus distance macro would be only possible through focus area all
 (where the focus distance is enabled again). I guess it's acceptable.
 
 It's only getting a bit harder for applications to present a single list
 of the focus modes to the user, since they would, for instance, grey out
 the entries corresponding to disabled control. It shouldn't be a big deal
 though.

It could indeed be a little bit confusing for users/applications, but having a 
separate private focus control wouldn't be much better :-) In both cases an 
application will need to know how to use the focus controls anyway.

-- 
Regards,

Laurent Pinchart

--
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


Re: [PATCH/RFC][DRAFT] V4L: Add camera auto focus controls

2012-03-01 Thread Laurent Pinchart
Hi Sylwester,

On Sunday 26 February 2012 17:57:55 Sylwester Nawrocki wrote:
 On 01/16/2012 10:33 PM, Sylwester Nawrocki wrote:
  diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
  index 012a296..0808b12 100644
  --- a/include/linux/videodev2.h
  +++ b/include/linux/videodev2.h
  @@ -1662,6 +1662,34 @@ enum  v4l2_exposure_auto_type {
  
#define V4L2_CID_IRIS_ABSOLUTE
  (V4L2_CID_CAMERA_CLASS_BASE+17)
#define V4L2_CID_IRIS_RELATIVE
  (V4L2_CID_CAMERA_CLASS_BASE+18)
  
  +#define V4L2_CID_AUTO_FOCUS_START  (V4L2_CID_CAMERA_CLASS_BASE+19)
  +#define V4L2_CID_AUTO_FOCUS_STOP   (V4L2_CID_CAMERA_CLASS_BASE+20)
  +#define V4L2_CID_AUTO_FOCUS_STATUS (V4L2_CID_CAMERA_CLASS_BASE+21)
  +enum v4l2_auto_focus_status {
  +   V4L2_AUTO_FOCUS_STATUS_IDLE = 0,
  +   V4L2_AUTO_FOCUS_STATUS_BUSY = 1,
  +   V4L2_AUTO_FOCUS_STATUS_SUCCESS  = 2,
  +   V4L2_AUTO_FOCUS_STATUS_FAIL = 3,
  +};
  +
  +#define V4L2_CID_AUTO_FOCUS_DISTANCE   
  (V4L2_CID_CAMERA_CLASS_BASE+22)
  +enum v4l2_auto_focus_distance {
  +   V4L2_AUTO_FOCUS_DISTANCE_NORMAL = 0,
  +   V4L2_AUTO_FOCUS_DISTANCE_MACRO  = 1,
  +   V4L2_AUTO_FOCUS_DISTANCE_INFINITY   = 2,
  +};
  +
  +#define V4L2_CID_AUTO_FOCUS_SELECTION  
(V4L2_CID_CAMERA_CLASS_BASE+23)
  +enum v4l2_auto_focus_selection {
  +   V4L2_AUTO_FOCUS_SELECTION_NORMAL= 0,
  +   V4L2_AUTO_FOCUS_SELECTION_SPOT  = 1,
  +   V4L2_AUTO_FOCUS_SELECTION_RECTANGLE = 2,
  +};
 
 I'd like to ask your advice, I've found those two above controls
 rather painful in use. After changing V4L2_CID_AUTO_FOCUS_SELECTION to
 
 #define V4L2_CID_AUTO_FOCUS_AREA  (V4L2_CID_CAMERA_CLASS_BASE+23)
 enum v4l2_auto_focus_selection {
   V4L2_AUTO_FOCUS_SELECTION_ALL   = 0,
   V4L2_AUTO_FOCUS_SELECTION_SPOT  = 1,
   V4L2_AUTO_FOCUS_SELECTION_RECTANGLE = 2,
 };
 
 I tried use them with the M-5MOLS sensor driver where there is only
 one register for setting following automatic focus modes:
 
 NORMAL AUTO (single-shot),
 MACRO,
 INFINITY,
 SPOT,
 FACE_DETECTION
 
 The issue is that when V4L2_CID_AUTO_FOCUS_AREA is set to for example
 V4L2_AUTO_FOCUS_SELECTION_SPOT, none of the menu entries of
 V4L2_CID_AUTO_FOCUS_DISTANCE is valid.
 
 So it would really be better to use single control for automatic focus
 mode. A private control could handle that. But there will be more than
 one sensor driver needing such a control, so I thought about an
 additional header, e.g. samsung_camera.h in include/linux/ that would
 define reguired control IDs and menus in the camera class private id
 range.
 
 What do you think about it ?

One option would be to disable the focus area control when the focus distance 
is set to a value different than normal (or the other way around). Control 
change events could be used to report that to userspace. Would that work with 
your hardware ?

-- 
Regards,

Laurent Pinchart

--
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


Re: [PATCH/RFC][DRAFT] V4L: Add camera auto focus controls

2012-03-01 Thread Sylwester Nawrocki
Hi Laurent,

On 03/01/2012 11:30 PM, Laurent Pinchart wrote:
 One option would be to disable the focus area control when the focus distance
 is set to a value different than normal (or the other way around). Control
 change events could be used to report that to userspace. Would that work with
 your hardware ?

What would work, would be disabling the focus distance control when the focus 
area is set to a value different than all.

I have also been considering adding an extra menu entry for the focus distance 
control, indicating some neutral state, but disabling the other control
sounds like a better idea. I couldn't find anything reasonable, as there was 
already the focus distance normal menu entry.

Then, after the focus are is set to, for instance, spot, transition to 
the focus distance macro would be only possible through focus area all
(where the focus distance is enabled again). I guess it's acceptable.

It's only getting a bit harder for applications to present a single list 
of the focus modes to the user, since they would, for instance, grey out 
the entries corresponding to disabled control. It shouldn't be a big deal 
though.


--
Regards,
Sylwester
--
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


Re: [PATCH/RFC][DRAFT] V4L: Add camera auto focus controls

2012-02-26 Thread Sylwester Nawrocki
Hi,

On 01/16/2012 10:33 PM, Sylwester Nawrocki wrote:
 diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
 index 012a296..0808b12 100644
 --- a/include/linux/videodev2.h
 +++ b/include/linux/videodev2.h
 @@ -1662,6 +1662,34 @@ enum  v4l2_exposure_auto_type {
   #define V4L2_CID_IRIS_ABSOLUTE  
 (V4L2_CID_CAMERA_CLASS_BASE+17)
   #define V4L2_CID_IRIS_RELATIVE  
 (V4L2_CID_CAMERA_CLASS_BASE+18)

 +#define V4L2_CID_AUTO_FOCUS_START(V4L2_CID_CAMERA_CLASS_BASE+19)
 +#define V4L2_CID_AUTO_FOCUS_STOP (V4L2_CID_CAMERA_CLASS_BASE+20)
 +#define V4L2_CID_AUTO_FOCUS_STATUS   (V4L2_CID_CAMERA_CLASS_BASE+21)
 +enum v4l2_auto_focus_status {
 + V4L2_AUTO_FOCUS_STATUS_IDLE = 0,
 + V4L2_AUTO_FOCUS_STATUS_BUSY = 1,
 + V4L2_AUTO_FOCUS_STATUS_SUCCESS  = 2,
 + V4L2_AUTO_FOCUS_STATUS_FAIL = 3,
 +};
 +
 +#define V4L2_CID_AUTO_FOCUS_DISTANCE (V4L2_CID_CAMERA_CLASS_BASE+22)
 +enum v4l2_auto_focus_distance {
 + V4L2_AUTO_FOCUS_DISTANCE_NORMAL = 0,
 + V4L2_AUTO_FOCUS_DISTANCE_MACRO  = 1,
 + V4L2_AUTO_FOCUS_DISTANCE_INFINITY   = 2,
 +};
 +
 +#define V4L2_CID_AUTO_FOCUS_SELECTION
 (V4L2_CID_CAMERA_CLASS_BASE+23)
 +enum v4l2_auto_focus_selection {
 + V4L2_AUTO_FOCUS_SELECTION_NORMAL= 0,
 + V4L2_AUTO_FOCUS_SELECTION_SPOT  = 1,
 + V4L2_AUTO_FOCUS_SELECTION_RECTANGLE = 2,
 +};

I'd like to ask your advice, I've found those two above controls 
rather painful in use. After changing V4L2_CID_AUTO_FOCUS_SELECTION to

#define V4L2_CID_AUTO_FOCUS_AREA(V4L2_CID_CAMERA_CLASS_BASE+23)
enum v4l2_auto_focus_selection {
V4L2_AUTO_FOCUS_SELECTION_ALL   = 0,
V4L2_AUTO_FOCUS_SELECTION_SPOT  = 1,
V4L2_AUTO_FOCUS_SELECTION_RECTANGLE = 2,
};

I tried use them with the M-5MOLS sensor driver where there is only 
one register for setting following automatic focus modes:

NORMAL AUTO (single-shot),
MACRO,
INFINITY,
SPOT,
FACE_DETECTION

The issue is that when V4L2_CID_AUTO_FOCUS_AREA is set to for example
V4L2_AUTO_FOCUS_SELECTION_SPOT, none of the menu entries of
V4L2_CID_AUTO_FOCUS_DISTANCE is valid.

So it would really be better to use single control for automatic focus
mode. A private control could handle that. But there will be more than
one sensor driver needing such a control, so I thought about an
additional header, e.g. samsung_camera.h in include/linux/ that would 
define reguired control IDs and menus in the camera class private id 
range.

What do you think about it ?


 +#define V4L2_CID_AUTO_FOCUS_X_POSITION   
 (V4L2_CID_CAMERA_CLASS_BASE+24)
 +#define V4L2_CID_AUTO_FOCUS_Y_POSITION   
 (V4L2_CID_CAMERA_CLASS_BASE+25)
...

--

Regards,
Sylwester
--
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


Re: [PATCH/RFC][DRAFT] V4L: Add camera auto focus controls

2012-02-26 Thread Sylwester Nawrocki
On 02/26/2012 05:57 PM, Sylwester Nawrocki wrote:
 rather painful in use. After changing V4L2_CID_AUTO_FOCUS_SELECTION to
 
 #define V4L2_CID_AUTO_FOCUS_AREA  (V4L2_CID_CAMERA_CLASS_BASE+23)

Oops, of course each occurence of SELECTION below should be replaced with
AREA. Sorry for the confusion.

 enum v4l2_auto_focus_selection {
   V4L2_AUTO_FOCUS_SELECTION_ALL   = 0,
   V4L2_AUTO_FOCUS_SELECTION_SPOT  = 1,
   V4L2_AUTO_FOCUS_SELECTION_RECTANGLE = 2,
 };
 
 I tried use them with the M-5MOLS sensor driver where there is only
 one register for setting following automatic focus modes:
 
 NORMAL AUTO (single-shot),
 MACRO,
 INFINITY,
 SPOT,
 FACE_DETECTION
 
 The issue is that when V4L2_CID_AUTO_FOCUS_AREA is set to for example
 V4L2_AUTO_FOCUS_SELECTION_SPOT, none of the menu entries of
 V4L2_CID_AUTO_FOCUS_DISTANCE is valid.
 
 So it would really be better to use single control for automatic focus
 mode. A private control could handle that. But there will be more than
 one sensor driver needing such a control, so I thought about an
 additional header, e.g. samsung_camera.h in include/linux/ that would
 define reguired control IDs and menus in the camera class private id
 range.
 
 What do you think about it ?
 
 
 +#define V4L2_CID_AUTO_FOCUS_X_POSITION  
 (V4L2_CID_CAMERA_CLASS_BASE+24)
 +#define V4L2_CID_AUTO_FOCUS_Y_POSITION  
 (V4L2_CID_CAMERA_CLASS_BASE+25)
 ...
 
 --
 
 Regards,
 Sylwester

--
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


[PATCH/RFC][DRAFT] V4L: Add camera auto focus controls

2012-01-16 Thread Sylwester Nawrocki
The following auto focus controls are added:

 - V4L2_CID_AUTO_FOCUS_START - one-shot auto focus start
 - V4L2_CID_AUTO_FOCUS_STOP -  one-shot auto focus start
 - V4L2_CID_AUTO_FOCUS_STATUS - auto focus status
 - V4L2_CID_AUTO_FOCUS_DISTANCE - auto focus scan reange selection
 - V4L2_CID_AUTO_FOCUS_SELECTION - auto focus area selection
 - V4L2_CID_AUTO_FOCUS_X_POSITION - horizontal AF spot position
 - V4L2_CID_AUTO_FOCUS_Y_POSITION - vertical AF spot position
 - V4L2_CID_AUTO_FOCUS_RECTANGLE_COUNT - number of AF statistics
 rectangles
 - V4L2_CID_AUTO_FOCUS_FACE_PRIORITY - enable/disable face priority
   auto focus

Signed-off-by: Sylwester Nawrocki sylvester.nawro...@gmail.com
---
Hello,

This is a draft of new Auto Focus controls, it incorporates comments
from the previous discussions.

I decided to drop the idea of of new pixel point control type for AF spot
configuration, as the benefits from having it are minor comparing to the
implementation efforts.

Thanks,
Sylwester
---
 Documentation/DocBook/media/v4l/controls.xml |  172 +-
 drivers/media/video/v4l2-ctrls.c |   44 +++-
 include/linux/videodev2.h|   28 
 3 files changed, 241 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index a1be378..1a5e90f 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -2798,13 +2798,181 @@ negative values towards infinity. This is a write-only 
control./entry
  row
entry 
spanname=idconstantV4L2_CID_FOCUS_AUTO/constantnbsp;/entry
entryboolean/entry
- /rowrowentry spanname=descrEnables automatic focus
-adjustments. The effect of manual focus adjustments while this feature
+ /rowrowentry spanname=descrEnables continuous automatic
+focus adjustments. The effect of manual focus adjustments while this feature
 is enabled is undefined, drivers should ignore such requests./entry
  /row
  rowentry/entry/row

  row
+   entry 
spanname=idconstantV4L2_CID_AUTO_FOCUS_START/constantnbsp;/entry
+   entrybutton/entry
+ /rowrowentry spanname=descrStart single auto focus action.
+The effect of setting this control when 
constantV4L2_CID_FOCUS_AUTO/constant
+is set to constantTRUE/constant (1) is undefined, drivers should ignore
+such requests./entry
+ /row
+ rowentry/entry/row
+
+ row
+   entry 
spanname=idconstantV4L2_CID_AUTO_FOCUS_STOP/constantnbsp;/entry
+   entrybutton/entry
+ /rowrowentry spanname=descrAbort automatic focus started with
+constantV4L2_CID_AUTO_FOCUS_START/constant. This control is effective only
+when the continuous automatic focus is disabled, i.e. constant
+V4L2_CID_FOCUS_AUTO/constant control is set to constantFALSE/constant
+(0)./entry
+ /row
+ rowentry/entry/row
+
+ row id=v4l2-auto-focus-status
+   entry spanname=id
+ constantV4L2_CID_AUTO_FOCUS_STATUS/constantnbsp;/entry
+   entryenumnbsp;v4l2_auto_focus_status/entry
+ /row
+ rowentry spanname=descrThe automatic focus status. This is a 
read-only
+ control./entry
+ /row
+ row
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 
entryconstantV4L2_AUTO_FOCUS_STATUS_IDLE/constantnbsp;/entry
+ entryAutomatic focus is inactive./entry
+   /row
+   row
+ 
entryconstantV4L2_AUTO_FOCUS_STATUS_BUSY/constantnbsp;/entry
+ entryAutomatic focusing is in progress and the focus is 
changing./entry
+   /row
+   row
+ 
entryconstantV4L2_AUTO_FOCUS_STATUS_SUCCESS/constantnbsp;/entry
+ entryAutomatic focus has completed or is continued 
successfully./entry
+   /row
+   row
+ 
entryconstantV4L2_AUTO_FOCUS_STATUS_FAIL/constantnbsp;/entry
+ entryAutomatic focus has failed./entry
+   /row
+ /tbody
+   /entrytbl
+ /row
+ rowentry/entry/row
+
+ row id=v4l2-auto-focus-distance
+   entry spanname=id
+ constantV4L2_CID_AUTO_FOCUS_DISTANCE/constantnbsp;/entry
+   entryenumnbsp;v4l2_auto_focus_distance/entry
+ /row
+ rowentry spanname=descrThe automatic focus distance range
+for which lens may be adjusted. /entry
+ /row
+ row
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 
entryconstantV4L2_AUTO_FOCUS_DISTANCE_NORMAL/constantnbsp;/entry
+ entryThe normal distance range of the camera. It is limited
+in order to achieve best auto focus