linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 13/82] media: usbtv: core: make use of new usb_endpoint_maxp_mult()
       [not found] <20161031104914.1990-1-felipe.balbi@linux.intel.com>
@ 2016-10-31 10:48 ` Felipe Balbi
  2016-11-21 14:16   ` Mauro Carvalho Chehab
  2016-10-31 10:48 ` [PATCH 14/82] media: usb: uvc: " Felipe Balbi
  2016-10-31 10:48 ` [PATCH 30/82] media: usb: uvc: remove unnecessary & operation Felipe Balbi
  2 siblings, 1 reply; 5+ messages in thread
From: Felipe Balbi @ 2016-10-31 10:48 UTC (permalink / raw)
  To: Linux USB; +Cc: Felipe Balbi, Mauro Carvalho Chehab, linux-media

We have introduced a helper to calculate multiplier
value from wMaxPacketSize. Start using it.

Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: <linux-media@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/media/usb/usbtv/usbtv-core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
index dc76fd41e00f..ceb953be0770 100644
--- a/drivers/media/usb/usbtv/usbtv-core.c
+++ b/drivers/media/usb/usbtv/usbtv-core.c
@@ -71,6 +71,7 @@ static int usbtv_probe(struct usb_interface *intf,
 	int size;
 	struct device *dev = &intf->dev;
 	struct usbtv *usbtv;
+	struct usb_host_endpoint *ep;
 
 	/* Checks that the device is what we think it is. */
 	if (intf->num_altsetting != 2)
@@ -78,10 +79,12 @@ static int usbtv_probe(struct usb_interface *intf,
 	if (intf->altsetting[1].desc.bNumEndpoints != 4)
 		return -ENODEV;
 
+	ep = &intf->altsetting[1].endpoint[0];
+
 	/* Packet size is split into 11 bits of base size and count of
 	 * extra multiplies of it.*/
-	size = usb_endpoint_maxp(&intf->altsetting[1].endpoint[0].desc);
-	size = (size & 0x07ff) * (((size & 0x1800) >> 11) + 1);
+	size = usb_endpoint_maxp(&ep->desc);
+	size = (size & 0x07ff) * usb_endpoint_maxp_mult(&ep->desc);
 
 	/* Device structure */
 	usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL);
-- 
2.10.1


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

* [PATCH 14/82] media: usb: uvc: make use of new usb_endpoint_maxp_mult()
       [not found] <20161031104914.1990-1-felipe.balbi@linux.intel.com>
  2016-10-31 10:48 ` [PATCH 13/82] media: usbtv: core: make use of new usb_endpoint_maxp_mult() Felipe Balbi
@ 2016-10-31 10:48 ` Felipe Balbi
  2016-10-31 20:23   ` Laurent Pinchart
  2016-10-31 10:48 ` [PATCH 30/82] media: usb: uvc: remove unnecessary & operation Felipe Balbi
  2 siblings, 1 reply; 5+ messages in thread
From: Felipe Balbi @ 2016-10-31 10:48 UTC (permalink / raw)
  To: Linux USB
  Cc: Felipe Balbi, Laurent Pinchart, Mauro Carvalho Chehab,
	linux-media

We have introduced a helper to calculate multiplier
value from wMaxPacketSize. Start using it.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: <linux-media@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/media/usb/uvc/uvc_video.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index b5589d5f5da4..11e0e5f4e1c2 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1467,6 +1467,7 @@ 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:
@@ -1474,7 +1475,8 @@ static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev,
 		return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
 	case USB_SPEED_HIGH:
 		psize = usb_endpoint_maxp(&ep->desc);
-		return (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
+		mult = usb_endpoint_maxp_mult(&ep->desc);
+		return (psize & 0x07ff) * mult;
 	case USB_SPEED_WIRELESS:
 		psize = usb_endpoint_maxp(&ep->desc);
 		return psize;
-- 
2.10.1


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

* [PATCH 30/82] media: usb: uvc: remove unnecessary & operation
       [not found] <20161031104914.1990-1-felipe.balbi@linux.intel.com>
  2016-10-31 10:48 ` [PATCH 13/82] media: usbtv: core: make use of new usb_endpoint_maxp_mult() Felipe Balbi
  2016-10-31 10:48 ` [PATCH 14/82] media: usb: uvc: " Felipe Balbi
@ 2016-10-31 10:48 ` Felipe Balbi
  2 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2016-10-31 10:48 UTC (permalink / raw)
  To: Linux USB
  Cc: Felipe Balbi, Laurent Pinchart, Mauro Carvalho Chehab,
	linux-media

Now that usb_endpoint_maxp() only returns the lowest
11 bits from wMaxPacketSize, we can remove the &
operation from this driver.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: <linux-media@vger.kernel.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/media/usb/uvc/uvc_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 11e0e5f4e1c2..f3c1c852e401 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1553,7 +1553,7 @@ static int uvc_init_video_bulk(struct uvc_streaming *stream,
 	u16 psize;
 	u32 size;
 
-	psize = usb_endpoint_maxp(&ep->desc) & 0x7ff;
+	psize = usb_endpoint_maxp(&ep->desc);
 	size = stream->ctrl.dwMaxPayloadTransferSize;
 	stream->bulk.max_payload_size = size;
 
-- 
2.10.1


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

* Re: [PATCH 14/82] media: usb: uvc: make use of new usb_endpoint_maxp_mult()
  2016-10-31 10:48 ` [PATCH 14/82] media: usb: uvc: " Felipe Balbi
@ 2016-10-31 20:23   ` Laurent Pinchart
  0 siblings, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2016-10-31 20:23 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: Linux USB, Mauro Carvalho Chehab, linux-media

Hi Felipe,

Thank you for the patch.

On Monday 31 Oct 2016 12:48:06 Felipe Balbi wrote:
> We have introduced a helper to calculate multiplier
> value from wMaxPacketSize. Start using it.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: <linux-media@vger.kernel.org>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/usb/uvc/uvc_video.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_video.c
> b/drivers/media/usb/uvc/uvc_video.c index b5589d5f5da4..11e0e5f4e1c2 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -1467,6 +1467,7 @@ 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:
> @@ -1474,7 +1475,8 @@ static unsigned int uvc_endpoint_max_bpi(struct
> usb_device *dev, return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
>  	case USB_SPEED_HIGH:
>  		psize = usb_endpoint_maxp(&ep->desc);
> -		return (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
> +		mult = usb_endpoint_maxp_mult(&ep->desc);
> +		return (psize & 0x07ff) * mult;
>  	case USB_SPEED_WIRELESS:
>  		psize = usb_endpoint_maxp(&ep->desc);
>  		return psize;

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 13/82] media: usbtv: core: make use of new usb_endpoint_maxp_mult()
  2016-10-31 10:48 ` [PATCH 13/82] media: usbtv: core: make use of new usb_endpoint_maxp_mult() Felipe Balbi
@ 2016-11-21 14:16   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2016-11-21 14:16 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: Linux USB, Mauro Carvalho Chehab, linux-media

Em Mon, 31 Oct 2016 12:48:05 +0200
Felipe Balbi <felipe.balbi@linux.intel.com> escreveu:

> We have introduced a helper to calculate multiplier
> value from wMaxPacketSize. Start using it.

Good idea! Btw, we have something similar at em28xx, stk1160-core.c and
tm6000 drivers. On them, we have this:
	/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
	#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))

PLease add the same changes for the above files on this patch.

Btw, are you planning to send this patch via USB tree or via the
media one? If you want to send via USB, after this change,
feel free to add my ack:

	Acked-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


> 
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: <linux-media@vger.kernel.org>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> ---
>  drivers/media/usb/usbtv/usbtv-core.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
> index dc76fd41e00f..ceb953be0770 100644
> --- a/drivers/media/usb/usbtv/usbtv-core.c
> +++ b/drivers/media/usb/usbtv/usbtv-core.c
> @@ -71,6 +71,7 @@ static int usbtv_probe(struct usb_interface *intf,
>  	int size;
>  	struct device *dev = &intf->dev;
>  	struct usbtv *usbtv;
> +	struct usb_host_endpoint *ep;
>  
>  	/* Checks that the device is what we think it is. */
>  	if (intf->num_altsetting != 2)
> @@ -78,10 +79,12 @@ static int usbtv_probe(struct usb_interface *intf,
>  	if (intf->altsetting[1].desc.bNumEndpoints != 4)
>  		return -ENODEV;
>  
> +	ep = &intf->altsetting[1].endpoint[0];
> +
>  	/* Packet size is split into 11 bits of base size and count of
>  	 * extra multiplies of it.*/
> -	size = usb_endpoint_maxp(&intf->altsetting[1].endpoint[0].desc);
> -	size = (size & 0x07ff) * (((size & 0x1800) >> 11) + 1);
> +	size = usb_endpoint_maxp(&ep->desc);
> +	size = (size & 0x07ff) * usb_endpoint_maxp_mult(&ep->desc);
>  
>  	/* Device structure */
>  	usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL);


Thanks,
Mauro

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

end of thread, other threads:[~2016-11-21 14:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20161031104914.1990-1-felipe.balbi@linux.intel.com>
2016-10-31 10:48 ` [PATCH 13/82] media: usbtv: core: make use of new usb_endpoint_maxp_mult() Felipe Balbi
2016-11-21 14:16   ` Mauro Carvalho Chehab
2016-10-31 10:48 ` [PATCH 14/82] media: usb: uvc: " Felipe Balbi
2016-10-31 20:23   ` Laurent Pinchart
2016-10-31 10:48 ` [PATCH 30/82] media: usb: uvc: remove unnecessary & operation Felipe Balbi

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