From: Volodymyr Kharuk <vkh@melexis.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org, Andrii Kyselov <ays@melexis.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
devicetree@vger.kernel.org,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Subject: Re: [PATCH v3 4/8] media: v4l: ctrls-api: Allow array update in __v4l2_ctrl_modify_range
Date: Thu, 1 Dec 2022 17:44:52 +0200 [thread overview]
Message-ID: <Y4jL9Mu7T/TO4g66@melexis.com> (raw)
In-Reply-To: <023c0d14-c3f1-4b59-4718-d2cf2bb4699f@xs4all.nl>
Hi Hans,
On Fri, Nov 25, 2022 at 03:35:34PM +0100, Hans Verkuil wrote:
> On 25/11/2022 14:34, Volodymyr Kharuk wrote:
> > For V4L2_CID_TOF_TINT, which is dynamic array, it is required to use
> > __v4l2_ctrl_modify_range. So the idea is to use type_ops instead of u64
> > from union. It will allow to work with any type.
> >
> > Signed-off-by: Volodymyr Kharuk <vkh@melexis.com>
> > ---
> > drivers/media/v4l2-core/v4l2-ctrls-api.c | 15 +++------------
> > 1 file changed, 3 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-core/v4l2-ctrls-api.c
> > index d0a3aa3806fb..09735644a2f1 100644
> > --- a/drivers/media/v4l2-core/v4l2-ctrls-api.c
> > +++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c
> > @@ -942,8 +942,6 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
> > case V4L2_CTRL_TYPE_U8:
> > case V4L2_CTRL_TYPE_U16:
> > case V4L2_CTRL_TYPE_U32:
> > - if (ctrl->is_array)
> > - return -EINVAL;
> > ret = check_range(ctrl->type, min, max, step, def);
> > if (ret)
> > return ret;
> > @@ -960,17 +958,10 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
> > ctrl->default_value = def;
> > }
> > cur_to_new(ctrl);
> > - if (validate_new(ctrl, ctrl->p_new)) {
> > - if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64)
> > - *ctrl->p_new.p_s64 = def;
> > - else
> > - *ctrl->p_new.p_s32 = def;
> > - }
> > + if (validate_new(ctrl, ctrl->p_new))
> > + ctrl->type_ops->init(ctrl, 0, ctrl->p_new);
>
> Hmm, this sets *all* elements of the array to the default_value, not
> just the elements whose value is out of range.
>
> Is that what you want? Should this perhaps depend on the type of
> control? I.e. in some cases it might make sense to do this, in other
> cases it makes more sense to only adjust the elements that are out
> of range.
>
> How does that work for this TINT control?
Actually for types like INTEGER/U8/U16/U32/BOOLEAN/BUTTON/BITMASK, the function
validate_new will return zero always as well as they fix the range on the fly.
So that is ok for mlx7502x sensors.
For types like compound/string/menu indeed, it will sets all elements of array
to default array. To fix it I propose to fix it by using the functions
std_validate_elem to check per element and then set the default manually.
But then it means, that __v4l2_ctrl_modify_range will work only for standart
v4l2 types, and not if driver use their own implementation.
Is it fine for you? What do you think?
>
> Regards,
>
> Hans
>
> >
> > - if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64)
> > - value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64;
> > - else
> > - value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32;
> > + value_changed = !ctrl->type_ops->equal(ctrl, ctrl->p_cur, ctrl->p_new);
> > if (value_changed)
> > ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE);
> > else if (range_changed)
>
--
--
BR,
Volodymyr Kharuk
next prev parent reply other threads:[~2022-12-01 15:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 13:34 [PATCH v3 0/8] media: i2c: mlx7502x ToF camera support Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 1/8] media: uapi: ctrls: Add Time of Flight class controls Volodymyr Kharuk
2022-11-25 14:20 ` Hans Verkuil
2022-11-25 15:05 ` Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 2/8] media: v4l: ctrls: Fill V4L2_CID_TOF_CLASS controls Volodymyr Kharuk
2022-11-25 14:22 ` Hans Verkuil
2022-11-25 15:07 ` Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 3/8] media: Documentation: v4l: Add TOF class controls Volodymyr Kharuk
2022-11-25 14:28 ` Hans Verkuil
2022-11-25 16:01 ` Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 4/8] media: v4l: ctrls-api: Allow array update in __v4l2_ctrl_modify_range Volodymyr Kharuk
2022-11-25 14:35 ` Hans Verkuil
2022-12-01 15:44 ` Volodymyr Kharuk [this message]
2022-12-01 16:46 ` Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 5/8] media: v4l: ctrls: Add user control base for mlx7502x Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 6/8] media: uapi: Add mlx7502x header file Volodymyr Kharuk
2022-11-25 14:39 ` Hans Verkuil
2022-11-25 15:09 ` Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 7/8] media: dt-bindings: media: i2c: Add mlx7502x camera sensor Volodymyr Kharuk
2022-11-25 15:19 ` Krzysztof Kozlowski
2022-11-25 15:37 ` Volodymyr Kharuk
2022-11-25 13:34 ` [PATCH v3 8/8] media: i2c: Add driver for mlx7502x ToF sensor Volodymyr Kharuk
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=Y4jL9Mu7T/TO4g66@melexis.com \
--to=vkh@melexis.com \
--cc=ays@melexis.com \
--cc=benjamin.mugnier@foss.st.com \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh+dt@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