Re: Multiple configuration Implementation problem in Linux USB gadget driver - reg

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Mon, 8 Oct 2007, praveen koduru wrote:

> Hi Linux-usb-devel,
>    I am trying to implement multiple configurations for USB gadget
> driver in Linux, for different bMaxPower 100mA & 500mA.The rest i.e
> interfaces & endpoints are same for both configurations and the host
> should select the appropriate one.

That last part isn't necessarily true.  The host should select a valid 
configuration, but it doesn't have to select the best or the most
appropriate configuration.

>  After plugging the device, host is
> able to read the 2 configuration descriptors, but it is selecting
> always the default one only i.e with index 0.

That makes sense.  If the first configuration is valid, the host is 
free to select it.

>    When we send first configuration with bMaxPower = 2000(invalid
> value) and second configuration bMaxPower = 500. It is selecting the
> first configuration only. And at host the bMaxPower is changed to some
> other small value.

If you deliberately program your gadget to violate the USB spec then 
you shouldn't expect anything to work correctly.

Besides, it isn't possible to set bMaxPower to 2000.  The field is only 
8 bits (hence the "b" in "bMaxPower"), and it expresses the maximum 
current usage in units of 2 mA.  Since the largest value expressible in 
8 bits is 255, the largest possible maxpower amount is 510 mA.  But the 
largest legal amount is 500 mA.

> Observations on the above Experiment:
> -----------------------------------------------------
>            ---------------------------------------------
> bMaxPower on Gadget driver is set to
> bMaxPower at host changed to
> -----------------------------------------------------
>             -----------------------------------------------
> 
>                  Linux    -------------  Windows
>          500 mA
>             250 mA                250 mA

I don't believe this.  Linux doesn't change maxpower values from 500 mA
to 250 mA (unless the host controller is unable to supply more than 
250 mA).  You must have made a mistake.

All of the following lines are meaningless, as explained above.

>          2500 mA
>           144 mA                 196 mA
>          5000 mA
>           144 mA                  136 mA
>         10000 mA
>           144 mA                 16 mA
>         20000 mA
>           144 mA                  32 mA
>         30000 mA
>           144 mA                  48 mA
>         50000 mA
>           144 mA                  80 mA
> 
> In linux, both of the descriptors were read by host passing the value
> in index 0 and index 1.
> In Windows Xp, only index 0 is read.
> 
> 1. How to make Host to select the second configuration , instad of
> ceiling to 144 mA??

With Linux, you can tell the system to select any configuration by doing:

	echo N >/sys/bus/usb/device/.../bConfigurationValue

where N is the bConfigurationValue for the config you want and "..." is 
the USB device's ID.

> 2. How to implement the same in Windows Xp also.

I don't know.  You are more likely to get an answer if you ask on a 
Windows mailing list instead of a Linux mailing list.

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.