All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 00/23] V4L: camera control enhancements
@ 2012-05-10 10:30 Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 01/23] V4L: Add helper function for standard integer menu controls Sylwester Nawrocki
                   ` (22 more replies)
  0 siblings, 23 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media; +Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki

Hi everyone,

It's probably the last update of this patch series, it contains a few
minor changes to the V4L2 API patches and updated patches for m5mols
sensor driver that were previously posted to LMML.

Changes since v4:
  - removed V4L2_AUTO_FOCUS_STATUS_LOST AF status bit definition;
  - added m5mols patches instead of s5c73m3 driver;
  - minor changes in V4L2_CID_AUTO_FOCUS_AREA control description;

Changes since v3:
 - V4L2_CID_IMAGE_STABILIZATION and V4L2_CID_WIDE_DYNAMIC_RANGE controls
   type reverted back to boolean, added a note in the documentation that
   these controls may be converted to menu controls in future;
 - Added description for new integer menu control helpers to
   Documentation/video4linux/v4l2-controls.txt
 - edited V4L2_CID_3A_LOCK control's description;
 - removed the vivi patch from the series;

Changes since v2:
 - V4L2_CID_WHITE_BALANCE_PRESET replaced with V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE
   according to suggestions from Hans de Goede;
 - added Flurescent H white balance preset;
 - V4L2_CID_IMAGE_STABILIZATION and V4L2_CID_WIDE_DYNAMIC_RANGE controls type
   changed from boolean to menu, to make any further extensions of these
   controls easier;
   I'm just not 100% sure if V4L2_WIDE_DYNAMIC_RANGE_ENABLED and
   V4L2_IMAGE_STABILIZATION_ENABLED are good names for cases where the camera
   doesn't support wide dynamic range or image stabilization technique
   selection and only allows to enable or disable those algorithms;
 - V4L2_CID_ISO_SENSITIVITY_AUTO control type changed from boolean to menu in
   order to support ISO presets; currently enum v4l2_iso_sensitivity_auto_type
   does not contain any presets though;
 - V4L2_CID_COLORFX patch removed from this series;
 - updated vivi and s5c73m3 driver patches.

Changes since v1:
 - the V4L2_CID_AUTO_FOCUS_FACE_PRIORITY control merged with
   V4L2_CID_AUTO_FOCUS_FACE_AREA,
 - many minor documentation corrections,
 - removed "08/23 V4L: camera control class..." patch, which got
   accidentally added at v1,
 - added V4L2_CID_SCENE_MODE and V4L2_CID_3A_LOCK controls,
 - added vivi patch for testing.

The patches will be also available in few hours in git repository at:
http://git.infradead.org/users/kmpark/linux-samsung/shortlog/refs/heads/v4l-camera-controls

Regards,
Sylwester


Sylwester Nawrocki (23):
  V4L: Add helper function for standard integer menu controls
  V4L: Add camera exposure bias control
  V4L: Add an extended camera white balance control
  V4L: Add camera wide dynamic range control
  V4L: Add camera image stabilization control
  V4L: Add camera ISO sensitivity controls
  V4L: Add camera exposure metering control
  V4L: Add camera scene mode control
  V4L: Add camera 3A lock control
  V4L: Add auto focus targets to the selections API
  V4L: Add auto focus targets to the subdev selections API
  V4L: Add camera auto focus controls
  m5mols: Convert macros to inline functions
  m5mols: Refactored controls handling
  m5mols: Use proper sensor mode for the controls
  m5mols: Add ISO sensitivity controls
  m5mols: Add auto and preset white balance control
  m5mols: Add exposure bias control
  m5mols: Add wide dynamic range control
  m5mols: Add image stabilization control
  m5mols: Add exposure metering control
  m5mols: Add JPEG compression quality control
  m5mols: Add 3A lock control

 Documentation/DocBook/media/v4l/biblio.xml         |   11 +
 Documentation/DocBook/media/v4l/compat.xml         |   20 +
 Documentation/DocBook/media/v4l/controls.xml       |  486 +++++++++++++++++++-
 Documentation/DocBook/media/v4l/dev-subdev.xml     |   27 +-
 Documentation/DocBook/media/v4l/selection-api.xml  |   33 +-
 Documentation/DocBook/media/v4l/v4l2.xml           |    9 +-
 .../DocBook/media/v4l/vidioc-g-selection.xml       |   11 +
 .../media/v4l/vidioc-subdev-g-selection.xml        |   14 +-
 Documentation/video4linux/v4l2-controls.txt        |   21 +
 drivers/media/video/m5mols/m5mols.h                |   81 +++-
 drivers/media/video/m5mols/m5mols_capture.c        |   11 +-
 drivers/media/video/m5mols/m5mols_controls.c       |  479 ++++++++++++++++---
 drivers/media/video/m5mols/m5mols_core.c           |   93 +---
 drivers/media/video/m5mols/m5mols_reg.h            |    1 +
 drivers/media/video/v4l2-ctrls.c                   |  121 ++++-
 include/linux/v4l2-subdev.h                        |    4 +
 include/linux/videodev2.h                          |   85 ++++
 include/media/v4l2-ctrls.h                         |   17 +
 18 files changed, 1326 insertions(+), 198 deletions(-)

-- 
1.7.10


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

* [PATCH 01/23] V4L: Add helper function for standard integer menu controls
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 02/23] V4L: Add camera exposure bias control Sylwester Nawrocki
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

This patch adds v4l2_ctrl_new_int_menu() helper function which can be used
in drivers for creating standard integer menu control with driver-specific
menu item list. It is similar to v4l2_ctrl_new_std_menu(), except it doesn't
have a mask parameter and an additional qmenu parameter allows passing
an array of signed 64-bit integers as the menu item list.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Tested-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 Documentation/video4linux/v4l2-controls.txt |   21 +++++++++++++++++++++
 drivers/media/video/v4l2-ctrls.c            |   21 +++++++++++++++++++++
 include/media/v4l2-ctrls.h                  |   17 +++++++++++++++++
 3 files changed, 59 insertions(+)

diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt
index e2492a9..43da22b 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -130,8 +130,18 @@ Menu controls are added by calling v4l2_ctrl_new_std_menu:
 			const struct v4l2_ctrl_ops *ops,
 			u32 id, s32 max, s32 skip_mask, s32 def);
 
+Or alternatively for integer menu controls, by calling v4l2_ctrl_new_int_menu:
+
+	struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
+			const struct v4l2_ctrl_ops *ops,
+			u32 id, s32 max, s32 def, const s64 *qmenu_int);
+
 These functions are typically called right after the v4l2_ctrl_handler_init:
 
+	static const s64 exp_bias_qmenu[] = {
+	       -2, -1, 0, 1, 2
+	};
+
 	v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
 	v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
 			V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
@@ -141,6 +151,11 @@ These functions are typically called right after the v4l2_ctrl_handler_init:
 			V4L2_CID_POWER_LINE_FREQUENCY,
 			V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0,
 			V4L2_CID_POWER_LINE_FREQUENCY_DISABLED);
+	v4l2_ctrl_new_int_menu(&foo->ctrl_handler, &foo_ctrl_ops,
+			V4L2_CID_EXPOSURE_BIAS,
+			ARRAY_SIZE(exp_bias_qmenu) - 1,
+			ARRAY_SIZE(exp_bias_qmenu) / 2 - 1,
+			exp_bias_qmenu);
 	...
 	if (foo->ctrl_handler.error) {
 		int err = foo->ctrl_handler.error;
@@ -164,6 +179,12 @@ controls. There is no min argument since that is always 0 for menu controls,
 and instead of a step there is a skip_mask argument: if bit X is 1, then menu
 item X is skipped.
 
+The v4l2_ctrl_new_int_menu function creates a new standard integer menu
+control with driver-specific items in the menu. It differs from
+v4l2_ctrl_new_std_menu in that it doesn't have the mask argument and takes
+as the last argument an array of signed 64-bit integers that form an exact
+menu item list.
+
 Note that if something fails, the function will return NULL or an error and
 set ctrl_handler->error to the error code. If ctrl_handler->error was already
 set, then it will just return and do nothing. This is also true for
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index bc97bcf..1bc8791 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -1524,6 +1524,27 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
 
+/* Helper function for standard integer menu controls */
+struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
+			const struct v4l2_ctrl_ops *ops,
+			u32 id, s32 max, s32 def, const s64 *qmenu_int)
+{
+	const char *name;
+	enum v4l2_ctrl_type type;
+	s32 min;
+	s32 step;
+	u32 flags;
+
+	v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags);
+	if (type != V4L2_CTRL_TYPE_INTEGER_MENU) {
+		handler_set_err(hdl, -EINVAL);
+		return NULL;
+	}
+	return v4l2_ctrl_new(hdl, ops, id, name, type,
+			     0, max, 0, def, flags, NULL, qmenu_int, NULL);
+}
+EXPORT_SYMBOL(v4l2_ctrl_new_int_menu);
+
 /* Add a control from another handler to this handler */
 struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
 					  struct v4l2_ctrl *ctrl)
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index c6f6b4c..4fd3cc9 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -347,6 +347,23 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
 			const struct v4l2_ctrl_ops *ops,
 			u32 id, s32 max, s32 mask, s32 def);
 
+/** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
+  * @hdl:	The control handler.
+  * @ops:	The control ops.
+  * @id:	The control ID.
+  * @max:	The control's maximum value.
+  * @def:	The control's default value.
+  * @qmenu_int:	The control's menu entries.
+  *
+  * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly
+  * takes as an argument an array of integers determining the menu items.
+  *
+  * If @id refers to a non-integer-menu control, then this function will return NULL.
+  */
+struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
+			const struct v4l2_ctrl_ops *ops,
+			u32 id, s32 max, s32 def, const s64 *qmenu_int);
+
 /** v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler.
   * @hdl:	The control handler.
   * @ctrl:	The control to add.
-- 
1.7.10


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

* [PATCH 02/23] V4L: Add camera exposure bias control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 01/23] V4L: Add helper function for standard integer menu controls Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 03/23] V4L: Add an extended camera white balance control Sylwester Nawrocki
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

The camera may in some conditions incorrectly determine the exposure,
and a manual automatic exposure correction may be needed. This patch
adds V4L2_CID_AUTO_EXPOSURE_BIAS control which allows to add some
offset in the automatic exposure control loop, to compensate for
frame under- or over-exposure.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   16 ++++++++++++++++
 drivers/media/video/v4l2-ctrls.c             |    4 ++++
 include/linux/videodev2.h                    |    2 ++
 3 files changed, 22 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index fadc0a6..40e6485 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -2849,6 +2849,22 @@ remain constant.</entry>
 	  <row><entry></entry></row>
 
 	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_EXPOSURE_BIAS</constant>&nbsp;</entry>
+	    <entry>integer menu</entry>
+	  </row><row><entry spanname="descr"> Determines the automatic
+exposure compensation, it is effective only when <constant>V4L2_CID_EXPOSURE_AUTO</constant>
+control is set to <constant>AUTO</constant>, <constant>SHUTTER_PRIORITY </constant>
+or <constant>APERTURE_PRIORITY</constant>.
+It is expressed in terms of EV, drivers should interpret the values as 0.001 EV
+units, where the value 1000 stands for +1 EV.
+<para>Increasing the exposure compensation value is equivalent to decreasing
+the exposure value (EV) and will increase the amount of light at the image
+sensor. The camera performs the exposure compensation by adjusting absolute
+exposure time and/or aperture.</para></entry>
+	  </row>
+	  <row><entry></entry></row>
+
+	  <row>
 	    <entry spanname="id"><constant>V4L2_CID_PAN_RELATIVE</constant>&nbsp;</entry>
 	    <entry>integer</entry>
 	  </row><row><entry spanname="descr">This control turns the
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 1bc8791..4157d4c 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -604,6 +604,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_PRIVACY:			return "Privacy";
 	case V4L2_CID_IRIS_ABSOLUTE:		return "Iris, Absolute";
 	case V4L2_CID_IRIS_RELATIVE:		return "Iris, Relative";
+	case V4L2_CID_AUTO_EXPOSURE_BIAS:	return "Auto Exposure, Bias";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -746,6 +747,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_RDS_TX_RADIO_TEXT:
 		*type = V4L2_CTRL_TYPE_STRING;
 		break;
+	case V4L2_CID_AUTO_EXPOSURE_BIAS:
+		*type = V4L2_CTRL_TYPE_INTEGER_MENU;
+		break;
 	case V4L2_CID_USER_CLASS:
 	case V4L2_CID_CAMERA_CLASS:
 	case V4L2_CID_MPEG_CLASS:
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index becb2ed..8b174dc 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1700,6 +1700,8 @@ 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_EXPOSURE_BIAS		(V4L2_CID_CAMERA_CLASS_BASE+19)
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 03/23] V4L: Add an extended camera white balance control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 01/23] V4L: Add helper function for standard integer menu controls Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 02/23] V4L: Add camera exposure bias control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-14  0:02   ` Sakari Ailus
  2012-05-10 10:30 ` [PATCH 04/23] V4L: Add camera wide dynamic range control Sylwester Nawrocki
                   ` (19 subsequent siblings)
  22 siblings, 1 reply; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

This patch adds V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE control which is
an extended version of the V4L2_CID_AUTO_WHITE_BALANCE control,
including white balance presets. The following presets are defined:

 - V4L2_WHITE_BALANCE_INCANDESCENT,
 - V4L2_WHITE_BALANCE_FLUORESCENT,
 - V4L2_WHITE_BALANCE_FLUORESCENT_H,
 - V4L2_WHITE_BALANCE_HORIZON,
 - V4L2_WHITE_BALANCE_DAYLIGHT,
 - V4L2_WHITE_BALANCE_FLASH,
 - V4L2_WHITE_BALANCE_CLOUDY,
 - V4L2_WHITE_BALANCE_SHADE.

Signed-off-by: HeungJun Kim <riverful.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   70 ++++++++++++++++++++++++++
 drivers/media/video/v4l2-ctrls.c             |   17 +++++++
 include/linux/videodev2.h                    |   14 ++++++
 3 files changed, 101 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 40e6485..85d1ca0 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3022,6 +3022,76 @@ camera sensor on or off, or specify its strength. Such band-stop filters can
 be used, for example, to filter out the fluorescent light component.</entry>
 	  </row>
 	  <row><entry></entry></row>
+
+	  <row id="v4l2-auto-n-preset-white-balance">
+	    <entry spanname="id"><constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>&nbsp;</entry>
+	    <entry>enum&nbsp;v4l2_auto_n_preset_white_balance</entry>
+	  </row><row><entry spanname="descr">Sets white balance to automatic,
+manual or a preset. The presets determine color temperature of the light as
+a hint to the camera for white balance adjustments resulting in most accurate
+color representation. The following white balance presets are listed in order
+of increasing color temperature.</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_MANUAL</constant>&nbsp;</entry>
+		  <entry>Manual white balance.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_AUTO</constant>&nbsp;</entry>
+		  <entry>Automatic white balance adjustments.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_INCANDESCENT</constant>&nbsp;</entry>
+		  <entry>White balance setting for incandescent (tungsten) lighting.
+It generally cools down the colors and corresponds approximately to 2500...3500 K
+color temperature range.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
+		  <entry>White balance preset for fluorescent lighting.
+It corresponds approximately to 4000...5000 K color temperature.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
+		  <entry>With this setting the camera will compensate for
+fluorescent H lighting.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_HORIZON</constant>&nbsp;</entry>
+		  <entry>White balance setting for horizon daylight.
+It corresponds approximately to 5000 K color temperature.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_DAYLIGHT</constant>&nbsp;</entry>
+		  <entry>White balance preset for daylight (with clear sky).
+It corresponds approximately to 5000...6500 K color temperature.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_FLASH</constant>&nbsp;</entry>
+		  <entry>With this setting the camera will compensate for the flash
+light. It slightly warms up the colors and corresponds roughly to 5000...5500 K
+color temperature.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_CLOUDY</constant>&nbsp;</entry>
+		  <entry>White balance preset for moderately overcast sky.
+This option corresponds approximately to 6500...8000 K color temperature
+range.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_WHITE_BALANCE_SHADE</constant>&nbsp;</entry>
+		  <entry>White balance preset for shade or heavily overcast
+sky. It corresponds approximately to 9000...10000 K color temperature.
+</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry></entry></row>
+
 	</tbody>
       </tgroup>
     </table>
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 4157d4c..abcbada 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -249,6 +249,19 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"Set Cb/Cr",
 		NULL
 	};
+	static const char * const auto_n_preset_white_balance[] = {
+		"Manual",
+		"Auto",
+		"Incandescent",
+		"Fluorescent",
+		"Fluorescent H",
+		"Horizon",
+		"Daylight",
+		"Flash",
+		"Cloudy",
+		"Shade",
+		NULL,
+	};
 	static const char * const tune_preemphasis[] = {
 		"No Preemphasis",
 		"50 Microseconds",
@@ -418,6 +431,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return camera_exposure_auto;
 	case V4L2_CID_COLORFX:
 		return colorfx;
+	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
+		return auto_n_preset_white_balance;
 	case V4L2_CID_TUNE_PREEMPHASIS:
 		return tune_preemphasis;
 	case V4L2_CID_FLASH_LED_MODE:
@@ -605,6 +620,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_IRIS_ABSOLUTE:		return "Iris, Absolute";
 	case V4L2_CID_IRIS_RELATIVE:		return "Iris, Relative";
 	case V4L2_CID_AUTO_EXPOSURE_BIAS:	return "Auto Exposure, Bias";
+	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE: return "White Balance, Auto & Preset";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -728,6 +744,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_STREAM_VBI_FMT:
 	case V4L2_CID_EXPOSURE_AUTO:
 	case V4L2_CID_COLORFX:
+	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
 	case V4L2_CID_TUNE_PREEMPHASIS:
 	case V4L2_CID_FLASH_LED_MODE:
 	case V4L2_CID_FLASH_STROBE_SOURCE:
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 8b174dc..243b2f4 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1702,6 +1702,20 @@ enum  v4l2_exposure_auto_type {
 
 #define V4L2_CID_AUTO_EXPOSURE_BIAS		(V4L2_CID_CAMERA_CLASS_BASE+19)
 
+#define V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE	(V4L2_CID_CAMERA_CLASS_BASE+20)
+enum v4l2_auto_n_preset_white_balance {
+	V4L2_WHITE_BALANCE_MANUAL		= 0,
+	V4L2_WHITE_BALANCE_AUTO			= 1,
+	V4L2_WHITE_BALANCE_INCANDESCENT		= 2,
+	V4L2_WHITE_BALANCE_FLUORESCENT		= 3,
+	V4L2_WHITE_BALANCE_FLUORESCENT_H	= 4,
+	V4L2_WHITE_BALANCE_HORIZON		= 5,
+	V4L2_WHITE_BALANCE_DAYLIGHT		= 6,
+	V4L2_WHITE_BALANCE_FLASH		= 7,
+	V4L2_WHITE_BALANCE_CLOUDY		= 8,
+	V4L2_WHITE_BALANCE_SHADE		= 9,
+};
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 04/23] V4L: Add camera wide dynamic range control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (2 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 03/23] V4L: Add an extended camera white balance control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 05/23] V4L: Add camera image stabilization control Sylwester Nawrocki
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add V4L2_CID_WIDE_DYNAMIC_RANGE camera class control for the
camera wide dynamic range (WDR, HDR) feature. This control
can be used to enable/disable wide dynamic range. It might
get converted to a menu control in future if more options
are needed.

Signed-off-by: HeungJun Kim <riverful.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   15 +++++++++++++++
 drivers/media/video/v4l2-ctrls.c             |    2 ++
 include/linux/videodev2.h                    |    2 ++
 3 files changed, 19 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 85d1ca0..02bf5a6 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3092,6 +3092,21 @@ sky. It corresponds approximately to 9000...10000 K color temperature.
 	  </row>
 	  <row><entry></entry></row>
 
+	  <row id="v4l2-wide-dynamic-range">
+	    <entry spanname="id"><constant>V4L2_CID_WIDE_DYNAMIC_RANGE</constant></entry>
+	    <entry>boolean</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Enables or disables the camera's wide dynamic
+range feature. This feature allows to obtain clear images in situations where
+intensity of the illumination varies significantly throughout the scene, i.e.
+there are simultaneously very dark and very bright areas. It is most commonly
+realized in cameras by combining two subsequent frames with different exposure
+times. <footnote id="ctypeconv"><para> This control may be changed to a menu
+control in the future, if more options are required.</para></footnote></entry>
+	  </row>
+	  <row><entry></entry></row>
+
 	</tbody>
       </tgroup>
     </table>
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index abcbada..6d7109e 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -621,6 +621,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_IRIS_RELATIVE:		return "Iris, Relative";
 	case V4L2_CID_AUTO_EXPOSURE_BIAS:	return "Auto Exposure, Bias";
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE: return "White Balance, Auto & Preset";
+	case V4L2_CID_WIDE_DYNAMIC_RANGE:	return "Wide Dynamic Range";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -712,6 +713,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
 	case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
 	case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
+	case V4L2_CID_WIDE_DYNAMIC_RANGE:
 		*type = V4L2_CTRL_TYPE_BOOLEAN;
 		*min = 0;
 		*max = *step = 1;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 243b2f4..a84e93c 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1716,6 +1716,8 @@ enum v4l2_auto_n_preset_white_balance {
 	V4L2_WHITE_BALANCE_SHADE		= 9,
 };
 
+#define V4L2_CID_WIDE_DYNAMIC_RANGE		(V4L2_CID_CAMERA_CLASS_BASE+21)
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 05/23] V4L: Add camera image stabilization control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (3 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 04/23] V4L: Add camera wide dynamic range control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 06/23] V4L: Add camera ISO sensitivity controls Sylwester Nawrocki
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add V4L2_CID_IMAGE_STABILIZATION control for the camera image
stabilization feature. This control can be used to enable/disable
image stabilization. It might get converted to a menu control
in future if more options are needed.

Signed-off-by: HeungJun Kim <riverful.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   10 ++++++++++
 drivers/media/video/v4l2-ctrls.c             |    2 ++
 include/linux/videodev2.h                    |    1 +
 3 files changed, 13 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 02bf5a6..5679089 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3107,6 +3107,16 @@ control in the future, if more options are required.</para></footnote></entry>
 	  </row>
 	  <row><entry></entry></row>
 
+	  <row id="v4l2-image-stabilization">
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_STABILIZATION</constant></entry>
+	    <entry>boolean</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Enables or disables image stabilization.
+	      <footnoteref linkend="ctypeconv"/></entry>
+	  </row>
+	  <row><entry></entry></row>
+
 	</tbody>
       </tgroup>
     </table>
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 6d7109e..9b2cd71 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -622,6 +622,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_AUTO_EXPOSURE_BIAS:	return "Auto Exposure, Bias";
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE: return "White Balance, Auto & Preset";
 	case V4L2_CID_WIDE_DYNAMIC_RANGE:	return "Wide Dynamic Range";
+	case V4L2_CID_IMAGE_STABILIZATION:	return "Image Stabilization";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -714,6 +715,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE:
 	case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
 	case V4L2_CID_WIDE_DYNAMIC_RANGE:
+	case V4L2_CID_IMAGE_STABILIZATION:
 		*type = V4L2_CTRL_TYPE_BOOLEAN;
 		*min = 0;
 		*max = *step = 1;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index a84e93c..8f73ef6 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1717,6 +1717,7 @@ enum v4l2_auto_n_preset_white_balance {
 };
 
 #define V4L2_CID_WIDE_DYNAMIC_RANGE		(V4L2_CID_CAMERA_CLASS_BASE+21)
+#define V4L2_CID_IMAGE_STABILIZATION		(V4L2_CID_CAMERA_CLASS_BASE+22)
 
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
-- 
1.7.10


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

* [PATCH 06/23] V4L: Add camera ISO sensitivity controls
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (4 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 05/23] V4L: Add camera image stabilization control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 07/23] V4L: Add camera exposure metering control Sylwester Nawrocki
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add ISO sensitivity and ISO auto/manual controls. The sensitivity
values are related to level of amplification of the analog signal
between image sensor and ADC. These controls allow to support sensors
exposing an interface to accept the ISO values directly.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/biblio.xml   |   11 ++++++++
 Documentation/DocBook/media/v4l/controls.xml |   38 ++++++++++++++++++++++++++
 drivers/media/video/v4l2-ctrls.c             |   11 ++++++++
 include/linux/videodev2.h                    |    7 +++++
 4 files changed, 67 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/biblio.xml b/Documentation/DocBook/media/v4l/biblio.xml
index 7dc65c5..66a0ef2 100644
--- a/Documentation/DocBook/media/v4l/biblio.xml
+++ b/Documentation/DocBook/media/v4l/biblio.xml
@@ -197,4 +197,15 @@ in the frequency range from 87,5 to 108,0 MHz</title>
       <title>NTSC-4: United States RBDS Standard</title>
     </biblioentry>
 
+    <biblioentry id="iso12232">
+      <abbrev>ISO&nbsp;12232:2006</abbrev>
+      <authorgroup>
+	<corpauthor>International Organization for Standardization
+(<ulink url="http://www.iso.org">http://www.iso.org</ulink>)</corpauthor>
+      </authorgroup>
+      <title>Photography &mdash; Digital still cameras &mdash; Determination
+      of exposure index, ISO speed ratings, standard output sensitivity, and
+      recommended exposure index</title>
+    </biblioentry>
+
   </bibliography>
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 5679089..b1646b9 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3117,6 +3117,44 @@ control in the future, if more options are required.</para></footnote></entry>
 	  </row>
 	  <row><entry></entry></row>
 
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_ISO_SENSITIVITY</constant>&nbsp;</entry>
+	    <entry>integer menu</entry>
+	  </row><row><entry spanname="descr">Determines ISO equivalent of an
+image sensor indicating the sensor's sensitivity to light. The numbers are
+expressed in arithmetic scale, as per <xref linkend="iso12232" /> standard,
+where doubling the sensor sensitivity is represented by doubling the numerical
+ISO value. Applications should interpret the values as standard ISO values
+multiplied by 1000, e.g. control value 800 stands for ISO 0.8. Drivers will
+usually support only a subset of standard ISO values. The effect of setting
+this control while the <constant>V4L2_CID_ISO_SENSITIVITY_AUTO</constant>
+control is set to a value other than <constant>V4L2_CID_ISO_SENSITIVITY_MANUAL
+</constant> is undefined, drivers should ignore such requests.</entry>
+	  </row>
+	  <row><entry></entry></row>
+
+	  <row id="v4l2-iso-sensitivity-auto-type">
+	    <entry spanname="id"><constant>V4L2_CID_ISO_SENSITIVITY_AUTO</constant>&nbsp;</entry>
+	    <entry>enum&nbsp;v4l2_iso_sensitivity_type</entry>
+	  </row><row><entry spanname="descr">Enables or disables automatic ISO
+sensitivity adjustments.</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_CID_ISO_SENSITIVITY_MANUAL</constant>&nbsp;</entry>
+		  <entry>Manual ISO sensitivity.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_CID_ISO_SENSITIVITY_AUTO</constant>&nbsp;</entry>
+		  <entry>Automatic ISO sensitivity adjustments.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry></entry></row>
+
 	</tbody>
       </tgroup>
     </table>
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 9b2cd71..f4c4072 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -262,6 +262,11 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"Shade",
 		NULL,
 	};
+	static const char * const camera_iso_sensitivity_auto[] = {
+		"Manual",
+		"Auto",
+		NULL
+	};
 	static const char * const tune_preemphasis[] = {
 		"No Preemphasis",
 		"50 Microseconds",
@@ -433,6 +438,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return colorfx;
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
 		return auto_n_preset_white_balance;
+	case V4L2_CID_ISO_SENSITIVITY_AUTO:
+		return camera_iso_sensitivity_auto;
 	case V4L2_CID_TUNE_PREEMPHASIS:
 		return tune_preemphasis;
 	case V4L2_CID_FLASH_LED_MODE:
@@ -623,6 +630,8 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE: return "White Balance, Auto & Preset";
 	case V4L2_CID_WIDE_DYNAMIC_RANGE:	return "Wide Dynamic Range";
 	case V4L2_CID_IMAGE_STABILIZATION:	return "Image Stabilization";
+	case V4L2_CID_ISO_SENSITIVITY:		return "ISO Sensitivity";
+	case V4L2_CID_ISO_SENSITIVITY_AUTO:	return "ISO Sensitivity, Auto";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -762,12 +771,14 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
 	case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
 	case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
+	case V4L2_CID_ISO_SENSITIVITY_AUTO:
 		*type = V4L2_CTRL_TYPE_MENU;
 		break;
 	case V4L2_CID_RDS_TX_PS_NAME:
 	case V4L2_CID_RDS_TX_RADIO_TEXT:
 		*type = V4L2_CTRL_TYPE_STRING;
 		break;
+	case V4L2_CID_ISO_SENSITIVITY:
 	case V4L2_CID_AUTO_EXPOSURE_BIAS:
 		*type = V4L2_CTRL_TYPE_INTEGER_MENU;
 		break;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 8f73ef6..fe5592e 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1719,6 +1719,13 @@ enum v4l2_auto_n_preset_white_balance {
 #define V4L2_CID_WIDE_DYNAMIC_RANGE		(V4L2_CID_CAMERA_CLASS_BASE+21)
 #define V4L2_CID_IMAGE_STABILIZATION		(V4L2_CID_CAMERA_CLASS_BASE+22)
 
+#define V4L2_CID_ISO_SENSITIVITY		(V4L2_CID_CAMERA_CLASS_BASE+23)
+#define V4L2_CID_ISO_SENSITIVITY_AUTO		(V4L2_CID_CAMERA_CLASS_BASE+24)
+enum v4l2_iso_sensitivity_auto_type {
+	V4L2_ISO_SENSITIVITY_MANUAL		= 0,
+	V4L2_ISO_SENSITIVITY_AUTO		= 1,
+};
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 07/23] V4L: Add camera exposure metering control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (5 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 06/23] V4L: Add camera ISO sensitivity controls Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 08/23] V4L: Add camera scene mode control Sylwester Nawrocki
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

The V4L2_CID_EXPOSURE_METERING control allows to determine
a method used by the camera for measuring the amount of light
available for automatic exposure.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   29 ++++++++++++++++++++++++++
 drivers/media/video/v4l2-ctrls.c             |   10 +++++++++
 include/linux/videodev2.h                    |    7 +++++++
 3 files changed, 46 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index b1646b9..9571c96 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -2864,6 +2864,35 @@ exposure time and/or aperture.</para></entry>
 	  </row>
 	  <row><entry></entry></row>
 
+	  <row id="v4l2-exposure-metering">
+	    <entry spanname="id"><constant>V4L2_CID_EXPOSURE_METERING</constant>&nbsp;</entry>
+	    <entry>enum&nbsp;v4l2_exposure_metering</entry>
+	  </row><row><entry spanname="descr">Determines how the camera measures
+the amount of light available for the frame exposure. Possible values are:</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_EXPOSURE_METERING_AVERAGE</constant>&nbsp;</entry>
+		  <entry>Use the light information coming from the entire frame
+and average giving no weighting to any particular portion of the metered area.
+		  </entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_EXPOSURE_METERING_CENTER_WEIGHTED</constant>&nbsp;</entry>
+		  <entry>Average the light information coming from the entire frame
+giving priority to the center of the metered area.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_EXPOSURE_METERING_SPOT</constant>&nbsp;</entry>
+		  <entry>Measure only very small area at the center of the frame.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry></entry></row>
+
 	  <row>
 	    <entry spanname="id"><constant>V4L2_CID_PAN_RELATIVE</constant>&nbsp;</entry>
 	    <entry>integer</entry>
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index f4c4072..33a4b8a 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -230,6 +230,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"Aperture Priority Mode",
 		NULL
 	};
+	static const char * const camera_exposure_metering[] = {
+		"Average",
+		"Center Weighted",
+		"Spot",
+		NULL
+	};
 	static const char * const colorfx[] = {
 		"None",
 		"Black & White",
@@ -434,6 +440,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return camera_power_line_frequency;
 	case V4L2_CID_EXPOSURE_AUTO:
 		return camera_exposure_auto;
+	case V4L2_CID_EXPOSURE_METERING:
+		return camera_exposure_metering;
 	case V4L2_CID_COLORFX:
 		return colorfx;
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
@@ -632,6 +640,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_IMAGE_STABILIZATION:	return "Image Stabilization";
 	case V4L2_CID_ISO_SENSITIVITY:		return "ISO Sensitivity";
 	case V4L2_CID_ISO_SENSITIVITY_AUTO:	return "ISO Sensitivity, Auto";
+	case V4L2_CID_EXPOSURE_METERING:	return "Exposure, Metering Mode";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -772,6 +781,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
 	case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
 	case V4L2_CID_ISO_SENSITIVITY_AUTO:
+	case V4L2_CID_EXPOSURE_METERING:
 		*type = V4L2_CTRL_TYPE_MENU;
 		break;
 	case V4L2_CID_RDS_TX_PS_NAME:
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index fe5592e..215b7df 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1726,6 +1726,13 @@ enum v4l2_iso_sensitivity_auto_type {
 	V4L2_ISO_SENSITIVITY_AUTO		= 1,
 };
 
+#define V4L2_CID_EXPOSURE_METERING		(V4L2_CID_CAMERA_CLASS_BASE+25)
+enum v4l2_exposure_metering {
+	V4L2_EXPOSURE_METERING_AVERAGE		= 0,
+	V4L2_EXPOSURE_METERING_CENTER_WEIGHTED	= 1,
+	V4L2_EXPOSURE_METERING_SPOT		= 2,
+};
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 08/23] V4L: Add camera scene mode control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (6 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 07/23] V4L: Add camera exposure metering control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 09/23] V4L: Add camera 3A lock control Sylwester Nawrocki
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add control for the scene mode feature available in image sensor
with more advanced ISP firmware. The V4L2_CID_SCENE_MODE menu
control allows to select a set of parameters or a specific image
processing and capture control algorithm optimized for common
image capture conditions.

Signed-off-by: HeungJun Kim <riverful.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/controls.xml |  117 ++++++++++++++++++++++++++
 drivers/media/video/v4l2-ctrls.c             |   21 +++++
 include/linux/videodev2.h                    |   18 ++++
 3 files changed, 156 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 9571c96..c0256a0 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3184,6 +3184,123 @@ sensitivity adjustments.</entry>
 	  </row>
 	  <row><entry></entry></row>
 
+	  <row id="v4l2-scene-mode">
+	    <entry spanname="id"><constant>V4L2_CID_SCENE_MODE</constant>&nbsp;</entry>
+	    <entry>enum&nbsp;v4l2_scene_mode</entry>
+	  </row><row><entry spanname="descr">This control allows to select
+scene programs as the camera automatic modes optimized for common shooting
+scenes. Within these modes the camera determines best exposure, aperture,
+focusing, light metering, white balance and equivalent sensitivity. The
+controls of those parameters are influenced by the scene mode control.
+An exact behavior in each mode is subject to the camera specification.
+
+<para>When the scene mode feature is not used, this control should be set to
+<constant>V4L2_SCENE_MODE_NONE</constant> to make sure the other possibly
+related controls are accessible. The following scene programs are defined:
+</para>
+</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_NONE</constant>&nbsp;</entry>
+		  <entry>The scene mode feature is disabled.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_BACKLIGHT</constant>&nbsp;</entry>
+		  <entry>Backlight. Compensates for dark shadows when light is
+		  coming from behind a subject, also by automatically turning
+		  on the flash.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_BEACH_SNOW</constant>&nbsp;</entry>
+		  <entry>Beach and snow. This mode compensates for all-white or
+bright scenes, which tend to look gray and low contrast, when camera's automatic
+exposure is based on an average scene brightness. To compensate, this mode
+automatically slightly overexposes the frames. The white balance may also be
+adjusted to compensate for the fact that reflected snow looks bluish rather
+than white.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_CANDLELIGHT</constant>&nbsp;</entry>
+		  <entry>Candle light. The camera generally raises the ISO
+sensitivity and lowers the shutter speed. This mode compensates for relatively
+close subject in the scene. The flash is disabled in order to preserve the
+ambiance of the light.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_DAWN_DUSK</constant>&nbsp;</entry>
+		  <entry>Dawn and dusk. Preserves the colors seen in low
+natural light before dusk and after down. The camera may turn off the flash,
+and automatically focus at infinity. It will usually boost saturation and
+lower the shutter speed.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_FALL_COLORS</constant>&nbsp;</entry>
+		  <entry>Fall colors. Increases saturation and adjusts white
+balance for color enhancement. Pictures of autumn leaves get saturated reds
+and yellows.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_FIREWORKS</constant>&nbsp;</entry>
+		  <entry>Fireworks. Long exposure times are used to capture
+the expanding burst of light from a firework. The camera may invoke image
+stabilization.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_LANDSCAPE</constant>&nbsp;</entry>
+		  <entry>Landscape. The camera may choose a small aperture to
+provide deep depth of field and long exposure duration to help capture detail
+in dim light conditions. The focus is fixed at infinity. Suitable for distant
+and wide scenery.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_NIGHT</constant>&nbsp;</entry>
+		  <entry>Night, also known as Night Landscape. Designed for low
+light conditions, it preserves detail in the dark areas without blowing out bright
+objects. The camera generally sets itself to a medium-to-high ISO sensitivity,
+with a relatively long exposure time, and turns flash off. As such, there will be
+increased image noise and the possibility of blurred image.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_PARTY_INDOOR</constant>&nbsp;</entry>
+		  <entry>Party and indoor. Designed to capture indoor scenes
+that are lit by indoor background lighting as well as the flash. The camera
+usually increases ISO sensitivity, and adjusts exposure for the low light
+conditions.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_PORTRAIT</constant>&nbsp;</entry>
+		  <entry>Portrait. The camera adjusts the aperture so that the
+depth of field is reduced, which helps to isolate the subject against a smooth
+background. Most cameras recognize the presence of faces in the scene and focus
+on them. The color hue is adjusted to enhance skin tones. The intensity of the
+flash is often reduced.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_SPORTS</constant>&nbsp;</entry>
+		  <entry>Sports. Significantly increases ISO and uses a fast
+shutter speed to freeze motion of rapidly-moving subjects. Increased image
+noise may be seen in this mode.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_SUNSET</constant>&nbsp;</entry>
+		  <entry>Sunset. Preserves deep hues seen in sunsets and
+sunrises. It bumps up the saturation.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_SCENE_MODE_TEXT</constant>&nbsp;</entry>
+		  <entry>Text. It applies extra contrast and sharpness, it is
+typically a black-and-white mode optimized for readability. Automatic focus
+may be switched to close-up mode and this setting may also involve some
+lens-distortion correction.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry></entry></row>
+
 	</tbody>
       </tgroup>
     </table>
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 33a4b8a..4758e61 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -273,6 +273,23 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"Auto",
 		NULL
 	};
+	static const char * const scene_mode[] = {
+		"None",
+		"Backlight",
+		"Beach/Snow",
+		"Candle Light",
+		"Dusk/Dawn",
+		"Fall Colors",
+		"Fireworks",
+		"Landscape",
+		"Night",
+		"Party/Indoor",
+		"Portrait",
+		"Sports",
+		"Sunset",
+		"Text",
+		NULL
+	};
 	static const char * const tune_preemphasis[] = {
 		"No Preemphasis",
 		"50 Microseconds",
@@ -448,6 +465,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return auto_n_preset_white_balance;
 	case V4L2_CID_ISO_SENSITIVITY_AUTO:
 		return camera_iso_sensitivity_auto;
+	case V4L2_CID_SCENE_MODE:
+		return scene_mode;
 	case V4L2_CID_TUNE_PREEMPHASIS:
 		return tune_preemphasis;
 	case V4L2_CID_FLASH_LED_MODE:
@@ -641,6 +660,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_ISO_SENSITIVITY:		return "ISO Sensitivity";
 	case V4L2_CID_ISO_SENSITIVITY_AUTO:	return "ISO Sensitivity, Auto";
 	case V4L2_CID_EXPOSURE_METERING:	return "Exposure, Metering Mode";
+	case V4L2_CID_SCENE_MODE:		return "Scene Mode";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -782,6 +802,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
 	case V4L2_CID_ISO_SENSITIVITY_AUTO:
 	case V4L2_CID_EXPOSURE_METERING:
+	case V4L2_CID_SCENE_MODE:
 		*type = V4L2_CTRL_TYPE_MENU;
 		break;
 	case V4L2_CID_RDS_TX_PS_NAME:
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 215b7df..6f1c5de 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1733,6 +1733,24 @@ enum v4l2_exposure_metering {
 	V4L2_EXPOSURE_METERING_SPOT		= 2,
 };
 
+#define V4L2_CID_SCENE_MODE			(V4L2_CID_CAMERA_CLASS_BASE+26)
+enum v4l2_scene_mode {
+	V4L2_SCENE_MODE_NONE			= 0,
+	V4L2_SCENE_MODE_BACKLIGHT		= 1,
+	V4L2_SCENE_MODE_BEACH_SNOW		= 2,
+	V4L2_SCENE_MODE_CANDLE_LIGHT		= 3,
+	V4L2_SCENE_MODE_DAWN_DUSK		= 4,
+	V4L2_SCENE_MODE_FALL_COLORS		= 5,
+	V4L2_SCENE_MODE_FIREWORKS		= 6,
+	V4L2_SCENE_MODE_LANDSCAPE		= 7,
+	V4L2_SCENE_MODE_NIGHT			= 8,
+	V4L2_SCENE_MODE_PARTY_INDOOR		= 9,
+	V4L2_SCENE_MODE_PORTRAIT		= 10,
+	V4L2_SCENE_MODE_SPORTS			= 11,
+	V4L2_SCENE_MODE_SUNSET			= 12,
+	V4L2_SCENE_MODE_TEXT			= 13,
+};
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 09/23] V4L: Add camera 3A lock control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (7 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 08/23] V4L: Add camera scene mode control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 10/23] V4L: Add auto focus targets to the selections API Sylwester Nawrocki
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

The V4L2_CID_3A_LOCK bitmask control allows applications to pause
or resume the automatic exposure, focus and wite balance adjustments.
It can be used, for example, to lock the 3A adjustments right before
a still image is captured, for pre-focus, etc.
The applications can control each of the algorithms independently,
through a corresponding control bit, if driver allows that.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   39 ++++++++++++++++++++++++++
 drivers/media/video/v4l2-ctrls.c             |    2 ++
 include/linux/videodev2.h                    |    5 ++++
 3 files changed, 46 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index c0256a0..ccb1df9 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3301,6 +3301,45 @@ lens-distortion correction.</entry>
 	  </row>
 	  <row><entry></entry></row>
 
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_3A_LOCK</constant></entry>
+	    <entry>bitmask</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">This control locks or unlocks the automatic
+focus, exposure and white balance. The automatic adjustments can be paused
+independently by setting the corresponding lock bit to 1. The camera then retains
+the settings until the lock bit is cleared. The following lock bits are defined:
+</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_LOCK_EXPOSURE</constant></entry>
+		  <entry>Automatic exposure adjustments lock.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_LOCK_WHITE_BALANCE</constant></entry>
+		  <entry>Automatic white balance adjustments lock.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_LOCK_FOCUS</constant></entry>
+		  <entry>Automatic focus lock.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry spanname="descr">
+When a given algorithm is not enabled, drivers should ignore requests
+to lock it and should return no error. An example might be an application
+setting bit <constant>V4L2_LOCK_WHITE_BALANCE</constant> when the
+<constant>V4L2_CID_AUTO_WHITE_BALANCE</constant> control is set to
+<constant>FALSE</constant>. The value of this control may be changed
+by exposure, white balance or focus controls.</entry>
+	  </row>
+	  <row><entry></entry></row>
+
 	</tbody>
       </tgroup>
     </table>
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 4758e61..877ce60 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -661,6 +661,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_ISO_SENSITIVITY_AUTO:	return "ISO Sensitivity, Auto";
 	case V4L2_CID_EXPOSURE_METERING:	return "Exposure, Metering Mode";
 	case V4L2_CID_SCENE_MODE:		return "Scene Mode";
+	case V4L2_CID_3A_LOCK:			return "3A Lock";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -833,6 +834,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 		break;
 	case V4L2_CID_FLASH_FAULT:
 	case V4L2_CID_JPEG_ACTIVE_MARKER:
+	case V4L2_CID_3A_LOCK:
 		*type = V4L2_CTRL_TYPE_BITMASK;
 		break;
 	case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 6f1c5de..dae57ed 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1751,6 +1751,11 @@ enum v4l2_scene_mode {
 	V4L2_SCENE_MODE_TEXT			= 13,
 };
 
+#define V4L2_CID_3A_LOCK			(V4L2_CID_CAMERA_CLASS_BASE+27)
+#define V4L2_LOCK_EXPOSURE			(1 << 0)
+#define V4L2_LOCK_WHITE_BALANCE			(1 << 1)
+#define V4L2_LOCK_FOCUS				(1 << 2)
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 10/23] V4L: Add auto focus targets to the selections API
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (8 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 09/23] V4L: Add camera 3A lock control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-10-29 20:00   ` Sakari Ailus
  2012-05-10 10:30 ` [PATCH 11/23] V4L: Add auto focus targets to the subdev " Sylwester Nawrocki
                   ` (12 subsequent siblings)
  22 siblings, 1 reply; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

The camera automatic focus algorithms may require setting up
a spot or rectangle coordinates or multiple such parameters.

The automatic focus selection targets are introduced in order
to allow applications to query and set such coordinates. Those
selections are intended to be used together with the automatic
focus controls available in the camera control class.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/selection-api.xml  |   33 +++++++++++++++++++-
 .../DocBook/media/v4l/vidioc-g-selection.xml       |   11 +++++++
 include/linux/videodev2.h                          |    5 +++
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/selection-api.xml b/Documentation/DocBook/media/v4l/selection-api.xml
index b299e47..490d29a 100644
--- a/Documentation/DocBook/media/v4l/selection-api.xml
+++ b/Documentation/DocBook/media/v4l/selection-api.xml
@@ -1,6 +1,6 @@
 <section id="selection-api">
 
-  <title>Experimental API for cropping, composing and scaling</title>
+  <title>Experimental selections API</title>
 
       <note>
 	<title>Experimental</title>
@@ -9,6 +9,10 @@
 interface and may change in the future.</para>
       </note>
 
+ <section>
+
+ <title>Image cropping, composing and scaling</title>
+
   <section>
     <title>Introduction</title>
 
@@ -321,5 +325,32 @@ V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> for other devices</para>
       </example>
 
    </section>
+ </section>
+
+   <section>
+     <title>Automatic focus regions of interest</title>
+
+<para> The camera automatic focus algorithms may require configuration of
+regions of interest in form of rectangle or spot coordinates. The automatic
+focus selection targets allow applications to query and set such coordinates.
+Those selections are intended to be used together with the
+<constant>V4L2_CID_AUTO_FOCUS_AREA</constant> <link linkend="camera-controls">
+camera class</link> control. The <constant>V4L2_SEL_TGT_AUTO_FOCUS_ACTUAL
+</constant> target is used for querying or setting actual spot or rectangle
+coordinates, while <constant>V4L2_SEL_TGT_AUTO_FOCUS_BOUNDS</constant> target
+determines bounds for a single spot or rectangle.
+These selections are only effective when the <constant>V4L2_CID_AUTO_FOCUS_AREA
+</constant>control is set to <constant>V4L2_AUTO_FOCUS_AREA_SPOT</constant> or
+<constant>V4L2_AUTO_FOCUS_AREA_RECTANGLE</constant>. The new coordinates shall
+be accepted and applied to hardware when the focus area control value is
+changed and also during a &VIDIOC-S-SELECTION; ioctl call, only when the focus
+area control is already set to required value.</para>
+
+<para> For the <constant>V4L2_AUTO_FOCUS_AREA_SPOT</constant> case, the selection
+rectangle <structfield> width</structfield> and <structfield>height</structfield>
+are not used, i.e. shall be set to 0 by applications and ignored by drivers for
+the &VIDIOC-S-SELECTION; ioctl and shall be ignored by applications for the
+&VIDIOC-G-SELECTION; ioctl.</para>
+   </section>
 
 </section>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-selection.xml b/Documentation/DocBook/media/v4l/vidioc-g-selection.xml
index bb04eff..87df4da 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-selection.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-selection.xml
@@ -195,6 +195,17 @@ exist no rectangle </emphasis> that satisfies the constraints.</para>
             <entry>0x0103</entry>
             <entry>The active area and all padding pixels that are inserted or modified by hardware.</entry>
 	  </row>
+	  <row>
+            <entry><constant>V4L2_SEL_TGT_AUTO_FOCUS_ACTUAL</constant></entry>
+            <entry>0x1000</entry>
+	    <entry>Actual automatic focus rectangle or spot coordinates.</entry>
+	  </row>
+	  <row>
+            <entry><constant>V4L2_SEL_TGT_AUTO_FOCUS_BOUNDS</constant></entry>
+            <entry>0x1002</entry>
+            <entry>Bounds of the automatic focus region of interest.
+	    </entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index dae57ed..4077d62 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -777,6 +777,11 @@ struct v4l2_crop {
 /* Current composing area plus all padding pixels */
 #define V4L2_SEL_TGT_COMPOSE_PADDED	0x0103
 
+/* Auto focus region of interest */
+#define V4L2_SEL_TGT_AUTO_FOCUS_ACTUAL	0x1000
+/* Auto focus region (spot coordinates) bounds */
+#define V4L2_SEL_TGT_AUTO_FOCUS_BOUNDS	0x1001
+
 /**
  * struct v4l2_selection - selection info
  * @type:	buffer type (do not use *_MPLANE types)
-- 
1.7.10


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

* [PATCH 11/23] V4L: Add auto focus targets to the subdev selections API
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (9 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 10/23] V4L: Add auto focus targets to the selections API Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 12/23] V4L: Add camera auto focus controls Sylwester Nawrocki
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/dev-subdev.xml     |   27 +++++++++++++++++++-
 .../media/v4l/vidioc-subdev-g-selection.xml        |   14 ++++++++--
 include/linux/v4l2-subdev.h                        |    4 +++
 3 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/dev-subdev.xml b/Documentation/DocBook/media/v4l/dev-subdev.xml
index 4afcbbe..8a212c4 100644
--- a/Documentation/DocBook/media/v4l/dev-subdev.xml
+++ b/Documentation/DocBook/media/v4l/dev-subdev.xml
@@ -277,7 +277,7 @@
     </section>
 
     <section>
-      <title>Selections: cropping, scaling and composition</title>
+      <title>Selections - cropping, scaling and composition</title>
 
       <para>Many sub-devices support cropping frames on their input or output
       pads (or possible even on both). Cropping is used to select the area of
@@ -330,6 +330,31 @@
     </section>
 
     <section>
+      <title>Selections - regions of interest</title>
+    <section>
+      <title>Automatic focus</title>
+
+      <para>The camera automatic focus algorithms may require configuration
+      of a region or multiple regions of interest in form of rectangle or spot
+      coordinates.</para>
+
+      <para>A single rectangle of interest is represented in &v4l2-rect;
+      by the coordinates of the top left corner and the rectangle size. Both
+      the coordinates and sizes are expressed in pixels. When the <structfield>
+      width</structfield> and <structfield>height</structfield> fields of
+      &v4l2-rect; are set to 0 the selection determines spot coordinates,
+      rather than a rectangle.</para>
+
+      <para>Auto focus rectangles are reset to their default values when the
+      output image format is modified. Drivers should use the output image size
+      as the auto focus rectangle default value, but hardware requirements may
+      prevent this.
+      </para>
+      <para>The auto focus selections on input pads are not defined.</para>
+    </section>
+    </section>
+
+    <section>
       <title>Types of selection targets</title>
 
       <section>
diff --git a/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml b/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml
index 208e9f0..c4ccae5 100644
--- a/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml
@@ -57,8 +57,8 @@
 
     <para>The selections are used to configure various image
     processing functionality performed by the subdevs which affect the
-    image size. This currently includes cropping, scaling and
-    composition.</para>
+    image size. This currently includes cropping, scaling, composition
+    and automatic focus regions of interest.</para>
 
     <para>The selection API replaces <link
     linkend="vidioc-subdev-g-crop">the old subdev crop API</link>. All
@@ -114,6 +114,16 @@
 	    <entry>0x0102</entry>
 	    <entry>Bounds of the compose rectangle.</entry>
 	  </row>
+	  <row>
+	    <entry><constant>V4L2_SUBDEV_SEL_TGT_AUTO_FOCUS_BOUNDS</constant></entry>
+	    <entry>0x1000</entry>
+	    <entry>Bounds of the automatic focus region of interest.</entry>
+	  </row>
+	  <row>
+	    <entry><constant>V4L2_SUBDEV_SEL_TGT_AUTO_FOCUS_ACTUAL</constant></entry>
+	    <entry>0x1001</entry>
+	    <entry>Actual automatic focus rectangle or spot coordinates.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
index 812019e..49b1f14 100644
--- a/include/linux/v4l2-subdev.h
+++ b/include/linux/v4l2-subdev.h
@@ -136,6 +136,10 @@ struct v4l2_subdev_frame_interval_enum {
 /* composing bounds */
 #define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS		0x0102
 
+/* auto focus region of interest */
+#define V4L2_SUBDEV_SEL_TGT_AUTO_FOCUS_ACTUAL		0x1000
+/* auto focus region (spot coordinates) bounds */
+#define V4L2_SUBDEV_SEL_TGT_AUTO_FOCUS_BOUNDS		0x1001
 
 /**
  * struct v4l2_subdev_selection - selection info
-- 
1.7.10


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

* [PATCH 12/23] V4L: Add camera auto focus controls
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (10 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 11/23] V4L: Add auto focus targets to the subdev " Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 13/23] m5mols: Convert macros to inline functions Sylwester Nawrocki
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add following auto focus controls:

 - V4L2_CID_AUTO_FOCUS_START - single-shot auto focus start
 - V4L2_CID_AUTO_FOCUS_STOP -  single-shot auto focus stop
 - V4L2_CID_AUTO_FOCUS_STATUS - automatic focus status
 - V4L2_CID_AUTO_FOCUS_AREA - automatic focus area selection
 - V4L2_CID_AUTO_FOCUS_RANGE - automatic focus scan range selection

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 Documentation/DocBook/media/v4l/compat.xml   |   20 ++++
 Documentation/DocBook/media/v4l/controls.xml |  152 +++++++++++++++++++++++++-
 Documentation/DocBook/media/v4l/v4l2.xml     |    9 +-
 drivers/media/video/v4l2-ctrls.c             |   31 +++++-
 include/linux/videodev2.h                    |   24 ++++
 5 files changed, 232 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 149f65d..fa39d76 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2435,6 +2435,22 @@ details.</para>
         <listitem>
 	  <para> Added <constant>V4L2_CID_COLORFX_CBCR</constant> control.</para>
         </listitem>
+        <listitem>
+	  <para> Added camera controls <constant>V4L2_CID_AUTO_EXPOSURE_BIAS</constant>,
+	  <constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>,
+	  <constant>V4L2_CID_IMAGE_STABILIZATION</constant>,
+	  <constant>V4L2_CID_ISO_SENSITIVITY</constant>,
+	  <constant>V4L2_CID_ISO_SENSITIVITY_AUTO</constant>,
+	  <constant>V4L2_CID_EXPOSURE_METERING</constant>,
+	  <constant>V4L2_CID_SCENE_MODE</constant>,
+	  <constant>V4L2_CID_3A_LOCK</constant>,
+	  <constant>V4L2_CID_AUTO_FOCUS_START</constant>,
+	  <constant>V4L2_CID_AUTO_FOCUS_STOP</constant>,
+	  <constant>V4L2_CID_AUTO_FOCUS_STATUS</constant>,
+	  <constant>V4L2_CID_AUTO_FOCUS_RANGE</constant> and
+	  <constant>V4L2_CID_AUTO_FOCUS_AREA</constant>.
+	  </para>
+        </listitem>
       </orderedlist>
     </section>
 
@@ -2555,6 +2571,10 @@ ioctls.</para>
 	  <para>Sub-device selection API: &VIDIOC-SUBDEV-G-SELECTION;
 	  and &VIDIOC-SUBDEV-S-SELECTION; ioctls.</para>
         </listitem>
+        <listitem>
+	  <para><link linkend="v4l2-auto-focus-area"><constant>
+	  V4L2_CID_AUTO_FOCUS_AREA</constant></link> control.</para>
+        </listitem>
       </itemizedlist>
     </section>
 
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index ccb1df9..538f977 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -2976,13 +2976,161 @@ negative values towards infinity. This is a write-only control.</entry>
 	  <row>
 	    <entry spanname="id"><constant>V4L2_CID_FOCUS_AUTO</constant>&nbsp;</entry>
 	    <entry>boolean</entry>
-	  </row><row><entry spanname="descr">Enables automatic focus
-adjustments. The effect of manual focus adjustments while this feature
+	  </row><row><entry spanname="descr">Enables continuous automatic
+focus adjustments. The effect of manual focus adjustments while this feature
 is enabled is undefined, drivers should ignore such requests.</entry>
 	  </row>
 	  <row><entry></entry></row>
 
 	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUTO_FOCUS_START</constant>&nbsp;</entry>
+	    <entry>button</entry>
+	  </row><row><entry spanname="descr">Starts single auto focus process.
+The effect of setting this control when <constant>V4L2_CID_FOCUS_AUTO</constant>
+is set to <constant>TRUE</constant> (1) is undefined, drivers should ignore
+such requests.</entry>
+	  </row>
+	  <row><entry></entry></row>
+
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_AUTO_FOCUS_STOP</constant>&nbsp;</entry>
+	    <entry>button</entry>
+	  </row><row><entry spanname="descr">Aborts automatic focusing
+started with <constant>V4L2_CID_AUTO_FOCUS_START</constant> control. It is
+effective only when the continuous autofocus is disabled, that is when
+<constant>V4L2_CID_FOCUS_AUTO</constant> control is set to <constant>FALSE
+</constant> (0).</entry>
+	  </row>
+	  <row><entry></entry></row>
+
+	  <row id="v4l2-auto-focus-status">
+	    <entry spanname="id">
+	      <constant>V4L2_CID_AUTO_FOCUS_STATUS</constant>&nbsp;</entry>
+	    <entry>bitmask</entry>
+	  </row>
+	  <row><entry spanname="descr">The automatic focus status. This is a read-only
+	  control.</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_STATUS_IDLE</constant>&nbsp;</entry>
+		  <entry>Automatic focus is not active.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_STATUS_BUSY</constant>&nbsp;</entry>
+		  <entry>Automatic focusing is in progress.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_STATUS_REACHED</constant>&nbsp;</entry>
+		  <entry>Focus has been reached.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_STATUS_FAILED</constant>&nbsp;</entry>
+		  <entry>Automatic focus has failed, the driver will not
+		  transition from this state until another action is
+		  performed by an application.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry spanname="descr">
+Setting <constant>V4L2_LOCK_FOCUS</constant> lock bit of the <constant>V4L2_CID_3A_LOCK
+</constant> control may stop updates of the <constant>V4L2_CID_AUTO_FOCUS_STATUS</constant>
+control value.</entry>
+	  </row>
+	  <row><entry></entry></row>
+
+	  <row id="v4l2-auto-focus-range">
+	    <entry spanname="id">
+	      <constant>V4L2_CID_AUTO_FOCUS_RANGE</constant>&nbsp;</entry>
+	    <entry>enum&nbsp;v4l2_auto_focus_range</entry>
+	  </row>
+	  <row><entry spanname="descr">Determines auto focus distance range
+for which lens may be adjusted. </entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_RANGE_AUTO</constant>&nbsp;</entry>
+		  <entry>The camera automatically selects the focus range.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_RANGE_NORMAL</constant>&nbsp;</entry>
+		  <entry>Normal distance range, limited for best automatic focus
+performance.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_RANGE_MACRO</constant>&nbsp;</entry>
+		  <entry>Macro (close-up) auto focus. The camera will
+use its minimum possible distance for auto focus.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_RANGE_INFINITY</constant>&nbsp;</entry>
+		  <entry>The lens is set to focus on an object at infinite distance.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry></entry></row>
+
+	  <row id="v4l2-auto-focus-area">
+	    <entry spanname="id">
+	      <constant>V4L2_CID_AUTO_FOCUS_AREA</constant>&nbsp;</entry>
+	    <entry>enum&nbsp;v4l2_auto_focus_area</entry>
+	  </row>
+	  <row><entry spanname="descr">Determines the area of the frame that
+the camera uses for automatic focus. The corresponding coordinates of the
+focusing spot or rectangle can be specified and queried using the selection API.
+To change the auto focus region of interest applications first select required
+mode of this control and then set the rectangle or spot coordinates by means
+of the &VIDIOC-SUBDEV-S-SELECTION; or &VIDIOC-S-SELECTION; ioctl. In order to
+trigger again a one shot auto focus with same coordinates applications should
+use the <constant>V4L2_CID_AUTO_FOCUS_START </constant> control. Or alternatively
+invoke a &VIDIOC-SUBDEV-S-SELECTION; or a &VIDIOC-S-SELECTION; ioctl again.
+In the latter case the new pixel coordinates are applied to hardware only when
+the focus area control was set to <constant>V4L2_AUTO_FOCUS_AREA_SPOT</constant>
+or <constant>V4L2_AUTO_FOCUS_AREA_RECTANGLE</constant>.</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_AREA_ALL</constant>&nbsp;</entry>
+		  <entry>Normal auto focus, the focusing area extends over the
+entire frame.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_AREA_SPOT</constant>&nbsp;</entry>
+		  <entry>Automatic focus on a spot within the frame at position
+specified by the <constant>V4L2_SEL_TGT_AUTO_FOCUS_ACTUAL</constant> or
+<constant>V4L2_SUBDEV_SEL_TGT_AUTO_FOCUS_ACTUAL</constant> selection. When these
+selections are not supported by driver the default spot's position is center of
+the frame.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_AREA_RECTANGLE</constant>&nbsp;</entry>
+		  <entry>The auto focus area is determined by the <constant>
+V4L2_SEL_TGT_AUTO_FOCUS_ACTUAL</constant> or <constant>
+V4L2_SUBDEV_SEL_TGT_AUTO_FOCUS_ACTUAL</constant> selection rectangle.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_AUTO_FOCUS_AREA_FACE_DETECTION</constant>&nbsp;</entry>
+		  <entry>The camera automatically focuses on the face detection
+regions.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row><entry spanname="descr">
+	    This is an <link linkend="experimental">experimental</link>
+control and may change in the future.</entry>
+	  </row>
+	  <row><entry></entry></row>
+
+	  <row>
 	    <entry spanname="id"><constant>V4L2_CID_ZOOM_ABSOLUTE</constant>&nbsp;</entry>
 	    <entry>integer</entry>
 	  </row><row><entry spanname="descr">Specify the objective lens
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index 63242e2..e24ac68 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -140,11 +140,18 @@ applications. -->
 
       <revision>
 	<revnumber>3.5</revnumber>
-	<date>2012-04-02</date>
+	<date>2012-05-07</date>
 	<authorinitials>sa, sn</authorinitials>
 	<revremark>Added V4L2_CTRL_TYPE_INTEGER_MENU and V4L2 subdev
 	    selections API. Improved the description of V4L2_CID_COLORFX
 	    control, added V4L2_CID_COLORFX_CBCR control.
+	    Added camera controls V4L2_CID_AUTO_EXPOSURE_BIAS,
+	    V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, V4L2_CID_IMAGE_STABILIZATION,
+	    V4L2_CID_ISO_SENSITIVITY, V4L2_CID_ISO_SENSITIVITY_AUTO,
+	    V4L2_CID_EXPOSURE_METERING, V4L2_CID_SCENE_MODE,
+	    V4L2_CID_3A_LOCK, V4L2_CID_AUTO_FOCUS_START,
+	    V4L2_CID_AUTO_FOCUS_STOP, V4L2_CID_AUTO_FOCUS_STATUS,
+	    V4L2_CID_AUTO_FOCUS_RANGE and V4L2_CID_AUTO_FOCUS_AREA.
 	</revremark>
       </revision>
 
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 877ce60..6a63cf9 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -236,6 +236,20 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"Spot",
 		NULL
 	};
+	static const char * const camera_auto_focus_area[] = {
+		"All",
+		"Spot",
+		"Rectangle",
+		"Face Detection",
+		NULL
+	};
+	static const char * const camera_auto_focus_range[] = {
+		"Auto",
+		"Normal",
+		"Macro",
+		"Infinity",
+		NULL
+	};
 	static const char * const colorfx[] = {
 		"None",
 		"Black & White",
@@ -459,6 +473,10 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return camera_exposure_auto;
 	case V4L2_CID_EXPOSURE_METERING:
 		return camera_exposure_metering;
+	case V4L2_CID_AUTO_FOCUS_AREA:
+		return camera_auto_focus_area;
+	case V4L2_CID_AUTO_FOCUS_RANGE:
+		return camera_auto_focus_range;
 	case V4L2_CID_COLORFX:
 		return colorfx;
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
@@ -646,7 +664,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_TILT_ABSOLUTE:		return "Tilt, Absolute";
 	case V4L2_CID_FOCUS_ABSOLUTE:		return "Focus, Absolute";
 	case V4L2_CID_FOCUS_RELATIVE:		return "Focus, Relative";
-	case V4L2_CID_FOCUS_AUTO:		return "Focus, Automatic";
+	case V4L2_CID_FOCUS_AUTO:		return "Focus, Automatic Continuous";
 	case V4L2_CID_ZOOM_ABSOLUTE:		return "Zoom, Absolute";
 	case V4L2_CID_ZOOM_RELATIVE:		return "Zoom, Relative";
 	case V4L2_CID_ZOOM_CONTINUOUS:		return "Zoom, Continuous";
@@ -662,6 +680,11 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_EXPOSURE_METERING:	return "Exposure, Metering Mode";
 	case V4L2_CID_SCENE_MODE:		return "Scene Mode";
 	case V4L2_CID_3A_LOCK:			return "3A Lock";
+	case V4L2_CID_AUTO_FOCUS_START:		return "Auto Focus, Start";
+	case V4L2_CID_AUTO_FOCUS_STOP:		return "Auto Focus, Stop";
+	case V4L2_CID_AUTO_FOCUS_STATUS:	return "Auto Focus, Status";
+	case V4L2_CID_AUTO_FOCUS_RANGE:		return "Auto Focus, Range";
+	case V4L2_CID_AUTO_FOCUS_AREA:		return "Auto Focus, Area";
 
 	/* FM Radio Modulator control */
 	/* Keep the order of the 'case's the same as in videodev2.h! */
@@ -763,6 +786,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_TILT_RESET:
 	case V4L2_CID_FLASH_STROBE:
 	case V4L2_CID_FLASH_STROBE_STOP:
+	case V4L2_CID_AUTO_FOCUS_START:
+	case V4L2_CID_AUTO_FOCUS_STOP:
 		*type = V4L2_CTRL_TYPE_BUTTON;
 		*flags |= V4L2_CTRL_FLAG_WRITE_ONLY;
 		*min = *max = *step = *def = 0;
@@ -786,6 +811,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_STREAM_TYPE:
 	case V4L2_CID_MPEG_STREAM_VBI_FMT:
 	case V4L2_CID_EXPOSURE_AUTO:
+	case V4L2_CID_AUTO_FOCUS_AREA:
+	case V4L2_CID_AUTO_FOCUS_RANGE:
 	case V4L2_CID_COLORFX:
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
 	case V4L2_CID_TUNE_PREEMPHASIS:
@@ -835,6 +862,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_FLASH_FAULT:
 	case V4L2_CID_JPEG_ACTIVE_MARKER:
 	case V4L2_CID_3A_LOCK:
+	case V4L2_CID_AUTO_FOCUS_STATUS:
 		*type = V4L2_CTRL_TYPE_BITMASK;
 		break;
 	case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
@@ -894,6 +922,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 		*flags |= V4L2_CTRL_FLAG_WRITE_ONLY;
 		break;
 	case V4L2_CID_FLASH_STROBE_STATUS:
+	case V4L2_CID_AUTO_FOCUS_STATUS:
 	case V4L2_CID_FLASH_READY:
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
 		break;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 4077d62..8e1ac9a 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1761,6 +1761,30 @@ enum v4l2_scene_mode {
 #define V4L2_LOCK_WHITE_BALANCE			(1 << 1)
 #define V4L2_LOCK_FOCUS				(1 << 2)
 
+#define V4L2_CID_AUTO_FOCUS_START		(V4L2_CID_CAMERA_CLASS_BASE+28)
+#define V4L2_CID_AUTO_FOCUS_STOP		(V4L2_CID_CAMERA_CLASS_BASE+29)
+#define V4L2_CID_AUTO_FOCUS_STATUS		(V4L2_CID_CAMERA_CLASS_BASE+30)
+#define V4L2_AUTO_FOCUS_STATUS_IDLE		(0 << 0)
+#define V4L2_AUTO_FOCUS_STATUS_BUSY		(1 << 0)
+#define V4L2_AUTO_FOCUS_STATUS_REACHED		(1 << 1)
+#define V4L2_AUTO_FOCUS_STATUS_FAILED		(1 << 2)
+
+#define V4L2_CID_AUTO_FOCUS_RANGE		(V4L2_CID_CAMERA_CLASS_BASE+31)
+enum v4l2_auto_focus_range {
+	V4L2_AUTO_FOCUS_RANGE_AUTO		= 0,
+	V4L2_AUTO_FOCUS_RANGE_NORMAL		= 1,
+	V4L2_AUTO_FOCUS_RANGE_MACRO		= 2,
+	V4L2_AUTO_FOCUS_RANGE_INFINITY		= 3,
+};
+
+#define V4L2_CID_AUTO_FOCUS_AREA		(V4L2_CID_CAMERA_CLASS_BASE+32)
+enum v4l2_auto_focus_area {
+	V4L2_AUTO_FOCUS_AREA_ALL		= 0,
+	V4L2_AUTO_FOCUS_AREA_SPOT		= 1,
+	V4L2_AUTO_FOCUS_AREA_RECTANGLE		= 2,
+	V4L2_AUTO_FOCUS_AREA_FACE_DETECTION	= 3,
+};
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS			(V4L2_CTRL_CLASS_FM_TX | 1)
-- 
1.7.10


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

* [PATCH 13/23] m5mols: Convert macros to inline functions
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (11 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 12/23] V4L: Add camera auto focus controls Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 14/23] m5mols: Refactored controls handling Sylwester Nawrocki
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Make to_sd and to_m5mols macros static inline functions
for better type safety.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 4b021e1..0acc3d6 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -21,11 +21,6 @@
 
 extern int m5mols_debug;
 
-#define to_m5mols(__sd)	container_of(__sd, struct m5mols_info, sd)
-
-#define to_sd(__ctrl) \
-	(&container_of(__ctrl->handler, struct m5mols_info, handle)->sd)
-
 enum m5mols_restype {
 	M5MOLS_RESTYPE_MONITOR,
 	M5MOLS_RESTYPE_CAPTURE,
@@ -296,4 +291,16 @@ int m5mols_set_ctrl(struct v4l2_ctrl *ctrl);
 int m5mols_update_fw(struct v4l2_subdev *sd,
 		     int (*set_power)(struct m5mols_info *, bool));
 
+static inline struct m5mols_info *to_m5mols(struct v4l2_subdev *subdev)
+{
+	return container_of(subdev, struct m5mols_info, sd);
+}
+
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+	struct m5mols_info *info = container_of(ctrl->handler,
+						struct m5mols_info, handle);
+	return &info->sd;
+}
+
 #endif	/* M5MOLS_H */
-- 
1.7.10


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

* [PATCH 14/23] m5mols: Refactored controls handling
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (12 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 13/23] m5mols: Convert macros to inline functions Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 15/23] m5mols: Use proper sensor mode for the controls Sylwester Nawrocki
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

This patch is a prerequisite for the new controls addition. It consolidates
the control handling code, which is moved to m5mols_controls.c and
staticized. The controls initialization is reordered to better reflect
the control clusters and make the diffs smaller when new controls are added.
To make the code easier to follow when more controls is added use separate
set function for each control.

Rewrite the image effect registers handling.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |   24 +--
 drivers/media/video/m5mols/m5mols_capture.c  |    4 +-
 drivers/media/video/m5mols/m5mols_controls.c |  227 ++++++++++++++++++++------
 drivers/media/video/m5mols/m5mols_core.c     |   93 +----------
 4 files changed, 198 insertions(+), 150 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 0acc3d6..ed75bbe 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -160,12 +160,12 @@ struct m5mols_version {
  * @irq_waitq: waitqueue for the capture
  * @flags: state variable for the interrupt handler
  * @handle: control handler
- * @autoexposure: Auto Exposure control
- * @exposure: Exposure control
+ * @auto_exposure: auto/manual exposure control
+ * @exposure: manual exposure control
  * @autowb: Auto White Balance control
- * @colorfx: Color effect control
- * @saturation:	Saturation control
- * @zoom: Zoom control
+ * @colorfx: color effect control
+ * @saturation: saturation control
+ * @zoom: zoom control
  * @ver: information of the version
  * @cap: the capture mode attributes
  * @power: current sensor's power status
@@ -188,12 +188,13 @@ struct m5mols_info {
 	atomic_t irq_done;
 
 	struct v4l2_ctrl_handler handle;
+	struct {
+		/* exposure/auto-exposure cluster */
+		struct v4l2_ctrl *auto_exposure;
+		struct v4l2_ctrl *exposure;
+	};
 
-	/* Autoexposure/exposure control cluster */
-	struct v4l2_ctrl *autoexposure;
-	struct v4l2_ctrl *exposure;
-
-	struct v4l2_ctrl *autowb;
+	struct v4l2_ctrl *auto_wb;
 	struct v4l2_ctrl *colorfx;
 	struct v4l2_ctrl *saturation;
 	struct v4l2_ctrl *zoom;
@@ -277,7 +278,7 @@ int m5mols_busy_wait(struct v4l2_subdev *sd, u32 reg, u32 value, u32 mask,
  * The available executing order between each modes are as follows:
  *   PARAMETER <---> MONITOR <---> CAPTURE
  */
-int m5mols_mode(struct m5mols_info *info, u8 mode);
+int m5mols_set_mode(struct m5mols_info *info, u8 mode);
 
 int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg);
 int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout);
@@ -286,6 +287,7 @@ int m5mols_start_capture(struct m5mols_info *info);
 int m5mols_do_scenemode(struct m5mols_info *info, u8 mode);
 int m5mols_lock_3a(struct m5mols_info *info, bool lock);
 int m5mols_set_ctrl(struct v4l2_ctrl *ctrl);
+int m5mols_init_controls(struct v4l2_subdev *sd);
 
 /* The firmware function */
 int m5mols_update_fw(struct v4l2_subdev *sd,
diff --git a/drivers/media/video/m5mols/m5mols_capture.c b/drivers/media/video/m5mols/m5mols_capture.c
index ba25e8e..4f27aed 100644
--- a/drivers/media/video/m5mols/m5mols_capture.c
+++ b/drivers/media/video/m5mols/m5mols_capture.c
@@ -114,7 +114,7 @@ int m5mols_start_capture(struct m5mols_info *info)
 	 * format. The frame capture is initiated during switching from Monitor
 	 * to Capture mode.
 	 */
-	ret = m5mols_mode(info, REG_MONITOR);
+	ret = m5mols_set_mode(info, REG_MONITOR);
 	if (!ret)
 		ret = m5mols_restore_controls(info);
 	if (!ret)
@@ -124,7 +124,7 @@ int m5mols_start_capture(struct m5mols_info *info)
 	if (!ret)
 		ret = m5mols_lock_3a(info, true);
 	if (!ret)
-		ret = m5mols_mode(info, REG_CAPTURE);
+		ret = m5mols_set_mode(info, REG_CAPTURE);
 	if (!ret)
 		/* Wait until a frame is captured to ISP internal memory */
 		ret = m5mols_wait_interrupt(sd, REG_INT_CAPTURE, 2000);
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index d135d20..464ec0c 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -169,7 +169,7 @@ int m5mols_do_scenemode(struct m5mols_info *info, u8 mode)
 	if (!ret)
 		ret = m5mols_write(sd, AE_ISO, scenemode.iso);
 	if (!ret)
-		ret = m5mols_mode(info, REG_CAPTURE);
+		ret = m5mols_set_mode(info, REG_CAPTURE);
 	if (!ret)
 		ret = m5mols_write(sd, CAPP_WDR_EN, scenemode.wdr);
 	if (!ret)
@@ -181,7 +181,7 @@ int m5mols_do_scenemode(struct m5mols_info *info, u8 mode)
 	if (!ret)
 		ret = m5mols_write(sd, CAPC_MODE, scenemode.capt_mode);
 	if (!ret)
-		ret = m5mols_mode(info, REG_MONITOR);
+		ret = m5mols_set_mode(info, REG_MONITOR);
 
 	return ret;
 }
@@ -227,73 +227,194 @@ int m5mols_lock_3a(struct m5mols_info *info, bool lock)
 	return ret;
 }
 
-/* m5mols_set_ctrl() - The main s_ctrl function called by m5mols_set_ctrl() */
-int m5mols_set_ctrl(struct v4l2_ctrl *ctrl)
+/* Set exposure/auto exposure cluster */
+static int m5mols_set_exposure(struct m5mols_info *info, int exposure)
+{
+	struct v4l2_subdev *sd = &info->sd;
+	int ret;
+
+	ret = m5mols_lock_ae(info, exposure != V4L2_EXPOSURE_AUTO);
+	if (ret < 0)
+		return ret;
+
+	if (exposure == V4L2_EXPOSURE_AUTO) {
+		ret = m5mols_write(sd, AE_MODE, REG_AE_ALL);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (exposure == V4L2_EXPOSURE_MANUAL) {
+		ret = m5mols_write(sd, AE_MODE, REG_AE_OFF);
+		if (ret == 0)
+			ret = m5mols_write(sd, AE_MAN_GAIN_MON,
+					   info->exposure->val);
+		if (ret == 0)
+			ret = m5mols_write(sd, AE_MAN_GAIN_CAP,
+					   info->exposure->val);
+	}
+
+	return ret;
+}
+
+static int m5mols_set_white_balance(struct m5mols_info *info, int awb)
+{
+	int ret;
+
+	ret = m5mols_lock_awb(info, !awb);
+	if (ret < 0)
+		return ret;
+
+	return m5mols_write(&info->sd, AWB_MODE, awb ? REG_AWB_AUTO :
+			    REG_AWB_PRESET);
+}
+
+static int m5mols_set_saturation(struct m5mols_info *info, int val)
+{
+	int ret = m5mols_write(&info->sd, MON_CHROMA_LVL, val);
+	if (ret < 0)
+		return ret;
+
+	return m5mols_write(&info->sd, MON_CHROMA_EN, REG_CHROMA_ON);
+}
+
+static int m5mols_set_color_effect(struct m5mols_info *info, int val)
+{
+	unsigned int m_effect = REG_COLOR_EFFECT_OFF;
+	unsigned int p_effect = REG_EFFECT_OFF;
+	unsigned int cfix_r = 0, cfix_b = 0;
+	struct v4l2_subdev *sd = &info->sd;
+	int ret = 0;
+
+	switch (val) {
+	case V4L2_COLORFX_BW:
+		m_effect = REG_COLOR_EFFECT_ON;
+		break;
+	case V4L2_COLORFX_NEGATIVE:
+		p_effect = REG_EFFECT_NEGA;
+		break;
+	case V4L2_COLORFX_EMBOSS:
+		p_effect = REG_EFFECT_EMBOSS;
+		break;
+	case V4L2_COLORFX_SEPIA:
+		m_effect = REG_COLOR_EFFECT_ON;
+		cfix_r = REG_CFIXR_SEPIA;
+		cfix_b = REG_CFIXB_SEPIA;
+		break;
+	}
+
+	ret = m5mols_write(sd, PARM_EFFECT, p_effect);
+	if (!ret)
+		ret = m5mols_write(sd, MON_EFFECT, m_effect);
+
+	if (ret == 0 && m_effect == REG_COLOR_EFFECT_ON) {
+		ret = m5mols_write(sd, MON_CFIXR, cfix_r);
+		if (!ret)
+			ret = m5mols_write(sd, MON_CFIXB, cfix_b);
+	}
+
+	v4l2_dbg(1, m5mols_debug, sd,
+		 "p_effect: %#x, m_effect: %#x, r: %#x, b: %#x (%d)\n",
+		 p_effect, m_effect, cfix_r, cfix_b, ret);
+
+	return ret;
+}
+
+static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 {
 	struct v4l2_subdev *sd = to_sd(ctrl);
 	struct m5mols_info *info = to_m5mols(sd);
+	int ispstate = info->mode;
 	int ret;
 
+	/*
+	 * If needed, defer restoring the controls until
+	 * the device is fully initialized.
+	 */
+	if (!info->isp_ready) {
+		info->ctrl_sync = 0;
+		return 0;
+	}
+
+	ret = m5mols_mode(info, REG_PARAMETER);
+	if (ret < 0)
+		return ret;
+
 	switch (ctrl->id) {
 	case V4L2_CID_ZOOM_ABSOLUTE:
-		return m5mols_write(sd, MON_ZOOM, ctrl->val);
+		ret = m5mols_write(sd, MON_ZOOM, ctrl->val);
+		break;
 
 	case V4L2_CID_EXPOSURE_AUTO:
-		ret = m5mols_lock_ae(info,
-			ctrl->val == V4L2_EXPOSURE_AUTO ? false : true);
-		if (!ret && ctrl->val == V4L2_EXPOSURE_AUTO)
-			ret = m5mols_write(sd, AE_MODE, REG_AE_ALL);
-		if (!ret && ctrl->val == V4L2_EXPOSURE_MANUAL) {
-			int val = info->exposure->val;
-			ret = m5mols_write(sd, AE_MODE, REG_AE_OFF);
-			if (!ret)
-				ret = m5mols_write(sd, AE_MAN_GAIN_MON, val);
-			if (!ret)
-				ret = m5mols_write(sd, AE_MAN_GAIN_CAP, val);
-		}
-		return ret;
+		ret = m5mols_set_exposure(info, ctrl->val);
+		break;
 
 	case V4L2_CID_AUTO_WHITE_BALANCE:
-		ret = m5mols_lock_awb(info, ctrl->val ? false : true);
-		if (!ret)
-			ret = m5mols_write(sd, AWB_MODE, ctrl->val ?
-				REG_AWB_AUTO : REG_AWB_PRESET);
-		return ret;
+		ret = m5mols_set_white_balance(info, ctrl->val);
+		break;
 
 	case V4L2_CID_SATURATION:
-		ret = m5mols_write(sd, MON_CHROMA_LVL, ctrl->val);
-		if (!ret)
-			ret = m5mols_write(sd, MON_CHROMA_EN, REG_CHROMA_ON);
-		return ret;
+		ret = m5mols_set_saturation(info, ctrl->val);
+		break;
 
 	case V4L2_CID_COLORFX:
-		/*
-		 * This control uses two kinds of registers: normal & color.
-		 * The normal effect belongs to category 1, while the color
-		 * one belongs to category 2.
-		 *
-		 * The normal effect uses one register: CAT1_EFFECT.
-		 * The color effect uses three registers:
-		 * CAT2_COLOR_EFFECT, CAT2_CFIXR, CAT2_CFIXB.
-		 */
-		ret = m5mols_write(sd, PARM_EFFECT,
-			ctrl->val == V4L2_COLORFX_NEGATIVE ? REG_EFFECT_NEGA :
-			ctrl->val == V4L2_COLORFX_EMBOSS ? REG_EFFECT_EMBOSS :
-			REG_EFFECT_OFF);
-		if (!ret)
-			ret = m5mols_write(sd, MON_EFFECT,
-				ctrl->val == V4L2_COLORFX_SEPIA ?
-				REG_COLOR_EFFECT_ON : REG_COLOR_EFFECT_OFF);
-		if (!ret)
-			ret = m5mols_write(sd, MON_CFIXR,
-				ctrl->val == V4L2_COLORFX_SEPIA ?
-				REG_CFIXR_SEPIA : 0);
-		if (!ret)
-			ret = m5mols_write(sd, MON_CFIXB,
-				ctrl->val == V4L2_COLORFX_SEPIA ?
-				REG_CFIXB_SEPIA : 0);
+		ret = m5mols_set_color_effect(info, ctrl->val);
+		break;
+	}
+	if (ret < 0)
+		return ret;
+
+	return m5mols_mode(info, ispstate);
+}
+
+static const struct v4l2_ctrl_ops m5mols_ctrl_ops = {
+	.s_ctrl			= m5mols_s_ctrl,
+};
+
+int m5mols_init_controls(struct v4l2_subdev *sd)
+{
+	struct m5mols_info *info = to_m5mols(sd);
+	u16 exposure_max;
+	u16 zoom_step;
+	int ret;
+
+	/* Determine the firmware dependant control range and step values */
+	ret = m5mols_read_u16(sd, AE_MAX_GAIN_MON, &exposure_max);
+	if (ret < 0)
+		return ret;
+
+	zoom_step = is_manufacturer(info, REG_SAMSUNG_OPTICS) ? 31 : 1;
+
+	v4l2_ctrl_handler_init(&info->handle, 6);
+
+	info->auto_wb = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1);
+
+	info->auto_exposure = v4l2_ctrl_new_std_menu(&info->handle,
+			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE_AUTO,
+			1, ~0x03, V4L2_EXPOSURE_AUTO);
+
+	info->exposure = v4l2_ctrl_new_std(&info->handle,
+			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE,
+			0, exposure_max, 1, exposure_max / 2);
+
+	info->saturation = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_SATURATION, 1, 5, 1, 3);
+
+	info->zoom = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_ZOOM_ABSOLUTE, 1, 70, zoom_step, 1);
+
+	info->colorfx = v4l2_ctrl_new_std_menu(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_COLORFX, 4, 0, V4L2_COLORFX_NONE);
+
+	if (info->handle.error) {
+		int ret = info->handle.error;
+		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);
+		v4l2_ctrl_handler_free(&info->handle);
 		return ret;
 	}
 
-	return -EINVAL;
+	v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false);
+	sd->ctrl_handler = &info->handle;
+
+	return 0;
 }
diff --git a/drivers/media/video/m5mols/m5mols_core.c b/drivers/media/video/m5mols/m5mols_core.c
index d718aee..ac7d28b 100644
--- a/drivers/media/video/m5mols/m5mols_core.c
+++ b/drivers/media/video/m5mols/m5mols_core.c
@@ -362,14 +362,14 @@ static int m5mols_reg_mode(struct v4l2_subdev *sd, u8 mode)
 }
 
 /**
- * m5mols_mode - manage the M-5MOLS's mode
+ * m5mols_set_mode - set the M-5MOLS controller mode
  * @mode: the required operation mode
  *
  * The commands of M-5MOLS are grouped into specific modes. Each functionality
- * can be guaranteed only when the sensor is operating in mode which which
- * a command belongs to.
+ * can be guaranteed only when the sensor is operating in mode which a command
+ * belongs to.
  */
-int m5mols_mode(struct m5mols_info *info, u8 mode)
+int m5mols_set_mode(struct m5mols_info *info, u8 mode)
 {
 	struct v4l2_subdev *sd = &info->sd;
 	int ret = -EINVAL;
@@ -645,13 +645,13 @@ static int m5mols_start_monitor(struct m5mols_info *info)
 	struct v4l2_subdev *sd = &info->sd;
 	int ret;
 
-	ret = m5mols_mode(info, REG_PARAMETER);
+	ret = m5mols_set_mode(info, REG_PARAMETER);
 	if (!ret)
 		ret = m5mols_write(sd, PARM_MON_SIZE, info->resolution);
 	if (!ret)
 		ret = m5mols_write(sd, PARM_MON_FPS, REG_FPS_30);
 	if (!ret)
-		ret = m5mols_mode(info, REG_MONITOR);
+		ret = m5mols_set_mode(info, REG_MONITOR);
 	if (!ret)
 		ret = m5mols_restore_controls(info);
 
@@ -674,42 +674,13 @@ static int m5mols_s_stream(struct v4l2_subdev *sd, int enable)
 		return ret;
 	}
 
-	return m5mols_mode(info, REG_PARAMETER);
+	return m5mols_set_mode(info, REG_PARAMETER);
 }
 
 static const struct v4l2_subdev_video_ops m5mols_video_ops = {
 	.s_stream	= m5mols_s_stream,
 };
 
-static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct v4l2_subdev *sd = to_sd(ctrl);
-	struct m5mols_info *info = to_m5mols(sd);
-	int ispstate = info->mode;
-	int ret;
-
-	/*
-	 * If needed, defer restoring the controls until
-	 * the device is fully initialized.
-	 */
-	if (!info->isp_ready) {
-		info->ctrl_sync = 0;
-		return 0;
-	}
-
-	ret = m5mols_mode(info, REG_PARAMETER);
-	if (ret < 0)
-		return ret;
-	ret = m5mols_set_ctrl(ctrl);
-	if (ret < 0)
-		return ret;
-	return m5mols_mode(info, ispstate);
-}
-
-static const struct v4l2_ctrl_ops m5mols_ctrl_ops = {
-	.s_ctrl	= m5mols_s_ctrl,
-};
-
 static int m5mols_sensor_power(struct m5mols_info *info, bool enable)
 {
 	struct v4l2_subdev *sd = &info->sd;
@@ -802,52 +773,6 @@ static int m5mols_fw_start(struct v4l2_subdev *sd)
 	return ret;
 }
 
-static int m5mols_init_controls(struct m5mols_info *info)
-{
-	struct v4l2_subdev *sd = &info->sd;
-	u16 max_exposure;
-	u16 step_zoom;
-	int ret;
-
-	/* Determine value's range & step of controls for various FW version */
-	ret = m5mols_read_u16(sd, AE_MAX_GAIN_MON, &max_exposure);
-	if (!ret)
-		step_zoom = is_manufacturer(info, REG_SAMSUNG_OPTICS) ? 31 : 1;
-	if (ret)
-		return ret;
-
-	v4l2_ctrl_handler_init(&info->handle, 6);
-	info->autowb = v4l2_ctrl_new_std(&info->handle,
-			&m5mols_ctrl_ops, V4L2_CID_AUTO_WHITE_BALANCE,
-			0, 1, 1, 0);
-	info->saturation = v4l2_ctrl_new_std(&info->handle,
-			&m5mols_ctrl_ops, V4L2_CID_SATURATION,
-			1, 5, 1, 3);
-	info->zoom = v4l2_ctrl_new_std(&info->handle,
-			&m5mols_ctrl_ops, V4L2_CID_ZOOM_ABSOLUTE,
-			1, 70, step_zoom, 1);
-	info->exposure = v4l2_ctrl_new_std(&info->handle,
-			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE,
-			0, max_exposure, 1, (int)max_exposure/2);
-	info->colorfx = v4l2_ctrl_new_std_menu(&info->handle,
-			&m5mols_ctrl_ops, V4L2_CID_COLORFX,
-			4, (1 << V4L2_COLORFX_BW), V4L2_COLORFX_NONE);
-	info->autoexposure = v4l2_ctrl_new_std_menu(&info->handle,
-			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE_AUTO,
-			1, 0, V4L2_EXPOSURE_AUTO);
-
-	sd->ctrl_handler = &info->handle;
-	if (info->handle.error) {
-		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);
-		v4l2_ctrl_handler_free(&info->handle);
-		return info->handle.error;
-	}
-
-	v4l2_ctrl_cluster(2, &info->autoexposure);
-
-	return 0;
-}
-
 /**
  * m5mols_s_power - Main sensor power control function
  *
@@ -868,7 +793,7 @@ static int m5mols_s_power(struct v4l2_subdev *sd, int on)
 	}
 
 	if (is_manufacturer(info, REG_SAMSUNG_TECHWIN)) {
-		ret = m5mols_mode(info, REG_MONITOR);
+		ret = m5mols_set_mode(info, REG_MONITOR);
 		if (!ret)
 			ret = m5mols_write(sd, AF_EXECUTE, REG_AF_STOP);
 		if (!ret)
@@ -1010,7 +935,7 @@ static int __devinit m5mols_probe(struct i2c_client *client,
 
 	ret = m5mols_fw_start(sd);
 	if (!ret)
-		ret = m5mols_init_controls(info);
+		ret = m5mols_init_controls(sd);
 
 	m5mols_sensor_power(info, false);
 	if (!ret)
-- 
1.7.10


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

* [PATCH 15/23] m5mols: Use proper sensor mode for the controls
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (13 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 14/23] m5mols: Refactored controls handling Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 16/23] m5mols: Add ISO sensitivity controls Sylwester Nawrocki
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

The parameters corresponding to the V4L controls can be reconfigured
only in associated M-5MOLS operation mode. Use struct v4l2_ctrl
priv field to assign the working mode to the controls which can be
modified only in certain conditions.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |   11 ++++++++++
 drivers/media/video/m5mols/m5mols_controls.c |   28 ++++++++++++++++++--------
 2 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index ed75bbe..87684c4 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -305,4 +305,15 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
 	return &info->sd;
 }
 
+static inline void m5mols_set_ctrl_mode(struct v4l2_ctrl *ctrl,
+					unsigned int mode)
+{
+	ctrl->priv = (void *)mode;
+}
+
+static inline unsigned int m5mols_get_ctrl_mode(struct v4l2_ctrl *ctrl)
+{
+	return (unsigned int)ctrl->priv;
+}
+
 #endif	/* M5MOLS_H */
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 464ec0c..4776601 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -321,10 +321,11 @@ static int m5mols_set_color_effect(struct m5mols_info *info, int val)
 
 static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+	unsigned int ctrl_mode = m5mols_get_ctrl_mode(ctrl);
 	struct v4l2_subdev *sd = to_sd(ctrl);
 	struct m5mols_info *info = to_m5mols(sd);
-	int ispstate = info->mode;
-	int ret;
+	int last_mode = info->mode;
+	int ret = 0;
 
 	/*
 	 * If needed, defer restoring the controls until
@@ -335,9 +336,14 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 		return 0;
 	}
 
-	ret = m5mols_mode(info, REG_PARAMETER);
-	if (ret < 0)
-		return ret;
+	v4l2_dbg(1, m5mols_debug, sd, "%s: %s, val: %d, priv: %#x\n",
+		 __func__, ctrl->name, ctrl->val, (int)ctrl->priv);
+
+	if (ctrl_mode && ctrl_mode != info->mode) {
+		ret = m5mols_set_mode(info, ctrl_mode);
+		if (ret < 0)
+			return ret;
+	}
 
 	switch (ctrl->id) {
 	case V4L2_CID_ZOOM_ABSOLUTE:
@@ -360,10 +366,11 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 		ret = m5mols_set_color_effect(info, ctrl->val);
 		break;
 	}
-	if (ret < 0)
-		return ret;
 
-	return m5mols_mode(info, ispstate);
+	if (ret == 0 && info->mode != last_mode)
+		ret = m5mols_set_mode(info, last_mode);
+
+	return ret;
 }
 
 static const struct v4l2_ctrl_ops m5mols_ctrl_ops = {
@@ -414,6 +421,11 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 	}
 
 	v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false);
+
+	m5mols_set_ctrl_mode(info->auto_exposure, REG_PARAMETER);
+	m5mols_set_ctrl_mode(info->auto_wb, REG_PARAMETER);
+	m5mols_set_ctrl_mode(info->colorfx, REG_MONITOR);
+
 	sd->ctrl_handler = &info->handle;
 
 	return 0;
-- 
1.7.10


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

* [PATCH 16/23] m5mols: Add ISO sensitivity controls
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (14 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 15/23] m5mols: Use proper sensor mode for the controls Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 17/23] m5mols: Add auto and preset white balance control Sylwester Nawrocki
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add controls for manual/auto ISO sensitivity.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |    7 ++++
 drivers/media/video/m5mols/m5mols_controls.c |   56 ++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 87684c4..598bb0f 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -162,6 +162,8 @@ struct m5mols_version {
  * @handle: control handler
  * @auto_exposure: auto/manual exposure control
  * @exposure: manual exposure control
+ * @auto_iso: auto/manual ISO sensitivity control
+ * @iso: manual ISO sensitivity control
  * @autowb: Auto White Balance control
  * @colorfx: color effect control
  * @saturation: saturation control
@@ -193,6 +195,11 @@ struct m5mols_info {
 		struct v4l2_ctrl *auto_exposure;
 		struct v4l2_ctrl *exposure;
 	};
+	struct {
+		/* iso/auto iso cluster */
+		struct v4l2_ctrl *auto_iso;
+		struct v4l2_ctrl *iso;
+	};
 
 	struct v4l2_ctrl *auto_wb;
 	struct v4l2_ctrl *colorfx;
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 4776601..f1c8850 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -319,6 +319,39 @@ static int m5mols_set_color_effect(struct m5mols_info *info, int val)
 	return ret;
 }
 
+static int m5mols_set_iso(struct m5mols_info *info, int auto_iso)
+{
+	u32 iso = auto_iso ? 0 : info->iso->val + 1;
+
+	return m5mols_write(&info->sd, AE_ISO, iso);
+}
+
+static int m5mols_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct v4l2_subdev *sd = to_sd(ctrl);
+	struct m5mols_info *info = to_m5mols(sd);
+	int ret = 0;
+	u8 status;
+
+	v4l2_dbg(1, m5mols_debug, sd, "%s: ctrl: %s (%d)\n",
+		 __func__, ctrl->name, info->isp_ready);
+
+	if (!info->isp_ready)
+		return -EBUSY;
+
+	switch (ctrl->id) {
+	case V4L2_CID_ISO_SENSITIVITY_AUTO:
+		ret = m5mols_read_u8(sd, AE_ISO, &status);
+		if (ret == 0)
+			ctrl->val = !status;
+		if (status != REG_ISO_AUTO)
+			info->iso->val = status - 1;
+		break;
+	}
+
+	return ret;
+}
+
 static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 {
 	unsigned int ctrl_mode = m5mols_get_ctrl_mode(ctrl);
@@ -354,6 +387,10 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 		ret = m5mols_set_exposure(info, ctrl->val);
 		break;
 
+	case V4L2_CID_ISO_SENSITIVITY:
+		ret = m5mols_set_iso(info, ctrl->val);
+		break;
+
 	case V4L2_CID_AUTO_WHITE_BALANCE:
 		ret = m5mols_set_white_balance(info, ctrl->val);
 		break;
@@ -374,9 +411,16 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 }
 
 static const struct v4l2_ctrl_ops m5mols_ctrl_ops = {
+	.g_volatile_ctrl	= m5mols_g_volatile_ctrl,
 	.s_ctrl			= m5mols_s_ctrl,
 };
 
+/* Supported manual ISO values */
+static const s64 iso_qmenu[] = {
+	/* AE_ISO: 0x01...0x07 */
+	50, 100, 200, 400, 800, 1600, 3200
+};
+
 int m5mols_init_controls(struct v4l2_subdev *sd)
 {
 	struct m5mols_info *info = to_m5mols(sd);
@@ -404,6 +448,14 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE,
 			0, exposure_max, 1, exposure_max / 2);
 
+	/* ISO control cluster */
+	info->auto_iso = v4l2_ctrl_new_std_menu(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_ISO_SENSITIVITY_AUTO, 1, ~0x03, 1);
+
+	info->iso = v4l2_ctrl_new_int_menu(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_ISO_SENSITIVITY, ARRAY_SIZE(iso_qmenu) - 1,
+			ARRAY_SIZE(iso_qmenu)/2 - 1, iso_qmenu);
+
 	info->saturation = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
 			V4L2_CID_SATURATION, 1, 5, 1, 3);
 
@@ -422,6 +474,10 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 
 	v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false);
 
+	info->auto_iso->flags |= V4L2_CTRL_FLAG_VOLATILE |
+				V4L2_CTRL_FLAG_UPDATE;
+	v4l2_ctrl_auto_cluster(2, &info->auto_iso, 0, false);
+
 	m5mols_set_ctrl_mode(info->auto_exposure, REG_PARAMETER);
 	m5mols_set_ctrl_mode(info->auto_wb, REG_PARAMETER);
 	m5mols_set_ctrl_mode(info->colorfx, REG_MONITOR);
-- 
1.7.10


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

* [PATCH 17/23] m5mols: Add auto and preset white balance control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (15 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 16/23] m5mols: Add ISO sensitivity controls Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 18/23] m5mols: Add exposure bias control Sylwester Nawrocki
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |    4 +--
 drivers/media/video/m5mols/m5mols_controls.c |   47 ++++++++++++++++++++------
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 598bb0f..fa1f2c1 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -164,7 +164,7 @@ struct m5mols_version {
  * @exposure: manual exposure control
  * @auto_iso: auto/manual ISO sensitivity control
  * @iso: manual ISO sensitivity control
- * @autowb: Auto White Balance control
+ * @auto_wb: auto white balance control
  * @colorfx: color effect control
  * @saturation: saturation control
  * @zoom: zoom control
@@ -200,8 +200,8 @@ struct m5mols_info {
 		struct v4l2_ctrl *auto_iso;
 		struct v4l2_ctrl *iso;
 	};
-
 	struct v4l2_ctrl *auto_wb;
+
 	struct v4l2_ctrl *colorfx;
 	struct v4l2_ctrl *saturation;
 	struct v4l2_ctrl *zoom;
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index f1c8850..1ab21f0 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -256,16 +256,42 @@ static int m5mols_set_exposure(struct m5mols_info *info, int exposure)
 	return ret;
 }
 
-static int m5mols_set_white_balance(struct m5mols_info *info, int awb)
+static int m5mols_set_white_balance(struct m5mols_info *info, int val)
 {
-	int ret;
+	static const unsigned short wb[][2] = {
+		{ V4L2_WHITE_BALANCE_INCANDESCENT,  REG_AWB_INCANDESCENT },
+		{ V4L2_WHITE_BALANCE_FLUORESCENT,   REG_AWB_FLUORESCENT_1 },
+		{ V4L2_WHITE_BALANCE_FLUORESCENT_H, REG_AWB_FLUORESCENT_2 },
+		{ V4L2_WHITE_BALANCE_HORIZON,       REG_AWB_HORIZON },
+		{ V4L2_WHITE_BALANCE_DAYLIGHT,      REG_AWB_DAYLIGHT },
+		{ V4L2_WHITE_BALANCE_FLASH,         REG_AWB_LEDLIGHT },
+		{ V4L2_WHITE_BALANCE_CLOUDY,        REG_AWB_CLOUDY },
+		{ V4L2_WHITE_BALANCE_SHADE,         REG_AWB_SHADE },
+		{ V4L2_WHITE_BALANCE_AUTO,          REG_AWB_AUTO },
+	};
+	int i;
+	struct v4l2_subdev *sd = &info->sd;
+	int ret = -EINVAL;
 
-	ret = m5mols_lock_awb(info, !awb);
-	if (ret < 0)
-		return ret;
+	for (i = 0; i < ARRAY_SIZE(wb); i++) {
+		int awb;
+		if (wb[i][0] != val)
+			continue;
+
+		v4l2_dbg(1, m5mols_debug, sd,
+			 "Setting white balance to: %#x\n", wb[i][0]);
 
-	return m5mols_write(&info->sd, AWB_MODE, awb ? REG_AWB_AUTO :
-			    REG_AWB_PRESET);
+		awb = wb[i][0] == V4L2_WHITE_BALANCE_AUTO;
+		ret = m5mols_write(sd, AWB_MODE, awb ? REG_AWB_AUTO :
+						 REG_AWB_PRESET);
+		if (ret < 0)
+			return ret;
+
+		if (!awb)
+			ret = m5mols_write(sd, AWB_MANUAL, wb[i][1]);
+	}
+
+	return ret;
 }
 
 static int m5mols_set_saturation(struct m5mols_info *info, int val)
@@ -391,7 +417,7 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 		ret = m5mols_set_iso(info, ctrl->val);
 		break;
 
-	case V4L2_CID_AUTO_WHITE_BALANCE:
+	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
 		ret = m5mols_set_white_balance(info, ctrl->val);
 		break;
 
@@ -437,8 +463,9 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 
 	v4l2_ctrl_handler_init(&info->handle, 6);
 
-	info->auto_wb = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
-			V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1);
+	info->auto_wb = v4l2_ctrl_new_std_menu(&info->handle,
+			&m5mols_ctrl_ops, V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
+			9, ~0x3fe, V4L2_WHITE_BALANCE_AUTO);
 
 	info->auto_exposure = v4l2_ctrl_new_std_menu(&info->handle,
 			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE_AUTO,
-- 
1.7.10


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

* [PATCH 18/23] m5mols: Add exposure bias control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (16 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 17/23] m5mols: Add auto and preset white balance control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 19/23] m5mols: Add wide dynamic range control Sylwester Nawrocki
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add integer menu control for exposure bias. The control value range is
-2.0 EV to +2.0 EV, in 0.5 EV steps.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |    4 +++-
 drivers/media/video/m5mols/m5mols_controls.c |   24 ++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index fa1f2c1..03421fc 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -161,6 +161,7 @@ struct m5mols_version {
  * @flags: state variable for the interrupt handler
  * @handle: control handler
  * @auto_exposure: auto/manual exposure control
+ * @exposure_bias: exposure compensation control
  * @exposure: manual exposure control
  * @auto_iso: auto/manual ISO sensitivity control
  * @iso: manual ISO sensitivity control
@@ -191,8 +192,9 @@ struct m5mols_info {
 
 	struct v4l2_ctrl_handler handle;
 	struct {
-		/* exposure/auto-exposure cluster */
+		/* exposure/exposure bias/auto exposure cluster */
 		struct v4l2_ctrl *auto_exposure;
+		struct v4l2_ctrl *exposure_bias;
 		struct v4l2_ctrl *exposure;
 	};
 	struct {
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 1ab21f0..7978363 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -241,6 +241,11 @@ static int m5mols_set_exposure(struct m5mols_info *info, int exposure)
 		ret = m5mols_write(sd, AE_MODE, REG_AE_ALL);
 		if (ret < 0)
 			return ret;
+
+		v4l2_dbg(1, m5mols_debug, sd, "%s: exposure bias: %#x\n",
+			 __func__, info->exposure_bias->val);
+
+		return m5mols_write(sd, AE_INDEX, info->exposure_bias->val);
 	}
 
 	if (exposure == V4L2_EXPOSURE_MANUAL) {
@@ -251,6 +256,9 @@ static int m5mols_set_exposure(struct m5mols_info *info, int exposure)
 		if (ret == 0)
 			ret = m5mols_write(sd, AE_MAN_GAIN_CAP,
 					   info->exposure->val);
+
+		v4l2_dbg(1, m5mols_debug, sd, "%s: exposure: %#x\n",
+			 __func__, info->exposure->val);
 	}
 
 	return ret;
@@ -447,6 +455,12 @@ static const s64 iso_qmenu[] = {
 	50, 100, 200, 400, 800, 1600, 3200
 };
 
+/* Supported Exposure Bias values, -2.0EV...+2.0EV */
+static const s64 ev_bias_qmenu[] = {
+	/* AE_INDEX: 0x00...0x08 */
+	-2000, -1500, -1000, -500, 0, 500, 1000, 1500, 2000
+};
+
 int m5mols_init_controls(struct v4l2_subdev *sd)
 {
 	struct m5mols_info *info = to_m5mols(sd);
@@ -467,6 +481,7 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 			&m5mols_ctrl_ops, V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
 			9, ~0x3fe, V4L2_WHITE_BALANCE_AUTO);
 
+	/* Exposure control cluster */
 	info->auto_exposure = v4l2_ctrl_new_std_menu(&info->handle,
 			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE_AUTO,
 			1, ~0x03, V4L2_EXPOSURE_AUTO);
@@ -475,6 +490,12 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE,
 			0, exposure_max, 1, exposure_max / 2);
 
+	info->exposure_bias = v4l2_ctrl_new_int_menu(&info->handle,
+			&m5mols_ctrl_ops, V4L2_CID_AUTO_EXPOSURE_BIAS,
+			ARRAY_SIZE(ev_bias_qmenu) - 1,
+			ARRAY_SIZE(ev_bias_qmenu)/2 - 1,
+			ev_bias_qmenu);
+
 	/* ISO control cluster */
 	info->auto_iso = v4l2_ctrl_new_std_menu(&info->handle, &m5mols_ctrl_ops,
 			V4L2_CID_ISO_SENSITIVITY_AUTO, 1, ~0x03, 1);
@@ -499,8 +520,7 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 		return ret;
 	}
 
-	v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false);
-
+	v4l2_ctrl_auto_cluster(3, &info->auto_exposure, 1, false);
 	info->auto_iso->flags |= V4L2_CTRL_FLAG_VOLATILE |
 				V4L2_CTRL_FLAG_UPDATE;
 	v4l2_ctrl_auto_cluster(2, &info->auto_iso, 0, false);
-- 
1.7.10


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

* [PATCH 19/23] m5mols: Add wide dynamic range control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (17 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 18/23] m5mols: Add exposure bias control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 20/23] m5mols: Add image stabilization control Sylwester Nawrocki
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |    2 ++
 drivers/media/video/m5mols/m5mols_controls.c |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 03421fc..978a4ab 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -169,6 +169,7 @@ struct m5mols_version {
  * @colorfx: color effect control
  * @saturation: saturation control
  * @zoom: zoom control
+ * @wdr: wide dynamic range control
  * @ver: information of the version
  * @cap: the capture mode attributes
  * @power: current sensor's power status
@@ -207,6 +208,7 @@ struct m5mols_info {
 	struct v4l2_ctrl *colorfx;
 	struct v4l2_ctrl *saturation;
 	struct v4l2_ctrl *zoom;
+	struct v4l2_ctrl *wdr;
 
 	struct m5mols_version ver;
 	struct m5mols_capture cap;
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 7978363..512c360 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -360,6 +360,21 @@ static int m5mols_set_iso(struct m5mols_info *info, int auto_iso)
 	return m5mols_write(&info->sd, AE_ISO, iso);
 }
 
+static int m5mols_set_wdr(struct m5mols_info *info, int wdr)
+{
+	int ret;
+
+	ret = m5mols_write(&info->sd, MON_TONE_CTL, wdr ? 9 : 5);
+	if (ret < 0)
+		return ret;
+
+	ret = m5mols_set_mode(info, REG_CAPTURE);
+	if (ret < 0)
+		return ret;
+
+	return m5mols_write(&info->sd, CAPP_WDR_EN, wdr);
+}
+
 static int m5mols_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 {
 	struct v4l2_subdev *sd = to_sd(ctrl);
@@ -436,6 +451,10 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 	case V4L2_CID_COLORFX:
 		ret = m5mols_set_color_effect(info, ctrl->val);
 		break;
+
+	case V4L2_CID_WIDE_DYNAMIC_RANGE:
+		ret = m5mols_set_wdr(info, ctrl->val);
+		break;
 	}
 
 	if (ret == 0 && info->mode != last_mode)
@@ -513,6 +532,9 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 	info->colorfx = v4l2_ctrl_new_std_menu(&info->handle, &m5mols_ctrl_ops,
 			V4L2_CID_COLORFX, 4, 0, V4L2_COLORFX_NONE);
 
+	info->wdr = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_WIDE_DYNAMIC_RANGE, 0, 1, 1, 0);
+
 	if (info->handle.error) {
 		int ret = info->handle.error;
 		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);
-- 
1.7.10


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

* [PATCH 20/23] m5mols: Add image stabilization control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (18 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 19/23] m5mols: Add wide dynamic range control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 21/23] m5mols: Add exposure metering control Sylwester Nawrocki
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |    2 ++
 drivers/media/video/m5mols/m5mols_controls.c |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 978a4ab..305a75b 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -170,6 +170,7 @@ struct m5mols_version {
  * @saturation: saturation control
  * @zoom: zoom control
  * @wdr: wide dynamic range control
+ * @stabilization: image stabilization control
  * @ver: information of the version
  * @cap: the capture mode attributes
  * @power: current sensor's power status
@@ -209,6 +210,7 @@ struct m5mols_info {
 	struct v4l2_ctrl *saturation;
 	struct v4l2_ctrl *zoom;
 	struct v4l2_ctrl *wdr;
+	struct v4l2_ctrl *stabilization;
 
 	struct m5mols_version ver;
 	struct m5mols_capture cap;
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 512c360..6c607d4 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -375,6 +375,19 @@ static int m5mols_set_wdr(struct m5mols_info *info, int wdr)
 	return m5mols_write(&info->sd, CAPP_WDR_EN, wdr);
 }
 
+static int m5mols_set_stabilization(struct m5mols_info *info, int val)
+{
+	struct v4l2_subdev *sd = &info->sd;
+	unsigned int evp = val ? 0xe : 0x0;
+	int ret;
+
+	ret = m5mols_write(sd, AE_EV_PRESET_MONITOR, evp);
+	if (ret < 0)
+		return ret;
+
+	return m5mols_write(sd, AE_EV_PRESET_CAPTURE, evp);
+}
+
 static int m5mols_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 {
 	struct v4l2_subdev *sd = to_sd(ctrl);
@@ -455,6 +468,10 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 	case V4L2_CID_WIDE_DYNAMIC_RANGE:
 		ret = m5mols_set_wdr(info, ctrl->val);
 		break;
+
+	case V4L2_CID_IMAGE_STABILIZATION:
+		ret = m5mols_set_stabilization(info, ctrl->val);
+		break;
 	}
 
 	if (ret == 0 && info->mode != last_mode)
@@ -535,6 +552,9 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 	info->wdr = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
 			V4L2_CID_WIDE_DYNAMIC_RANGE, 0, 1, 1, 0);
 
+	info->stabilization = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_IMAGE_STABILIZATION, 0, 1, 1, 0);
+
 	if (info->handle.error) {
 		int ret = info->handle.error;
 		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);
-- 
1.7.10


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

* [PATCH 21/23] m5mols: Add exposure metering control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (19 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 20/23] m5mols: Add image stabilization control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 22/23] m5mols: Add JPEG compression quality control Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 23/23] m5mols: Add 3A lock control Sylwester Nawrocki
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

This patch adds V4L2_CID_EXPOSURE_METERING control which allows
to select the light metering mode for automatic exposure as one
of the following modes: spot (small area at the frame center),
center weighted and frame averaged.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |    2 ++
 drivers/media/video/m5mols/m5mols_controls.c |   34 ++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 305a75b..b783465 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -163,6 +163,7 @@ struct m5mols_version {
  * @auto_exposure: auto/manual exposure control
  * @exposure_bias: exposure compensation control
  * @exposure: manual exposure control
+ * @metering: exposure metering control
  * @auto_iso: auto/manual ISO sensitivity control
  * @iso: manual ISO sensitivity control
  * @auto_wb: auto white balance control
@@ -198,6 +199,7 @@ struct m5mols_info {
 		struct v4l2_ctrl *auto_exposure;
 		struct v4l2_ctrl *exposure_bias;
 		struct v4l2_ctrl *exposure;
+		struct v4l2_ctrl *metering;
 	};
 	struct {
 		/* iso/auto iso cluster */
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 6c607d4..ebc3a904 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -227,7 +227,25 @@ int m5mols_lock_3a(struct m5mols_info *info, bool lock)
 	return ret;
 }
 
-/* Set exposure/auto exposure cluster */
+static int m5mols_set_metering_mode(struct m5mols_info *info, int mode)
+{
+	unsigned int metering;
+
+	switch (mode) {
+	case V4L2_EXPOSURE_METERING_CENTER_WEIGHTED:
+		metering = REG_AE_CENTER;
+		break;
+	case V4L2_EXPOSURE_METERING_SPOT:
+		metering = REG_AE_SPOT;
+		break;
+	default:
+		metering = REG_AE_ALL;
+		break;
+	}
+
+	return m5mols_write(&info->sd, AE_MODE, metering);
+}
+
 static int m5mols_set_exposure(struct m5mols_info *info, int exposure)
 {
 	struct v4l2_subdev *sd = &info->sd;
@@ -238,12 +256,14 @@ static int m5mols_set_exposure(struct m5mols_info *info, int exposure)
 		return ret;
 
 	if (exposure == V4L2_EXPOSURE_AUTO) {
-		ret = m5mols_write(sd, AE_MODE, REG_AE_ALL);
+		ret = m5mols_set_metering_mode(info, info->metering->val);
 		if (ret < 0)
 			return ret;
 
-		v4l2_dbg(1, m5mols_debug, sd, "%s: exposure bias: %#x\n",
-			 __func__, info->exposure_bias->val);
+		v4l2_dbg(1, m5mols_debug, sd,
+			 "%s: exposure bias: %#x, metering: %#x\n",
+			 __func__, info->exposure_bias->val,
+			 info->metering->val);
 
 		return m5mols_write(sd, AE_INDEX, info->exposure_bias->val);
 	}
@@ -532,6 +552,10 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 			ARRAY_SIZE(ev_bias_qmenu)/2 - 1,
 			ev_bias_qmenu);
 
+	info->metering = v4l2_ctrl_new_std_menu(&info->handle,
+			&m5mols_ctrl_ops, V4L2_CID_EXPOSURE_METERING,
+			2, ~0x7, V4L2_EXPOSURE_METERING_AVERAGE);
+
 	/* ISO control cluster */
 	info->auto_iso = v4l2_ctrl_new_std_menu(&info->handle, &m5mols_ctrl_ops,
 			V4L2_CID_ISO_SENSITIVITY_AUTO, 1, ~0x03, 1);
@@ -562,7 +586,7 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 		return ret;
 	}
 
-	v4l2_ctrl_auto_cluster(3, &info->auto_exposure, 1, false);
+	v4l2_ctrl_auto_cluster(4, &info->auto_exposure, 1, false);
 	info->auto_iso->flags |= V4L2_CTRL_FLAG_VOLATILE |
 				V4L2_CTRL_FLAG_UPDATE;
 	v4l2_ctrl_auto_cluster(2, &info->auto_iso, 0, false);
-- 
1.7.10


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

* [PATCH 22/23] m5mols: Add JPEG compression quality control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (20 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 21/23] m5mols: Add exposure metering control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  2012-05-10 10:30 ` [PATCH 23/23] m5mols: Add 3A lock control Sylwester Nawrocki
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |    2 ++
 drivers/media/video/m5mols/m5mols_controls.c |   10 ++++++++--
 drivers/media/video/m5mols/m5mols_reg.h      |    1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index b783465..00f8d31 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -172,6 +172,7 @@ struct m5mols_version {
  * @zoom: zoom control
  * @wdr: wide dynamic range control
  * @stabilization: image stabilization control
+ * @jpeg_quality: JPEG compression quality control
  * @ver: information of the version
  * @cap: the capture mode attributes
  * @power: current sensor's power status
@@ -213,6 +214,7 @@ struct m5mols_info {
 	struct v4l2_ctrl *zoom;
 	struct v4l2_ctrl *wdr;
 	struct v4l2_ctrl *stabilization;
+	struct v4l2_ctrl *jpeg_quality;
 
 	struct m5mols_version ver;
 	struct m5mols_capture cap;
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index ebc3a904..1c3b1e0 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -492,6 +492,10 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 	case V4L2_CID_IMAGE_STABILIZATION:
 		ret = m5mols_set_stabilization(info, ctrl->val);
 		break;
+
+	case V4L2_CID_JPEG_COMPRESSION_QUALITY:
+		ret = m5mols_write(sd, CAPP_JPEG_RATIO, ctrl->val);
+		break;
 	}
 
 	if (ret == 0 && info->mode != last_mode)
@@ -530,8 +534,7 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 		return ret;
 
 	zoom_step = is_manufacturer(info, REG_SAMSUNG_OPTICS) ? 31 : 1;
-
-	v4l2_ctrl_handler_init(&info->handle, 6);
+	v4l2_ctrl_handler_init(&info->handle, 20);
 
 	info->auto_wb = v4l2_ctrl_new_std_menu(&info->handle,
 			&m5mols_ctrl_ops, V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
@@ -579,6 +582,9 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 	info->stabilization = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
 			V4L2_CID_IMAGE_STABILIZATION, 0, 1, 1, 0);
 
+	info->jpeg_quality = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_JPEG_COMPRESSION_QUALITY, 1, 100, 1, 80);
+
 	if (info->handle.error) {
 		int ret = info->handle.error;
 		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);
diff --git a/drivers/media/video/m5mols/m5mols_reg.h b/drivers/media/video/m5mols/m5mols_reg.h
index ae4aced..14d4be7 100644
--- a/drivers/media/video/m5mols/m5mols_reg.h
+++ b/drivers/media/video/m5mols/m5mols_reg.h
@@ -310,6 +310,7 @@
 #define REG_JPEG		0x10
 
 #define CAPP_MAIN_IMAGE_SIZE	I2C_REG(CAT_CAPT_PARM, 0x01, 1)
+#define CAPP_JPEG_RATIO		I2C_REG(CAT_CAPT_PARM, 0x17, 1)
 
 #define CAPP_MCC_MODE		I2C_REG(CAT_CAPT_PARM, 0x1d, 1)
 #define REG_MCC_OFF		0x00
-- 
1.7.10


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

* [PATCH 23/23] m5mols: Add 3A lock control
  2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
                   ` (21 preceding siblings ...)
  2012-05-10 10:30 ` [PATCH 22/23] m5mols: Add JPEG compression quality control Sylwester Nawrocki
@ 2012-05-10 10:30 ` Sylwester Nawrocki
  22 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-10 10:30 UTC (permalink / raw)
  To: linux-media
  Cc: m.szyprowski, riverful.kim, sw0312.kim, s.nawrocki, Kyungmin Park

Add control for locking automatic exposure, focus and white balance
adjustments. While at it, tidy up the data structure documentation.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/video/m5mols/m5mols.h          |   10 ++-
 drivers/media/video/m5mols/m5mols_capture.c  |    7 +-
 drivers/media/video/m5mols/m5mols_controls.c |   89 ++++++++++++++++----------
 3 files changed, 60 insertions(+), 46 deletions(-)

diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 00f8d31..bb58991 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -158,7 +158,7 @@ struct m5mols_version {
  * @ffmt: current fmt according to resolution type
  * @res_type: current resolution type
  * @irq_waitq: waitqueue for the capture
- * @flags: state variable for the interrupt handler
+ * @irq_done: set to 1 in the interrupt handler
  * @handle: control handler
  * @auto_exposure: auto/manual exposure control
  * @exposure_bias: exposure compensation control
@@ -167,6 +167,7 @@ struct m5mols_version {
  * @auto_iso: auto/manual ISO sensitivity control
  * @iso: manual ISO sensitivity control
  * @auto_wb: auto white balance control
+ * @lock_3a: 3A lock control
  * @colorfx: color effect control
  * @saturation: saturation control
  * @zoom: zoom control
@@ -175,11 +176,9 @@ struct m5mols_version {
  * @jpeg_quality: JPEG compression quality control
  * @ver: information of the version
  * @cap: the capture mode attributes
- * @power: current sensor's power status
  * @isp_ready: 1 when the ISP controller has completed booting
+ * @power: current sensor's power status
  * @ctrl_sync: 1 when the control handler state is restored in H/W
- * @lock_ae: true means the Auto Exposure is locked
- * @lock_awb: true means the Aut WhiteBalance is locked
  * @resolution:	register value for current resolution
  * @mode: register value for current operation mode
  * @set_power: optional power callback to the board code
@@ -209,6 +208,7 @@ struct m5mols_info {
 	};
 	struct v4l2_ctrl *auto_wb;
 
+	struct v4l2_ctrl *lock_3a;
 	struct v4l2_ctrl *colorfx;
 	struct v4l2_ctrl *saturation;
 	struct v4l2_ctrl *zoom;
@@ -223,8 +223,6 @@ struct m5mols_info {
 	unsigned int power:1;
 	unsigned int ctrl_sync:1;
 
-	bool lock_ae;
-	bool lock_awb;
 	u8 resolution;
 	u8 mode;
 
diff --git a/drivers/media/video/m5mols/m5mols_capture.c b/drivers/media/video/m5mols/m5mols_capture.c
index 4f27aed..cb243bd 100644
--- a/drivers/media/video/m5mols/m5mols_capture.c
+++ b/drivers/media/video/m5mols/m5mols_capture.c
@@ -106,7 +106,6 @@ static int m5mols_capture_info(struct m5mols_info *info)
 int m5mols_start_capture(struct m5mols_info *info)
 {
 	struct v4l2_subdev *sd = &info->sd;
-	u8 resolution = info->resolution;
 	int ret;
 
 	/*
@@ -120,16 +119,12 @@ int m5mols_start_capture(struct m5mols_info *info)
 	if (!ret)
 		ret = m5mols_write(sd, CAPP_YUVOUT_MAIN, REG_JPEG);
 	if (!ret)
-		ret = m5mols_write(sd, CAPP_MAIN_IMAGE_SIZE, resolution);
-	if (!ret)
-		ret = m5mols_lock_3a(info, true);
+		ret = m5mols_write(sd, CAPP_MAIN_IMAGE_SIZE, info->resolution);
 	if (!ret)
 		ret = m5mols_set_mode(info, REG_CAPTURE);
 	if (!ret)
 		/* Wait until a frame is captured to ISP internal memory */
 		ret = m5mols_wait_interrupt(sd, REG_INT_CAPTURE, 2000);
-	if (!ret)
-		ret = m5mols_lock_3a(info, false);
 	if (ret)
 		return ret;
 
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 1c3b1e0..392a028 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -139,7 +139,7 @@ int m5mols_do_scenemode(struct m5mols_info *info, u8 mode)
 	if (mode > REG_SCENE_CANDLE)
 		return -EINVAL;
 
-	ret = m5mols_lock_3a(info, false);
+	ret = v4l2_ctrl_s_ctrl(info->lock_3a, 0);
 	if (!ret)
 		ret = m5mols_write(sd, AE_EV_PRESET_MONITOR, mode);
 	if (!ret)
@@ -186,42 +186,34 @@ int m5mols_do_scenemode(struct m5mols_info *info, u8 mode)
 	return ret;
 }
 
-static int m5mols_lock_ae(struct m5mols_info *info, bool lock)
+static int m5mols_3a_lock(struct m5mols_info *info, struct v4l2_ctrl *ctrl)
 {
+	bool af_lock = ctrl->val & V4L2_LOCK_FOCUS;
 	int ret = 0;
 
-	if (info->lock_ae != lock)
-		ret = m5mols_write(&info->sd, AE_LOCK,
-				lock ? REG_AE_LOCK : REG_AE_UNLOCK);
-	if (!ret)
-		info->lock_ae = lock;
+	if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_EXPOSURE) {
+		bool ae_lock = ctrl->val & V4L2_LOCK_EXPOSURE;
 
-	return ret;
-}
-
-static int m5mols_lock_awb(struct m5mols_info *info, bool lock)
-{
-	int ret = 0;
+		ret = m5mols_write(&info->sd, AE_LOCK, ae_lock ?
+				   REG_AE_LOCK : REG_AE_UNLOCK);
+		if (ret)
+			return ret;
+	}
 
-	if (info->lock_awb != lock)
-		ret = m5mols_write(&info->sd, AWB_LOCK,
-				lock ? REG_AWB_LOCK : REG_AWB_UNLOCK);
-	if (!ret)
-		info->lock_awb = lock;
+	if (((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_WHITE_BALANCE)
+	    && info->auto_wb->val) {
+		bool awb_lock = ctrl->val & V4L2_LOCK_WHITE_BALANCE;
 
-	return ret;
-}
+		ret = m5mols_write(&info->sd, AWB_LOCK, awb_lock ?
+				   REG_AWB_LOCK : REG_AWB_UNLOCK);
+		if (ret)
+			return ret;
+	}
 
-/* m5mols_lock_3a() - Lock 3A(Auto Exposure, Auto Whitebalance, Auto Focus) */
-int m5mols_lock_3a(struct m5mols_info *info, bool lock)
-{
-	int ret;
+	if (!info->ver.af || !af_lock)
+		return ret;
 
-	ret = m5mols_lock_ae(info, lock);
-	if (!ret)
-		ret = m5mols_lock_awb(info, lock);
-	/* Don't need to handle unlocking AF */
-	if (!ret && is_available_af(info) && lock)
+	if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS)
 		ret = m5mols_write(&info->sd, AF_EXECUTE, REG_AF_STOP);
 
 	return ret;
@@ -249,13 +241,13 @@ static int m5mols_set_metering_mode(struct m5mols_info *info, int mode)
 static int m5mols_set_exposure(struct m5mols_info *info, int exposure)
 {
 	struct v4l2_subdev *sd = &info->sd;
-	int ret;
-
-	ret = m5mols_lock_ae(info, exposure != V4L2_EXPOSURE_AUTO);
-	if (ret < 0)
-		return ret;
+	int ret = 0;
 
 	if (exposure == V4L2_EXPOSURE_AUTO) {
+		/* Unlock auto exposure */
+		info->lock_3a->val &= ~V4L2_LOCK_EXPOSURE;
+		m5mols_3a_lock(info, info->lock_3a);
+
 		ret = m5mols_set_metering_mode(info, info->metering->val);
 		if (ret < 0)
 			return ret;
@@ -429,6 +421,26 @@ static int m5mols_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 		if (status != REG_ISO_AUTO)
 			info->iso->val = status - 1;
 		break;
+
+	case V4L2_CID_3A_LOCK:
+		ctrl->val &= ~0x7;
+
+		ret = m5mols_read_u8(sd, AE_LOCK, &status);
+		if (ret)
+			return ret;
+		if (status)
+			info->lock_3a->val |= V4L2_LOCK_EXPOSURE;
+
+		ret = m5mols_read_u8(sd, AWB_LOCK, &status);
+		if (ret)
+			return ret;
+		if (status)
+			info->lock_3a->val |= V4L2_LOCK_EXPOSURE;
+
+		ret = m5mols_read_u8(sd, AF_EXECUTE, &status);
+		if (!status)
+			info->lock_3a->val |= V4L2_LOCK_EXPOSURE;
+		break;
 	}
 
 	return ret;
@@ -461,6 +473,10 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
 	}
 
 	switch (ctrl->id) {
+	case V4L2_CID_3A_LOCK:
+		ret = m5mols_3a_lock(info, ctrl);
+		break;
+
 	case V4L2_CID_ZOOM_ABSOLUTE:
 		ret = m5mols_write(sd, MON_ZOOM, ctrl->val);
 		break;
@@ -585,6 +601,9 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 	info->jpeg_quality = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
 			V4L2_CID_JPEG_COMPRESSION_QUALITY, 1, 100, 1, 80);
 
+	info->lock_3a = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
+			V4L2_CID_3A_LOCK, 0, 0x7, 0, 0);
+
 	if (info->handle.error) {
 		int ret = info->handle.error;
 		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);
@@ -597,6 +616,8 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
 				V4L2_CTRL_FLAG_UPDATE;
 	v4l2_ctrl_auto_cluster(2, &info->auto_iso, 0, false);
 
+	info->lock_3a->flags |= V4L2_CTRL_FLAG_VOLATILE;
+
 	m5mols_set_ctrl_mode(info->auto_exposure, REG_PARAMETER);
 	m5mols_set_ctrl_mode(info->auto_wb, REG_PARAMETER);
 	m5mols_set_ctrl_mode(info->colorfx, REG_MONITOR);
-- 
1.7.10


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

* Re: [PATCH 03/23] V4L: Add an extended camera white balance control
  2012-05-10 10:30 ` [PATCH 03/23] V4L: Add an extended camera white balance control Sylwester Nawrocki
@ 2012-05-14  0:02   ` Sakari Ailus
  2012-05-15 21:28     ` Sylwester Nawrocki
                       ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: Sakari Ailus @ 2012-05-14  0:02 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: linux-media, m.szyprowski, riverful.kim, sw0312.kim, Kyungmin Park

Hi Sylwaster,

Thanks for the patch. I noticed your pull req; I hope you could take into
account a few more comments. :)

On Thu, May 10, 2012 at 12:30:38PM +0200, Sylwester Nawrocki wrote:
> This patch adds V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE control which is
> an extended version of the V4L2_CID_AUTO_WHITE_BALANCE control,
> including white balance presets. The following presets are defined:
> 
>  - V4L2_WHITE_BALANCE_INCANDESCENT,
>  - V4L2_WHITE_BALANCE_FLUORESCENT,
>  - V4L2_WHITE_BALANCE_FLUORESCENT_H,
>  - V4L2_WHITE_BALANCE_HORIZON,
>  - V4L2_WHITE_BALANCE_DAYLIGHT,
>  - V4L2_WHITE_BALANCE_FLASH,
>  - V4L2_WHITE_BALANCE_CLOUDY,
>  - V4L2_WHITE_BALANCE_SHADE.
> 
> Signed-off-by: HeungJun Kim <riverful.kim@samsung.com>
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Acked-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  Documentation/DocBook/media/v4l/controls.xml |   70 ++++++++++++++++++++++++++
>  drivers/media/video/v4l2-ctrls.c             |   17 +++++++
>  include/linux/videodev2.h                    |   14 ++++++
>  3 files changed, 101 insertions(+)
> 
> diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
> index 40e6485..85d1ca0 100644
> --- a/Documentation/DocBook/media/v4l/controls.xml
> +++ b/Documentation/DocBook/media/v4l/controls.xml
> @@ -3022,6 +3022,76 @@ camera sensor on or off, or specify its strength. Such band-stop filters can
>  be used, for example, to filter out the fluorescent light component.</entry>
>  	  </row>
>  	  <row><entry></entry></row>
> +
> +	  <row id="v4l2-auto-n-preset-white-balance">
> +	    <entry spanname="id"><constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>&nbsp;</entry>
> +	    <entry>enum&nbsp;v4l2_auto_n_preset_white_balance</entry>
> +	  </row><row><entry spanname="descr">Sets white balance to automatic,
> +manual or a preset. The presets determine color temperature of the light as
> +a hint to the camera for white balance adjustments resulting in most accurate
> +color representation. The following white balance presets are listed in order
> +of increasing color temperature.</entry>
> +	  </row>
> +	  <row>
> +	    <entrytbl spanname="descr" cols="2">
> +	      <tbody valign="top">
> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_MANUAL</constant>&nbsp;</entry>
> +		  <entry>Manual white balance.</entry>
> +		</row>
> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_AUTO</constant>&nbsp;</entry>
> +		  <entry>Automatic white balance adjustments.</entry>
> +		</row>
> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_INCANDESCENT</constant>&nbsp;</entry>
> +		  <entry>White balance setting for incandescent (tungsten) lighting.
> +It generally cools down the colors and corresponds approximately to 2500...3500 K
> +color temperature range.</entry>
> +		</row>
> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
> +		  <entry>White balance preset for fluorescent lighting.
> +It corresponds approximately to 4000...5000 K color temperature.</entry>
> +		</row>
> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
> +		  <entry>With this setting the camera will compensate for
> +fluorescent H lighting.</entry>
> +		</row>

I don't remember for quite sure if I replied to this already... what's the
diff between the above two?

The colour temperature of the fluorescent light depends on the lamp; 2500 K
is not uncommon here in Finland. It's the spectrum that's different from
incandescents, not necessarily the colour temperature.

> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_HORIZON</constant>&nbsp;</entry>
> +		  <entry>White balance setting for horizon daylight.
> +It corresponds approximately to 5000 K color temperature.</entry>
> +		</row>
> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_DAYLIGHT</constant>&nbsp;</entry>
> +		  <entry>White balance preset for daylight (with clear sky).
> +It corresponds approximately to 5000...6500 K color temperature.</entry>
> +		</row>
> +		<row>
> +		  <entry><constant>V4L2_WHITE_BALANCE_FLASH</constant>&nbsp;</entry>
> +		  <entry>With this setting the camera will compensate for the flash
> +light. It slightly warms up the colors and corresponds roughly to 5000...5500 K
> +color temperature.</entry>

This also depends heavily on the type of the flash.

I'd just remove the colour temperature from most of these since it looks
more like assumptions made in a particular system rather than something
generic.

Kind regards,

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	jabber/XMPP/Gmail: sailus@retiisi.org.uk

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

* Re: [PATCH 03/23] V4L: Add an extended camera white balance control
  2012-05-14  0:02   ` Sakari Ailus
@ 2012-05-15 21:28     ` Sylwester Nawrocki
  2012-05-16  6:57       ` Sakari Ailus
  2012-05-15 21:53     ` [PATCH] V4L: DocBook: Improve V4L2_AUTO_N_WHITE_BALANCE control description Sylwester Nawrocki
  2012-05-15 22:05     ` [PATCH v2] " Sylwester Nawrocki
  2 siblings, 1 reply; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-15 21:28 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Sylwester Nawrocki, linux-media, m.szyprowski, riverful.kim,
	sw0312.kim, Kyungmin Park

Hi Sakari,

On 05/14/2012 02:02 AM, Sakari Ailus wrote:
> Hi Sylwester,
> 
> Thanks for the patch. I noticed your pull req; I hope you could take into
> account a few more comments. :)

Thank you for your comments, I'll try to come up with a fix up patch.
 
> On Thu, May 10, 2012 at 12:30:38PM +0200, Sylwester Nawrocki wrote:
>> This patch adds V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE control which is
>> an extended version of the V4L2_CID_AUTO_WHITE_BALANCE control,
>> including white balance presets. The following presets are defined:
>>
>>   - V4L2_WHITE_BALANCE_INCANDESCENT,
>>   - V4L2_WHITE_BALANCE_FLUORESCENT,
>>   - V4L2_WHITE_BALANCE_FLUORESCENT_H,
>>   - V4L2_WHITE_BALANCE_HORIZON,
>>   - V4L2_WHITE_BALANCE_DAYLIGHT,
>>   - V4L2_WHITE_BALANCE_FLASH,
>>   - V4L2_WHITE_BALANCE_CLOUDY,
>>   - V4L2_WHITE_BALANCE_SHADE.
>>
>> Signed-off-by: HeungJun Kim<riverful.kim@samsung.com>
>> Signed-off-by: Sylwester Nawrocki<s.nawrocki@samsung.com>
>> Signed-off-by: Kyungmin Park<kyungmin.park@samsung.com>
>> Acked-by: Hans de Goede<hdegoede@redhat.com>
>> ---
>>   Documentation/DocBook/media/v4l/controls.xml |   70 ++++++++++++++++++++++++++
>>   drivers/media/video/v4l2-ctrls.c             |   17 +++++++
>>   include/linux/videodev2.h                    |   14 ++++++
>>   3 files changed, 101 insertions(+)
>>
>> diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
>> index 40e6485..85d1ca0 100644
>> --- a/Documentation/DocBook/media/v4l/controls.xml
>> +++ b/Documentation/DocBook/media/v4l/controls.xml
>> @@ -3022,6 +3022,76 @@ camera sensor on or off, or specify its strength. Such band-stop filters can
>>   be used, for example, to filter out the fluorescent light component.</entry>
>>   	</row>
>>   	<row><entry></entry></row>
>> +
>> +	<row id="v4l2-auto-n-preset-white-balance">
>> +	<entry spanname="id"><constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>&nbsp;</entry>
>> +	<entry>enum&nbsp;v4l2_auto_n_preset_white_balance</entry>
>> +	</row><row><entry spanname="descr">Sets white balance to automatic,
>> +manual or a preset. The presets determine color temperature of the light as
>> +a hint to the camera for white balance adjustments resulting in most accurate
>> +color representation. The following white balance presets are listed in order
>> +of increasing color temperature.</entry>
>> +	</row>
>> +	<row>
>> +	<entrytbl spanname="descr" cols="2">
>> +	<tbody valign="top">
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_MANUAL</constant>&nbsp;</entry>
>> +		<entry>Manual white balance.</entry>
>> +		</row>
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_AUTO</constant>&nbsp;</entry>
>> +		<entry>Automatic white balance adjustments.</entry>
>> +		</row>
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_INCANDESCENT</constant>&nbsp;</entry>
>> +		<entry>White balance setting for incandescent (tungsten) lighting.
>> +It generally cools down the colors and corresponds approximately to 2500...3500 K
>> +color temperature range.</entry>
>> +		</row>
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
>> +		<entry>White balance preset for fluorescent lighting.
>> +It corresponds approximately to 4000...5000 K color temperature.</entry>
>> +		</row>
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
>> +		<entry>With this setting the camera will compensate for
>> +fluorescent H lighting.</entry>
>> +		</row>
> 
> I don't remember for quite sure if I replied to this already... what's the
> diff between the above two?

No, you didn't, otherwise I would certainly remember that ;)

V4L2_WHITE_BALANCE_FLUORESCENT_H is for newer, daylight calibrated fluorescent
lamps. So this preset will generally cool down the colours less than
V4L2_WHITE_BALANCE_FLUORESCENT. I was even thinking about a separate control 
for V4L2_WHITE_BALANCE_FLUORESCENT, since some ISPs have several presets for
fluorescent lighting. I dropped that idea finally though.

> The colour temperature of the fluorescent light depends on the lamp; 2500 K
> is not uncommon here in Finland. It's the spectrum that's different from
> incandescents, not necessarily the colour temperature.
>
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_HORIZON</constant>&nbsp;</entry>
>> +		<entry>White balance setting for horizon daylight.
>> +It corresponds approximately to 5000 K color temperature.</entry>
>> +		</row>
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_DAYLIGHT</constant>&nbsp;</entry>
>> +		<entry>White balance preset for daylight (with clear sky).
>> +It corresponds approximately to 5000...6500 K color temperature.</entry>
>> +		</row>
>> +		<row>
>> +		<entry><constant>V4L2_WHITE_BALANCE_FLASH</constant>&nbsp;</entry>
>> +		<entry>With this setting the camera will compensate for the flash
>> +light. It slightly warms up the colors and corresponds roughly to 5000...5500 K
>> +color temperature.</entry>
> 
> This also depends heavily on the type of the flash.

OK, I'm going to remove this one, and for V4L2_WHITE_BALANCE_FLUORESCENT as well.
I would prefer to keep the remaining ones though.

> I'd just remove the colour temperature from most of these since it looks
> more like assumptions made in a particular system rather than something
> generic.

The colour temperature ranges are mostly rough estimates to give an overview
of what these presets are. I compared multiple information sources when
preparing those colour temperature ranges. So it's obviously not based on 
a single system. However since some may give false information, I'm going
to remove them.

Regards,
Sylwester

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

* [PATCH] V4L: DocBook: Improve V4L2_AUTO_N_WHITE_BALANCE control description
  2012-05-14  0:02   ` Sakari Ailus
  2012-05-15 21:28     ` Sylwester Nawrocki
@ 2012-05-15 21:53     ` Sylwester Nawrocki
  2012-05-19 20:27       ` [PATCH v3] V4L: DocBook: Improve V4L2_CID_AUTO_N_WHITE_BALANCE " Sylwester Nawrocki
  2012-05-15 22:05     ` [PATCH v2] " Sylwester Nawrocki
  2 siblings, 1 reply; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-15 21:53 UTC (permalink / raw)
  To: linux-media; +Cc: Sylwester Nawrocki

This patch removes the estimate color temperature range specification
for white balance presets for which exact values heavily depend on
a particular camera specification.

Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 8994132..1cef967 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3174,8 +3174,7 @@ color temperature range.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
-		  <entry>White balance preset for fluorescent lighting.
-It corresponds approximately to 4000...5000 K color temperature.</entry>
+		  <entry>White balance preset for fluorescent lighting.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
@@ -3184,8 +3183,7 @@ fluorescent H lighting.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_HORIZON</constant>&nbsp;</entry>
-		  <entry>White balance setting for horizon daylight.
-It corresponds approximately to 5000 K color temperature.</entry>
+		  <entry>White balance setting for horizon daylight.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_DAYLIGHT</constant>&nbsp;</entry>
@@ -3195,8 +3193,7 @@ It corresponds approximately to 5000...6500 K color temperature.</entry>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLASH</constant>&nbsp;</entry>
 		  <entry>With this setting the camera will compensate for the flash
-light. It slightly warms up the colors and corresponds roughly to 5000...5500 K
-color temperature.</entry>
+light.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_CLOUDY</constant>&nbsp;</entry>
@@ -3207,9 +3204,7 @@ range.</entry>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_SHADE</constant>&nbsp;</entry>
 		  <entry>White balance preset for shade or heavily overcast
-sky. It corresponds approximately to 9000...10000 K color temperature.
-</entry>
+sky.</entry>
 		</row>
 	      </tbody>
 	    </entrytbl>
--
1.7.4.1


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

* [PATCH v2] V4L: DocBook: Improve V4L2_CID_AUTO_N_WHITE_BALANCE control description
  2012-05-14  0:02   ` Sakari Ailus
  2012-05-15 21:28     ` Sylwester Nawrocki
  2012-05-15 21:53     ` [PATCH] V4L: DocBook: Improve V4L2_AUTO_N_WHITE_BALANCE control description Sylwester Nawrocki
@ 2012-05-15 22:05     ` Sylwester Nawrocki
  2012-05-17 22:42       ` Sakari Ailus
  2 siblings, 1 reply; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-15 22:05 UTC (permalink / raw)
  To: linux-media; +Cc: Sylwester Nawrocki

This patch removes the estimate color temperature range specification
for the white balance presets for which exact values heavily depend
on a particular camera specification.

Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
---

Fixed typo in the patch summary line.

 Documentation/DocBook/media/v4l/controls.xml |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 8994132..2ed82ee 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3174,8 +3174,7 @@ color temperature range.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
-		  <entry>White balance preset for fluorescent lighting.
-It corresponds approximately to 4000...5000 K color temperature.</entry>
+		  <entry>White balance preset for fluorescent lighting.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
@@ -3184,19 +3183,17 @@ fluorescent H lighting.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_HORIZON</constant>&nbsp;</entry>
-		  <entry>White balance setting for horizon daylight.
-It corresponds approximately to 5000 K color temperature.</entry>
+		  <entry>White balance setting for horizon daylight.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_DAYLIGHT</constant>&nbsp;</entry>
-		  <entry>White balance preset for daylight (with clear sky).
+		  <entry>White balance preset for clear-sky daylight.
 It corresponds approximately to 5000...6500 K color temperature.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLASH</constant>&nbsp;</entry>
 		  <entry>With this setting the camera will compensate for the flash
-light. It slightly warms up the colors and corresponds roughly to 5000...5500 K
-color temperature.</entry>
+light.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_CLOUDY</constant>&nbsp;</entry>
@@ -3207,8 +3204,7 @@ range.</entry>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_SHADE</constant>&nbsp;</entry>
 		  <entry>White balance preset for shade or heavily overcast
-sky. It corresponds approximately to 9000...10000 K color temperature.
-</entry>
+sky.</entry>
 		</row>
 	      </tbody>
 	    </entrytbl>
--
1.7.4.1


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

* Re: [PATCH 03/23] V4L: Add an extended camera white balance control
  2012-05-15 21:28     ` Sylwester Nawrocki
@ 2012-05-16  6:57       ` Sakari Ailus
  2012-05-16  9:34         ` Sylwester Nawrocki
  0 siblings, 1 reply; 36+ messages in thread
From: Sakari Ailus @ 2012-05-16  6:57 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: Sylwester Nawrocki, linux-media, m.szyprowski, riverful.kim,
	sw0312.kim, Kyungmin Park

Hi Sylwester,

On Tue, May 15, 2012 at 11:28:03PM +0200, Sylwester Nawrocki wrote:
> Hi Sakari,
> 
> On 05/14/2012 02:02 AM, Sakari Ailus wrote:
> > Hi Sylwester,
> > 
> > Thanks for the patch. I noticed your pull req; I hope you could take into
> > account a few more comments. :)
> 
> Thank you for your comments, I'll try to come up with a fix up patch.
>  
> > On Thu, May 10, 2012 at 12:30:38PM +0200, Sylwester Nawrocki wrote:
> >> This patch adds V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE control which is
> >> an extended version of the V4L2_CID_AUTO_WHITE_BALANCE control,
> >> including white balance presets. The following presets are defined:
> >>
> >>   - V4L2_WHITE_BALANCE_INCANDESCENT,
> >>   - V4L2_WHITE_BALANCE_FLUORESCENT,
> >>   - V4L2_WHITE_BALANCE_FLUORESCENT_H,
> >>   - V4L2_WHITE_BALANCE_HORIZON,
> >>   - V4L2_WHITE_BALANCE_DAYLIGHT,
> >>   - V4L2_WHITE_BALANCE_FLASH,
> >>   - V4L2_WHITE_BALANCE_CLOUDY,
> >>   - V4L2_WHITE_BALANCE_SHADE.
> >>
> >> Signed-off-by: HeungJun Kim<riverful.kim@samsung.com>
> >> Signed-off-by: Sylwester Nawrocki<s.nawrocki@samsung.com>
> >> Signed-off-by: Kyungmin Park<kyungmin.park@samsung.com>
> >> Acked-by: Hans de Goede<hdegoede@redhat.com>
> >> ---
> >>   Documentation/DocBook/media/v4l/controls.xml |   70 ++++++++++++++++++++++++++
> >>   drivers/media/video/v4l2-ctrls.c             |   17 +++++++
> >>   include/linux/videodev2.h                    |   14 ++++++
> >>   3 files changed, 101 insertions(+)
> >>
> >> diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
> >> index 40e6485..85d1ca0 100644
> >> --- a/Documentation/DocBook/media/v4l/controls.xml
> >> +++ b/Documentation/DocBook/media/v4l/controls.xml
> >> @@ -3022,6 +3022,76 @@ camera sensor on or off, or specify its strength. Such band-stop filters can
> >>   be used, for example, to filter out the fluorescent light component.</entry>
> >>   	</row>
> >>   	<row><entry></entry></row>
> >> +
> >> +	<row id="v4l2-auto-n-preset-white-balance">
> >> +	<entry spanname="id"><constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>&nbsp;</entry>
> >> +	<entry>enum&nbsp;v4l2_auto_n_preset_white_balance</entry>
> >> +	</row><row><entry spanname="descr">Sets white balance to automatic,
> >> +manual or a preset. The presets determine color temperature of the light as
> >> +a hint to the camera for white balance adjustments resulting in most accurate
> >> +color representation. The following white balance presets are listed in order
> >> +of increasing color temperature.</entry>
> >> +	</row>
> >> +	<row>
> >> +	<entrytbl spanname="descr" cols="2">
> >> +	<tbody valign="top">
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_MANUAL</constant>&nbsp;</entry>
> >> +		<entry>Manual white balance.</entry>
> >> +		</row>
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_AUTO</constant>&nbsp;</entry>
> >> +		<entry>Automatic white balance adjustments.</entry>
> >> +		</row>
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_INCANDESCENT</constant>&nbsp;</entry>
> >> +		<entry>White balance setting for incandescent (tungsten) lighting.
> >> +It generally cools down the colors and corresponds approximately to 2500...3500 K
> >> +color temperature range.</entry>
> >> +		</row>
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
> >> +		<entry>White balance preset for fluorescent lighting.
> >> +It corresponds approximately to 4000...5000 K color temperature.</entry>
> >> +		</row>
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
> >> +		<entry>With this setting the camera will compensate for
> >> +fluorescent H lighting.</entry>
> >> +		</row>
> > 
> > I don't remember for quite sure if I replied to this already... what's the
> > diff between the above two?
> 
> No, you didn't, otherwise I would certainly remember that ;)
> 
> V4L2_WHITE_BALANCE_FLUORESCENT_H is for newer, daylight calibrated fluorescent
> lamps. So this preset will generally cool down the colours less than
> V4L2_WHITE_BALANCE_FLUORESCENT. I was even thinking about a separate control 
> for V4L2_WHITE_BALANCE_FLUORESCENT, since some ISPs have several presets for
> fluorescent lighting. I dropped that idea finally though.

I don't know about the daylight calibrated ones, but the older ones often
tend to give colder light. Nevertheless, I think it'd be good to mention
this in the documentation. I couldn't thave guessed it. :)

> > The colour temperature of the fluorescent light depends on the lamp; 2500 K
> > is not uncommon here in Finland. It's the spectrum that's different from
> > incandescents, not necessarily the colour temperature.
> >
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_HORIZON</constant>&nbsp;</entry>
> >> +		<entry>White balance setting for horizon daylight.
> >> +It corresponds approximately to 5000 K color temperature.</entry>
> >> +		</row>
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_DAYLIGHT</constant>&nbsp;</entry>
> >> +		<entry>White balance preset for daylight (with clear sky).
> >> +It corresponds approximately to 5000...6500 K color temperature.</entry>
> >> +		</row>
> >> +		<row>
> >> +		<entry><constant>V4L2_WHITE_BALANCE_FLASH</constant>&nbsp;</entry>
> >> +		<entry>With this setting the camera will compensate for the flash
> >> +light. It slightly warms up the colors and corresponds roughly to 5000...5500 K
> >> +color temperature.</entry>
> > 
> > This also depends heavily on the type of the flash.
> 
> OK, I'm going to remove this one, and for V4L2_WHITE_BALANCE_FLUORESCENT as well.
> I would prefer to keep the remaining ones though.

Sounds good to me.

Cheers,

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	jabber/XMPP/Gmail: sailus@retiisi.org.uk

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

* Re: [PATCH 03/23] V4L: Add an extended camera white balance control
  2012-05-16  6:57       ` Sakari Ailus
@ 2012-05-16  9:34         ` Sylwester Nawrocki
  2012-05-17 22:37           ` Sakari Ailus
  0 siblings, 1 reply; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-16  9:34 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Sylwester Nawrocki, linux-media, m.szyprowski, riverful.kim,
	sw0312.kim, Kyungmin Park

Hi Sakari,

On 05/16/2012 08:57 AM, Sakari Ailus wrote:
...
>>>> +
>>>> +	<row id="v4l2-auto-n-preset-white-balance">
>>>> +	<entry spanname="id"><constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>&nbsp;</entry>
>>>> +	<entry>enum&nbsp;v4l2_auto_n_preset_white_balance</entry>
>>>> +	</row><row><entry spanname="descr">Sets white balance to automatic,
>>>> +manual or a preset. The presets determine color temperature of the light as
>>>> +a hint to the camera for white balance adjustments resulting in most accurate
>>>> +color representation. The following white balance presets are listed in order
>>>> +of increasing color temperature.</entry>
>>>> +	</row>
>>>> +	<row>
>>>> +	<entrytbl spanname="descr" cols="2">
>>>> +	<tbody valign="top">
>>>> +		<row>
>>>> +		<entry><constant>V4L2_WHITE_BALANCE_MANUAL</constant>&nbsp;</entry>
>>>> +		<entry>Manual white balance.</entry>
>>>> +		</row>
>>>> +		<row>
>>>> +		<entry><constant>V4L2_WHITE_BALANCE_AUTO</constant>&nbsp;</entry>
>>>> +		<entry>Automatic white balance adjustments.</entry>
>>>> +		</row>
>>>> +		<row>
>>>> +		<entry><constant>V4L2_WHITE_BALANCE_INCANDESCENT</constant>&nbsp;</entry>
>>>> +		<entry>White balance setting for incandescent (tungsten) lighting.
>>>> +It generally cools down the colors and corresponds approximately to 2500...3500 K
>>>> +color temperature range.</entry>
>>>> +		</row>
>>>> +		<row>
>>>> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
>>>> +		<entry>White balance preset for fluorescent lighting.
>>>> +It corresponds approximately to 4000...5000 K color temperature.</entry>
>>>> +		</row>
>>>> +		<row>
>>>> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
>>>> +		<entry>With this setting the camera will compensate for
>>>> +fluorescent H lighting.</entry>
>>>> +		</row>
>>>
>>> I don't remember for quite sure if I replied to this already... what's the
>>> diff between the above two?
>>
>> No, you didn't, otherwise I would certainly remember that ;)
>>
>> V4L2_WHITE_BALANCE_FLUORESCENT_H is for newer, daylight calibrated fluorescent
>> lamps. So this preset will generally cool down the colours less than
                                        ^^^^^^^^^   
Sorry, I put it wrong. It should have been "warm up", since "cooling down"
the colours happens only for V4L2_WHITE_BALANCE_INCANDESCENT, other presets
just generally warm up colours, with various degree.

>> V4L2_WHITE_BALANCE_FLUORESCENT. I was even thinking about a separate control 
>> for V4L2_WHITE_BALANCE_FLUORESCENT, since some ISPs have several presets for
>> fluorescent lighting. I dropped that idea finally though.
> 
> I don't know about the daylight calibrated ones, but the older ones often
> tend to give colder light. Nevertheless, I think it'd be good to mention
> this in the documentation. I couldn't have guessed it. :)

Do you think something like this would be OK:

+		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
+		<entry>Variant of <constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant> 
+ for fluorescent lamp lighting with spectral power distribution more similar
+ to daylight.</entry>
+		</row>

?
>>> The colour temperature of the fluorescent light depends on the lamp; 2500 K
>>> is not uncommon here in Finland. It's the spectrum that's different from
>>> incandescents, not necessarily the colour temperature.

--
Regards,
Sylwester
-- 
Sylwester Nawrocki
실베스터 나브로츠키
Samsung Poland R&D Center

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

* Re: [PATCH 03/23] V4L: Add an extended camera white balance control
  2012-05-16  9:34         ` Sylwester Nawrocki
@ 2012-05-17 22:37           ` Sakari Ailus
  0 siblings, 0 replies; 36+ messages in thread
From: Sakari Ailus @ 2012-05-17 22:37 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: linux-media, m.szyprowski, riverful.kim, sw0312.kim, Kyungmin Park

Hi Sylwester,

Sylwester Nawrocki wrote:
> Hi Sakari,
> 
> On 05/16/2012 08:57 AM, Sakari Ailus wrote:
> ...
>>>>> +
>>>>> +	<row id="v4l2-auto-n-preset-white-balance">
>>>>> +	<entry spanname="id"><constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>&nbsp;</entry>
>>>>> +	<entry>enum&nbsp;v4l2_auto_n_preset_white_balance</entry>
>>>>> +	</row><row><entry spanname="descr">Sets white balance to automatic,
>>>>> +manual or a preset. The presets determine color temperature of the light as
>>>>> +a hint to the camera for white balance adjustments resulting in most accurate
>>>>> +color representation. The following white balance presets are listed in order
>>>>> +of increasing color temperature.</entry>
>>>>> +	</row>
>>>>> +	<row>
>>>>> +	<entrytbl spanname="descr" cols="2">
>>>>> +	<tbody valign="top">
>>>>> +		<row>
>>>>> +		<entry><constant>V4L2_WHITE_BALANCE_MANUAL</constant>&nbsp;</entry>
>>>>> +		<entry>Manual white balance.</entry>
>>>>> +		</row>
>>>>> +		<row>
>>>>> +		<entry><constant>V4L2_WHITE_BALANCE_AUTO</constant>&nbsp;</entry>
>>>>> +		<entry>Automatic white balance adjustments.</entry>
>>>>> +		</row>
>>>>> +		<row>
>>>>> +		<entry><constant>V4L2_WHITE_BALANCE_INCANDESCENT</constant>&nbsp;</entry>
>>>>> +		<entry>White balance setting for incandescent (tungsten) lighting.
>>>>> +It generally cools down the colors and corresponds approximately to 2500...3500 K
>>>>> +color temperature range.</entry>
>>>>> +		</row>
>>>>> +		<row>
>>>>> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
>>>>> +		<entry>White balance preset for fluorescent lighting.
>>>>> +It corresponds approximately to 4000...5000 K color temperature.</entry>
>>>>> +		</row>
>>>>> +		<row>
>>>>> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
>>>>> +		<entry>With this setting the camera will compensate for
>>>>> +fluorescent H lighting.</entry>
>>>>> +		</row>
>>>>
>>>> I don't remember for quite sure if I replied to this already... what's the
>>>> diff between the above two?
>>>
>>> No, you didn't, otherwise I would certainly remember that ;)
>>>
>>> V4L2_WHITE_BALANCE_FLUORESCENT_H is for newer, daylight calibrated fluorescent
>>> lamps. So this preset will generally cool down the colours less than
>                                         ^^^^^^^^^   
> Sorry, I put it wrong. It should have been "warm up", since "cooling down"
> the colours happens only for V4L2_WHITE_BALANCE_INCANDESCENT, other presets
> just generally warm up colours, with various degree.
> 
>>> V4L2_WHITE_BALANCE_FLUORESCENT. I was even thinking about a separate control 
>>> for V4L2_WHITE_BALANCE_FLUORESCENT, since some ISPs have several presets for
>>> fluorescent lighting. I dropped that idea finally though.
>>
>> I don't know about the daylight calibrated ones, but the older ones often
>> tend to give colder light. Nevertheless, I think it'd be good to mention
>> this in the documentation. I couldn't have guessed it. :)
> 
> Do you think something like this would be OK:
> 
> +		<entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
> +		<entry>Variant of <constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant> 
> + for fluorescent lamp lighting with spectral power distribution more similar
> + to daylight.</entry>
> +		</row>
> 
> ?

Looks good to me!

Cheers,

-- 
Sakari Ailus
sakari.ailus@iki.fi

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

* Re: [PATCH v2] V4L: DocBook: Improve V4L2_CID_AUTO_N_WHITE_BALANCE control description
  2012-05-15 22:05     ` [PATCH v2] " Sylwester Nawrocki
@ 2012-05-17 22:42       ` Sakari Ailus
  0 siblings, 0 replies; 36+ messages in thread
From: Sakari Ailus @ 2012-05-17 22:42 UTC (permalink / raw)
  To: Sylwester Nawrocki; +Cc: linux-media

On Wed, May 16, 2012 at 12:05:24AM +0200, Sylwester Nawrocki wrote:
> This patch removes the estimate color temperature range specification
> for the white balance presets for which exact values heavily depend
> on a particular camera specification.
> 
> Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>

Acked-by: Sakari Ailus <sakari.ailus@iki.fi>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	jabber/XMPP/Gmail: sailus@retiisi.org.uk

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

* [PATCH v3] V4L: DocBook: Improve V4L2_CID_AUTO_N_WHITE_BALANCE control description
  2012-05-15 21:53     ` [PATCH] V4L: DocBook: Improve V4L2_AUTO_N_WHITE_BALANCE control description Sylwester Nawrocki
@ 2012-05-19 20:27       ` Sylwester Nawrocki
  0 siblings, 0 replies; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-05-19 20:27 UTC (permalink / raw)
  To: linux-media; +Cc: sakari.ailus, Sylwester Nawrocki

This patch removes the estimate color temperature range specification
for the white balance presets for which exact values heavily depend
on a particular camera specification.

Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
---
 Documentation/DocBook/media/v4l/controls.xml |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 8994132..8391107 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3174,29 +3174,27 @@ color temperature range.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>&nbsp;</entry>
-		  <entry>White balance preset for fluorescent lighting.
-It corresponds approximately to 4000...5000 K color temperature.</entry>
+		  <entry>White balance preset for fluorescent lighting.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLUORESCENT_H</constant>&nbsp;</entry>
-		  <entry>With this setting the camera will compensate for
-fluorescent H lighting.</entry>
+		  <entry>Variant of <constant>V4L2_WHITE_BALANCE_FLUORESCENT</constant>
+for fluorescent lamp lighting with spectral power distribution more similar
+to daylight.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_HORIZON</constant>&nbsp;</entry>
-		  <entry>White balance setting for horizon daylight.
-It corresponds approximately to 5000 K color temperature.</entry>
+		  <entry>White balance setting for horizon daylight.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_DAYLIGHT</constant>&nbsp;</entry>
-		  <entry>White balance preset for daylight (with clear sky).
+		  <entry>White balance preset for clear-sky daylight.
 It corresponds approximately to 5000...6500 K color temperature.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_FLASH</constant>&nbsp;</entry>
 		  <entry>With this setting the camera will compensate for the flash
-light. It slightly warms up the colors and corresponds roughly to 5000...5500 K
-color temperature.</entry>
+light.</entry>
 		</row>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_CLOUDY</constant>&nbsp;</entry>
@@ -3207,9 +3205,7 @@ range.</entry>
 		<row>
 		  <entry><constant>V4L2_WHITE_BALANCE_SHADE</constant>&nbsp;</entry>
 		  <entry>White balance preset for shade or heavily overcast
-sky. It corresponds approximately to 9000...10000 K color temperature.
-</entry>
+sky.</entry>
 		</row>
 	      </tbody>
 	    </entrytbl>
--
1.7.4.1


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

* Re: [PATCH 10/23] V4L: Add auto focus targets to the selections API
  2012-05-10 10:30 ` [PATCH 10/23] V4L: Add auto focus targets to the selections API Sylwester Nawrocki
@ 2012-10-29 20:00   ` Sakari Ailus
  2012-10-29 22:43     ` Sylwester Nawrocki
  0 siblings, 1 reply; 36+ messages in thread
From: Sakari Ailus @ 2012-10-29 20:00 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: linux-media, m.szyprowski, riverful.kim, sw0312.kim, Kyungmin Park

Hi Sylwester,

On Thu, May 10, 2012 at 12:30:45PM +0200, Sylwester Nawrocki wrote:
> The camera automatic focus algorithms may require setting up
> a spot or rectangle coordinates or multiple such parameters.
> 
> The automatic focus selection targets are introduced in order
> to allow applications to query and set such coordinates. Those
> selections are intended to be used together with the automatic
> focus controls available in the camera control class.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
>  Documentation/DocBook/media/v4l/selection-api.xml  |   33 +++++++++++++++++++-
>  .../DocBook/media/v4l/vidioc-g-selection.xml       |   11 +++++++
>  include/linux/videodev2.h                          |    5 +++
>  3 files changed, 48 insertions(+), 1 deletion(-)

What's the status of this patch? May I ask if you have plans to continue
with it?

Speaking of multiple AF windows --- I originally thought we could just have
multiple selection targets for them. I'm not sure which one would be better;
multiple selection targets or another field telling the window ID. In case
of the former we'd leave a largish gap for additional window IDs.

I think I'm leaning towards using one reserved field for the purpose.

Another question I had was that which of the selection rectangles would the
AF rectangle be related to? Is it the compose bounds rectangle, or the crop
bounds rectangle, for example? I thought it might make sense to use another
field to tell that, since I think which one this really is related to is
purely hardware specific.

What do you think?

Kind regards,

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

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

* Re: [PATCH 10/23] V4L: Add auto focus targets to the selections API
  2012-10-29 20:00   ` Sakari Ailus
@ 2012-10-29 22:43     ` Sylwester Nawrocki
  2012-11-04 17:29       ` Sakari Ailus
  0 siblings, 1 reply; 36+ messages in thread
From: Sylwester Nawrocki @ 2012-10-29 22:43 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Sylwester Nawrocki, linux-media, m.szyprowski, sw0312.kim, Kyungmin Park

Hi Sakari,

On 10/29/2012 09:00 PM, Sakari Ailus wrote:
> On Thu, May 10, 2012 at 12:30:45PM +0200, Sylwester Nawrocki wrote:
>> The camera automatic focus algorithms may require setting up
>> a spot or rectangle coordinates or multiple such parameters.
>>
>> The automatic focus selection targets are introduced in order
>> to allow applications to query and set such coordinates. Those
>> selections are intended to be used together with the automatic
>> focus controls available in the camera control class.
>>
>> Signed-off-by: Sylwester Nawrocki<s.nawrocki@samsung.com>
>> Signed-off-by: Kyungmin Park<kyungmin.park@samsung.com>
>> ---
>>   Documentation/DocBook/media/v4l/selection-api.xml  |   33 +++++++++++++++++++-
>>   .../DocBook/media/v4l/vidioc-g-selection.xml       |   11 +++++++
>>   include/linux/videodev2.h                          |    5 +++
>>   3 files changed, 48 insertions(+), 1 deletion(-)
> 
> What's the status of this patch? May I ask if you have plans to continue
> with it?

Thanks for reminding about it. I'd like to make this ready for v3.8, if 
possible. I've done some minor improvements of the related 
V4L2_CID_AUTO_FOCUS_AREA control and we use this patch internally. We would 
like to see how all this can be used for auto focus feature of the s5c73m3 
camera. I hope to have these patches posted next week.
 
> Speaking of multiple AF windows --- I originally thought we could just have
> multiple selection targets for them. I'm not sure which one would be better;
> multiple selection targets or another field telling the window ID. In case
> of the former we'd leave a largish gap for additional window IDs.
> 
> I think I'm leaning towards using one reserved field for the purpose.

That also as my preference. I imagine the ID field could be reused for
other future or existing selection targets anyway. I recall someone already
asked about multiple ROI support for image cropping [1], perhaps the ID 
field could be used also for that.
 
> Another question I had was that which of the selection rectangles would the
> AF rectangle be related to? Is it the compose bounds rectangle, or the crop
> bounds rectangle, for example? I thought it might make sense to use another
> field to tell that, since I think which one this really is related to is
> purely hardware specific.

It's indeed very hardware specific. I've seen sensors that allow to define
bounds for the auto focus rectangle entirely independent from the output 
format, crop or compose rectangle. It may look strange, but some sensor 
firmwares just accept rectangle/point coordinates with bounds rectangle 
corresponding to video display area (so it is easy, e.g. to use coordinates 
coming directly from a touchscreen) and then perform required calculations 
to map/scale it onto e.g. sensor crop or output rectangle.

I guess your question is related to how to determine in what stage of 
video pipeline the AF selections would be and what the configuration 
order should be from the user space side ?
 
--
Regards,
Sylwester

[1] http://www.spinics.net/lists/linux-media/msg55091.html

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

* Re: [PATCH 10/23] V4L: Add auto focus targets to the selections API
  2012-10-29 22:43     ` Sylwester Nawrocki
@ 2012-11-04 17:29       ` Sakari Ailus
  0 siblings, 0 replies; 36+ messages in thread
From: Sakari Ailus @ 2012-11-04 17:29 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: Sylwester Nawrocki, linux-media, m.szyprowski, sw0312.kim, Kyungmin Park

Hi Sylwester,

Thanks  for the update!

On Mon, Oct 29, 2012 at 11:43:07PM +0100, Sylwester Nawrocki wrote:
> Hi Sakari,
> 
> On 10/29/2012 09:00 PM, Sakari Ailus wrote:
> > On Thu, May 10, 2012 at 12:30:45PM +0200, Sylwester Nawrocki wrote:
> >> The camera automatic focus algorithms may require setting up
> >> a spot or rectangle coordinates or multiple such parameters.
> >>
> >> The automatic focus selection targets are introduced in order
> >> to allow applications to query and set such coordinates. Those
> >> selections are intended to be used together with the automatic
> >> focus controls available in the camera control class.
> >>
> >> Signed-off-by: Sylwester Nawrocki<s.nawrocki@samsung.com>
> >> Signed-off-by: Kyungmin Park<kyungmin.park@samsung.com>
> >> ---
> >>   Documentation/DocBook/media/v4l/selection-api.xml  |   33 +++++++++++++++++++-
> >>   .../DocBook/media/v4l/vidioc-g-selection.xml       |   11 +++++++
> >>   include/linux/videodev2.h                          |    5 +++
> >>   3 files changed, 48 insertions(+), 1 deletion(-)
> > 
> > What's the status of this patch? May I ask if you have plans to continue
> > with it?
> 
> Thanks for reminding about it. I'd like to make this ready for v3.8, if 
> possible. I've done some minor improvements of the related 
> V4L2_CID_AUTO_FOCUS_AREA control and we use this patch internally. We would 
> like to see how all this can be used for auto focus feature of the s5c73m3 
> camera. I hope to have these patches posted next week.

I'm looking forward to that!

> > Speaking of multiple AF windows --- I originally thought we could just have
> > multiple selection targets for them. I'm not sure which one would be better;
> > multiple selection targets or another field telling the window ID. In case
> > of the former we'd leave a largish gap for additional window IDs.
> > 
> > I think I'm leaning towards using one reserved field for the purpose.
> 
> That also as my preference. I imagine the ID field could be reused for
> other future or existing selection targets anyway. I recall someone already
> asked about multiple ROI support for image cropping [1], perhaps the ID 
> field could be used also for that.

I wonder how that would make sense with a single stream.

Selections could also be used on the event interface: they fit exactly to
the union there. One of the applications is passing face tracking
information to the user space.

> > Another question I had was that which of the selection rectangles would the
> > AF rectangle be related to? Is it the compose bounds rectangle, or the crop
> > bounds rectangle, for example? I thought it might make sense to use another
> > field to tell that, since I think which one this really is related to is
> > purely hardware specific.
> 
> It's indeed very hardware specific. I've seen sensors that allow to define
> bounds for the auto focus rectangle entirely independent from the output 
> format, crop or compose rectangle. It may look strange, but some sensor 
> firmwares just accept rectangle/point coordinates with bounds rectangle 
> corresponding to video display area (so it is easy, e.g. to use coordinates 
> coming directly from a touchscreen) and then perform required calculations 
> to map/scale it onto e.g. sensor crop or output rectangle.
> 
> I guess your question is related to how to determine in what stage of 
> video pipeline the AF selections would be and what the configuration 
> order should be from the user space side ?

How to determine what the coordinates are related to. Only that, and inside
a single subdev, actually. The rest is already well visible to the user.

The targets defined up to now are well defined in relation to the other
targets in the documentation. About the configuration order --- the AF
window target could likely be configured after the related target has been
configured.

Perhaps this information should actually come from
VIDIOC_(SUBDEV_,)QUERY_SELECTION. :-) I think this can well be done later
on.

Kind regards,

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

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

end of thread, other threads:[~2012-11-04 17:30 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-10 10:30 [PATCH v5 00/23] V4L: camera control enhancements Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 01/23] V4L: Add helper function for standard integer menu controls Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 02/23] V4L: Add camera exposure bias control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 03/23] V4L: Add an extended camera white balance control Sylwester Nawrocki
2012-05-14  0:02   ` Sakari Ailus
2012-05-15 21:28     ` Sylwester Nawrocki
2012-05-16  6:57       ` Sakari Ailus
2012-05-16  9:34         ` Sylwester Nawrocki
2012-05-17 22:37           ` Sakari Ailus
2012-05-15 21:53     ` [PATCH] V4L: DocBook: Improve V4L2_AUTO_N_WHITE_BALANCE control description Sylwester Nawrocki
2012-05-19 20:27       ` [PATCH v3] V4L: DocBook: Improve V4L2_CID_AUTO_N_WHITE_BALANCE " Sylwester Nawrocki
2012-05-15 22:05     ` [PATCH v2] " Sylwester Nawrocki
2012-05-17 22:42       ` Sakari Ailus
2012-05-10 10:30 ` [PATCH 04/23] V4L: Add camera wide dynamic range control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 05/23] V4L: Add camera image stabilization control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 06/23] V4L: Add camera ISO sensitivity controls Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 07/23] V4L: Add camera exposure metering control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 08/23] V4L: Add camera scene mode control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 09/23] V4L: Add camera 3A lock control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 10/23] V4L: Add auto focus targets to the selections API Sylwester Nawrocki
2012-10-29 20:00   ` Sakari Ailus
2012-10-29 22:43     ` Sylwester Nawrocki
2012-11-04 17:29       ` Sakari Ailus
2012-05-10 10:30 ` [PATCH 11/23] V4L: Add auto focus targets to the subdev " Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 12/23] V4L: Add camera auto focus controls Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 13/23] m5mols: Convert macros to inline functions Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 14/23] m5mols: Refactored controls handling Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 15/23] m5mols: Use proper sensor mode for the controls Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 16/23] m5mols: Add ISO sensitivity controls Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 17/23] m5mols: Add auto and preset white balance control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 18/23] m5mols: Add exposure bias control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 19/23] m5mols: Add wide dynamic range control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 20/23] m5mols: Add image stabilization control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 21/23] m5mols: Add exposure metering control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 22/23] m5mols: Add JPEG compression quality control Sylwester Nawrocki
2012-05-10 10:30 ` [PATCH 23/23] m5mols: Add 3A lock control Sylwester Nawrocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.