mbox series

[0/4] Add configfs HS/SS bInterval, optimized or fixed

Message ID 20220127114331.41367-1-pavel.hofman@ivitera.com
Headers show
Series Add configfs HS/SS bInterval, optimized or fixed | expand

Message

Pavel Hofman Jan. 27, 2022, 11:43 a.m. UTC
The existing UAC2 gadget has hard-coded bInterval=4 for HS/SS EP IN and
EP OUT. This setting precludes using higher-bandwidth configurations
successfully (the srate/chmask/ssize combination is accepted, but data
are silently dropped). 

After discussing with John Keeping
(https://lore.kernel.org/all/YcHIsR4AFaL9g6N2@donbot/) this series
implements a compromise among the various requirements. Configfs params
c_hs_bint/p_hs_bint between 1 to 4 set fixed bInterval. If the params
are set to 0, maximum fitting max packet size and bInterval values for
the required bandwidth are calculated and used, minimizing thus CPU
load.

The default value is 0, i.e. the automated calculation. It was chosen to
simplify using the UAC2 gadget. Also, when existing installations
require minimum bInterval to achieve minimum latency, they had to be
modified in the code so far. Therefore it is assumed that having to set
the parameters to fixed bInterval values would be no major difference to
the current status.

Additionally, the code warns if the required bandwidth exceeds the used
max packet size/bInterval combination. The warning check if performed
for FS too even if the current configuration ends up using HS/SS. The
optimal solution would be preventing FS/HS/SS enumeration instead but
such feature will require more patches and is not part of this series.

The bInterval parameters are added to the legacy g_audio too as this
module is still used in many existing UAC2 gadget tutorials and the
added code is minimal.


With regards,

Pavel Hofman.

Pavel Hofman (4):
  usb: gadget: f_uac2: add HS/SS bInterval to configfs
  usb: gadget: audio: Add HS/SS bInterval params for UAC2
  usb: gadget: f_uac2: Optionally determine bInterval for HS and SS
  usb: gadget: f_uac2: Add speed names to bInterval dbg/warn

 .../ABI/testing/configfs-usb-gadget-uac2      |   2 +
 Documentation/usb/gadget-testing.rst          |   2 +
 drivers/usb/gadget/function/f_uac2.c          | 160 +++++++++++++-----
 drivers/usb/gadget/function/u_uac2.h          |   4 +
 drivers/usb/gadget/legacy/audio.c             |  15 ++
 5 files changed, 142 insertions(+), 41 deletions(-)