mbox series

[v5,00/10] usb: gadget: audio: Multiple rates, notify

Message ID 20220121155308.48794-1-pavel.hofman@ivitera.com
Headers show
Series usb: gadget: audio: Multiple rates, notify | expand

Message

Pavel Hofman Jan. 21, 2022, 3:52 p.m. UTC
This series implements:
* Support for multiple rates in the audio gadget
* Notification of gadget-side alsa processes about playback/capture
  start/stop on the host side via Playback/Capture Rate controls.
* Detection of the USB cable disconnection by handling SUSPEND call
  in f_uac1/2. The disconnection generates a stop notification.

Patches for the multirate support, originally authored by Julian Scheel,
were rebased and modified for the current code base. Julian has
acknowledged the presented patches.

The detection of cable disconnection was discussed with dwc2 maintainer
Minas Harutyunyan who confirmed that the suspend event can be used
(https://lore.kernel.org/all/5aada8e3-f385-0589-8d58-187abd1a924d@synopsys.com/T/).
Tests on dwc2 have confirmed reliable detection, the gadget correctly
reports playback/capture stop at cable disconnection.

The start/stop/current rate notification feature is accompanied by
example implementation of audio gadget controller
https://github.com/pavhofman/gaudio_ctl. The controller also handles
debouncing fast start/stop events when USB host audio driver is loaded
and/or audio daemon re/started.

Changes:
--------

v2:
* Fixed compilation of "usb: gadget: f_uac1: Support multiple sampling
  rates" - added changes for CONFIG_GADGET_UAC1

v3:
* Implemented most of changes suggested by John Keeping
* Patches for bInterval calculation moved to a separate patch series
* Patches for stopping substreams moved to a separate patch series
* audio: Replaced deprecated macro S_IRUGO
* u_audio: Moved dynamic srate from params to rtd
* f_uac2: removed current state srates from struct f_uac2_opts, using
  u_audio_get_playback/capture_srate() instead.
* f_uac2: Reworked macros for struct cntrl_ranges_lay3_xxx

v4:
* Fixed the unused-but-set-variable warnings
* Patch "usb: gadget: f_uac2: Rename Clock Sources to fixed names"
  squashed to patch "usb: gadget: f_uac2: Support multiple sampling
  rates"

v5:
* Fixed sparse warnings (cast to restricted __le32, restricted __le16
  degrades to integer), as reported by the kernel test robot
  <lkp@intel.com>

Julian Scheel (3):
  usb: gadget: u_audio: Support multiple sampling rates
  usb: gadget: f_uac2: Support multiple sampling rates
  usb: gadget: f_uac1: Support multiple sampling rates

Pavel Hofman (7):
  usb: gadget:audio: Replace deprecated macro S_IRUGO
  usb: gadget: u_audio: Move dynamic srate from params to rtd
  usb: gadget: u_audio: Add capture/playback srate getter
  usb: gadget: u_audio: Rate ctl notifies about current srate
    (0=stopped)
  usb: gadget: u_audio: Add suspend call
  usb: gadget: f_uac2: Add suspend callback
  usb: gadget: f_uac1: Add suspend callback

 .../ABI/testing/configfs-usb-gadget-uac1      |   4 +-
 .../ABI/testing/configfs-usb-gadget-uac2      |   4 +-
 Documentation/usb/gadget-testing.rst          |   8 +-
 drivers/usb/gadget/function/f_uac1.c          | 190 ++++++++++++--
 drivers/usb/gadget/function/f_uac2.c          | 208 ++++++++++++---
 drivers/usb/gadget/function/u_audio.c         | 238 ++++++++++++++++--
 drivers/usb/gadget/function/u_audio.h         |  14 +-
 drivers/usb/gadget/function/u_uac1.h          |   5 +-
 drivers/usb/gadget/function/u_uac2.h          |   5 +-
 drivers/usb/gadget/function/uac_common.h      |   9 +
 drivers/usb/gadget/legacy/audio.c             |  78 +++---
 11 files changed, 633 insertions(+), 130 deletions(-)
 create mode 100644 drivers/usb/gadget/function/uac_common.h