linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Lars-Peter Clausen <lars@metafoo.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH 07/11] media: adv7180: Split device initialization and reset
Date: Thu,  3 Jul 2025 22:52:19 +0200	[thread overview]
Message-ID: <20250703205223.2810806-8-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20250703205223.2810806-1-niklas.soderlund+renesas@ragnatech.se>

The two different tasks of resetting and initializing the devices, and
configured the video formats are grouped lumped together in a single
function. These two tasks are then only performed at probe time, or when
resuming from suspend. Configuration of formats are then done directly
by the IOCTL callbacks, such as .set_fmt.

Prepare for reworking the driver to only reset the device at probe and
resume, and configuring all video formats in .s_stream instead of in
each IOCTL callback by splitting the two tasks in two different
functions.

At this point there is no functional change.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/i2c/adv7180.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index eab3ae2331fd..a6f2bf7caa73 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -891,6 +891,23 @@ static int init_device(struct adv7180_state *state)
 
 	lockdep_assert_held(&state->mutex);
 
+	ret = adv7180_program_std(state);
+	if (ret)
+		return ret;
+
+	adv7180_set_field_mode(state);
+
+	__v4l2_ctrl_handler_setup(&state->ctrl_hdl);
+
+	return ret;
+}
+
+static int adv7180_reset_device(struct adv7180_state *state)
+{
+	int ret;
+
+	lockdep_assert_held(&state->mutex);
+
 	adv7180_set_power_pin(state, true);
 	adv7180_set_reset_pin(state, false);
 
@@ -908,14 +925,10 @@ static int init_device(struct adv7180_state *state)
 	if (ret)
 		return ret;
 
-	ret = adv7180_program_std(state);
+	ret = init_device(state);
 	if (ret)
 		return ret;
 
-	adv7180_set_field_mode(state);
-
-	__v4l2_ctrl_handler_setup(&state->ctrl_hdl);
-
 	/* register for interrupts */
 	if (state->irq > 0) {
 		/* config the Interrupt pin to be active low */
@@ -1501,7 +1514,7 @@ static int adv7180_probe(struct i2c_client *client)
 		goto err_free_ctrl;
 
 	mutex_lock(&state->mutex);
-	ret = init_device(state);
+	ret = adv7180_reset_device(state);
 	mutex_unlock(&state->mutex);
 	if (ret)
 		goto err_media_entity_cleanup;
@@ -1587,7 +1600,7 @@ static int adv7180_resume(struct device *dev)
 
 	guard(mutex)(&state->mutex);
 
-	ret = init_device(state);
+	ret = adv7180_reset_device(state);
 	if (ret < 0)
 		return ret;
 
-- 
2.50.0


  parent reply	other threads:[~2025-07-03 20:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 20:52 [PATCH 00/11] media: adv7180: Improve the control over decoder power Niklas Söderlund
2025-07-03 20:52 ` [PATCH 01/11] media: adv7180: Move adv7180_set_power() and init_device() Niklas Söderlund
2025-07-03 22:41   ` Laurent Pinchart
2025-07-03 20:52 ` [PATCH 02/11] media: adv7180: Add missing lock in suspend callback Niklas Söderlund
2025-07-03 22:43   ` Laurent Pinchart
2025-07-03 22:51     ` Niklas Söderlund
2025-07-03 23:06       ` Laurent Pinchart
2025-07-03 23:07         ` Niklas Söderlund
2025-07-03 20:52 ` [PATCH 03/11] media: adv7180: Move state mutex handling outside init_device() Niklas Söderlund
2025-07-03 22:45   ` Laurent Pinchart
2025-07-03 20:52 ` [PATCH 04/11] media: adv7180: Use v4l2-ctrls core to handle s_ctrl locking Niklas Söderlund
2025-07-03 22:46   ` Laurent Pinchart
2025-07-03 20:52 ` [PATCH 05/11] media: adv7180: Setup controls every time the device is reset Niklas Söderlund
2025-07-03 22:47   ` Laurent Pinchart
2025-07-03 20:52 ` [PATCH 06/11] media: adv7180: Power down decoder when configuring the device Niklas Söderlund
2025-07-03 20:52 ` Niklas Söderlund [this message]
2025-07-03 20:52 ` [PATCH 08/11] media: adv7180: Remove the s_power callback Niklas Söderlund
2025-07-03 20:52 ` [PATCH 09/11] media: adv7180: Do not write format to device in set_fmt Niklas Söderlund
2025-07-03 22:49   ` Laurent Pinchart
2025-07-03 20:52 ` [PATCH 10/11] media: adv7180: Only validate format in s_std Niklas Söderlund
2025-07-03 20:52 ` [PATCH 11/11] media: adv7180: Only validate format in querystd Niklas Söderlund

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=20250703205223.2810806-8-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=hverkuil@xs4all.nl \
    --cc=lars@metafoo.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).