[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3j36yvlolepk7ififzknknsdqr2gjueuqh4exlqidsiqrs6d7h@nbix74eojlyb>
Date: Mon, 12 Jan 2026 17:43:21 +0800
From: Xu Yang <xu.yang_2@....com>
To: Frank Li <Frank.li@....com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Michael Grzeschik <m.grzeschik@...gutronix.de>, jun.li@....com, imx@...ts.linux.dev, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH 2/4] usb: gadget: uvc: fix interval_duration calculation
On Thu, Jan 08, 2026 at 11:04:19AM -0500, Frank Li wrote:
> On Thu, Jan 08, 2026 at 03:43:03PM +0800, Xu Yang wrote:
> > According to USB specification:
> >
> > For full-/high-speed isochronous endpoints, the bInterval value is
> > used as the exponent for a 2^(bInterval-1) value.
> >
> > To correctly convert bInterval as interval_duration:
> > interval_duration = 2^(bInterval-1) * frame_interval
> >
> > Because the unit of video->interval is 100ns, add a comment info to
> > make it clear.
> >
> > Fixes: 48dbe731171e ("usb: gadget: uvc: set req_size and n_requests based on the frame interval")
> > Cc: stable@...r.kernel.org
> > Signed-off-by: Xu Yang <xu.yang_2@....com>
> > ---
> > drivers/usb/gadget/function/uvc.h | 2 +-
> > drivers/usb/gadget/function/uvc_video.c | 7 +++++--
> > 2 files changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
> > index b3f88670bff801a43d084646974602e5995bb192..676419a049762f9eb59e1ac68b19fa34f153b793 100644
> > --- a/drivers/usb/gadget/function/uvc.h
> > +++ b/drivers/usb/gadget/function/uvc.h
> > @@ -107,7 +107,7 @@ struct uvc_video {
> > unsigned int width;
> > unsigned int height;
> > unsigned int imagesize;
> > - unsigned int interval;
> > + unsigned int interval; /* in 100ns units */
> > struct mutex mutex; /* protects frame parameters */
> >
> > unsigned int uvc_num_requests;
> > diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
> > index 1c0672f707e4e5f29c937a1868f0400aad62e5cb..b1c5c1d3e9390c82cc84e736a7f288626ee69d51 100644
> > --- a/drivers/usb/gadget/function/uvc_video.c
> > +++ b/drivers/usb/gadget/function/uvc_video.c
> > @@ -499,7 +499,7 @@ uvc_video_prep_requests(struct uvc_video *video)
> > {
> > struct uvc_device *uvc = container_of(video, struct uvc_device, video);
> > struct usb_composite_dev *cdev = uvc->func.config->cdev;
> > - unsigned int interval_duration = video->ep->desc->bInterval * 1250;
> > + unsigned int interval_duration;
> > unsigned int max_req_size, req_size, header_size;
> > unsigned int nreq;
> >
> > @@ -513,8 +513,11 @@ uvc_video_prep_requests(struct uvc_video *video)
> > return;
> > }
> >
> > + interval_duration = int_pow(2, video->ep->desc->bInterval - 1);
>
> 2 << (video->ep->desc->bInterval - 1) or BIT(video->ep->desc->bInterval - 1);
>
> int_pow() use while loop. slice better.
>
> Reviewed-by: Frank Li <Frank.Li@....com>
Good suggestion!
Thanks,
Xu Yang
Powered by blists - more mailing lists