* [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi @ 2022-04-01 17:24 Ricardo Ribalda 2022-04-01 17:24 ` [PATCH 2/2] media: uvc: Undup use uvv-endpoint_max_bpi code Ricardo Ribalda 2022-04-24 22:18 ` [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi Laurent Pinchart 0 siblings, 2 replies; 4+ messages in thread From: Ricardo Ribalda @ 2022-04-01 17:24 UTC (permalink / raw) To: Laurent Pinchart, Mauro Carvalho Chehab, linux-media, linux-kernel Cc: Ricardo Ribalda The case USB_SPEED_WIRELESS and the default one were doing the same. Also, make always use of usb_endpoint_maxp_mult, as it should have a sane value, even for LOW speed and WIRELESS. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/usb/uvc/uvc_video.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index 1b4cc934109e..a2dcfeaaac1b 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1760,21 +1760,14 @@ static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep) { u16 psize; - u16 mult; switch (dev->speed) { case USB_SPEED_SUPER: case USB_SPEED_SUPER_PLUS: return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval); - case USB_SPEED_HIGH: - psize = usb_endpoint_maxp(&ep->desc); - mult = usb_endpoint_maxp_mult(&ep->desc); - return psize * mult; - case USB_SPEED_WIRELESS: - psize = usb_endpoint_maxp(&ep->desc); - return psize; default: psize = usb_endpoint_maxp(&ep->desc); + psize *= usb_endpoint_maxp_mult(&ep->desc); return psize; } } -- 2.35.1.1094.g7c7d902a7c-goog ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] media: uvc: Undup use uvv-endpoint_max_bpi code 2022-04-01 17:24 [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi Ricardo Ribalda @ 2022-04-01 17:24 ` Ricardo Ribalda 2022-04-24 22:31 ` Laurent Pinchart 2022-04-24 22:18 ` [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi Laurent Pinchart 1 sibling, 1 reply; 4+ messages in thread From: Ricardo Ribalda @ 2022-04-01 17:24 UTC (permalink / raw) To: Laurent Pinchart, Mauro Carvalho Chehab, linux-media, linux-kernel Cc: Ricardo Ribalda Replace manual decoding of psize in uvc_parse_streaming(), with the code from uvc_endpoint_max_bpi(). It also handles usb3 devices. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/usb/uvc/uvc_driver.c | 4 +--- drivers/media/usb/uvc/uvc_video.c | 3 +-- drivers/media/usb/uvc/uvcvideo.h | 1 + 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index dda0f0aa78b8..977566aa2c89 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1009,9 +1009,7 @@ static int uvc_parse_streaming(struct uvc_device *dev, streaming->header.bEndpointAddress); if (ep == NULL) continue; - - psize = le16_to_cpu(ep->desc.wMaxPacketSize); - psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); + psize = uvc_endpoint_max_bpi(dev->udev, ep); if (psize > streaming->maxpsize) streaming->maxpsize = psize; } diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index a2dcfeaaac1b..9dc0a5dba158 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1756,8 +1756,7 @@ static void uvc_video_stop_transfer(struct uvc_streaming *stream, /* * Compute the maximum number of bytes per interval for an endpoint. */ -static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev, - struct usb_host_endpoint *ep) +u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep) { u16 psize; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 143230b3275b..28eb337a6cfb 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -911,6 +911,7 @@ void uvc_simplify_fraction(u32 *numerator, u32 *denominator, u32 uvc_fraction_to_interval(u32 numerator, u32 denominator); struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts, u8 epaddr); +u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep); /* Quirks support */ void uvc_video_decode_isight(struct uvc_urb *uvc_urb, -- 2.35.1.1094.g7c7d902a7c-goog ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] media: uvc: Undup use uvv-endpoint_max_bpi code 2022-04-01 17:24 ` [PATCH 2/2] media: uvc: Undup use uvv-endpoint_max_bpi code Ricardo Ribalda @ 2022-04-24 22:31 ` Laurent Pinchart 0 siblings, 0 replies; 4+ messages in thread From: Laurent Pinchart @ 2022-04-24 22:31 UTC (permalink / raw) To: Ricardo Ribalda; +Cc: Mauro Carvalho Chehab, linux-media, linux-kernel Hi Ricardo, Thank you for the patch. And here the subject line should mention uvc_endpoint_max_bpi() :-) While at it, I'll replace "uvc" with "uvcvideo". On Fri, Apr 01, 2022 at 07:24:37PM +0200, Ricardo Ribalda wrote: > Replace manual decoding of psize in uvc_parse_streaming(), with the code > from uvc_endpoint_max_bpi(). It also handles usb3 devices. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_driver.c | 4 +--- > drivers/media/usb/uvc/uvc_video.c | 3 +-- > drivers/media/usb/uvc/uvcvideo.h | 1 + > 3 files changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > index dda0f0aa78b8..977566aa2c89 100644 > --- a/drivers/media/usb/uvc/uvc_driver.c > +++ b/drivers/media/usb/uvc/uvc_driver.c > @@ -1009,9 +1009,7 @@ static int uvc_parse_streaming(struct uvc_device *dev, > streaming->header.bEndpointAddress); > if (ep == NULL) > continue; > - > - psize = le16_to_cpu(ep->desc.wMaxPacketSize); > - psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); > + psize = uvc_endpoint_max_bpi(dev->udev, ep); > if (psize > streaming->maxpsize) > streaming->maxpsize = psize; > } > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c > index a2dcfeaaac1b..9dc0a5dba158 100644 > --- a/drivers/media/usb/uvc/uvc_video.c > +++ b/drivers/media/usb/uvc/uvc_video.c > @@ -1756,8 +1756,7 @@ static void uvc_video_stop_transfer(struct uvc_streaming *stream, > /* > * Compute the maximum number of bytes per interval for an endpoint. > */ > -static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev, > - struct usb_host_endpoint *ep) > +u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep) > { > u16 psize; > > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h > index 143230b3275b..28eb337a6cfb 100644 > --- a/drivers/media/usb/uvc/uvcvideo.h > +++ b/drivers/media/usb/uvc/uvcvideo.h > @@ -911,6 +911,7 @@ void uvc_simplify_fraction(u32 *numerator, u32 *denominator, > u32 uvc_fraction_to_interval(u32 numerator, u32 denominator); > struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts, > u8 epaddr); > +u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep); > > /* Quirks support */ > void uvc_video_decode_isight(struct uvc_urb *uvc_urb, -- Regards, Laurent Pinchart ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi 2022-04-01 17:24 [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi Ricardo Ribalda 2022-04-01 17:24 ` [PATCH 2/2] media: uvc: Undup use uvv-endpoint_max_bpi code Ricardo Ribalda @ 2022-04-24 22:18 ` Laurent Pinchart 1 sibling, 0 replies; 4+ messages in thread From: Laurent Pinchart @ 2022-04-24 22:18 UTC (permalink / raw) To: Ricardo Ribalda; +Cc: Mauro Carvalho Chehab, linux-media, linux-kernel Hi Ricardo, Thank you for the patch. I think you meant uvc_endpoint_max_bpi() in the subject line. On Fri, Apr 01, 2022 at 07:24:36PM +0200, Ricardo Ribalda wrote: > The case USB_SPEED_WIRELESS and the default one were doing the same. > > Also, make always use of usb_endpoint_maxp_mult, as it should have a > sane value, even for LOW speed and WIRELESS. I always fear regressions with this kind of patch, but I have no reason to think there's a specific issue, so Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_video.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c > index 1b4cc934109e..a2dcfeaaac1b 100644 > --- a/drivers/media/usb/uvc/uvc_video.c > +++ b/drivers/media/usb/uvc/uvc_video.c > @@ -1760,21 +1760,14 @@ static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev, > struct usb_host_endpoint *ep) > { > u16 psize; > - u16 mult; > > switch (dev->speed) { > case USB_SPEED_SUPER: > case USB_SPEED_SUPER_PLUS: > return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval); > - case USB_SPEED_HIGH: > - psize = usb_endpoint_maxp(&ep->desc); > - mult = usb_endpoint_maxp_mult(&ep->desc); > - return psize * mult; > - case USB_SPEED_WIRELESS: > - psize = usb_endpoint_maxp(&ep->desc); > - return psize; > default: > psize = usb_endpoint_maxp(&ep->desc); > + psize *= usb_endpoint_maxp_mult(&ep->desc); > return psize; > } > } -- Regards, Laurent Pinchart ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-24 22:31 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-01 17:24 [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi Ricardo Ribalda 2022-04-01 17:24 ` [PATCH 2/2] media: uvc: Undup use uvv-endpoint_max_bpi code Ricardo Ribalda 2022-04-24 22:31 ` Laurent Pinchart 2022-04-24 22:18 ` [PATCH 1/2] media: uvc: simplify uvc_enpoint_max_bpi Laurent Pinchart
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®