From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 01/11] media: adv7180: Move adv7180_set_power() and init_device()
Date: Fri, 4 Jul 2025 01:41:07 +0300 [thread overview]
Message-ID: <20250703224107.GC3798@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20250703205223.2810806-2-niklas.soderlund+renesas@ragnatech.se>
On Thu, Jul 03, 2025 at 10:52:13PM +0200, Niklas Söderlund wrote:
> Move the two functions adv7180_set_power() and init_device() earlier in
> the file so they in future changes can be used from .querystd and
> .s_stream as the driver is reworked to drop the usage of .s_power.
>
> While at it fix two style issues in init_device() that checkpatch
> complains about.
>
> - Two cases of indentation issues for function arguments split over
> multiple lines.
>
> - The repetition of the word 'interrupts' in a comment.
>
> Apart from these style fixes the functions are moved verbatim and there
> are no functional changes.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/media/i2c/adv7180.c | 176 ++++++++++++++++++------------------
> 1 file changed, 88 insertions(+), 88 deletions(-)
>
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index 6e50b14f888f..2519bc53333c 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -274,6 +274,38 @@ static int adv7180_vpp_write(struct adv7180_state *state, unsigned int reg,
> return i2c_smbus_write_byte_data(state->vpp_client, reg, value);
> }
>
> +static int adv7180_set_power(struct adv7180_state *state, bool on)
> +{
> + u8 val;
> + int ret;
> +
> + if (on)
> + val = ADV7180_PWR_MAN_ON;
> + else
> + val = ADV7180_PWR_MAN_OFF;
> +
> + ret = adv7180_write(state, ADV7180_REG_PWR_MAN, val);
> + if (ret)
> + return ret;
> +
> + if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> + if (on) {
> + adv7180_csi_write(state, 0xDE, 0x02);
> + adv7180_csi_write(state, 0xD2, 0xF7);
> + adv7180_csi_write(state, 0xD8, 0x65);
> + adv7180_csi_write(state, 0xE0, 0x09);
> + adv7180_csi_write(state, 0x2C, 0x00);
> + if (state->field == V4L2_FIELD_NONE)
> + adv7180_csi_write(state, 0x1D, 0x80);
> + adv7180_csi_write(state, 0x00, 0x00);
> + } else {
> + adv7180_csi_write(state, 0x00, 0x80);
> + }
> + }
> +
> + return 0;
> +}
> +
> static v4l2_std_id adv7180_std_to_v4l2(u8 status1)
> {
> /* in case V4L2_IN_ST_NO_SIGNAL */
> @@ -514,38 +546,6 @@ static void adv7180_set_reset_pin(struct adv7180_state *state, bool on)
> }
> }
>
> -static int adv7180_set_power(struct adv7180_state *state, bool on)
> -{
> - u8 val;
> - int ret;
> -
> - if (on)
> - val = ADV7180_PWR_MAN_ON;
> - else
> - val = ADV7180_PWR_MAN_OFF;
> -
> - ret = adv7180_write(state, ADV7180_REG_PWR_MAN, val);
> - if (ret)
> - return ret;
> -
> - if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
> - if (on) {
> - adv7180_csi_write(state, 0xDE, 0x02);
> - adv7180_csi_write(state, 0xD2, 0xF7);
> - adv7180_csi_write(state, 0xD8, 0x65);
> - adv7180_csi_write(state, 0xE0, 0x09);
> - adv7180_csi_write(state, 0x2C, 0x00);
> - if (state->field == V4L2_FIELD_NONE)
> - adv7180_csi_write(state, 0x1D, 0x80);
> - adv7180_csi_write(state, 0x00, 0x00);
> - } else {
> - adv7180_csi_write(state, 0x00, 0x80);
> - }
> - }
> -
> - return 0;
> -}
> -
> static int adv7180_s_power(struct v4l2_subdev *sd, int on)
> {
> struct adv7180_state *state = to_state(sd);
> @@ -889,6 +889,62 @@ static int adv7180_g_tvnorms(struct v4l2_subdev *sd, v4l2_std_id *norm)
> return 0;
> }
>
> +static int init_device(struct adv7180_state *state)
> +{
> + int ret;
> +
> + mutex_lock(&state->mutex);
> +
> + adv7180_set_power_pin(state, true);
> + adv7180_set_reset_pin(state, false);
> +
> + adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
> + usleep_range(5000, 10000);
> +
> + ret = state->chip_info->init(state);
> + if (ret)
> + goto out_unlock;
> +
> + ret = adv7180_program_std(state);
> + if (ret)
> + goto out_unlock;
> +
> + adv7180_set_field_mode(state);
> +
> + /* register for interrupts */
> + if (state->irq > 0) {
> + /* config the Interrupt pin to be active low */
> + ret = adv7180_write(state, ADV7180_REG_ICONF1,
> + ADV7180_ICONF1_ACTIVE_LOW |
> + ADV7180_ICONF1_PSYNC_ONLY);
> + if (ret < 0)
> + goto out_unlock;
> +
> + ret = adv7180_write(state, ADV7180_REG_IMR1, 0);
> + if (ret < 0)
> + goto out_unlock;
> +
> + ret = adv7180_write(state, ADV7180_REG_IMR2, 0);
> + if (ret < 0)
> + goto out_unlock;
> +
> + /* enable AD change interrupts */
> + ret = adv7180_write(state, ADV7180_REG_IMR3,
> + ADV7180_IRQ3_AD_CHANGE);
> + if (ret < 0)
> + goto out_unlock;
> +
> + ret = adv7180_write(state, ADV7180_REG_IMR4, 0);
> + if (ret < 0)
> + goto out_unlock;
> + }
> +
> +out_unlock:
> + mutex_unlock(&state->mutex);
> +
> + return ret;
> +}
> +
> static int adv7180_s_stream(struct v4l2_subdev *sd, int enable)
> {
> struct adv7180_state *state = to_state(sd);
> @@ -1359,62 +1415,6 @@ static const struct adv7180_chip_info adv7282_m_info = {
> .select_input = adv7182_select_input,
> };
>
> -static int init_device(struct adv7180_state *state)
> -{
> - int ret;
> -
> - mutex_lock(&state->mutex);
> -
> - adv7180_set_power_pin(state, true);
> - adv7180_set_reset_pin(state, false);
> -
> - adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
> - usleep_range(5000, 10000);
> -
> - ret = state->chip_info->init(state);
> - if (ret)
> - goto out_unlock;
> -
> - ret = adv7180_program_std(state);
> - if (ret)
> - goto out_unlock;
> -
> - adv7180_set_field_mode(state);
> -
> - /* register for interrupts */
> - if (state->irq > 0) {
> - /* config the Interrupt pin to be active low */
> - ret = adv7180_write(state, ADV7180_REG_ICONF1,
> - ADV7180_ICONF1_ACTIVE_LOW |
> - ADV7180_ICONF1_PSYNC_ONLY);
> - if (ret < 0)
> - goto out_unlock;
> -
> - ret = adv7180_write(state, ADV7180_REG_IMR1, 0);
> - if (ret < 0)
> - goto out_unlock;
> -
> - ret = adv7180_write(state, ADV7180_REG_IMR2, 0);
> - if (ret < 0)
> - goto out_unlock;
> -
> - /* enable AD change interrupts interrupts */
> - ret = adv7180_write(state, ADV7180_REG_IMR3,
> - ADV7180_IRQ3_AD_CHANGE);
> - if (ret < 0)
> - goto out_unlock;
> -
> - ret = adv7180_write(state, ADV7180_REG_IMR4, 0);
> - if (ret < 0)
> - goto out_unlock;
> - }
> -
> -out_unlock:
> - mutex_unlock(&state->mutex);
> -
> - return ret;
> -}
> -
> static int adv7180_probe(struct i2c_client *client)
> {
> struct device_node *np = client->dev.of_node;
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2025-07-03 22:41 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 [this message]
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 ` [PATCH 07/11] media: adv7180: Split device initialization and reset Niklas Söderlund
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=20250703224107.GC3798@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hverkuil@xs4all.nl \
--cc=lars@metafoo.de \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=niklas.soderlund+renesas@ragnatech.se \
/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).