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 v2 11/11] media: adv7180: Only validate format in querystd
Date: Thu, 28 Aug 2025 18:06:54 +0200 [thread overview]
Message-ID: <20250828160654.1467762-12-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20250828160654.1467762-1-niklas.soderlund+renesas@ragnatech.se>
The .querystd callback should not program the device with the detected
standard, it should only report the standard to user-space. User-space
may then use .s_std to set the standard, if it wants to use it.
All that is required of .querystd is to setup the auto detection of
standards and report its findings.
While at it add some documentation on why this can't happen while
streaming and improve the error handling using a scoped guard.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/media/i2c/adv7180.c | 37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 47112b43769d..ca0bdfa9dcda 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -388,32 +388,27 @@ static inline struct adv7180_state *to_state(struct v4l2_subdev *sd)
static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
{
struct adv7180_state *state = to_state(sd);
- int err = mutex_lock_interruptible(&state->mutex);
- if (err)
- return err;
+ int ret;
- if (state->streaming) {
- err = -EBUSY;
- goto unlock;
- }
+ guard(mutex)(&state->mutex);
- err = adv7180_set_video_standard(state,
- ADV7180_STD_AD_PAL_BG_NTSC_J_SECAM);
- if (err)
- goto unlock;
+ /*
+ * We can't sample the standard if the device is streaming as that would
+ * interfere with the capture session as the VID_SEL reg is touched.
+ */
+ if (state->streaming)
+ return -EBUSY;
+ /* Set the standard to autodetect PAL B/G/H/I/D, NTSC J or SECAM */
+ ret = adv7180_set_video_standard(state,
+ ADV7180_STD_AD_PAL_BG_NTSC_J_SECAM);
+ if (ret)
+ return ret;
+
+ /* Allow some time for the autodetection to run. */
msleep(100);
- __adv7180_status(state, NULL, std);
- err = v4l2_std_to_adv7180(state->curr_norm);
- if (err < 0)
- goto unlock;
-
- err = adv7180_set_video_standard(state, err);
-
-unlock:
- mutex_unlock(&state->mutex);
- return err;
+ return __adv7180_status(state, NULL, std);
}
static int adv7180_s_routing(struct v4l2_subdev *sd, u32 input,
--
2.51.0
next prev parent reply other threads:[~2025-08-28 16:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-28 16:06 [PATCH v2 00/11] media: adv7180: Improve the control over decoder power Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 01/11] media: adv7180: Move adv7180_set_power() and init_device() Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 02/11] media: adv7180: Add missing lock in suspend callback Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 03/11] media: adv7180: Move state mutex handling outside init_device() Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 04/11] media: adv7180: Use v4l2-ctrls core to handle s_ctrl locking Niklas Söderlund
2025-09-03 8:28 ` Hans Verkuil
2025-08-28 16:06 ` [PATCH v2 05/11] media: adv7180: Setup controls every time the device is reset Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 06/11] media: adv7180: Power down decoder when configuring the device Niklas Söderlund
2025-09-03 8:30 ` Hans Verkuil
2025-08-28 16:06 ` [PATCH v2 07/11] media: adv7180: Split device initialization and reset Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 08/11] media: adv7180: Remove the s_power callback Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 09/11] media: adv7180: Do not write format to device in set_fmt Niklas Söderlund
2025-08-28 16:06 ` [PATCH v2 10/11] media: adv7180: Only validate format in s_std Niklas Söderlund
2025-08-28 16:06 ` Niklas Söderlund [this message]
2025-09-03 8:46 ` [PATCH v2 00/11] media: adv7180: Improve the control over decoder power Hans Verkuil
2025-09-03 14:35 ` Niklas Söderlund
2025-09-03 21:29 ` Hans Verkuil
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=20250828160654.1467762-12-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).