mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tarang Raval <tarang.raval@siliconsignals.io>
To: sakari.ailus@linux.intel.com, kieran.bingham@ideasonboard.com
Cc: Shravan.Chippa@microchip.com,
	"Tarang Raval" <tarang.raval@siliconsignals.io>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Julien Massot" <julien.massot@collabora.com>,
	"Umang Jain" <umang.jain@ideasonboard.com>,
	"Zhi Mao" <zhi.mao@mediatek.com>,
	"André Apitzsch" <git@apitzsch.eu>,
	"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 9/9] media: i2c: imx334: switch to {enable,disable}_streams
Date: Sat, 29 Mar 2025 11:13:31 +0530	[thread overview]
Message-ID: <20250329054335.19931-10-tarang.raval@siliconsignals.io> (raw)
In-Reply-To: <20250329054335.19931-1-tarang.raval@siliconsignals.io>

Switch from s_stream to enable_streams and disable_streams callbacks.

Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
 drivers/media/i2c/imx334.c | 78 +++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 40 deletions(-)

diff --git a/drivers/media/i2c/imx334.c b/drivers/media/i2c/imx334.c
index 29eec4dd28cc..fe4e9155bca8 100644
--- a/drivers/media/i2c/imx334.c
+++ b/drivers/media/i2c/imx334.c
@@ -847,21 +847,31 @@ static int imx334_set_framefmt(struct imx334 *imx334)
 }
 
 /**
- * imx334_start_streaming() - Start sensor stream
- * @imx334: pointer to imx334 device
+ * imx334_enable_streams() - Enable specified streams for the sensor
+ * @sd: pointer to the V4L2 subdevice
+ * @state: pointer to the subdevice state
+ * @pad: pad number for which streams are enabled
+ * @streams_mask: bitmask specifying the streams to enable
  *
  * Return: 0 if successful, error code otherwise.
  */
-static int imx334_start_streaming(struct imx334 *imx334)
+static int imx334_enable_streams(struct v4l2_subdev *sd,
+				 struct v4l2_subdev_state *state, u32 pad,
+				 u64 streams_mask)
 {
+	struct imx334 *imx334 = to_imx334(sd);
 	const struct imx334_reg_list *reg_list;
 	int ret;
 
+	ret = pm_runtime_resume_and_get(imx334->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = cci_multi_reg_write(imx334->cci, common_mode_regs,
 				  ARRAY_SIZE(common_mode_regs), NULL);
 	if (ret) {
 		dev_err(imx334->dev, "fail to write common registers\n");
-		return ret;
+		goto err_rpm_put;
 	}
 
 	/* Write sensor mode registers */
@@ -870,28 +880,28 @@ static int imx334_start_streaming(struct imx334 *imx334)
 				  reg_list->num_of_regs, NULL);
 	if (ret) {
 		dev_err(imx334->dev, "fail to write initial registers\n");
-		return ret;
+		goto err_rpm_put;
 	}
 
 	ret = cci_write(imx334->cci, IMX334_REG_LANEMODE,
 			IMX334_CSI_4_LANE_MODE, NULL);
 	if (ret) {
 		dev_err(imx334->dev, "failed to configure lanes\n");
-		return ret;
+		goto err_rpm_put;
 	}
 
 	ret = imx334_set_framefmt(imx334);
 	if (ret) {
 		dev_err(imx334->dev, "%s failed to set frame format: %d\n",
 			__func__, ret);
-		return ret;
+		goto err_rpm_put;
 	}
 
 	/* Setup handler will write actual exposure and gain */
 	ret =  __v4l2_ctrl_handler_setup(imx334->sd.ctrl_handler);
 	if (ret) {
 		dev_err(imx334->dev, "fail to setup handler\n");
-		return ret;
+		goto err_rpm_put;
 	}
 
 	/* Start streaming */
@@ -899,53 +909,39 @@ static int imx334_start_streaming(struct imx334 *imx334)
 			IMX334_MODE_STREAMING, NULL);
 	if (ret) {
 		dev_err(imx334->dev, "fail to start streaming\n");
-		return ret;
+		goto err_rpm_put;
 	}
 
 	return 0;
-}
 
-/**
- * imx334_stop_streaming() - Stop sensor stream
- * @imx334: pointer to imx334 device
- *
- * Return: 0 if successful, error code otherwise.
- */
-static int imx334_stop_streaming(struct imx334 *imx334)
-{
-	return cci_write(imx334->cci, IMX334_REG_MODE_SELECT,
-			IMX334_MODE_STANDBY, NULL);
+err_rpm_put:
+	pm_runtime_put(imx334->dev);
+	return ret;
 }
 
 /**
- * imx334_set_stream() - Enable sensor streaming
- * @sd: pointer to imx334 subdevice
- * @enable: set to enable sensor streaming
+ * imx334_disable_streams() - Enable specified streams for the sensor
+ * @sd: pointer to the V4L2 subdevice
+ * @state: pointer to the subdevice state
+ * @pad: pad number for which streams are disabled
+ * @streams_mask: bitmask specifying the streams to disable
  *
  * Return: 0 if successful, error code otherwise.
  */
-static int imx334_set_stream(struct v4l2_subdev *sd, int enable)
+static int imx334_disable_streams(struct v4l2_subdev *sd,
+				  struct v4l2_subdev_state *state, u32 pad,
+				  u64 streams_mask)
 {
 	struct imx334 *imx334 = to_imx334(sd);
 	int ret;
 
-	if (enable) {
-		ret = pm_runtime_resume_and_get(imx334->dev);
-		if (ret < 0)
-			return ret;
-
-		ret = imx334_start_streaming(imx334);
-		if (ret)
-			goto error_power_off;
-	} else {
-		imx334_stop_streaming(imx334);
-		pm_runtime_put(imx334->dev);
-	}
-
-	return 0;
+	ret = cci_write(imx334->cci, IMX334_REG_MODE_SELECT,
+			IMX334_MODE_STANDBY, NULL);
+	if (ret)
+		dev_err(imx334->dev, "%s failed to stop stream\n", __func__);
 
-error_power_off:
 	pm_runtime_put(imx334->dev);
+
 	return ret;
 }
 
@@ -1040,7 +1036,7 @@ static int imx334_parse_hw_config(struct imx334 *imx334)
 
 /* V4l2 subdevice ops */
 static const struct v4l2_subdev_video_ops imx334_video_ops = {
-	.s_stream = imx334_set_stream,
+	.s_stream = v4l2_subdev_s_stream_helper,
 };
 
 static const struct v4l2_subdev_pad_ops imx334_pad_ops = {
@@ -1048,6 +1044,8 @@ static const struct v4l2_subdev_pad_ops imx334_pad_ops = {
 	.enum_frame_size = imx334_enum_frame_size,
 	.get_fmt = imx334_get_pad_format,
 	.set_fmt = imx334_set_pad_format,
+	.enable_streams = imx334_enable_streams,
+	.disable_streams = imx334_disable_streams,
 };
 
 static const struct v4l2_subdev_ops imx334_subdev_ops = {
-- 
2.34.1


  parent reply	other threads:[~2025-03-29  5:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-29  5:43 [PATCH v2 0/9] media: i2c: imx334: Miscellaneous cleanups and improvements Tarang Raval
2025-03-29  5:43 ` [PATCH v2 1/9] media: i2c: imx334: Simplify with dev_err_probe() Tarang Raval
2025-03-29  5:43 ` [PATCH v2 2/9] media: i2c: imx334: Convert to CCI register access helpers Tarang Raval
2025-03-29  5:43 ` [PATCH v2 3/9] media: i2c: imx334: Remove redundant register entries Tarang Raval
2025-03-29  5:43 ` [PATCH v2 4/9] media: i2c: imx334: Configure lane mode Dynamically Tarang Raval
2025-03-29  5:43 ` [PATCH v2 5/9] media: i2c: imx334: Fix power management and control handling Tarang Raval
2025-03-29  5:43 ` [PATCH v2 6/9] media: i2c: imx334: Fix runtime PM handling in remove function Tarang Raval
2025-03-29  5:43 ` [PATCH v2 7/9] media: i2c: imx334: Enable runtime PM before sub-device registration Tarang Raval
2025-03-29  5:43 ` [PATCH v2 8/9] media: i2c: imx334: Use subdev state lock for synchronization Tarang Raval
2025-03-29  5:43 ` Tarang Raval [this message]
2025-04-15  9:23 ` [PATCH v2 0/9] media: i2c: imx334: Miscellaneous cleanups and improvements Tarang Raval
2025-04-25  5:54   ` 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=20250329054335.19931-10-tarang.raval@siliconsignals.io \
    --to=tarang.raval@siliconsignals.io \
    --cc=Shravan.Chippa@microchip.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=git@apitzsch.eu \
    --cc=hverkuil@xs4all.nl \
    --cc=julien.massot@collabora.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=umang.jain@ideasonboard.com \
    --cc=zhi.mao@mediatek.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®