I'm trying to determine the bandwidth available so that I can know if a device should be allowed to enumerate at a given configuration or not. However, going through the LPCOpen host code there's a section that I can't understand, it actually seems contradictory to me... but what do I know, that's what I'm here for =)
First, lets assume number of transfers per (micro)frame is one (mult = 1).
When an iTD is queued with QueueITD(), it checks that the requested transfer length is less than the MPS*8*FRAME_LIST_SIZE (that is, max packet size by Xacts per iTD by the size in elements of the periodic list). So far so good. Next, it allocates an iTD for each MPS*8 segment by calling AllocHsItd() and this is where I get lost. The first thing this one does is look for an available TDindex, there are HCD_MAX_HS_ITD (4) indices in total. Here is where the math, to me, doesn't add up:
MaxTDLen = 8 * MPS
MaxXferLen = MaxTDLen * FRAME_LIST_SIZE (32 by default) = 32 * 8 * MPS = 256 * MPS
Lets say XferLen = 80 * MPS, that means the length verifies as Ok because 80*MPS < 256*MPS.
Then QueueITD() will try to allocate XferLen / MaxTDLen iTDs, that is 80 / 8 = 10
Now, this means AllocHsItd() will be called 10 times, however, since this one needs to get an available TDindex per call and there are only 4 (HCD_MAX_HS_ITD)... what's the point of FRAME_LIST_SIZE being 32 (which can be configured between 8 and 1024) if it won't be able to be allocated anyway because of the limit in indices?
I'm sure there's something I'm not understanding correctly here, but I can't for the life of me figure out what.
I'd appreciate it if you can help me figure out this.