diff mbox

[06/21,staging] tm6000: Increase maximum I2C packet size.

Message ID 1312442059-23935-7-git-send-email-thierry.reding@avionic-design.de (mailing list archive)
State Rejected
Headers show

Commit Message

Thierry Reding Aug. 4, 2011, 7:14 a.m. UTC
The TM6010 supports much larger I2C transfers than currently specified.
In fact the Windows driver seems to use 81 bytes per packet by default.
This commit improves the speed of firmware loading a bit.
---
 drivers/staging/tm6000/tm6000-cards.c |    1 +
 drivers/staging/tm6000/tm6000-i2c.c   |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

Comments

Mauro Carvalho Chehab Aug. 31, 2011, 7:45 p.m. UTC | #1
Em 04-08-2011 04:14, Thierry Reding escreveu:
> The TM6010 supports much larger I2C transfers than currently specified.
> In fact the Windows driver seems to use 81 bytes per packet by default.
> This commit improves the speed of firmware loading a bit.
> ---
>  drivers/staging/tm6000/tm6000-cards.c |    1 +
>  drivers/staging/tm6000/tm6000-i2c.c   |    2 +-
>  2 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
> index c3b84c9..a5d2a71 100644
> --- a/drivers/staging/tm6000/tm6000-cards.c
> +++ b/drivers/staging/tm6000/tm6000-cards.c
> @@ -929,6 +929,7 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
>  		memset(&ctl, 0, sizeof(ctl));
>  
>  		ctl.demod = XC3028_FE_ZARLINK456;
> +		ctl.max_len = 81;
>  
>  		xc2028_cfg.tuner = TUNER_XC2028;
>  		xc2028_cfg.priv  = &ctl;
> diff --git a/drivers/staging/tm6000/tm6000-i2c.c b/drivers/staging/tm6000/tm6000-i2c.c
> index 21cd9f8..2cb7573 100644
> --- a/drivers/staging/tm6000/tm6000-i2c.c
> +++ b/drivers/staging/tm6000/tm6000-i2c.c
> @@ -50,7 +50,7 @@ static int tm6000_i2c_send_regs(struct tm6000_core *dev, unsigned char addr,
>  	unsigned int i2c_packet_limit = 16;
>  
>  	if (dev->dev_type == TM6010)
> -		i2c_packet_limit = 64;
> +		i2c_packet_limit = 256;

This shouldn't work fine. As said at USB 2.0 specification:

	An endpoint for control transfers specifies the maximum data payload size that the endpoint can accept from
	or transmit to the bus. The allowable maximum control transfer data payload sizes for full-speed devices is
	8, 16, 32, or 64 bytes; for high-speed devices, it is 64 bytes and for low-speed devices, it is 8 bytes. This
	maximum applies to the data payloads of the Data packets following a Setup; i.e., the size specified is for
	the data field of the packet as defined in Chapter 8, not including other information that is required by the
	protocol. A Setup packet is always eight bytes. A control pipe (including the Default Control Pipe) always
	uses its wMaxPacketSize value for data payloads.
	(Item 5.5.3 Control Transfer Packet Size Constraints).

Using a value higher than 64 may cause troubles with some USB devices
(hubs, USB adapters, etc).

Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thierry Reding Sept. 1, 2011, 5:08 a.m. UTC | #2
* Mauro Carvalho Chehab wrote:
> Em 04-08-2011 04:14, Thierry Reding escreveu:
> > The TM6010 supports much larger I2C transfers than currently specified.
> > In fact the Windows driver seems to use 81 bytes per packet by default.
> > This commit improves the speed of firmware loading a bit.
> > ---
> >  drivers/staging/tm6000/tm6000-cards.c |    1 +
> >  drivers/staging/tm6000/tm6000-i2c.c   |    2 +-
> >  2 files changed, 2 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
> > index c3b84c9..a5d2a71 100644
> > --- a/drivers/staging/tm6000/tm6000-cards.c
> > +++ b/drivers/staging/tm6000/tm6000-cards.c
> > @@ -929,6 +929,7 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
> >  		memset(&ctl, 0, sizeof(ctl));
> >  
> >  		ctl.demod = XC3028_FE_ZARLINK456;
> > +		ctl.max_len = 81;
> >  
> >  		xc2028_cfg.tuner = TUNER_XC2028;
> >  		xc2028_cfg.priv  = &ctl;
> > diff --git a/drivers/staging/tm6000/tm6000-i2c.c b/drivers/staging/tm6000/tm6000-i2c.c
> > index 21cd9f8..2cb7573 100644
> > --- a/drivers/staging/tm6000/tm6000-i2c.c
> > +++ b/drivers/staging/tm6000/tm6000-i2c.c
> > @@ -50,7 +50,7 @@ static int tm6000_i2c_send_regs(struct tm6000_core *dev, unsigned char addr,
> >  	unsigned int i2c_packet_limit = 16;
> >  
> >  	if (dev->dev_type == TM6010)
> > -		i2c_packet_limit = 64;
> > +		i2c_packet_limit = 256;
> 
> This shouldn't work fine. As said at USB 2.0 specification:
> 
> 	An endpoint for control transfers specifies the maximum data payload size that the endpoint can accept from
> 	or transmit to the bus. The allowable maximum control transfer data payload sizes for full-speed devices is
> 	8, 16, 32, or 64 bytes; for high-speed devices, it is 64 bytes and for low-speed devices, it is 8 bytes. This
> 	maximum applies to the data payloads of the Data packets following a Setup; i.e., the size specified is for
> 	the data field of the packet as defined in Chapter 8, not including other information that is required by the
> 	protocol. A Setup packet is always eight bytes. A control pipe (including the Default Control Pipe) always
> 	uses its wMaxPacketSize value for data payloads.
> 	(Item 5.5.3 Control Transfer Packet Size Constraints).
> 
> Using a value higher than 64 may cause troubles with some USB devices
> (hubs, USB adapters, etc).

Okay, fine by me. I was basically just copying what the Windows driver was
doing here, but I've tested with smaller sizes as well and if my memory
serves me well that also worked. As I hinted at in the commit message this
was mostly for performance improvement.

Thierry
diff mbox

Patch

diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index c3b84c9..a5d2a71 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -929,6 +929,7 @@  static void tm6000_config_tuner(struct tm6000_core *dev)
 		memset(&ctl, 0, sizeof(ctl));
 
 		ctl.demod = XC3028_FE_ZARLINK456;
+		ctl.max_len = 81;
 
 		xc2028_cfg.tuner = TUNER_XC2028;
 		xc2028_cfg.priv  = &ctl;
diff --git a/drivers/staging/tm6000/tm6000-i2c.c b/drivers/staging/tm6000/tm6000-i2c.c
index 21cd9f8..2cb7573 100644
--- a/drivers/staging/tm6000/tm6000-i2c.c
+++ b/drivers/staging/tm6000/tm6000-i2c.c
@@ -50,7 +50,7 @@  static int tm6000_i2c_send_regs(struct tm6000_core *dev, unsigned char addr,
 	unsigned int i2c_packet_limit = 16;
 
 	if (dev->dev_type == TM6010)
-		i2c_packet_limit = 64;
+		i2c_packet_limit = 256;
 
 	if (!buf)
 		return -1;