From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH v8 3/3] uvcvideo: handle control pipe protocol STALLs
Date: Tue, 17 Jul 2018 23:58:03 +0300 [thread overview]
Message-ID: <7129850.vz39VDuykc@avalon> (raw)
In-Reply-To: <1525792064-30836-4-git-send-email-guennadi.liakhovetski@intel.com>
Hi Guennadi,
Thank you for the patch.
On Tuesday, 8 May 2018 18:07:44 EEST Guennadi Liakhovetski wrote:
> When a command ends up in a STALL on the control pipe, use the Request
> Error Code control to provide a more precise error information to the
> user. For example, if a camera is still busy processing a control,
> when the same or an interrelated control set request arrives, the
> camera can react with a STALL and then return the "Not ready" status
> in response to a UVC_VC_REQUEST_ERROR_CODE_CONTROL command. With this
> patch the user would then get an EBUSY error code instead of a
> generic EPIPE.
>
> Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>
> v8:
>
> * restrict UVC_VC_REQUEST_ERROR_CODE_CONTROL to the control interface
> * fix the wIndex value
> * improve error codes
> * cosmetic changes
>
> drivers/media/usb/uvc/uvc_video.c | 52 +++++++++++++++++++++++++++++++-----
> 1 file changed, 46 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c
> b/drivers/media/usb/uvc/uvc_video.c index aa0082f..ce65cd6 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -73,17 +73,57 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8
> unit, u8 intfnum, u8 cs, void *data, u16 size)
> {
> int ret;
> + u8 error;
> + u8 tmp;
>
> ret = __uvc_query_ctrl(dev, query, unit, intfnum, cs, data, size,
> UVC_CTRL_CONTROL_TIMEOUT);
> - if (ret != size) {
> - uvc_printk(KERN_ERR, "Failed to query (%s) UVC control %u on "
> - "unit %u: %d (exp. %u).\n", uvc_query_name(query), cs,
> - unit, ret, size);
> - return -EIO;
> + if (likely(ret == size))
> + return 0;
> +
> + uvc_printk(KERN_ERR,
> + "Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
> + uvc_query_name(query), cs, unit, ret, size);
> +
> + if (ret != -EPIPE)
> + return ret;
> +
> + tmp = *(u8 *)data;
> +
> + ret = __uvc_query_ctrl(dev, UVC_GET_CUR, 0, intfnum,
> + UVC_VC_REQUEST_ERROR_CODE_CONTROL, data, 1,
> + UVC_CTRL_CONTROL_TIMEOUT);
> +
> + error = *(u8 *)data;
> + *(u8 *)data = tmp;
> +
> + if (ret != 1)
> + return ret < 0 ? ret : -EPIPE;
> +
> + uvc_trace(UVC_TRACE_CONTROL, "Control error %u\n", error);
> +
> + switch (error) {
> + case 0:
> + /* Cannot happen - we received a STALL */
> + return -EPIPE;
> + case 1: /* Not ready */
> + return -EBUSY;
> + case 2: /* Wrong state */
> + return -EILSEQ;
> + case 3: /* Power */
> + return -EREMOTE;
> + case 4: /* Out of range */
> + return -ERANGE;
> + case 5: /* Invalid unit */
> + case 6: /* Invalid control */
> + case 7: /* Invalid Request */
> + case 8: /* Invalid value within range */
> + return -EINVAL;
> + default: /* reserved or unknown */
> + break;
> }
>
> - return 0;
> + return -EPIPE;
> }
>
> static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2018-07-17 21:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 15:07 [PATCH v8 0/3] uvcvideo: asynchronous controls Guennadi Liakhovetski
2018-05-08 15:07 ` [PATCH v8 1/3] uvcvideo: remove a redundant check Guennadi Liakhovetski
2018-07-10 22:18 ` Laurent Pinchart
2018-05-08 15:07 ` [PATCH v8 2/3] uvcvideo: send a control event when a Control Change interrupt arrives Guennadi Liakhovetski
2018-07-11 23:25 ` Laurent Pinchart
2018-07-12 7:30 ` Guennadi Liakhovetski
2018-07-17 13:07 ` Guennadi Liakhovetski
2018-07-17 20:26 ` Laurent Pinchart
2018-07-17 21:30 ` Guennadi Liakhovetski
2018-07-17 23:44 ` Laurent Pinchart
2018-07-18 6:55 ` Guennadi Liakhovetski
2018-07-25 17:10 ` Laurent Pinchart
2018-07-25 17:21 ` Guennadi Liakhovetski
2018-07-25 19:13 ` Laurent Pinchart
2018-07-26 7:03 ` Guennadi Liakhovetski
2018-07-26 8:17 ` [PATCH v9] " Guennadi Liakhovetski
2018-07-26 12:24 ` Laurent Pinchart
2018-07-26 12:42 ` Guennadi Liakhovetski
2018-07-25 17:25 ` [PATCH v8 2/3] " Laurent Pinchart
2018-07-25 19:06 ` Laurent Pinchart
2018-05-08 15:07 ` [PATCH v8 3/3] uvcvideo: handle control pipe protocol STALLs Guennadi Liakhovetski
2018-07-17 20:58 ` Laurent Pinchart [this message]
2018-07-17 23:17 ` Laurent Pinchart
2018-05-31 21:03 ` [PATCH v8 0/3] uvcvideo: asynchronous controls Guennadi Liakhovetski
2018-06-22 14:27 ` Guennadi Liakhovetski
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=7129850.vz39VDuykc@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=guennadi.liakhovetski@intel.com \
--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