From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Edgar Thier <info@edgarthier.net>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH] uvcvideo: Apply flags from device to actual properties
Date: Wed, 16 Aug 2017 17:58:04 +0300 [thread overview]
Message-ID: <1516233.pKQSzG3xyp@avalon> (raw)
In-Reply-To: <ca483e75-4519-2bc3-eb11-db647fc60860@edgarthier.net>
Hi Edgar,
Thank you for the patch.
On Tuesday 15 Aug 2017 12:59:47 Edgar Thier wrote:
> Use flags the device exposes for UVC controls.
In addition to explaining what the patch does, the commit message should
explain why the change is needed. What is the problem you're trying to address
here ?
> Signed-off-by: Edgar Thier <info@edgarthier.net>
> ---
> drivers/media/usb/uvc/uvc_ctrl.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c
> b/drivers/media/usb/uvc/uvc_ctrl.c index c2ee6e3..bc69e92 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1568,7 +1568,8 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
> return ret;
> }
>
> - ctrl->loaded = 1;
> + if (!(ctrl->info.flags && UVC_CTRL_FLAG_AUTO_UPDATE))
> + ctrl->loaded = 1;
I think this change is unrelated to the subject of this patch. It should be
split to a separate patch.
This being said, why is this change needed ? The uvc_ctrl_set() function is
called from uvc_ctrl_s_ctrl() and uvc_ioctl_s_try_ext_ctrls(), and followed by
a uvc_ctrl_rollback() or uvc_ctrl_commit() call that will set the loaded flag
back to 0 in uvc_ctrl_commit_entity().
> }
>
> /* Backup the current value in case we need to rollback later. */
> @@ -1889,8 +1890,13 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
> static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control
> *ctrl, const struct uvc_control_info *info)
> {
> + u8 *data;
> int ret = 0;
>
> + data = kmalloc(2, GFP_KERNEL);
> + if (data == NULL)
> + return -ENOMEM;
> +
> ctrl->info = *info;
> INIT_LIST_HEAD(&ctrl->info.mappings);
>
> @@ -1904,6 +1910,23 @@ static int uvc_ctrl_add_info(struct uvc_device *dev,
> struct uvc_control *ctrl,
>
> ctrl->initialized = 1;
>
> + ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev-
>intfnum,
> + info->selector, data, 1);
> + if (ret < 0) {
> + uvc_trace(UVC_TRACE_CONTROL,
> + "GET_INFO failed on control %pUl/%u (%d).\n",
> + info->entity, info->selector, ret);
> + }
> + else {
> + ctrl->info.flags = UVC_CTRL_FLAG_GET_MIN |
UVC_CTRL_FLAG_GET_MAX
> + | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
> + | (data[0] & UVC_CONTROL_CAP_GET ?
> + UVC_CTRL_FLAG_GET_CUR : 0)
> + | (data[0] & UVC_CONTROL_CAP_SET ?
> + UVC_CTRL_FLAG_SET_CUR : 0)
> + | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> + UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> + }
This code seems copied from uvc_ctrl_fill_xu_info(). I'd rather move it to a
function that can be called by both instead of duplicating it.
> uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
> "entity %u\n", ctrl->info.entity, ctrl->info.selector,
> dev->udev->devpath, ctrl->entity->id);
> @@ -1911,6 +1934,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev,
> struct uvc_control *ctrl, done:
> if (ret < 0)
> kfree(ctrl->uvc_data);
> + kfree(data);
> return ret;
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2017-08-16 14:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 10:59 [PATCH] uvcvideo: Apply flags from device to actual properties Edgar Thier
2017-08-16 14:58 ` Laurent Pinchart [this message]
2017-08-18 10:12 ` Edgar Thier
2017-10-05 9:23 ` Edgar Thier
2017-10-05 9:43 ` Kieran Bingham
2017-10-05 11:05 ` Kieran Bingham
2017-10-06 10:34 ` Edgar Thier
2017-10-09 8:28 ` Kieran Bingham
2017-10-11 11:56 ` Edgar Thier
2017-10-11 12:21 ` Kieran Bingham
2017-10-12 7:54 ` Edgar Thier
2017-11-15 8:11 ` Edgar Thier
2017-11-15 11:53 ` Kieran Bingham
2017-11-15 12:01 ` Edgar Thier
2017-11-15 11:54 ` Kieran Bingham
2017-12-15 7:07 ` Edgar Thier
2018-01-02 20:07 ` Laurent Pinchart
2018-01-02 23:33 ` Laurent Pinchart
2018-01-03 6:07 ` Edgar Thier
2018-01-03 10:57 ` Laurent Pinchart
2017-10-06 10:33 ` Edgar Thier
-- strict thread matches above, loose matches on Subject: below --
2018-01-03 10:59 Laurent Pinchart
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=1516233.pKQSzG3xyp@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=info@edgarthier.net \
--cc=linux-media@vger.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).