From: Hans de Goede <johannes.goede@oss.qualcomm.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>, Kate Hsuan <hpa@redhat.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Hans de Goede <hansg@kernel.org>
Subject: Re: [PATCH v11] media: Add t4ka3 camera sensor driver
Date: Tue, 17 Mar 2026 21:17:22 +0100 [thread overview]
Message-ID: <8b849d79-0248-471d-beed-b774b6cf218b@oss.qualcomm.com> (raw)
In-Reply-To: <abmVMOR9MMpTtj98@kekkonen.localdomain>
Hi Sakari,
On 17-Mar-26 18:53, Sakari Ailus wrote:
...
>>>> +static struct v4l2_mbus_framefmt *t4ka3_get_active_format(struct t4ka3_data *sensor)
>>>> +{
>>>> + struct v4l2_subdev_state *active_state =
>>>> + v4l2_subdev_get_locked_active_state(&sensor->sd);
>>>> +
>>>> + return v4l2_subdev_state_get_format(active_state, 0);
>>>> +}
>>>> +
>>>> +static struct v4l2_rect *t4ka3_get_active_crop(struct t4ka3_data *sensor)
>>>> +{
>>>> + struct v4l2_subdev_state *active_state =
>>>> + v4l2_subdev_get_locked_active_state(&sensor->sd);
>>>> +
>>>> + return v4l2_subdev_state_get_crop(active_state, 0);
>>>
>>> Please avoid adding such helpers.
>> As Hans mentioned, we can put active format and crop in the t4ka3_data
>> or keep the helpers.
>
> What prevents you doing:
>
> struct v4l2_subdev_state *active_state =
> v4l2_subdev_get_locked_active_state(&sensor->sd);
> struct v4l2_rect *r = v4l2_subdev_state_get_crop(active_state, 0);
>
> in the code? In a lot of the cases you could simply pass the state to the
> function using it as the caller already has it.
Ok, I've done a quick audit of the code and it indeed seems that
in some cases, especially in t4ka3_set_pad_format() these helpers
are used unnecessary (and even buggy in case of the crop in
t4ka3_set_pad_format()).
So I agree it is probably better to avoid these and in functions
where we have a sd_state pass the result of:
v4l2_subdev_state_get_format(sd_state, [0|sel->pad])
and:
v4l2_subdev_state_get_crop(sd_state, [0|sel->pad])
to helpers which currently rely on t4ka3_get_active_[format|crop]()
such as t4ka3_calc_mode().
E.g. all callers of t4ka3_calc_mode() already get sd_state passed
in; and both callers also already both should get crop and fmt
from the sd_state (t4ka3_set_pad_format() wrongly uses the
functions to get the active fmt/crop for this).
So we can simply pass the already retrieved fmt + crop
into t4ka3_calc_mode().
As for other calles of t4ka3_get_active_[format|crop]() if
they really do not have sd_state access then lets just
write out the code as suggested by Sakari.
Kate, let me know if you need any help with this.
Regards,
Hans
next prev parent reply other threads:[~2026-03-17 20:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 8:57 Kate Hsuan
2026-03-16 22:00 ` Sakari Ailus
2026-03-17 12:04 ` Hans de Goede
2026-03-17 12:24 ` Hans de Goede
2026-03-17 13:26 ` Kate Hsuan
2026-03-17 17:58 ` Sakari Ailus
2026-03-17 19:56 ` Hans de Goede
2026-03-17 22:35 ` Sakari Ailus
2026-03-17 13:24 ` Kate Hsuan
2026-03-17 17:53 ` Sakari Ailus
2026-03-17 20:17 ` Hans de Goede [this message]
2026-03-18 7:28 ` Kate Hsuan
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=8b849d79-0248-471d-beed-b774b6cf218b@oss.qualcomm.com \
--to=johannes.goede@oss.qualcomm.com \
--cc=hansg@kernel.org \
--cc=hpa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.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®