From: Umang Jain <umang.jain@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Kieran Bingham <kieran.bingham@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
open list <linux-kernel@vger.kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Umang Jain <umang.jain@ideasonboard.com>
Subject: [PATCH 2/4] media: i2c: imx335: Refactor power sequence to set controls
Date: Thu, 25 Jan 2024 21:19:06 +0530 [thread overview]
Message-ID: <20240125154908.465191-3-umang.jain@ideasonboard.com> (raw)
In-Reply-To: <20240125154908.465191-1-umang.jain@ideasonboard.com>
Additional controls might require the sensor to be powered up
to set the control value. Currently, only the exposure control
powers up the sensor.
Move the power up sequence out of the switch-case block.
In a subsequent patch, test pattern control will be added that
needs the sensor to be powered up. Hence, refactor the power
sequence to be present outside the switch-case block.
The VBLANK control is also moved out of the switch-case in order
to be handled early on, to propagate the changes to other controls.
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
drivers/media/i2c/imx335.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c
index 0df9ea189fff..5add50af20e6 100644
--- a/drivers/media/i2c/imx335.c
+++ b/drivers/media/i2c/imx335.c
@@ -475,8 +475,8 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl)
u32 exposure;
int ret;
- switch (ctrl->id) {
- case V4L2_CID_VBLANK:
+ /* Propagate change of current control to all related controls */
+ if (ctrl->id == V4L2_CID_VBLANK) {
imx335->vblank = imx335->vblank_ctrl->val;
dev_dbg(imx335->dev, "Received vblank %u, new lpfr %u\n",
@@ -489,12 +489,17 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl)
imx335->cur_mode->height -
IMX335_EXPOSURE_OFFSET,
1, IMX335_EXPOSURE_DEFAULT);
- break;
- case V4L2_CID_EXPOSURE:
- /* Set controls only if sensor is in power on state */
- if (!pm_runtime_get_if_in_use(imx335->dev))
- return 0;
+ }
+
+ /*
+ * Applying V4L2 control value only happens
+ * when power is up for streaming.
+ */
+ if (pm_runtime_get_if_in_use(imx335->dev) == 0)
+ return 0;
+ switch (ctrl->id) {
+ case V4L2_CID_EXPOSURE:
exposure = ctrl->val;
analog_gain = imx335->again_ctrl->val;
@@ -503,14 +508,14 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl)
ret = imx335_update_exp_gain(imx335, exposure, analog_gain);
- pm_runtime_put(imx335->dev);
-
break;
default:
dev_err(imx335->dev, "Invalid control %d\n", ctrl->id);
ret = -EINVAL;
}
+ pm_runtime_put(imx335->dev);
+
return ret;
}
--
2.41.0
next prev parent reply other threads:[~2024-01-25 15:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 15:49 [PATCH 0/4] imx335: Support additional link-freq and TPG Umang Jain
2024-01-25 15:49 ` [PATCH 1/4] media: i2c: imx335: Drop setting of 0x3a00 register Umang Jain
2024-01-25 16:05 ` Sakari Ailus
2024-01-25 15:49 ` Umang Jain [this message]
2024-01-25 15:49 ` [PATCH 3/4] media: i2c: imx335: Support multiple link frequency Umang Jain
2024-01-25 15:49 ` [PATCH 4/4] media: i2c: imx335: Add support for test pattern generator Umang Jain
2024-01-25 16:19 ` Sakari Ailus
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=20240125154908.465191-3-umang.jain@ideasonboard.com \
--to=umang.jain@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®