From: Matthias Fend <matthias.fend@emfend.at>
To: Dave Stevenson <dave.stevenson@raspberrypi.com>
Cc: Kieran Bingham <kieran.bingham@ideasonboard.com>,
Umang Jain <uajain@igalia.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] media: i2c: imx283: implement {g,s}_register
Date: Wed, 17 Dec 2025 13:21:28 +0100 [thread overview]
Message-ID: <2f93eda4-483e-4fa2-a765-73e8df4eeaea@emfend.at> (raw)
In-Reply-To: <CAPY8ntCiOJb9iyFDYS_wxhteoHL7vMFpEF8gVwrf2qeFd-Fssw@mail.gmail.com>
Hi Dave,
thanks for your comment.
Am 17.12.2025 um 12:54 schrieb Dave Stevenson:
> Hi Matthias
>
> On Wed, 17 Dec 2025 at 07:41, Matthias Fend <matthias.fend@emfend.at> wrote:
>>
>> Implement {g,s}_register to support advanced V4L2 debug functionality.
>
> Is there any real benefit to providing access via {g,s}_register
> rather than using i2ctransfer -f ? The I2C framework ensures that each
> transfer is atomic as long as it is formed into one transaction
> request.
This allows, for example, the registers to be changed when the image
sensor is actually used in streaming mode.
IMHO, this cannot be covered by i2ctransfer, as the device is used
exclusively by the driver.
>
> IMHO The only place these are really needed is with devices such as
> the adv7180 family which have a bank and page addressing scheme, and
> the driver is caching the last accessed bank.
>
>> Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
>> ---
>> drivers/media/i2c/imx283.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 44 insertions(+)
>>
>> diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
>> index 7a6ab2941ea985401b21d60163b58e980cf31ddc..d8ccde0a1587259f39a10984c517cc57d323b6bc 100644
>> --- a/drivers/media/i2c/imx283.c
>> +++ b/drivers/media/i2c/imx283.c
>> @@ -1295,7 +1295,51 @@ static const struct v4l2_subdev_internal_ops imx283_internal_ops = {
>> .init_state = imx283_init_state,
>> };
>>
>> +#ifdef CONFIG_VIDEO_ADV_DEBUG
>> +static int imx283_g_register(struct v4l2_subdev *sd,
>> + struct v4l2_dbg_register *reg)
>> +{
>> + struct imx283 *imx283 = to_imx283(sd);
>> + u64 val;
>> + int ret;
>> +
>> + if (!pm_runtime_get_if_active(imx283->dev))
>> + return 0;
>
> Returning no error if the device is powered down feels wrong. How is
> the caller meant to differentiate between powered down and the
> register actually containing 0?
The only other I2C drivers that use pm* in {g,s}_register seem to be
imx283 and tc358746. Since both return 0 when the device is inactive, I
figured there must be a reason for this and implemented it that way as well.
Thanks
~Matthias
>
>> +
>> + ret = cci_read(imx283->cci, CCI_REG8(reg->reg), &val, NULL);
>> + reg->val = val;
>> +
>> + pm_runtime_put(imx283->dev);
>> +
>> + return ret;
>> +}
>> +
>> +static int imx283_s_register(struct v4l2_subdev *sd,
>> + const struct v4l2_dbg_register *reg)
>> +{
>> + struct imx283 *imx283 = to_imx283(sd);
>> + int ret;
>> +
>> + if (!pm_runtime_get_if_active(imx283->dev))
>> + return 0;
>
> Ditto here. The caller is told the value was written, but it wasn't.
>
> Thanks.
> Dave
>
>> +
>> + ret = cci_write(imx283->cci, CCI_REG8(reg->reg), reg->val, NULL);
>> +
>> + pm_runtime_put(imx283->dev);
>> +
>> + return ret;
>> +}
>> +#endif
>> +
>> +static const struct v4l2_subdev_core_ops imx283_core_ops = {
>> +#ifdef CONFIG_VIDEO_ADV_DEBUG
>> + .g_register = imx283_g_register,
>> + .s_register = imx283_s_register,
>> +#endif
>> +};
>> +
>> static const struct v4l2_subdev_ops imx283_subdev_ops = {
>> + .core = &imx283_core_ops,
>> .video = &imx283_video_ops,
>> .pad = &imx283_pad_ops,
>> };
>>
>> --
>> 2.34.1
>>
>>
next prev parent reply other threads:[~2025-12-17 12:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 7:05 [PATCH 0/3] drivers: media: imx283 extensions Matthias Fend
2025-12-17 7:06 ` [PATCH 1/3] media: dt-bindings: imx283: add clock-noncontinuous Matthias Fend
2025-12-17 12:03 ` Krzysztof Kozlowski
2025-12-17 12:26 ` Matthias Fend
2025-12-17 12:31 ` Krzysztof Kozlowski
2025-12-17 7:06 ` [PATCH 2/3] media: i2c: imx283: add support for non-continuous MIPI clock mode Matthias Fend
2025-12-30 10:44 ` Kieran Bingham
2026-01-01 18:09 ` Matthias Fend
2025-12-17 7:06 ` [PATCH 3/3] media: i2c: imx283: implement {g,s}_register Matthias Fend
2025-12-17 11:54 ` Dave Stevenson
2025-12-17 12:21 ` Matthias Fend [this message]
2025-12-17 12:42 ` Kieran Bingham
2025-12-17 14:02 ` Matthias Fend
2025-12-17 15:39 ` Dave Stevenson
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=2f93eda4-483e-4fa2-a765-73e8df4eeaea@emfend.at \
--to=matthias.fend@emfend.at \
--cc=conor+dt@kernel.org \
--cc=dave.stevenson@raspberrypi.com \
--cc=devicetree@vger.kernel.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=uajain@igalia.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