linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 2/2] usb: webcam: Invalid size of Processing Unit Descriptor
@ 2021-03-15  7:17 Pawel Laszczak
  2021-03-16  0:25 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Pawel Laszczak @ 2021-03-15  7:17 UTC (permalink / raw)
  To: balbi, gregkh
  Cc: linux-api, laurent.pinchart, linux-usb, linux-kernel, peter.chen,
	kurahul, Pawel Laszczak

From: Pawel Laszczak <pawell@cadence.com>

According with USB Device Class Definition for Video Device the
Processing Unit Descriptor bLength should be 12 (10 + bmControlSize),
but it has 11.

Invalid length caused that Processing Unit Descriptor Test Video form
CV tool failed. To fix this issue patch adds bmVideoStandards into
uvc_processing_unit_descriptor structure.

The bmVideoStandards field was added in UVC 1.1 and it wasn't part of
UVC 1.0a.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>

---
Changelog:
v4:
- fixed compilation error caused by v2
v3:
- updated the commit message
- added bmVideoStandard field to UVC gadget driver
v2:
- updated UVC_DT_PROCESSING_UNIT_SIZE macro

 drivers/usb/gadget/function/f_uvc.c | 1 +
 drivers/usb/gadget/legacy/webcam.c  | 1 +
 include/uapi/linux/usb/video.h      | 3 ++-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 5d62720bb9e1..e3b0a79c8f01 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -823,6 +823,7 @@ static struct usb_function_instance *uvc_alloc_inst(void)
 	pd->bmControls[0]		= 1;
 	pd->bmControls[1]		= 0;
 	pd->iProcessing			= 0;
+	pd->bmVideoStandards		= 0;
 
 	od = &opts->uvc_output_terminal;
 	od->bLength			= UVC_DT_OUTPUT_TERMINAL_SIZE;
diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c
index 3a61de4bb2b1..accb4dacf715 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -125,6 +125,7 @@ static const struct uvc_processing_unit_descriptor uvc_processing = {
 	.bmControls[0]		= 1,
 	.bmControls[1]		= 0,
 	.iProcessing		= 0,
+	.bmVideoStandards	= 0,
 };
 
 static const struct uvc_output_terminal_descriptor uvc_output_terminal = {
diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h
index d854cb19c42c..bfdae12cdacf 100644
--- a/include/uapi/linux/usb/video.h
+++ b/include/uapi/linux/usb/video.h
@@ -302,9 +302,10 @@ struct uvc_processing_unit_descriptor {
 	__u8   bControlSize;
 	__u8   bmControls[2];
 	__u8   iProcessing;
+	__u8   bmVideoStandards;
 } __attribute__((__packed__));
 
-#define UVC_DT_PROCESSING_UNIT_SIZE(n)			(9+(n))
+#define UVC_DT_PROCESSING_UNIT_SIZE(n)			(10+(n))
 
 /* 3.7.2.6. Extension Unit Descriptor */
 struct uvc_extension_unit_descriptor {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4 2/2] usb: webcam: Invalid size of Processing Unit Descriptor
  2021-03-15  7:17 [PATCH v4 2/2] usb: webcam: Invalid size of Processing Unit Descriptor Pawel Laszczak
@ 2021-03-16  0:25 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2021-03-16  0:25 UTC (permalink / raw)
  To: Pawel Laszczak
  Cc: balbi, gregkh, linux-api, laurent.pinchart, linux-usb,
	linux-kernel, kurahul

On 21-03-15 08:17:48, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
> 
> According with USB Device Class Definition for Video Device the
> Processing Unit Descriptor bLength should be 12 (10 + bmControlSize),
> but it has 11.
> 
> Invalid length caused that Processing Unit Descriptor Test Video form
> CV tool failed. To fix this issue patch adds bmVideoStandards into
> uvc_processing_unit_descriptor structure.
> 
> The bmVideoStandards field was added in UVC 1.1 and it wasn't part of
> UVC 1.0a.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> 

Reviewed-by: Peter Chen <peter.chen@kernel.org>

> ---
> Changelog:
> v4:
> - fixed compilation error caused by v2
> v3:
> - updated the commit message
> - added bmVideoStandard field to UVC gadget driver
> v2:
> - updated UVC_DT_PROCESSING_UNIT_SIZE macro
> 
>  drivers/usb/gadget/function/f_uvc.c | 1 +
>  drivers/usb/gadget/legacy/webcam.c  | 1 +
>  include/uapi/linux/usb/video.h      | 3 ++-
>  3 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
> index 5d62720bb9e1..e3b0a79c8f01 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -823,6 +823,7 @@ static struct usb_function_instance *uvc_alloc_inst(void)
>  	pd->bmControls[0]		= 1;
>  	pd->bmControls[1]		= 0;
>  	pd->iProcessing			= 0;
> +	pd->bmVideoStandards		= 0;
>  
>  	od = &opts->uvc_output_terminal;
>  	od->bLength			= UVC_DT_OUTPUT_TERMINAL_SIZE;
> diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c
> index 3a61de4bb2b1..accb4dacf715 100644
> --- a/drivers/usb/gadget/legacy/webcam.c
> +++ b/drivers/usb/gadget/legacy/webcam.c
> @@ -125,6 +125,7 @@ static const struct uvc_processing_unit_descriptor uvc_processing = {
>  	.bmControls[0]		= 1,
>  	.bmControls[1]		= 0,
>  	.iProcessing		= 0,
> +	.bmVideoStandards	= 0,
>  };
>  
>  static const struct uvc_output_terminal_descriptor uvc_output_terminal = {
> diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h
> index d854cb19c42c..bfdae12cdacf 100644
> --- a/include/uapi/linux/usb/video.h
> +++ b/include/uapi/linux/usb/video.h
> @@ -302,9 +302,10 @@ struct uvc_processing_unit_descriptor {
>  	__u8   bControlSize;
>  	__u8   bmControls[2];
>  	__u8   iProcessing;
> +	__u8   bmVideoStandards;
>  } __attribute__((__packed__));
>  
> -#define UVC_DT_PROCESSING_UNIT_SIZE(n)			(9+(n))
> +#define UVC_DT_PROCESSING_UNIT_SIZE(n)			(10+(n))
>  
>  /* 3.7.2.6. Extension Unit Descriptor */
>  struct uvc_extension_unit_descriptor {
> -- 
> 2.25.1
> 

-- 

Thanks,
Peter Chen


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-16  0:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15  7:17 [PATCH v4 2/2] usb: webcam: Invalid size of Processing Unit Descriptor Pawel Laszczak
2021-03-16  0:25 ` Peter Chen

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).