All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: linux-media@vger.kernel.org
Cc: m.szyprowski@samsung.com, riverful.kim@samsung.com,
	sw0312.kim@samsung.com, s.nawrocki@samsung.com,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: [PATCH 15/23] m5mols: Use proper sensor mode for the controls
Date: Thu, 10 May 2012 12:30:50 +0200	[thread overview]
Message-ID: <1336645858-30366-16-git-send-email-s.nawrocki@samsung.com> (raw)
In-Reply-To: <1336645858-30366-1-git-send-email-s.nawrocki@samsung.com>

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


  parent reply	other threads:[~2012-05-10 10:31 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Sylwester Nawrocki [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336645858-30366-16-git-send-email-s.nawrocki@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=riverful.kim@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.